I have a tentative solution to the problem of putting units at the end
of an expression. It's in lisp, and only tested very lightly on sbcl,
but I think it looks like it might be made to function. Also, there is
now a dimension functionality, although it lacks the power of Barton's
dimension.mac package. I have created a lisp file with all the
relevant changes to the lisp code, both for unit reordering and the
post_eval_functions list, and it is loaded by unit.mac. If and when
code is merged into the main tree it can be removed from this lisp
file.
This is being uploaded to cvs now.
CY
Maxima 5.9.1.1cvs http://maxima.sourceforge.net
Using Lisp SBCL 0.8.20
Distributed under the GNU Public License. See the file COPYING.
Dedicated to the memory of William Schelter.
This is a development version of Maxima. The function bug_report()
provides bug reporting information.
(%i1) load("./newunits.mac");
*******************************************************************
* Units version 0.11 *
* Definitions based on the NIST Reference on *
* Constants, Units, and Uncertainty *
* Conversion factors from various sources including *
* NIST and the GNU units package *
*******************************************************************
Redefining necessary functions...
[snip lisp complaining]
Initializing unit arrays...
Done.
(%o1) ./newunits.mac
(%i2) a*kg*m/(u*s^2);
a kg m
(%o2) (-) (----)
u 2
s
(%i3) N*a;
kg m
(%o3) (a) (----)
2
s
(%i4) N*z;
kg m
(%o4) (z) (----)
2
s
(%i5) dimension(kg*m/s^2);
%length %mass
(%o5) -------------
2
%time
(%i6) setunits([N]);
(%o6) done
(%i7) dimension(kg*m/s^2);
(%o7) %force
(%i8) N*z;
(%o8) (z) (N)
(%i9) a*kg*N*z;
(%o9) (a z) (kg N)
(%i10) assignquantity(t,%time);
(%o10) %time
(%i11) assignquantity(x0,%length);
(%o11) %length
(%i12) assignquantity(v0,%length/%time);
%length
(%o12) -------
%time
(%i13) assignquantity(a,%length/(%time^2));
%length
(%o13) -------
2
%time
(%i14) x(t) := x0+v0*t+1/2*a*t^2;
1 2
(%o14) x(t) := x0 + v0 t + - a t
2
(%i15) dimension(x(t));
(%o15) %length
(%i16) diff(x(t),t);
(%o16) v0 + a t
(%i17) dimension(%);
%length
(%o17) -------
%time
(%i18) a*kg/s+z*g/minutes;
z kg kg
(%o18) (-----) (--) + (a) (--)
60000 s s
(%i19) ratsimp(%);
z kg kg
(%o19) (-----) (--) + (a) (--)
60000 s s
(%i20) %/(kg/s);
z
(%o20) ----- + a
60000
Yahoo! Mail
Stay connected, organized, and protected. Take the tour:
http://tour.mail.yahoo.com/mailtour.html