There is a way of operating with units as in the answers of Nasser and LouisB. However, before this was introduced, Mathematica used what I would call a more human way of treating units. It is exactly as you do. It only requires adding an assumption, as @Daniel Huber has shown. Instead, one can apply the following
yourExpression// Simplify[#, {m > 0, s > 0}] &
Alternatively, at the beginning of the session, one can evaluate the following:
$Assumptions = {erg > 0, dyne > 0, g > 0, cm > 0, s > 0, esu > 0,
m > 0, J > 0, Pa > 0, Ν > 0, F > 0, W > 0, μm > 0, nm > 0};
Here, one has to keep in mind that Ν
(Newton) is a Greek rather than a Latin letter.
After this, Mathematica will always know up to the end of the current session, that these units are positive, and you only need to apply Simplify
to your expression:
For example:
$Assumptions = {erg > 0, dyne > 0, g > 0, cm > 0, s > 0, esu > 0,
m > 0, J > 0, Pa > 0, Ν > 0, F > 0, W > 0, μm > 0,
nm > 0};
(314.159 m Sqrt[((7.34102*10^-6 - 0.0000178801 I) s^2)/m^2])/
s // Simplify
(* 1.14721 - 0.769126 I *)
The are three advantages:
- It is intuitive: it looks as we used to.
- It does not require extra typing.
- Easy rules help to transform them into any system. Below, for example, the rule to transform the units from the System International to CGS:
ruleSItoCGS = {Coul -> 310^9Sqrt[ergcm], J -> 10^7erg,
W -> 10^7erg/s, Pa -> (10^7erg)/(100cm)^3, kg -> 10^3g,
F -> 9.10^11cm, Ν -> 10^5ergcm^-1,
m -> 100cm, μm -> 10^-4cm, nm -> 10^-7cm,
kbar -> 10^9erg/cm^3};
One can easily invert this rule.
The disadvantage is that the letters reserved for units cannot be used as variables for some other aims.
Have fun
Assuming[{m > 0, s > 0}, (314.159 m Sqrt[((7.34102*10^-6 - 0.0000178801 I) s^2)/ m^2])/s // Simplify]
$\endgroup$