# Calculate with units

If I want to calculate with units, for example using Pythagoras theorem, I would do this:

c = Sqrt[(3m)^2 + (5m)^2]


The result will be 5 Sqrt[m^2].

How can I define that m = Sqrt[m^2] and so forth?

-

Take a look at this blog post by Jon McLoone:

Automatic Physical Units in Mathematica

where he explains how to use this package:

Automatic Units

which has over 1000 physical units. Also you can simply use Wolfram|Alpha integration in Mathematica. At the beginning of any input line type single equal sign and see it turn into a large orange equal sign, - then compute:

Using little plus sign at the top right corner you can do more complicated things, like mixed units computation for mechanical kinetic energy below, giving correct units of Joules:

Typing equal sign twice you can get a full Wolfram|Alpha query in your notebook with more relevant info:

-
Assuming[m > 0, Simplify[Sqrt[(3 m)^2 + (5 m)^2]]]


Sqrt[34] m

Or, if you want to have this assumption during your whole session you could define:

\$Assumptions = {m > 0};


Now Simplify and any other function accepting the Assumptions option will use this assumption:

Simplify[Sqrt[(3 m)^2 + (5 m)^2]]


Sqrt[34] m

-
PowerExpand[] would also be useful here. –  Ｊ. Ｍ. Aug 29 '12 at 11:11