Yet another units package -- based on simplification rules.
See also: http://maxima.sf.net/wiki/index.php/Units%20package
By the way, I had to fix some bugs in the simplification code
to make this work. You'll want to get src/matrun.lisp and
src/matcom.lisp from cvs.
Conversions: define one unit in terms of another.
Simplification moves factors from rhs to lhs.
(%i2) F: C*(5/9) + 32$
(%i3) 212`F;
(%o3) 100 ` C
(%i4) 32`F;
(%o4) 0 ` C
(%i5) deg: rad*%pi/180$
(%i6) 90`deg;
%pi
(%o6) --- ` rad
2
(%i7) foo`deg;
%pi foo
(%o7) ------- ` rad
180
Carrying units through calculations (Planck's law).
In case it looks goofed up, "µm" is micrometers.
(%i8) declare ([C1, C2], constant)$
(%i9) numerval (%C2, 14390.0, %C1, 3.742E+8)$
(%i10) declare ("µ", alphabetic)$
(%i11) (C1: %C1`W*µm^4/m^2, C2: %C2`µm*K, l: %l`µm, T: %T`K)$
(%i12) display (C1, C2)$
4
W µm
C1 = %C1 ` -----
2
m
C2 = %C2 ` K µm
Use of numerval hides numerical values above.
simp: false$ inhibits simplification below,
showing units in all subexpressions.
(%i13) simp: false$ expr: C1/(l^5*(exp(C2/(l*T)) - 1));
4
W µm
%C1 ` -----
2
m
(%o14) -------------------------------------
%C2 ` K µm
------------------
5 (%l ` µm) (%T ` K)
(%l ` µm) (%e - 1)
(%i15) simp: true$ ev (expr, infeval=true);
%C1 W
(%o16) ----------------- ` -----
%C2 2
----- m µm
5 %l %T
%l (%e - 1)
(%i17) plot2d (first (ev (%o16, %T=6000, numer)), [%l, 0.05, 3])$
The plot should look familiar.
There's somewhat more to it than that, but I'll let
that be enough for now. Let me know if the alignment
of the text is messed up.
For what it's worth,
Robert Dodier
__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com