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?

  • 4
    $\begingroup$ Convert[Newton*Second^2/Meter, Kilogram]. $\endgroup$ Feb 15, 2012 at 10:21
  • 2
    $\begingroup$ 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... $\endgroup$ Feb 15, 2012 at 10:35

3 Answers 3


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.

  • 5
    $\begingroup$ One wonders why the functionality of "Automatic Units" has not already been incorporated in the package shipped with Mathematica... *grumbles* $\endgroup$ Feb 15, 2012 at 10:30
  • $\begingroup$ @J.M. why did you not post an answer, and then why did you not vote for mine? I find your actions perplexing. $\endgroup$
    – Mr.Wizard
    Feb 15, 2012 at 10:36
  • 1
    $\begingroup$ I'm out of votes, so I owe you a vote tomorrow. And no, I don't want rep for answering this question... $\endgroup$ Feb 15, 2012 at 10:40
  • $\begingroup$ 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. $\endgroup$
    – mcandril
    Feb 15, 2012 at 10:57
  • $\begingroup$ @mcandril thanks for the Accept. Since that is the part of the answer you find most helpful I shall put it in bold. $\endgroup$
    – Mr.Wizard
    Feb 15, 2012 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]] *)    
  • 1
    $\begingroup$ 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. $\endgroup$
    – Mr.Wizard
    Feb 15, 2012 at 15:35
  • 2
    $\begingroup$ @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. $\endgroup$
    – rcollyer
    Feb 15, 2012 at 15:50
  • 3
    $\begingroup$ @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. $\endgroup$
    – JxB
    Feb 15, 2012 at 16:01
  • $\begingroup$ Thank you, I now see that interpretation. +1 $\endgroup$
    – Mr.Wizard
    Feb 15, 2012 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"]]] }]

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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