sandbox-maxima-worked-example-3

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);

∫

0

⁢

s

t

1

⁢

s

3

⁢

t

2

⁢

m

s

⁢

𝑑

t

⁢

s

Now go ahead and simplify it.

simp : true $
foo : ''foo;

3

⁢

(

∫

0

t

1

t

2

⁢

𝑑

t

)

⁢

m

%, nouns;

t

1

3

⁢

m

1.2

Derivative

Again, have a look at the unsimplified form.

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

d

+

1

d

⁢

`

1

⁢

(

t

,

𝑦𝑒𝑎𝑟

)

⁢

(

t

⁢

inch

)

Go ahead and simplify it.

simp : true $
foo : ''foo;

d

d

⁢

t

⁢

t

⁢

inch

year

foo, nouns;

1

2

⁢

t

⁢

inch

year

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 5

5

2

)

⁢

Btu

lbm

,

v

=

8 5

5

2

⁢

Btu

lbm

]

dimensions (foo);

[

𝑑𝑖𝑚𝑒𝑛𝑠𝑖𝑜𝑛𝑠

⁢

(

v

)

=

𝑙𝑒𝑛𝑔𝑡ℎ

𝑡𝑖𝑚𝑒

,

𝑑𝑖𝑚𝑒𝑛𝑠𝑖𝑜𝑛𝑠

⁢

(

v

)

=

𝑙𝑒𝑛𝑔𝑡ℎ

𝑡𝑖𝑚𝑒

]

foo1 : foo `` m/s;

[

`

⁢

`

⁢

(

v

,

m

s

)

=

(

-

128 5

13

2

⁢

1055

45359237

)

⁢

m

s

,

`

⁢

`

⁢

(

v

,

m

s

)

=

128 5

13

2

⁢

1055

45359237

⁢

m

s

]

float (foo1);

[

`

⁢

`

⁢

(

v

,

m

s

)

=

(

-

21567.92463845541

)

⁢

m

s

,

`

⁢

`

⁢

(

v

,

m

s

)

=

21567.92463845541

⁢

m

s

]

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.

''%;

42

⁢

m

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);

𝑟𝑒𝑎𝑙𝑝𝑎𝑟𝑡

⁢

(

a

⁢

m

)

''%;

𝑟𝑒𝑎𝑙𝑝𝑎𝑟𝑡

⁢

(

a

)

⁢

m

imagpart (a ` m);

𝑖𝑚𝑎𝑔𝑝𝑎𝑟𝑡

⁢

(

a

⁢

m

)

''%;

𝑖𝑚𝑎𝑔𝑝𝑎𝑟𝑡

⁢

(

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;

78125

12573

⁢

mile

10 ` km `` [mile, yard, foot, inch];

[

6

⁢

mile

,

376

⁢

yard

,

0

⁢

foot

,

608

127

⁢

inch

]

apply ("+", %) `` km;

10

⁢

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

Generated on Fri Feb 9 15:10:39 2018 by

LaTeXML