Mathematica Stack Exchange is a question and answer site for users of Mathematica. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I recently found the PhysicalConstants` package. First I thought this was nice, since I didn't have to look up some quantities all the time and copy them into the worksheet. But then I noticed the carried units. This is not automatically a bad thing, but it seems to me that they do not go together well, because Wolfram didn't just use base units. Consequently, if I use a quantity in Newton and divide it by a quantity in Meter/Second^2, the result will be Newton*Second^2/Meter, and not Kilogram. In my first try this made a huge mess in the result.

Is there a way to work with these in a useful way?

share|improve this question
Convert[Newton*Second^2/Meter, Kilogram]. – J. M. Feb 15 '12 at 10:21
What I'd really want to see implemented are functions that might be called SIBaseUnitsExpand[], MKSBaseUnitsExpand[], and CGSBaseUnitsExpand[], that perform the expansion of derived units entirely in terms of base units for the corresponding measurement systems... – J. M. Feb 15 '12 at 10:35
up vote 11 down vote accepted

As J.M. comments, but opts not to post as an answer, you can use Convert in the Units package to convert between types. Be sure to read the documentation on that package.


Convert[(32.5 Newton)/(7 Meter/Second^2), Kilogram]

4.64286 Kilogram

You will also find use in the Automatic Units package described on the Wolfram Blog.

share|improve this answer
One wonders why the functionality of "Automatic Units" has not already been incorporated in the package shipped with Mathematica... *grumbles* – J. M. Feb 15 '12 at 10:30
@J.M. why did you not post an answer, and then why did you not vote for mine? I find your actions perplexing. – Mr.Wizard Feb 15 '12 at 10:36
I'm out of votes, so I owe you a vote tomorrow. And no, I don't want rep for answering this question... – J. M. Feb 15 '12 at 10:40
The automatic unit package seems fine. The Convert version ... well, one needs to know what should come out for that. That is not always the case for single factors, for example - at least not without unnecessary thinking. – mcandril Feb 15 '12 at 10:57
@mcandril thanks for the Accept. Since that is the part of the answer you find most helpful I shall put it in bold. – Mr.Wizard Feb 15 '12 at 11:02

The units associated with physical constants do not play nicely with expressions that expect a numerical value. If you want only the numerical value of a constant, use Part. A motivating example:


Plot[1/Sqrt[1 - v^2/SpeedOfLight^2], {v, 0, 0.9 SpeedOfLight}]

 (* Plot::plln: Limiting value (2.69813*10^8 Meter)/Second in {v,0,0.9 SpeedOfLight} is not a machine-sized real number. >> *)    

 (* 299792458 *)

Plot[1/Sqrt[1 - v^2/c^2], {v, 0, 0.9 c}]

Mathematica graphics

To see why using Part works, turn the constant into a list:

 (* {299792458, Meter, 1/Second} *)

or look at its FullForm:

 (* Times[299792458, Meter, Power[Second, -1]] *)    
share|improve this answer
I don't mean to be rude, but I am unable to see how this is an answer to the question. Perhaps you could include an explanation of how one would use this. – Mr.Wizard Feb 15 '12 at 15:35
@Mr.Wizard I must disagree that it is not an answer. It provides a simple, if unexplained, way for stripping off the units. I'd say the answer can be improved by discussing why this works. Also, the only caution for this method is that by stripping off the units you're no longer able to check if they're correct. – rcollyer Feb 15 '12 at 15:50
@Mr OP indicated interest initially in the numerical quantities, only to find inconvenient units attached to them. I use the Part@ routinely in problems requiring the values but not the units. I will update with an example later. – JxB Feb 15 '12 at 16:01
Thank you, I now see that interpretation. +1 – Mr.Wizard Feb 15 '12 at 16:02

With version 9, this is now possible using this method:

Plot[1/Sqrt[1 - v^2/QuantityMagnitude[UnitConvert[Quantity["SpeedOfLight"]]]^2], {v, 0,0.9*QuantityMagnitude[UnitConvert[Quantity["SpeedOfLight"]]] }]
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.