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

Online Help

All Products    Maple    MapleSim


Improvements in Handling of Units in Maple 2024

Maple 2024 includes several improvements to the handling of units.

 

Faster computation with Matrices with Units

The Statistics package

The IPS system

Faster computation with Matrices with Units

• 

When working with matrices with entries with units, Maple can now perform operations much faster than before.  See the Performance Improvements in Maple 2024 help page for details.

The Statistics package

• 

The Statistics package deals with many aspects of statistics. Its functionality is divided up into a few large parts. Nearly all commands mentioned on the Descriptive Statistics, Random Variables, and Distributions help pages will work with units.

with(Statistics):

• 

Using a distribution will verify dimensional consistency of the units involved, and raise an error if the units are inconsistent, either because a particular parameter cannot have a (nontrivial) unit, or because multiple parameters have to agree with each other.

rv1 := RandomVariable(Normal(5*Unit(m), 2*Unit(s)));

Error, (in Statistics:-Distribution) units problem in parameters for distribution Normal; found contradictions {Distribution::(5*Units:-Unit(m)), Distribution::(2*Units:-Unit(s))}

rv1 := RandomVariable(Normal(5*Unit(m), 3*Unit(ft)));

rv1_R

(1)

rv2 := RandomVariable(Weibull(5*Unit(m), 2*Unit(m)));

Error, (in Statistics:-Distribution) units problem in 2nd parameter, 2*Units:-Unit(m), for distribution Weibull; found nontrivial unit, but did not expect one

rv2 := RandomVariable(Weibull(5*Unit(m), 2));

rv2_R0

(2)
• 

We can compute various statistical properties of these distributions as follows.

Mean(rv1);

5m

(3)

Variance(rv2);

2525π4m2

(4)

Skewness(rv1 - rv2);

61035156250ππ3403689499765625π32

(5)

evalf((5));

−0.5078727141

(6)
• 

The same commands are used to compute these properties of a data sample.

sample := [.0377*Unit(ft), .578*Unit(ft), 2.05*Unit(ft), 3.60*Unit(ft), 4.92*Unit(ft), 5.45*Unit(ft), 5.75*Unit(ft), 6.21*Unit(ft), 2.77*Unit(m), 3.41*Unit(m), 4.01*Unit(m), 4.54*Unit(m), 5.41*Unit(m), 5.54*Unit(m), 5.61*Unit(m), 6.18*Unit(m), 7.21*Unit(m), 9.34*Unit(m), 13.9*Unit(m), 14.9*Unit(m)];

sample0.0377ft,0.578ft,2.05ft,3.60ft,4.92ft,5.45ft,5.75ft,6.21ft,2.77m,3.41m,4.01m,4.54m,5.41m,5.54m,5.61m,6.18m,7.21m,9.34m,13.9m,14.9m

(7)

Mean(sample);

15.0157430049500ft

(8)

Variance(sample);

189.446615326348ft2

(9)

Skewness(sample);

1.18031316013932

(10)
• 

Cumulants of quantities with units are not well-defined. The Cumulant command checks for this and raises an error if appropriate.

Cumulant(rv1, 3);

Error, (in Statistics:-Cumulant) unexpected input: expected _R1*Units:-Unit(m) to not have units

distance := 3*Unit(m);

distance3m

(11)

Cumulant(rv2 / distance, 3);

2525π36125π18+125π32108

(12)

evalf((12));

0.290470418

(13)

Cumulant(sample, 3);

Error, (in Statistics:-Cumulant) unexpected input: expected Vector(20, [.1149096000e-1*Units:-Unit(m),.1761744000*Units:-Unit(m),.6248400000*Units:-Unit(m),1.097280000*Units:-Unit(m),1.499616000*Units:-Unit(m),1.661160000*Units:-Unit(m),1.752600000*Units:-Unit(m),1.892808000*Units:-Unit(m),2.77*Units:-Unit(m),3.41*Units:-Unit(m),4.01*Units:-Unit(m),4.54*Units:-Unit(m),5.41*Units:-Unit(m),5.54*Units:-Unit(m),5.61*Units:-Unit(m),6.18*Units:-Unit(m),7.21*Units:-Unit(m),9.34*Units:-Unit(m),13.9*Units:-Unit(m),14.9*Units:-Unit(m)]) to not have units

• 

The second argument of the AbsoluteDeviation command must have the same dimension as the first argument. If it doesn't, an error is raised.

AbsoluteDeviation(sample, 5*Unit(s));

Error, (in Statistics:-AbsoluteDeviation) unable to convert `s` to `ft`

AbsoluteDeviation(sample, 2*Unit(fathom));

10.1286139500500ft

(14)

AbsoluteDeviation(rv2, Mean(sample));

1.878130286m

(15)
• 

Covariance is defined for data samples with different dimensions. So is correlation. Note how the covariance has a unit, but the correlation doesn't.

Covariance(rv1 * rv2, rv1 + rv2);

125+40368949π625000525π5+5π22m3

(16)

evalf((16));

30.5302225m3

(17)

Correlation(rv1 * rv2, rv1);

114325π10403689499765625π

(18)

sample2 := [33.15 * Unit(N), 32.92 * Unit(N), 55.91 * Unit(N), 34.00 * Unit(N), 16.81 * Unit(N), 38.74 * Unit(N), 20.80 * Unit(N), -16.14 * Unit(N), 19.70 * Unit(N), 48.93 * Unit(N), 1.10 * Unit(N), 42.43 * Unit(N), 1.53 * Unit(N), -26.54 * Unit(N), 15.59 * Unit(N), 8.764 * Unit(N), -27.57 * Unit(N), -13.60 * Unit(N), -40.35 * Unit(N), -64.21 * Unit(N)];

sample233.15N,32.92N,55.91N,34.00N,16.81N,38.74N,20.80N,16.14N,19.70N,48.93N,1.10N,42.43N,1.53N,26.54N,15.59N,8.764N,27.57N,13.60N,40.35N,64.21N

(19)

Covariance(sample, sample2);

109.525825439543J

(20)

Correlation(sample, sample2);

−0.813010115206344

(21)

The IPS system

• 

Maple supports several so-called systems of units, which are combinations of units that are often used together. The default system is the SI system. Another system that is often used, especially in North America, is the FPS (foot-pound-second) system. For Maple 2024, we have added the IPS (inch-pound-second) system, demonstrated below.

restart;

with(Units):

Automatically loading the Units[Simple] subpackage

UseSystem(IPS);

velocity := 1*Unit(inch/second);

velocityins

(22)

mass := 5*Unit(pound);

mass5lb

(23)

velocity^2 * mass;

2540196133lbfin

(24)
• 

Converting this quantity to the SI and FPS system can be done, for example, as follows.

convert((24), 'system', 'SI');

731599133573500000000000000J

(25)

convert((24), 'system', 'FPS');

635588399lbfft

(26)
• 

The IPS system is also available in the Units Formatting dialog.

• 

Maple also supports more specialized systems of units.

convert((24), 'system', 'Atomic');

3.356155884×1014E0

(27)

convert((24), 'system', 'ESU');

73159913357350000000erg

(28)