Units - Maple Help
For the best experience, we recommend viewing online help using Google Chrome or Microsoft Edge.

 Units

 • The new Simple environment for units makes computations with units easier than ever.  It allows you to work with expressions such as $5⟦\mathrm{mm}⟧+x$, where $x$ is unassigned, as long as the dimensional analysis of the expression determines there is a valid quantity with units for the variable $x$.
 • Since the introduction of the Units package for Maple 7 (in 2001), there have been three ways to compute with unit expressions:
 – The default units environment, in which you explicitly invoke commands such as combine,units or convert,dimensions whenever you want to use unit functionality. This environment is suitable for expert users.
 – The Standard units environment, in which unit functionality is enabled for most basic operations. This environment requires that units are explicitly marked as such.
 – The Natural units environment, in which unit functionality is also enabled for most basic operations. This environment automatically interprets any variable name that corresponds to a unit name, as that unit.
 • Maple 2017 introduces a fourth way to compute with unit expressions: the Simple units environment. This differs from the Standard and Natural environments in two important ways, both of which make it easier to work with this environment in many cases:
 – The Standard and Natural environments require that whenever you use an unassigned variable (in the case of the Natural environment, an unassigned variable that is not the name of a unit), it represents a unitless quantity. This rule applies for verifying dimensional correctness - the process that makes sure you cannot add a distance to a velocity, for example. Concretely, you cannot just use a variable called $\mathrm{distance}$ to represent a distance to be determined later: instead, you might need to define $\mathrm{distance}$ by , so that $\mathrm{distance}$ is now an assigned variable and $\mathrm{distance_km}$ is a unitless quantity representing the number of kilometers that $\mathrm{distance}$ is long. This restriction is relaxed for the Simple units environment: unassigned variables are not assumed to have any particular dimension during testing of dimensional correctness.
 – The Simple units environment disregards so-called unit annotations when verifying dimensional correctness. These annotations are a mechanism to indicate that the physical quantity described by the unit is of a particular type. For example, the unit $\mathrm{mile_per_gallon}$ of fuel economy is defined in Maple as $\frac{\mathrm{mile}}{\mathrm{gallon}\left(\mathrm{petroleum}\right)}$; this allows Maple to distinguish it from a unit of the dimension $\frac{1}{{\mathrm{length}}^{2}}=\frac{1}{\mathrm{area}}$ (which would normally happen when simplifying an expression of the dimension $\frac{\mathrm{length}}{{\mathrm{length}}^{3}}=\frac{\mathrm{length}}{\mathrm{volume}}$). Another situation in which these annotations occur is in units of angle: a radian is defined as the angle that describes a circle sector in which the radius and the arc length are the same. This is defined in Maple as the unit $\frac{m}{m\left(\mathrm{radius}\right)}$.
 In many cases, however, users want to combine units while disregarding the unit annotations. This is particularly frequent whenever units of angle crop up. For that reason, the Simple units environment allows the addition of, for example, quantities with the dimension of angle to unitless quantities. The Standard and Natural environments do not.
 • Before Maple 2017, the default units environment always followed the same approach as the Standard and Natural units environments, with respect to these two issues. In Maple 2017, you can use the new $\mathrm{Units}\left[\mathrm{UseMode}\right]$ command to switch between these two approaches in the default units environment.

Examples

 > $\mathrm{with}\left(\mathrm{Units}:-\mathrm{Simple}\right):$

Consider a situation where you know an object will undergo uniform acceleration, with an initial velocity of 2.4 meters per second. We can derive the generic formula for the position of the object at an arbitrary time as follows. We start with the general formula for velocity under uniform acceleration.

 > $v≔\mathrm{v0}+at$
 ${v}{≔}{a}{}{t}{+}{\mathrm{v0}}$ (1)

Now we substitute the given starting velocity.

 > $\mathrm{eval}\left(v,\mathrm{v0}=2.4⟦\frac{m}{s}⟧\right)$
 ${a}{}{t}{+}{2.4}{}⟦\frac{{m}}{{s}}⟧$ (2)
 > $\mathrm{vs}≔$
 ${\mathrm{vs}}{≔}{a}{}{t}{+}{2.4}{}⟦\frac{{m}}{{s}}⟧$ (3)

Integrating this over time gives the requested answer.

 > $x≔\mathrm{x0}+{\int }_{0}^{\mathrm{t0}}\mathrm{vs}\phantom{\rule[-0.0ex]{0.3em}{0.0ex}}ⅆt$
 ${x}{≔}{\mathrm{x0}}{+}{0.5000000000}{}{a}{}{{\mathrm{t0}}}^{{2}}{+}{2.400000000}{}{\mathrm{t0}}{}⟦\frac{{m}}{{s}}⟧$ (4)

Now let's additionally specify that the object starts at the origin, and the acceleration is gravity. We orient our axis of displacement so that the initial velocity was upward, so in the opposite direction to gravity.

 > $\mathrm{gravity}≔\mathrm{evalf}\left(\mathrm{ScientificConstants}:-\mathrm{Constant}\left(g,\mathrm{units}\right)\right)$
 ${\mathrm{gravity}}{≔}{9.80665}{}⟦\frac{{m}}{{{s}}^{{2}}}⟧$ (5)
 > $\mathrm{eval}\left(x,\left[\mathrm{x0}=0⟦m⟧,a=-\mathrm{gravity}\right]\right)$
 ${-}{4.903325000}{}{{\mathrm{t0}}}^{{2}}{}⟦\frac{{m}}{{{s}}^{{2}}}⟧{+}{2.400000000}{}{\mathrm{t0}}{}⟦\frac{{m}}{{s}}⟧$ (6)

If we want to know the position after 0.4 seconds, we can obtain it like this.

 > $\mathrm{eval}\left(,\mathrm{t0}=0.4⟦s⟧\right)$
 ${0.1754680000}{}⟦{m}⟧$ (7)

This example comes from the example worksheets for the various units environments; specifically, for the version for the Simple units environment. You can compare the default units example worksheet, the Standard units example worksheet, and the Natural units example worksheet.

The first example shows how you can use unassigned variables to represent quantities that are not unitless. The following example will show a case where it comes in handy that annotations are ignored when verifying dimensional correctness.

Consider tightening a nut using a wrench. You apply a constant torque of 30 newton meters over 6 full rotations. The friction increases the temperature of the nut by 5 degrees Celsius; the nut, which is sizeable, has a mass of 80 grams and is made of steel. Steel has a specific heat capacity of 452 joules per kilogram per Kelvin. How much energy did you expend, how much of it was converted to heat, and how much leaked away into the environment?

 > $\mathrm{torque}≔30.⟦Nm⟧$
 ${\mathrm{torque}}{≔}{30.}{}⟦{N}{}{m}⟧$ (8)
 > $\mathrm{angle}≔6.⟦\mathrm{revolution}⟧$
 ${\mathrm{angle}}{≔}{6.}{}⟦{\mathrm{rev}}⟧$ (9)
 > $\mathrm{nut_mass}≔80.⟦g⟧$
 ${\mathrm{nut_mass}}{≔}{80.}{}⟦{g}⟧$ (10)
 > $\mathrm{heat_capacity}≔452.⟦\frac{\frac{J}{\mathrm{kg}}}{K}⟧$
 ${\mathrm{heat_capacity}}{≔}{452.}{}⟦\frac{{J}}{{\mathrm{kg}}{}{K}}⟧$ (11)
 > $\mathrm{temperature_rise}≔5⟦\mathrm{degC}⟧$
 ${\mathrm{temperature_rise}}{≔}{5}{}⟦{\mathrm{°C}}⟧$ (12)
 > $\mathrm{expended_energy}≔\mathrm{torque}\mathrm{angle}$
 ${\mathrm{expended_energy}}{≔}{1130.973355}{}⟦\frac{{{m}}^{{3}}{}{\mathrm{kg}}}{{{s}}^{{2}}{}{m}{}\left({\mathrm{radius}}\right)}⟧$ (13)
 > $\mathrm{heat}≔\mathrm{nut_mass}\mathrm{heat_capacity}\mathrm{temperature_rise}$
 ${\mathrm{heat}}{≔}{180.8000000}{}⟦{J}⟧$ (14)
 > $\mathrm{leaked}≔\mathrm{expended_energy}-\mathrm{heat}$
 ${\mathrm{leaked}}{≔}{950.1733550}{}⟦{J}⟧$ (15)

TestDimensions

 • At the heart of the Simple units environment is the new command Units[TestDimensions]. This command verifies dimensional correctness of one or more expressions with units. By default, it returns true if there is a valid assignment of dimensions to all subexpressions of expr, and false otherwise. Validity is tested for all subexpressions occurring in expr.
 • This command can be useful to verify the dimensional validity of, for example, a set of equations involving some quantities with units.
 > $\mathrm{with}\left(\mathrm{Units}\right):$
 > $\mathrm{eq1}≔F=ma$
 ${\mathrm{eq1}}{≔}{F}{=}{m}{}{a}$ (16)
 > $\mathrm{eq2}≔F={m}^{2}a$
 ${\mathrm{eq2}}{≔}{F}{=}{{m}}^{{2}}{}{a}$ (17)
 > $\mathrm{TestDimensions}\left(\mathrm{eq1},\left\{F::⟦N⟧,a::\left(⟦\frac{m}{{s}^{2}}⟧\right),m::⟦\mathrm{kg}⟧\right\}\right)$
 ${\mathrm{true}}$ (18)
 > $\mathrm{TestDimensions}\left(\mathrm{eq2},\left\{F::⟦N⟧,a::\left(⟦\frac{m}{{s}^{2}}⟧\right),m::⟦\mathrm{kg}⟧\right\}\right)$
 ${\mathrm{false}}$ (19)
 • If you know the dimension of only some of the quantities occurring in a set of equations, you can derive some things about the dimensions of the other symbols and of composite subexpressions. Sometimes you can fully derive the dimension of some quantities, other times there is not enough information.
 > $\mathrm{TestDimensions}\left(\mathrm{eq1},\left\{F::⟦N⟧,m::⟦\mathrm{kg}⟧\right\},\mathrm{output}=\mathrm{units}\right)$
 $\left\{{F}{::}⟦{N}⟧{,}{a}{::}\left(⟦\frac{{m}}{{{s}}^{{2}}}⟧\right){,}{m}{::}⟦{\mathrm{kg}}⟧{,}\left({m}{}{a}\right){::}⟦{N}⟧\right\}$ (20)
 • If there are multiple valid assignments of dimensions to the symbols in an expression (in other words, if there is not enough information to fully determine the dimensions of some quantities), then Maple will make an arbitrary choice.
 > $\mathrm{TestDimensions}\left(\mathrm{eq1},\left\{F::⟦N⟧\right\},\mathrm{output}=\mathrm{units}\right)$
 $\left\{{F}{::}⟦{N}⟧{,}{a}{::}{1}{,}{m}{::}⟦{N}⟧{,}\left({m}{}{a}\right){::}⟦{N}⟧\right\}$ (21)
 • Instead of expressing the dimension by using a unit of the given expression, Maple can also return the name of the dimension (as it would be returned by convert/dimensions with the base option).
 > $\mathrm{TestDimensions}\left(\mathrm{eq1},\left\{F::⟦N⟧,m::⟦\mathrm{kg}⟧\right\},\mathrm{output}=\mathrm{dimensions}\right)$
 $\left\{{F}{::}\left(\frac{{\mathrm{mass}}{}{\mathrm{length}}}{{{\mathrm{time}}}^{{2}}}\right){,}{a}{::}\left(\frac{{\mathrm{length}}}{{{\mathrm{time}}}^{{2}}}\right){,}{m}{::}{\mathrm{mass}}{,}\left({m}{}{a}\right){::}\left(\frac{{\mathrm{mass}}{}{\mathrm{length}}}{{{\mathrm{time}}}^{{2}}}\right)\right\}$ (22)
 • In this case, if there is ambiguity in the given set of expressions, Maple will determine an expression representing the fully general dimension for any subexpression. These expressions are mostly useful for programmer access.
 > $\mathrm{result}≔\mathrm{TestDimensions}\left(\mathrm{eq1},\left\{F::⟦N⟧\right\},\mathrm{output}=\mathrm{dimensions}\right)$
 ${\mathrm{result}}{≔}\left\{{F}{::}\left(\frac{{\mathrm{mass}}{}{\mathrm{length}}}{{{\mathrm{time}}}^{{2}}}\right){,}{a}{::}\left({{\mathrm{length}}}^{{{\mathrm{_t58}}}_{{1}{,}{1}}}{}{{\mathrm{mass}}}^{{{\mathrm{_t58}}}_{{1}{,}{2}}}{}{{\mathrm{time}}}^{{{\mathrm{_t58}}}_{{1}{,}{3}}}{}{{\mathrm{electric_current}}}^{{{\mathrm{_t58}}}_{{1}{,}{4}}}{}{{\mathrm{thermodynamic_temperature}}}^{{{\mathrm{_t58}}}_{{1}{,}{5}}}{}{{\mathrm{amount_of_substance}}}^{{{\mathrm{_t58}}}_{{1}{,}{6}}}{}{{\mathrm{luminous_intensity}}}^{{{\mathrm{_t58}}}_{{1}{,}{7}}}{}{{\mathrm{currency}}}^{{{\mathrm{_t58}}}_{{1}{,}{8}}}{}{{\mathrm{amount_of_information}}}^{{{\mathrm{_t58}}}_{{1}{,}{9}}}{}{{\mathrm{logarithmic_gain}}}^{{{\mathrm{_t58}}}_{{1}{,}{10}}}\right){,}{m}{::}\left({{\mathrm{length}}}^{{1}{-}{{\mathrm{_t58}}}_{{1}{,}{1}}}{}{{\mathrm{mass}}}^{{1}{-}{{\mathrm{_t58}}}_{{1}{,}{2}}}{}{{\mathrm{time}}}^{{-}{2}{-}{{\mathrm{_t58}}}_{{1}{,}{3}}}{}{{\mathrm{electric_current}}}^{{-}{{\mathrm{_t58}}}_{{1}{,}{4}}}{}{{\mathrm{thermodynamic_temperature}}}^{{-}{{\mathrm{_t58}}}_{{1}{,}{5}}}{}{{\mathrm{amount_of_substance}}}^{{-}{{\mathrm{_t58}}}_{{1}{,}{6}}}{}{{\mathrm{luminous_intensity}}}^{{-}{{\mathrm{_t58}}}_{{1}{,}{7}}}{}{{\mathrm{currency}}}^{{-}{{\mathrm{_t58}}}_{{1}{,}{8}}}{}{{\mathrm{amount_of_information}}}^{{-}{{\mathrm{_t58}}}_{{1}{,}{9}}}{}{{\mathrm{logarithmic_gain}}}^{{-}{{\mathrm{_t58}}}_{{1}{,}{10}}}\right){,}\left({m}{}{a}\right){::}\left(\frac{{\mathrm{mass}}{}{\mathrm{length}}}{{{\mathrm{time}}}^{{2}}}\right)\right\}$ (23)
 • By manipulating the result, we can see that the dimension of $ma$ is indeed what is claimed.
 > $\mathrm{result_as_equations}≔\mathrm{map}\left(\mathrm{lhs}=\mathrm{rhs},\mathrm{result}\right)$
 ${\mathrm{result_as_equations}}{≔}\left\{{F}{=}\frac{{\mathrm{mass}}{}{\mathrm{length}}}{{{\mathrm{time}}}^{{2}}}{,}{a}{=}{{\mathrm{length}}}^{{{\mathrm{_t58}}}_{{1}{,}{1}}}{}{{\mathrm{mass}}}^{{{\mathrm{_t58}}}_{{1}{,}{2}}}{}{{\mathrm{time}}}^{{{\mathrm{_t58}}}_{{1}{,}{3}}}{}{{\mathrm{electric_current}}}^{{{\mathrm{_t58}}}_{{1}{,}{4}}}{}{{\mathrm{thermodynamic_temperature}}}^{{{\mathrm{_t58}}}_{{1}{,}{5}}}{}{{\mathrm{amount_of_substance}}}^{{{\mathrm{_t58}}}_{{1}{,}{6}}}{}{{\mathrm{luminous_intensity}}}^{{{\mathrm{_t58}}}_{{1}{,}{7}}}{}{{\mathrm{currency}}}^{{{\mathrm{_t58}}}_{{1}{,}{8}}}{}{{\mathrm{amount_of_information}}}^{{{\mathrm{_t58}}}_{{1}{,}{9}}}{}{{\mathrm{logarithmic_gain}}}^{{{\mathrm{_t58}}}_{{1}{,}{10}}}{,}{m}{=}{{\mathrm{length}}}^{{1}{-}{{\mathrm{_t58}}}_{{1}{,}{1}}}{}{{\mathrm{mass}}}^{{1}{-}{{\mathrm{_t58}}}_{{1}{,}{2}}}{}{{\mathrm{time}}}^{{-}{2}{-}{{\mathrm{_t58}}}_{{1}{,}{3}}}{}{{\mathrm{electric_current}}}^{{-}{{\mathrm{_t58}}}_{{1}{,}{4}}}{}{{\mathrm{thermodynamic_temperature}}}^{{-}{{\mathrm{_t58}}}_{{1}{,}{5}}}{}{{\mathrm{amount_of_substance}}}^{{-}{{\mathrm{_t58}}}_{{1}{,}{6}}}{}{{\mathrm{luminous_intensity}}}^{{-}{{\mathrm{_t58}}}_{{1}{,}{7}}}{}{{\mathrm{currency}}}^{{-}{{\mathrm{_t58}}}_{{1}{,}{8}}}{}{{\mathrm{amount_of_information}}}^{{-}{{\mathrm{_t58}}}_{{1}{,}{9}}}{}{{\mathrm{logarithmic_gain}}}^{{-}{{\mathrm{_t58}}}_{{1}{,}{10}}}{,}{m}{}{a}{=}\frac{{\mathrm{mass}}{}{\mathrm{length}}}{{{\mathrm{time}}}^{{2}}}\right\}$ (24)
 > $\mathrm{m_dim}≔\mathrm{eval}\left(m,\mathrm{result_as_equations}\right)$
 ${\mathrm{m_dim}}{≔}{{\mathrm{length}}}^{{1}{-}{{\mathrm{_t58}}}_{{1}{,}{1}}}{}{{\mathrm{mass}}}^{{1}{-}{{\mathrm{_t58}}}_{{1}{,}{2}}}{}{{\mathrm{time}}}^{{-}{2}{-}{{\mathrm{_t58}}}_{{1}{,}{3}}}{}{{\mathrm{electric_current}}}^{{-}{{\mathrm{_t58}}}_{{1}{,}{4}}}{}{{\mathrm{thermodynamic_temperature}}}^{{-}{{\mathrm{_t58}}}_{{1}{,}{5}}}{}{{\mathrm{amount_of_substance}}}^{{-}{{\mathrm{_t58}}}_{{1}{,}{6}}}{}{{\mathrm{luminous_intensity}}}^{{-}{{\mathrm{_t58}}}_{{1}{,}{7}}}{}{{\mathrm{currency}}}^{{-}{{\mathrm{_t58}}}_{{1}{,}{8}}}{}{{\mathrm{amount_of_information}}}^{{-}{{\mathrm{_t58}}}_{{1}{,}{9}}}{}{{\mathrm{logarithmic_gain}}}^{{-}{{\mathrm{_t58}}}_{{1}{,}{10}}}$ (25)
 > $\mathrm{a_dim}≔\mathrm{eval}\left(a,\mathrm{result_as_equations}\right)$
 ${\mathrm{a_dim}}{≔}{{\mathrm{length}}}^{{{\mathrm{_t58}}}_{{1}{,}{1}}}{}{{\mathrm{mass}}}^{{{\mathrm{_t58}}}_{{1}{,}{2}}}{}{{\mathrm{time}}}^{{{\mathrm{_t58}}}_{{1}{,}{3}}}{}{{\mathrm{electric_current}}}^{{{\mathrm{_t58}}}_{{1}{,}{4}}}{}{{\mathrm{thermodynamic_temperature}}}^{{{\mathrm{_t58}}}_{{1}{,}{5}}}{}{{\mathrm{amount_of_substance}}}^{{{\mathrm{_t58}}}_{{1}{,}{6}}}{}{{\mathrm{luminous_intensity}}}^{{{\mathrm{_t58}}}_{{1}{,}{7}}}{}{{\mathrm{currency}}}^{{{\mathrm{_t58}}}_{{1}{,}{8}}}{}{{\mathrm{amount_of_information}}}^{{{\mathrm{_t58}}}_{{1}{,}{9}}}{}{{\mathrm{logarithmic_gain}}}^{{{\mathrm{_t58}}}_{{1}{,}{10}}}$ (26)
 > $\mathrm{expand}\left(\mathrm{m_dim}\mathrm{a_dim}\right)=\mathrm{eval}\left(ma,\mathrm{result_as_equations}\right)$
 $\frac{{\mathrm{mass}}{}{\mathrm{length}}}{{{\mathrm{time}}}^{{2}}}{=}\frac{{\mathrm{mass}}{}{\mathrm{length}}}{{{\mathrm{time}}}^{{2}}}$ (27)