4
$\begingroup$

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?

$\endgroup$

2 Answers 2

10
$\begingroup$

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:

enter image description here

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:

enter image description here

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

enter image description here

$\endgroup$
3
$\begingroup$
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

$\endgroup$
1
  • $\begingroup$ PowerExpand[] would also be useful here. $\endgroup$ Commented Aug 29, 2012 at 11:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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