Group Abstract Group Abstract

Message Boards Message Boards

0
|
11K Views
|
3 Replies
|
2 Total Likes
View groups...
Share
Share this post:

MixedRadixQuantity and a lot of problems

Posted 11 years ago
POSTED BY: Vorname
3 Replies

The examples with non-integer powers are not considered Quantity objects, even if they format nicely.

In[1]:= Quantity[3, "Meters"^Sqrt[2]]                                                   

                          Sqrt[2]
Out[1]= Quantity[3, Meters       ]

In[2]:= QuantityQ[%]                                                                    

Out[2]= False

The more ordinary examples such as

MixedRadixQuantity[{1, 2}, {"Meters"^2, "Centimeters"^2}]  

ought to work. I reported them to developers.

Thank you for pointing this out.

POSTED BY: Bruce Miller

These look like bugs to me. MixedRadixQuantity is a constructor that creates Quantity expressions of the form: Quantity[MixedRadix[...],MixedRadix[...]]

It seems to be failing to convert many of these, but you can re-write them in this form and they should work: Quantity[MixedRadix[1, 2], MixedRadix["Meters"^2, "Centimeters"^2]]

Note that "Meters/Seconds" isn't a canonical unit form(it should be "Meters"/"Seconds"):

In[14]:= KnownUnitQ["Meters/Seconds"]
Out[14]= False

In[15]:= KnownUnitQ["Meters"/"Seconds"]
Out[15]= True

This parses automatically in Quantity, but not in MixedRadixQuantity(another probable bug); Also note that while some of these exponents will typeset, they don't work in standard Quantity expressions:

In[18]:= Quantity[1, "Meters"^E] // UnitConvert
Out[18]= UnitConvert[Quantity[1, ("Meters")^E]]

In[19]:= Quantity[1, "Meters"^E] // QuantityQ
Out[19]= False

(I will confess that I'm not quite sure what you're trying to do with these however)

POSTED BY: Nick Lariviere

A minor correction; non-integer powers are acceptable, but only if they're Real or Rational:

In[21]:= QuantityQ[Quantity[3, "Meters"^(2/3)]]
Out[21]= True

In[22]:= QuantityQ[Quantity[3, "Meters"^(2.3)]]
Out[22]= True

In[23]:= QuantityQ[Quantity[3, "Meters"^(2.3 + 3 I)]]
Out[23]= False

In[24]:= QuantityQ[Quantity[3, "Meters"^(E)]]
Out[24]= False

In[25]:= QuantityQ[Quantity[3, "Meters"^(Sqrt[2])]]
Out[25]= False
POSTED BY: Nick Lariviere
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard