Before we get started, load ezunits.

load (ezunits);

1 Units in integrals and derivatives

1.1 Integral

Units for integrals and derivatives are derived as the same units that a finite approximation would yield. Turn off simplification for a moment so that we can have a look at the unsimplified form.

simp : false $
foo : 'integrate ((3 * t^2) ` m/s, t ` s, 0 ` s, t[1] ` s);

Now go ahead and simplify it.

simp : true $
foo : ''foo;
%, nouns;

1.2 Derivative

Again, have a look at the unsimplified form.

simp : false $
foo : 'diff (sqrt (t) ` inch, t ` year, 1);

Go ahead and simplify it.

simp : true $
foo : ''foo;
foo, nouns;

2 Units in solving equations

‘solve_dimensional’ can solve equations in which unit-ful expressions contain unknowns.

foo : solve_dimensional (10^6 ` Btu = 1/2 * (10 ` lbm) * v^2, v);
[v=(-8 552)Btulbm,v=8 552Btulbm]
dimensions (foo);
foo1 : foo `` m/s;
[``(v,ms)=(-128 5132105545359237)ms,``(v,ms)=128 5132105545359237ms]
float (foo1);

3 Selecting a named field from a unit-ful expression

‘@’ distributes over unit-ful expressions.

defstruct (my3d (x, y, z));
foo : my3d (17, 29, 42) ` m;
foo @ z;

Hmm, looks like it needs a little encouragement.


4 Real part and imaginary part of a unit-ful expression

Simplifications for unit-ful expressions apply only to noun forms of ‘realpart’ and ‘imagpart’. Oh well.

declare (a, complex) $
realpart (a ` m);
imagpart (a ` m);

5 Splitting off units of varying magnitudes

This one is for converting to units which come in conventional magnitude order, such as hours, minutes, and seconds, or miles, feet, and inches. When the units are specified as a list, the unit conversion operator will split off the first, then the second from the remainder of the first, the third from the remainder, etc.

10 ` km `` mile;
10 ` km `` [mile, yard, foot, inch];
apply ("+", %) `` km;
Title sandbox-maxima-worked-example-3
Canonical name Sandboxmaximaworkedexample3
Date of creation 2014-12-30 17:48:15
Last modified on 2014-12-30 17:48:15
Owner robert_dodier (1000903)
Last modified by robert_dodier (1000903)
Numerical id 1
Author robert_dodier (1000903)
Entry type Example