Using Units and Dimensions in Maple Documents - Maple Programming Help

Using Units and Dimensions in Maple Documents

 Introduction Maple provides the most comprehensive package in the software industry for managing units and dimensions. Problems in science and engineering can now be fully managed with appropriate dimensions in any modern unit system (and even some historical systems!), including MKS, FPS, CGS, atomic, and more. Over 500 standard units are recognized by the Maple Units package.   This document explains how the Units package is structured, how to do simple and complex conversions between units, and how to use units in a Maple document. It also gives tips and examples on how to effectively use the different notation styles, how to change the default measurement system, and how to customize defaults in an existing measurement system.   For an introductory tutorial on units, see the Units Tutorial.  For more detailed help on the support for units and dimensions in Maple, see the Units package. Operating Environments Default Environment: For basic units support, you do not need to load the Units package. Maple will allow you to assign units to variables and expressions through the Units palettes and perform calculations with them. The unit names are treated as non-assigned symbols and will be manipulated to give the correct combination of units in your results.   However, you can perform unit conversions and simplifications on your expressions by right-clicking the expression and using the context menu.   For more details on the Default units environment, click here. Default Environment Examples Enter the units by clicking the appropriate symbol in the Units (SI) or Units (FPS) palette on the left. $\colorbox[rgb]{0,0,0}{\mathrm{restart}}$ $\colorbox[rgb]{0,0,0}{}$ $\colorbox[rgb]{0,0,0}{\mathrm{mass}}\colorbox[rgb]{0,0,0}{:=}\colorbox[rgb]{0,0,0}{90.4}⟦\mathrm{kg}⟧\colorbox[rgb]{0,0,0}{:}$$\colorbox[rgb]{0,0,0}{}$ $\colorbox[rgb]{0,0,0}{l}\colorbox[rgb]{0,0,0}{:=}\colorbox[rgb]{0,0,0}{34}⟦\colorbox[rgb]{0,0,0}{\mathrm{cm}}⟧\colorbox[rgb]{0,0,0}{:}$ $\colorbox[rgb]{0,0,0}{t}\colorbox[rgb]{0,0,0}{:=}\colorbox[rgb]{0,0,0}{24.5}⟦s⟧:$$\colorbox[rgb]{0,0,0}{}$ $\colorbox[rgb]{0,0,0}{\mathrm{f1}}\colorbox[rgb]{0,0,0}{≔}\frac{\mathrm{mass}\cdot l}{{t}^{2}}$ = $\frac{\colorbox[rgb]{0,0,0}{{5.120533111}}\colorbox[rgb]{0,0,0}{{}}⟦\colorbox[rgb]{0,0,0}{{\mathrm{kg}}}⟧\colorbox[rgb]{0,0,0}{{}}⟦\colorbox[rgb]{0,0,0}{{\mathrm{cm}}}⟧}{{⟦\colorbox[rgb]{0,0,0}{{s}}⟧}^{\colorbox[rgb]{0,0,0}{{2}}}}$ Right-click and select Units>Simplify to give: $\colorbox[rgb]{0,0,0}{{0.05120533111}}\colorbox[rgb]{0,0,0}{{}}⟦\colorbox[rgb]{0,0,0}{{N}}⟧$$\colorbox[rgb]{0,0,0}{}$ $\colorbox[rgb]{0,0,0}{}$ Natural Environment: You can express unit variables as ordinary variables without special notation.   This convenient notation is very readable, and is suitable for many situations, including interactive calculations where you have a limited number of user-defined variable names. The Natural units notation is suitable for situations in which you are confident you will not create naming conflicts or expressions that appear ambiguous. Because the Units package supports many units, many names are "taken" when the Natural notation is used. This list will contain many unit names which you may not even be aware are units, for example, f, year, barn, and Pa. Using these names as variables could inadvertently create problems with your calculations.   For more details on Units[Natural], click here. Natural Environment Examples $\colorbox[rgb]{0,0,0}{\mathrm{with}}\left(\colorbox[rgb]{0,0,0}{\mathrm{Units}}\left[\colorbox[rgb]{0,0,0}{\mathrm{Natural}}\right]\right)\colorbox[rgb]{0,0,0}{:}$ $\colorbox[rgb]{0,0,0}{4.2}\colorbox[rgb]{0,0,0}{\cdot }\colorbox[rgb]{0,0,0}{m}\colorbox[rgb]{0,0,0}{+}\colorbox[rgb]{0,0,0}{32}\colorbox[rgb]{0,0,0}{\cdot }\colorbox[rgb]{0,0,0}{\mathrm{cm}}$ = $\colorbox[rgb]{0,0,0}{{4.520000000}}\colorbox[rgb]{0,0,0}{{}}⟦\colorbox[rgb]{0,0,0}{{m}}⟧$$\colorbox[rgb]{0,0,0}{}$ $\colorbox[rgb]{0,0,0}{\mathrm{f2}}\colorbox[rgb]{0,0,0}{≔}\frac{\mathrm{mass}\cdot l}{{t}^{2}}$ = $\colorbox[rgb]{0,0,0}{{0.05120533110}}\colorbox[rgb]{0,0,0}{{}}⟦\colorbox[rgb]{0,0,0}{{N}}⟧$ $\colorbox[rgb]{0,0,0}{}$ But, because s is defined as seconds in the Natural units environment, if you attempt to use it in a symbolic calculation, Maple returns an error. $\frac{ⅆ}{ⅆs\phantom{\rule[-0.0ex]{0.2em}{0.0ex}}}\phantom{\rule[-0.0ex]{0.4em}{0.0ex}}{s}^{2}$    $\colorbox[rgb]{0,0,0}{}$ Standard Environment: Allows you to take full advantage of the units and dimensions support in the Units package. Unit names are separated from variable names so that you can still use variables with the same name for other computations.   You assign units to variables or expressions either using the Unit() function or the Units palettes on the left. The palettes contain a selection of the most commonly used units in the SI and FPS (foot-pound-second) systems but there are many more built into the product. If you do not find the unit you need, simply select the $⟦{\mathrm{unit}}⟧$ symbol and enter the unit name into the placeholder.   For more details on Units[Standard], click here. Standard Environment Examples $\colorbox[rgb]{0,0,0}{\mathrm{restart}}$ $\colorbox[rgb]{0,0,0}{\mathrm{with}}\left(\colorbox[rgb]{0,0,0}{\mathrm{Units}}\left[\colorbox[rgb]{0,0,0}{\mathrm{Standard}}\right]\right)\colorbox[rgb]{0,0,0}{:}$ $\colorbox[rgb]{0,0,0}{}$ $\colorbox[rgb]{0,0,0}{\mathrm{mass}}\colorbox[rgb]{0,0,0}{:=}\colorbox[rgb]{0,0,0}{90.4}⟦\mathrm{kg}⟧:$$\colorbox[rgb]{0,0,0}{}$ $\colorbox[rgb]{0,0,0}{l}\colorbox[rgb]{0,0,0}{:=}\colorbox[rgb]{0,0,0}{34}⟦\colorbox[rgb]{0,0,0}{\mathrm{cm}}⟧\colorbox[rgb]{0,0,0}{:}$ $\colorbox[rgb]{0,0,0}{t}\colorbox[rgb]{0,0,0}{:=}\colorbox[rgb]{0,0,0}{24.5}⟦\colorbox[rgb]{0,0,0}{s}⟧\colorbox[rgb]{0,0,0}{:}$ $\colorbox[rgb]{0,0,0}{}$ $\mathrm{f3}≔\frac{\mathrm{mass}\cdot l}{{t}^{2}}$ = $\colorbox[rgb]{0,0,0}{{0.05120533110}}\colorbox[rgb]{0,0,0}{{}}⟦\colorbox[rgb]{0,0,0}{{N}}⟧$ $\colorbox[rgb]{0,0,0}{}$ $\frac{ⅆ}{ⅆ\phantom{\rule[-0.0ex]{0.2em}{0.0ex}}s}\colorbox[rgb]{0,0,0}{}\phantom{\rule[-0.0ex]{0.4em}{0.0ex}}{\colorbox[rgb]{0,0,0}{s}}^{\colorbox[rgb]{0,0,0}{2}}$ = $\colorbox[rgb]{0,0,0}{{2}}\colorbox[rgb]{0,0,0}{{}}\colorbox[rgb]{0,0,0}{{s}}$ $\colorbox[rgb]{0,0,0}{}$ Advanced Environment:  The full units environment provides functions that allow you to make changes to the units support: add new units, rename existing ones, even create your own systems of units.   For more information, click here.   Advanced Environment Examples Converting between Measurement Systems Maple automatically converts the answer to a default unit system and unit. SI is the default unit system used by the Units package.   $\mathrm{with}\left(\mathrm{Units}\right)\colorbox[rgb]{0,0,0}{:}$ $\colorbox[rgb]{0,0,0}{\mathrm{with}}\left(\colorbox[rgb]{0,0,0}{\mathrm{Units}}\left[\colorbox[rgb]{0,0,0}{\mathrm{Standard}}\right]\right)\colorbox[rgb]{0,0,0}{:}$  = $\colorbox[rgb]{0,0,0}{{1308.100000}}\colorbox[rgb]{0,0,0}{{}}⟦\colorbox[rgb]{0,0,0}{{\mathrm{mm}}}⟧$  You can easily express the above in the standard US (FPS: foot-pound-second) system using the convert command.  = $\colorbox[rgb]{0,0,0}{{4.291666667}}\colorbox[rgb]{0,0,0}{{}}⟦\colorbox[rgb]{0,0,0}{{\mathrm{ft}}}⟧$    The default unit system can be changed using the Units[UseSystem] command. $\mathrm{Units}\left[\mathrm{UseSystem}\right]\left(\mathrm{FPS}\right):$  = $\colorbox[rgb]{0,0,0}{{31603.35958}}\colorbox[rgb]{0,0,0}{{}}⟦\colorbox[rgb]{0,0,0}{{\mathrm{ft}}}⟧$ Finding what Unit Systems are Available The GetSystems() function returns an expression sequence of all systems of units.   $\colorbox[rgb]{0,0,0}{\mathrm{with}}\left(\colorbox[rgb]{0,0,0}{\mathrm{Units}}\right)\colorbox[rgb]{0,0,0}{:}$ $\colorbox[rgb]{0,0,0}{\mathrm{GetSystems}}\left(\colorbox[rgb]{0,0,0}{}\right)$ = $\colorbox[rgb]{0,0,0}{{\mathrm{Atomic}}}\colorbox[rgb]{0,0,0}{{,}}\colorbox[rgb]{0,0,0}{{\mathrm{CGS}}}\colorbox[rgb]{0,0,0}{{,}}\colorbox[rgb]{0,0,0}{{\mathrm{EMU}}}\colorbox[rgb]{0,0,0}{{,}}\colorbox[rgb]{0,0,0}{{\mathrm{ESU}}}\colorbox[rgb]{0,0,0}{{,}}\colorbox[rgb]{0,0,0}{{\mathrm{FPS}}}\colorbox[rgb]{0,0,0}{{,}}\colorbox[rgb]{0,0,0}{{\mathrm{MKS}}}\colorbox[rgb]{0,0,0}{{,}}\colorbox[rgb]{0,0,0}{{\mathrm{MTS}}}\colorbox[rgb]{0,0,0}{{,}}\colorbox[rgb]{0,0,0}{{\mathrm{SI}}}$$\colorbox[rgb]{0,0,0}{}$   Redefining Default Units inside a Measurement System Inside each measurement system, each dimension has a specified default unit. For example, all length calculations done inside the SI system return answers in meters. It is possible to change the default unit for a particular dimension, which will be respected even after combining and simplifying units, while leaving the rest of the measurement system unchanged.   $\mathrm{with}\left(\mathrm{Units}\right)\colorbox[rgb]{0,0,0}{:}$ $\mathrm{AddSystem}\left(\mathrm{NewSI},\mathrm{GetSystem}\colorbox[rgb]{0,0,0}{}\left(\mathrm{SI}\right),\mathrm{mm}\right)\colorbox[rgb]{0,0,0}{:}$ $\mathrm{UseSystem}\left(\mathrm{NewSI}\right)\colorbox[rgb]{0,0,0}{:}$ $\mathrm{Unit}\left(50000.⟦{\mathrm{cm}}^{2}⟧\right),\mathrm{Unit}\colorbox[rgb]{0,0,0}{}\left(3.⟦\mathrm{cm}⟧\right),\mathrm{Unit}\colorbox[rgb]{0,0,0}{}(11.⟦{\mathrm{ft}}^{3}⟧)$ = $\colorbox[rgb]{0,0,0}{{5.000000000}}\colorbox[rgb]{0,0,0}{{}}⟦{\colorbox[rgb]{0,0,0}{{m}}}^{\colorbox[rgb]{0,0,0}{{2}}}⟧\colorbox[rgb]{0,0,0}{{,}}\colorbox[rgb]{0,0,0}{{30.00000000}}\colorbox[rgb]{0,0,0}{{}}⟦\colorbox[rgb]{0,0,0}{{\mathrm{mm}}}⟧\colorbox[rgb]{0,0,0}{{,}}\colorbox[rgb]{0,0,0}{{0.3114853125}}\colorbox[rgb]{0,0,0}{{}}⟦{\colorbox[rgb]{0,0,0}{{m}}}^{\colorbox[rgb]{0,0,0}{{3}}}⟧$ Unit conversions For simple conversions between units, the convenient Unit Calculator is available. From Tools menu, select Assistants>Units Calculator or in Maple help, type assistants,Units. No knowledge of the Units package is required. All the available dimensions and units are selected from a list, so you know instantly what is available with no worries over choosing the proper spelling or abbreviation. The convert() command The Maple convert() command can be used directly for unit conversions without the with(Units) command.   To determine the conversion factor, use an unassigned variable in the convert command. For example, to see the conversion formula from calories to joules: $\colorbox[rgb]{0,0,0}{\mathrm{restart}}$ $\colorbox[rgb]{0,0,0}{\mathrm{convert}}\colorbox[rgb]{0,0,0}{(}\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}\colorbox[rgb]{0,0,0}{1.0}\colorbox[rgb]{0,0,0}{,}\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}\colorbox[rgb]{0,0,0}{\mathrm{units}}\colorbox[rgb]{0,0,0}{,}\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}\colorbox[rgb]{0,0,0}{\mathrm{ft}}\colorbox[rgb]{0,0,0}{,}\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}\colorbox[rgb]{0,0,0}{m}\colorbox[rgb]{0,0,0}{)}$ = $\colorbox[rgb]{0,0,0}{{0.3048000000}}$  $\colorbox[rgb]{0,0,0}{}$ $\colorbox[rgb]{0,0,0}{}$ $\colorbox[rgb]{0,0,0}{\mathrm{convert}}\colorbox[rgb]{0,0,0}{(}\colorbox[rgb]{0,0,0}{x}\colorbox[rgb]{0,0,0}{,}\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}\colorbox[rgb]{0,0,0}{\mathrm{units}}\colorbox[rgb]{0,0,0}{,}\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}\colorbox[rgb]{0,0,0}{\mathrm{cal}}\colorbox[rgb]{0,0,0}{,}\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}\colorbox[rgb]{0,0,0}{J}\colorbox[rgb]{0,0,0}{)}$ = $\frac{\colorbox[rgb]{0,0,0}{{523}}}{\colorbox[rgb]{0,0,0}{{125}}}\colorbox[rgb]{0,0,0}{{}}\colorbox[rgb]{0,0,0}{{x}}$ Temperature conversions The units conversion for temperature converts changes (for example, a temperature change of 5° Celsius is the same as a change of 9° Fahrenheit). To convert absolute temperatures from one scale to another, use the temperature option to convert(). $\colorbox[rgb]{0,0,0}{}$ $\colorbox[rgb]{0,0,0}{\mathrm{convert}}\colorbox[rgb]{0,0,0}{(}\colorbox[rgb]{0,0,0}{5}\colorbox[rgb]{0,0,0}{,}\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}\colorbox[rgb]{0,0,0}{\mathrm{units}}\colorbox[rgb]{0,0,0}{,}\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}\colorbox[rgb]{0,0,0}{\mathrm{degC}}\colorbox[rgb]{0,0,0}{,}\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}\colorbox[rgb]{0,0,0}{\mathrm{degF}}\colorbox[rgb]{0,0,0}{)}$ = $\colorbox[rgb]{0,0,0}{{9}}$  $\colorbox[rgb]{0,0,0}{}$ $\colorbox[rgb]{0,0,0}{\mathrm{convert}}\colorbox[rgb]{0,0,0}{(}\colorbox[rgb]{0,0,0}{0}\colorbox[rgb]{0,0,0}{,}\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}\colorbox[rgb]{0,0,0}{\mathrm{temperature}}\colorbox[rgb]{0,0,0}{,}\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}\colorbox[rgb]{0,0,0}{\mathrm{degC}}\colorbox[rgb]{0,0,0}{,}\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}\colorbox[rgb]{0,0,0}{\mathrm{degF}}\colorbox[rgb]{0,0,0}{)}$ = $\colorbox[rgb]{0,0,0}{{32}}$ Angle Conversions All trigonometric functions in Maple expect angles in radians. In the Units[Standard] mode, you can simply enter the angle in any units and Maple automatically performs the conversion. $\mathrm{with}\left(\mathrm{Units}\left[\mathrm{Standard}\right]\right)\colorbox[rgb]{0,0,0}{:}$   $\mathrm{α}≔45.⟦\mathrm{deg}⟧\colorbox[rgb]{0,0,0}{:}$ $\mathrm{cos}\left(\mathrm{α}\right)$ = $\colorbox[rgb]{0,0,0}{{0.7071067811}}$ Displaying results in the units you want Sometimes, you will need to change the units of your result from the units computed by Maple. To do this, you can right-click the result, select Units>Replace Units, and then enter your desired units.   If you enter units with incompatible dimensions, you will get an error message. $\colorbox[rgb]{0,0,0}{\mathrm{with}}\left(\colorbox[rgb]{0,0,0}{\mathrm{Units}}\left[\colorbox[rgb]{0,0,0}{\mathrm{Standard}}\right]\right)\colorbox[rgb]{0,0,0}{:}$ $\colorbox[rgb]{0,0,0}{\mathrm{distance}}\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}\colorbox[rgb]{0,0,0}{:=}\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}\colorbox[rgb]{0,0,0}{5.0}⟦m⟧:$ $\colorbox[rgb]{0,0,0}{\mathrm{elapsedtime}}\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}\colorbox[rgb]{0,0,0}{:=}\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}\colorbox[rgb]{0,0,0}{10}⟦s⟧:$ $\colorbox[rgb]{0,0,0}{\mathrm{speed}}\colorbox[rgb]{0,0,0}{:=}\frac{\colorbox[rgb]{0,0,0}{\mathrm{distance}}}{\colorbox[rgb]{0,0,0}{\mathrm{elapsedtime}}}$ = $\colorbox[rgb]{0,0,0}{{0.5000000000}}\colorbox[rgb]{0,0,0}{{}}⟦\frac{\colorbox[rgb]{0,0,0}{{m}}}{\colorbox[rgb]{0,0,0}{{s}}}⟧$To convert to miles per hour right-click the result, select Units>Replace Units, and then enter your desired units: $\colorbox[rgb]{0,0,0}{{1.118468146}}\colorbox[rgb]{0,0,0}{{}}⟦\frac{\colorbox[rgb]{0,0,0}{{\mathrm{mi}}}}{\colorbox[rgb]{0,0,0}{{h}}}⟧$

Example: How much space does 1 billion dollars worth of gold occupy?

Initialize the Units package.

$\colorbox[rgb]{0,0,0}{\mathrm{restart}}$

$\colorbox[rgb]{0,0,0}{\mathrm{with}}\left(\colorbox[rgb]{0,0,0}{\mathrm{Units}}\left[\colorbox[rgb]{0,0,0}{\mathrm{Standard}}\right]\right)\colorbox[rgb]{0,0,0}{:}$

First, define the dollar value of the gold, cost per troy ounce (assume \$268), and the density.

$\colorbox[rgb]{0,0,0}{\mathrm{val}}\colorbox[rgb]{0,0,0}{:=}{\colorbox[rgb]{0,0,0}{10}}^{\colorbox[rgb]{0,0,0}{9}}⟦\mathrm{USD}⟧\colorbox[rgb]{0,0,0}{:}$

$\colorbox[rgb]{0,0,0}{\mathrm{costPerOz}}\colorbox[rgb]{0,0,0}{:=}\colorbox[rgb]{0,0,0}{268.00}⟦\frac{\colorbox[rgb]{0,0,0}{\mathrm{USD}}}{\colorbox[rgb]{0,0,0}{\mathrm{oz}}\left[\colorbox[rgb]{0,0,0}{\mathrm{troy}}\right]}⟧\colorbox[rgb]{0,0,0}{:}$

$\colorbox[rgb]{0,0,0}{\mathrm{density}}:=19.3⟦\frac{g}{{\mathrm{cm}}^{3}}⟧$ = $\colorbox[rgb]{0,0,0}{{19300.0}}\colorbox[rgb]{0,0,0}{{}}⟦\frac{\colorbox[rgb]{0,0,0}{{\mathrm{kg}}}}{{\colorbox[rgb]{0,0,0}{{m}}}^{\colorbox[rgb]{0,0,0}{{3}}}}⟧$

The resulting mass and volume are:

$\colorbox[rgb]{0,0,0}{\mathrm{mass}}\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}\colorbox[rgb]{0,0,0}{:=}\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}\frac{\colorbox[rgb]{0,0,0}{\mathrm{val}}}{\colorbox[rgb]{0,0,0}{\mathrm{costPerOz}}}$ = $\colorbox[rgb]{0,0,0}{{1.160577493}}\colorbox[rgb]{0,0,0}{{}}{\colorbox[rgb]{0,0,0}{{10}}}^{\colorbox[rgb]{0,0,0}{{5}}}\colorbox[rgb]{0,0,0}{{}}⟦\colorbox[rgb]{0,0,0}{{\mathrm{kg}}}⟧$

$\colorbox[rgb]{0,0,0}{\mathrm{volume}}\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}\colorbox[rgb]{0,0,0}{:=}\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}\frac{\colorbox[rgb]{0,0,0}{\mathrm{mass}}}{\colorbox[rgb]{0,0,0}{\mathrm{density}}}$ = $\colorbox[rgb]{0,0,0}{{6.013354886}}\colorbox[rgb]{0,0,0}{{}}⟦{\colorbox[rgb]{0,0,0}{{m}}}^{\colorbox[rgb]{0,0,0}{{3}}}⟧$

What is the length of one side of a cube having this volume?

$\colorbox[rgb]{0,0,0}{\mathrm{LengthSide}}\colorbox[rgb]{0,0,0}{:=}\sqrt[3]{\mathrm{volume}}$ = $\colorbox[rgb]{0,0,0}{{1.818467785}}\colorbox[rgb]{0,0,0}{{}}⟦\colorbox[rgb]{0,0,0}{{m}}⟧$

$\colorbox[rgb]{0,0,0}{}$

$\colorbox[rgb]{0,0,0}{}$