 Part 10: Units - Maple Programming Help

Home : Support : Online Help : Getting Started : Tutorials : MaplePortal/Tutorial10 Part 10: Units

 Introduction Maple's Tutorials are designed to help you get started with Maple, learn about the key tools available in Maple, and lead you through a series of problems.   In Part 10: Units, you will learn how to add units to expressions, perform calculations with units, and convert units in Maple.  You will also learn how to customize units settings.  You will use units and tolerances together.   To try this material on your own, start with an empty Maple document. Perform the steps described in the left column of each table below.  The results of the steps are displayed in the right column for reference.   Refer to Help>Quick Reference for basic getting started tips.   Note for non-Windows users: The keystrokes given in this document are for Windows.  There will be differences for other platforms. If you are using a different platform, see Shortcut Keys.

Working with Units

Maple provides the most comprehensive package in the software industry for managing units and dimensions.  Over 500 standard units are recognized by Units package.

Steps

Result

Assigning Units from a Palette
Use the Units palette to define values with units.

Example:

Enter "Length:= 250.00", click on the Units palette, under Dimensionality select length, and then select $⟦m⟧$.

Repeat for lb (found under mass) and s (found under time).

Type "Force:= Length*Mass/Time^2" and press [Enter].

To simplify the units in this expression, select Units > Simplify from the Context Panel.

Tip: In the example above, if we'd try to assign to the variable Time, an error message would be displayed because Time is a Maple command name.

Other Units

To use a unit that does not appear in the palettes, use  $⟦{\mathrm{unit}}⟧$ from the palette, and replace ${\mathrm{unit}}$ with the desired unit.  You can enter a unit using its name or symbol.

Example:

Enter 60 miles per hour.











$\mathrm{Length}:=250.00⟦m⟧:$

$\mathrm{Mass}:=500.00⟦\mathrm{lb}⟧:$

$\mathrm{TimeDuration}≔25⟦s⟧:$

$\mathrm{Force}:=\frac{\mathrm{Length}\cdot \mathrm{Mass}}{{\mathrm{TimeDuration}}^{2}}$

 ${\mathrm{Force}}{≔}\frac{{200.0000000}}{{⟦{s}⟧}^{{2}}}⟦{m}⟧⟦{\mathrm{lb}}⟧$ (2.1)

$\stackrel{\text{simplify units}}{\to }$

 ${90.71847400}⟦{N}⟧$ (2.2)



















$60\frac{⟦\mathrm{mile}⟧}{⟦\mathrm{hour}⟧}$

 $\frac{{60}}{⟦{h}⟧}⟦{\mathrm{mi}}⟧$ (2.3)

Units Package

If the Units package is loaded, simplifications are automatic.

Example:

Type "with(Units):" and press [Enter] to load the Units package.

Reenter the computation for force and press [Enter].

Now units are automatically simplified into SI units.

Example:

Copy and paste 60 miles per hour, and press [Ctrl][=] to see the result inline.

The result is converted to meters per second.

Now, approximate the answer to 10 decimal places using the Context Panel item Approximate>10.

Example:

Using the palette, enter 12 feet + 1 inch.

Since the Units[Simple] package is loaded, the result is converted into meters, the SI base unit for length.

Tip:  Since $\mathbf{in}$ is a keyword in Maple, typing "in" as a unit will result in an error.  Instead, use the full name, "inch" or enclose the abbreviation in left single backquotes ( ) to indicate you are using it as a name.  See keyword for more information on reserved names.



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

$\frac{\mathrm{Length}\cdot \mathrm{Mass}}{{\mathrm{TimeDuration}}^{2}}$

 ${90.71847400}⟦{N}⟧$ (2.4)







$\frac{60⟦\mathrm{mi}⟧}{⟦h⟧}$ = $\frac{{16764}}{{625}}⟦\frac{{m}}{{s}}⟧$$\stackrel{\text{at 10 digits}}{\to }$${26.82240000}⟦\frac{{m}}{{s}}⟧$











$12⟦\mathrm{ft}⟧+1⟦\mathrm{inch}⟧$

 $\frac{{3683}}{{1000}}⟦{m}⟧$ (2.5)











 

$3⟦\mathrm{in}⟧$

 ${3}⟦{\mathrm{in}}⟧$ (2.6)







Converting Units with the Context Panel

The Context Panel item Units>Replace Units will convert your answer into the specified units.

Example:

Convert this example into kilometers per hour.  First, press [Ctrl][=] to see the result inline.  Then, from the Context Panel for the result, select Units>Replace Units and type "km/h".

You can also use the Context Panel to convert units from one system to another.

Example:

Consider the example with feet and inches.  Convert the result into feet.

From the Context Panel for the result, select Units > Convert > System >FPS  (foot-pound-second) to convert the length into feet.





$26.82240000⟦\frac{m}{s}⟧$ = ${26.82240000}⟦\frac{{m}}{{s}}⟧$$\stackrel{\text{replace units}}{\to }$${96.56064000}⟦\frac{{\mathrm{km}}}{{h}}⟧$

























$12⟦\mathrm{ft}⟧+1⟦\mathrm{inch}⟧$ = $\frac{{3683}}{{1000}}⟦{m}⟧$$\stackrel{\text{units to FPS system}}{\to }$$\frac{{145}}{{12}}⟦{\mathrm{ft}}⟧$

Customizing Unit Settings

Steps

Result

Setting the Default Unit System

You can control the unit system.  Initially, the default system is SI.  To change the default system, use the UseSystem command.

Example:

Set the unit system to FPS. .

Now, answers are returned in the FPS system.

$\mathrm{restart}$

$\mathrm{with}\left(\mathrm{Units}\left[\mathrm{Simple}\right]\right):$

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

$\mathrm{UsingSystem}\left(\right)$

 ${\mathrm{SI}}$ (3.1)

$\mathrm{UseSystem}\left('\mathrm{FPS}'\right)$

$12⟦\mathrm{ft}⟧+1⟦\mathrm{inch}⟧$

 $\frac{{145}}{{12}}⟦{\mathrm{ft}}⟧$ (3.2)



Converting Units with Commands

If necessary, you can customize a unit system for your needs.

For instance, consider the FPS units in this example.

Example:

Find the thermal conductivity of a conducting surface from its heat capacity and length.

The heat capacity of a conducting surface is given by k= 2, with units  $\frac{\mathrm{Btu}}{h\cdot \mathrm{ft}\cdot \mathrm{degF}}$.  The length is 2.5 ft.

The thermal capacity is heat capacity per length.

Notice the FPS units are not as expected.  The typical English units for heat capacity and thermal conductivity are $⟦\frac{\mathrm{Btu}}{h\cdot \mathrm{ft}\cdot \mathrm{degF}}⟧$ and $⟦\frac{\mathrm{Btu}}{h\cdot {\mathrm{ft}}^{2}\cdot \mathrm{degF}}⟧$.

Convert this result into the desired units.  The format is convert(u, 'units', unitTo), where u is the expression with units, and unitTo is the desired units.















$k≔2⟦\frac{\mathrm{Btu}}{h\cdot \mathrm{ft}\cdot \mathrm{degF}}⟧$

 ${k}{≔}{2}⟦\frac{{\mathrm{Btu}}}{{h}{\mathrm{ft}}{\mathrm{°F}}}⟧$ (3.3)

$m≔2.5⟦\mathrm{ft}⟧$

 ${m}{≔}{2.5}⟦{\mathrm{ft}}⟧$ (3.4)

$\mathrm{thermalcapacity}≔\frac{k}{m}$

 ${\mathrm{thermalcapacity}}{≔}{5.560024837}⟦\frac{{\mathrm{lb}}}{{{s}}^{{3}}{\mathrm{°F}}}⟧$ (3.5)







 ${0.7999999999}⟦\frac{{\mathrm{Btu}}}{{h}{{\mathrm{ft}}}^{{2}}{\mathrm{°F}}}⟧$ (3.6)



If you will use these units frequently, you may want to add them to the unit system.

Example:

Add the units $\frac{\mathrm{Btu}}{h\cdot \mathrm{ft}\cdot \mathrm{degF}}$ and $\frac{\mathrm{Btu}}{h\cdot {\mathrm{ft}}^{2}\cdot \mathrm{degF}}$ to the FPS unit system.  Call the new unit system myFPS.

Change the default system to the new system myFPS.

Review the calculation for thermal conductivity.









$\mathrm{AddSystem}\left(\mathrm{myFPS},\mathrm{GetSystem}\left(\mathrm{FPS}\right),\left(\frac{\mathrm{Btu}}{h\cdot \mathrm{ft}\cdot \mathrm{degF}}\right),\left(\frac{\mathrm{Btu}}{h\cdot {\mathrm{ft}}^{2}\cdot \mathrm{degF}}\right)\right)$







$\mathrm{UseSystem}\left(\mathrm{myFPS}\right)$

$\mathrm{k2}≔2⟦\frac{\mathrm{Btu}}{h\cdot \mathrm{ft}\cdot \mathrm{degF}}⟧$

 ${\mathrm{k2}}{≔}{2}⟦\frac{{\mathrm{Btu}}}{{h}{\mathrm{ft}}{\mathrm{°F}}}⟧$ (3.7)

$\mathrm{m2}≔2.5⟦\mathrm{ft}⟧$

 ${\mathrm{m2}}{≔}{2.5}⟦{\mathrm{ft}}⟧$ (3.8)

$\frac{\mathrm{k2}}{\mathrm{m2}}$

 ${0.8000000000}⟦\frac{{\mathrm{Btu}}}{{h}{{\mathrm{ft}}}^{{2}}{\mathrm{°F}}}⟧$ (3.9)





Reset the unit system to SI.

$\mathrm{UseSystem}\left('\mathrm{SI}'\right)$

Tolerances

Steps

Result

Using Tolerances

You can use the Tolerances package to calculate values with tolerances.  This utilizes the plus/minus notation. Units and Tolerances can be used concurrently.

Example:
Type "with(Tolerances):" and press [Enter] to load the package.

Enter values and tolerances for length, mass, and time.

To create the$±$sign, after each of the values, type "pm[Esc]".  Then, input the tolerance amount. Enter the units from the Units palette.

Now recalculate the answer for Force given the specified tolerance levels.















$\mathrm{with}\left(\mathrm{Tolerances}\right):$

 ${\mathrm{Length2}}{≔}{250.000}{±}{1.000}⟦{m}⟧$ (4.1)

 ${\mathrm{Mass2}}{≔}{500.000}{±}{0.500}⟦{\mathrm{lb}}⟧$ (4.2)

 ${\mathrm{Time2}}{≔}{25.000}{±}{3.000}⟦{s}⟧$ (4.3)

$\mathrm{Force2}≔\frac{\mathrm{Length2}\cdot \mathrm{Mass2}}{{\mathrm{Time2}}^{2}}$

 ${\mathrm{Force2}}{≔}{94.846}{±}{22.887}⟦{N}⟧$ (4.4)