sandbox-maxima-worked-example-3


Before we get started, load ezunits.

load (ezunits);
/usr/local/share/maxima/branch_5_32_base_2_g0e99686/share/ezunits/ezunits.mac

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);
0st1s3t2ms𝑑ts

Now go ahead and simplify it.

simp : true $
foo : ''foo;
3(0t1t2𝑑t)m
%, nouns;
t13m

1.2 Derivative

Again, have a look at the unsimplified form.

simp : false $
foo : 'diff (sqrt (t) ` inch, t ` year, 1);
d+1d`1(t,𝑦𝑒𝑎𝑟)(tinch)

Go ahead and simplify it.

simp : true $
foo : ''foo;
ddttinchyear
foo, nouns;
12tinchyear

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);
[𝑑𝑖𝑚𝑒𝑛𝑠𝑖𝑜𝑛𝑠(v)=𝑙𝑒𝑛𝑔𝑡ℎ𝑡𝑖𝑚𝑒,𝑑𝑖𝑚𝑒𝑛𝑠𝑖𝑜𝑛𝑠(v)=𝑙𝑒𝑛𝑔𝑡ℎ𝑡𝑖𝑚𝑒]
foo1 : foo `` m/s;
[``(v,ms)=(-128 5132105545359237)ms,``(v,ms)=128 5132105545359237ms]
float (foo1);
[``(v,ms)=(-21567.92463845541)ms,``(v,ms)=21567.92463845541ms]

3 Selecting a named field from a unit-ful expression

‘@’ distributes over unit-ful expressions.

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

Hmm, looks like it needs a little encouragement.

''%;
42m

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);
𝑟𝑒𝑎𝑙𝑝𝑎𝑟𝑡(am)
''%;
𝑟𝑒𝑎𝑙𝑝𝑎𝑟𝑡(a)m
imagpart (a ` m);
𝑖𝑚𝑎𝑔𝑝𝑎𝑟𝑡(am)
''%;
𝑖𝑚𝑎𝑔𝑝𝑎𝑟𝑡(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;
7812512573mile
10 ` km `` [mile, yard, foot, inch];
[6mile,376yard,0foot,608127inch]
apply ("+", %) `` km;
10km
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