## [Maxima-commits] CVS: maxima/doc/info unit.texi,1.6,1.7

 [Maxima-commits] CVS: maxima/doc/info unit.texi,1.6,1.7 From: Alexey Beshenov - 2008-12-31 17:58:14 ```Update of /cvsroot/maxima/maxima/doc/info In directory 23jxhf1.ch3.sourceforge.com:/tmp/cvs-serv3764 Modified Files: unit.texi Log Message: @group stuff Index: unit.texi =================================================================== RCS file: /cvsroot/maxima/maxima/doc/info/unit.texi,v retrieving revision 1.6 retrieving revision 1.7 diff -u -d -r1.6 -r1.7 --- unit.texi 28 Nov 2007 03:36:55 -0000 1.6 +++ unit.texi 31 Dec 2008 17:58:01 -0000 1.7 @@ -1,6 +1,6 @@ @menu -* Introduction to Units:: -* Functions and Variables for Units:: +* Introduction to Units:: +* Functions and Variables for Units:: @end menu @node Introduction to Units, Functions and Variables for Units, unit, unit @@ -15,45 +15,47 @@ allowing the user to readily identify the units associated with a particular answer. It will allow a user to simplify an expression to its fundamental Base Units, as well as providing fine control over simplifying to derived units. -Dimensional analysis is possible, and a variety of tools are available to -manage conversion and simplification options. In addition to customizable -automatic conversion, @emph{units} also provides a traditional manual -conversion option. +Dimensional analysis is possible, and a variety of tools are available to +manage conversion and simplification options. In addition to customizable +automatic conversion, @emph{units} also provides a traditional manual +conversion option. -Note - when unit conversions are inexact Maxima will make approximations resulting +Note - when unit conversions are inexact Maxima will make approximations resulting in fractions. This is a consequence of the techniques used to simplify units. -The messages warning of this type of substitution are disabled by default in +The messages warning of this type of substitution are disabled by default in the case of units (normally they are on) since this situation occurs frequently and the warnings clutter the output. (The existing state of ratprint is restored -after unit conversions, so user changes to that setting will be preserved -otherwise.) If the user needs this information for units, they can set -@...{unitverbose:on} to reactivate the printing of warnings from the unit +after unit conversions, so user changes to that setting will be preserved +otherwise.) If the user needs this information for units, they can set +@emph{unitverbose:on} to reactivate the printing of warnings from the unit conversion process. @emph{unit} is included in Maxima in the share/contrib/unit directory. It obeys normal Maxima package loading conventions: @example +@group (%i1) load("unit")\$ -******************************************************************* -* Units version 0.50 * -* 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... +******************************************************************* +* Units version 0.50 * +* 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... WARNING: DEFUN/DEFMACRO: redefining function TOPLEVEL-MACSYMA-EVAL ... WARNING: DEFUN/DEFMACRO: redefining function MSETCHK ... WARNING: DEFUN/DEFMACRO: redefining function KILL1 ... WARNING: DEFUN/DEFMACRO: redefining function NFORMAT ... -Initializing unit arrays... +Initializing unit arrays... Done. +@end group @end example The WARNING messages are expected and not a cause for concern - they indicate -the @emph{unit} package is redefining functions already defined in Maxima proper. +the @emph{unit} package is redefining functions already defined in Maxima proper. This is necessary in order to properly handle units. The user should be aware that if other changes have been made to these functions by other packages those changes will be overwritten by this loading process. @@ -68,7 +70,7 @@ There are probably lots of bugs. Let me know. @code{float} and @code{numer} don't do what is expected. -TODO : dimension functionality, handling of temperature, +TODO : dimension functionality, handling of temperature, showabbr and friends. Show examples with addition of quantities containing units. @@ -84,80 +86,112 @@ By default, the @emph{unit} package does not use any derived dimensions, but will convert all units to the seven fundamental dimensions using MKS units. @example +@group (%i2) N; kg m (%o2) ---- 2 s +@end group +@group (%i3) dyn; 1 kg m (%o3) (------) (----) 100000 2 s +@end group +@group (%i4) g; 1 (%o4) (----) (kg) 1000 +@end group +@group (%i5) centigram*inch/minutes^2; 127 kg m (%o5) (-------------) (----) 1800000000000 2 s +@end group @end example In some cases this is the desired behavior. If the user wishes to use other units, this is achieved with the @code{setunits} command: @example +@group (%i6) setunits([centigram,inch,minute]); (%o6) done +@end group +@group (%i7) N; 1800000000000 %in cg (%o7) (-------------) (------) 127 2 %min +@end group +@group (%i8) dyn; 18000000 %in cg (%o8) (--------) (------) 127 2 %min +@end group +@group (%i9) g; (%o9) (100) (cg) +@end group +@group (%i10) centigram*inch/minutes^2; %in cg (%o10) ------ 2 %min +@end group @end example The setting of units is quite flexible. For example, if we want to get back to kilograms, meters, and seconds as defaults for those dimensions we can do: @example +@group (%i11) setunits([kg,m,s]); (%o11) done +@end group +@group (%i12) centigram*inch/minutes^2; 127 kg m (%o12) (-------------) (----) 1800000000000 2 s +@end group @end example Derived units are also handled by this command: @example +@group (%i17) setunits(N); (%o17) done +@end group +@group (%i18) N; (%o18) N -(%i19) dyn; +@end group +@group +(%i19) dyn; 1 (%o19) (------) (N) 100000 +@end group +@group (%i20) kg*m/s^2; (%o20) N +@end group +@group (%i21) centigram*inch/minutes^2; 127 (%o21) (-------------) (N) 1800000000000 +@end group @end example Notice that the @emph{unit} package recognized the non MKS combination @@ -165,32 +199,44 @@ to Newtons. This is how Maxima works in general. If, for example, we prefer dyne to Newtons, we simply do the following: @example +@group (%i22) setunits(dyn); (%o22) done +@end group +@group (%i23) kg*m/s^2; (%o23) (100000) (dyn) +@end group +@group (%i24) centigram*inch/minutes^2; 127 (%o24) (--------) (dyn) 18000000 +@end group @end example To discontinue simplifying to any force, we use the uforget command: @example +@group (%i26) uforget(dyn); (%o26) false +@end group +@group (%i27) kg*m/s^2; kg m (%o27) ---- 2 s +@end group +@group (%i28) centigram*inch/minutes^2; 127 kg m (%o28) (-------------) (----) 1800000000000 2 s +@end group @end example -This would have worked equally well with @code{uforget(N)} or +This would have worked equally well with @code{uforget(N)} or @code{uforget(%force)}. See also @code{uforget}. To use this function write first @code{load("unit")}. @@ -202,26 +248,34 @@ @end deffn @deffn {Function} uforget (@var{list}) -By default, the @emph{unit} package converts all units to the +By default, the @emph{unit} package converts all units to the seven fundamental dimensions using MKS units. This behavior can be changed with the @code{setunits} command. After that, the user can restore the default behavior for a particular dimension by means of the @code{uforget} command: @example +@group (%i13) setunits([centigram,inch,minute]); (%o13) done +@end group +@group (%i14) centigram*inch/minutes^2; %in cg (%o14) ------ 2 %min +@end group +@group (%i15) uforget([cg,%in,%min]); (%o15) [false, false, false] +@end group +@group (%i16) centigram*inch/minutes^2; 127 kg m (%o16) (-------------) (----) 1800000000000 2 s +@end group @end example @code{uforget} operates on dimensions, @@ -231,7 +285,7 @@ See also @code{setunits}. To use this function write first @code{load("unit")}. @opencatbox -@...{Package unit} +@category{Package unit} @closecatbox @end deffn @@ -249,16 +303,21 @@ simplify to a Derived Dimension. @example +@group (%i2) kg*m/s^2; kg m (%o2) ---- 2 s +@end group +@group (%i3) convert(kg*m/s^2,[g,km,s]); g km (%o3) ---- 2 s +@end group +@group (%i4) convert(kg*m/s^2,[g,inch,minute]); `rat' replaced 39.37007874015748 by 5000/127 = 39.37007874015748 @@ -266,35 +325,59 @@ (%o4) (-----------) (-----) 127 2 %min +@end group +@group (%i5) convert(kg*m/s^2,[N]); (%o5) N +@end group +@group (%i6) convert(kg*m^2/s^2,[N]); (%o6) m N +@end group +@group (%i7) setunits([N,J]); (%o7) done +@end group +@group (%i8) convert(kg*m^2/s^2,[N]); (%o8) m N +@end group +@group (%i9) convert(kg*m^2/s^2,[N,inch]); `rat' replaced 39.37007874015748 by 5000/127 = 39.37007874015748 5000 (%o9) (----) (%in N) 127 +@end group +@group (%i10) convert(kg*m^2/s^2,[J]); (%o10) J +@end group +@group (%i11) kg*m^2/s^2; (%o11) J +@end group +@group (%i12) setunits([g,inch,s]); (%o12) done +@end group +@group (%i13) kg*m/s^2; (%o13) N +@end group +@group (%i14) uforget(N); (%o14) false +@end group +@group (%i15) kg*m/s^2; 5000000 %in g (%o15) (-------) (-----) 127 2 s +@end group +@group (%i16) convert(kg*m/s^2,[g,inch,s]); `rat' replaced 39.37007874015748 by 5000/127 = 39.37007874015748 @@ -302,12 +385,13 @@ (%o16) (-------) (-----) 127 2 s +@end group @end example See also @code{setunits} and @code{uforget}. To use this function write first @code{load("unit")}. @opencatbox -@...{Package unit} +@category{Package unit} @closecatbox @end deffn @@ -317,9 +401,9 @@ Default value: none If a user wishes to have a default unit behavior other than that described, -they can make use of @emph{maxima-init.mac} and the @emph{usersetunits} -variable. The @emph{unit} package will check on startup to see if this variable -has been assigned a list. If it has, it will use setunits on that list and take +they can make use of @emph{maxima-init.mac} and the @emph{usersetunits} +variable. The @emph{unit} package will check on startup to see if this variable +has been assigned a list. If it has, it will use setunits on that list and take the units from that list to be defaults. @code{uforget} will revert to the behavior defined by usersetunits over its own defaults. For example, if we have a @emph{maxima-init.mac} file containing: @@ -328,53 +412,83 @@ @end example we would see the following behavior: @example +@group (%i1) load("unit")\$ -******************************************************************* -* Units version 0.50 * -* 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... +******************************************************************* +* Units version 0.50 * +* 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... WARNING: DEFUN/DEFMACRO: redefining function TOPLEVEL-MACSYMA-EVAL ... WARNING: DEFUN/DEFMACRO: redefining function MSETCHK ... WARNING: DEFUN/DEFMACRO: redefining function KILL1 ... WARNING: DEFUN/DEFMACRO: redefining function NFORMAT ... -Initializing unit arrays... -Done. -User defaults found... +Initializing unit arrays... +Done. +User defaults found... User defaults initialized. +@end group +@group (%i2) kg*m/s^2; (%o2) N +@end group +@group (%i3) kg*m^2/s^2; (%o3) J +@end group +@group (%i4) kg*m^3/s^2; (%o4) J m +@end group +@group (%i5) kg*m*km/s^2; (%o5) (1000) (J) +@end group +@group (%i6) setunits([dyn,eV]); (%o6) done +@end group +@group (%i7) kg*m/s^2; (%o7) (100000) (dyn) +@end group +@group (%i8) kg*m^2/s^2; (%o8) (6241509596477042688) (eV) +@end group +@group (%i9) kg*m^3/s^2; (%o9) (6241509596477042688) (eV m) +@end group +@group (%i10) kg*m*km/s^2; (%o10) (6241509596477042688000) (eV) -(%i11) uforget([dyn,eV]); +@end group +@group +(%i11) uforget([dyn,eV]); (%o11) [false, false] +@end group +@group (%i12) kg*m/s^2; (%o12) N +@end group +@group (%i13) kg*m^2/s^2; (%o13) J +@end group +@group (%i14) kg*m^3/s^2; (%o14) J m +@end group +@group (%i15) kg*m*km/s^2; (%o15) (1000) (J) +@end group @end example Without @code{usersetunits}, the initial inputs would have been converted to MKS, and uforget would have resulted in a return to MKS rules. Instead, @@ -386,109 +500,173 @@ @code{kill(usersetunits)} will completely remove all knowledge of the user defaults from the session. Here are some examples of how these various options work. @example +@group (%i2) kg*m/s^2; (%o2) N +@end group +@group (%i3) kg*m^2/s^2; (%o3) J +@end group +@group (%i4) setunits([dyn,eV]); (%o4) done +@end group +@group (%i5) kg*m/s^2; (%o5) (100000) (dyn) +@end group +@group (%i6) kg*m^2/s^2; (%o6) (6241509596477042688) (eV) +@end group +@group (%i7) uforget([dyn,eV]); (%o7) [false, false] +@end group +@group (%i8) kg*m/s^2; (%o8) N +@end group +@group (%i9) kg*m^2/s^2; (%o9) J +@end group +@group (%i10) dontusedimension(N); (%o10) [%force] +@end group +@group (%i11) dontusedimension(J); (%o11) [%energy, %force] +@end group +@group (%i12) kg*m/s^2; kg m (%o12) ---- 2 s +@end group +@group (%i13) kg*m^2/s^2; 2 kg m (%o13) ----- 2 s +@end group +@group (%i14) setunits([dyn,eV]); (%o14) done +@end group +@group (%i15) kg*m/s^2; kg m (%o15) ---- 2 s +@end group +@group (%i16) kg*m^2/s^2; 2 kg m (%o16) ----- 2 s +@end group +@group (%i17) uforget([dyn,eV]); (%o17) [false, false] +@end group +@group (%i18) kg*m/s^2; kg m (%o18) ---- 2 s +@end group +@group (%i19) kg*m^2/s^2; 2 kg m (%o19) ----- 2 s +@end group +@group (%i20) usedimension(N); Done. To have Maxima simplify to this dimension, use -setunits([unit]) to select a unit. +setunits([unit]) to select a unit. (%o20) true +@end group +@group (%i21) usedimension(J); Done. To have Maxima simplify to this dimension, use -setunits([unit]) to select a unit. +setunits([unit]) to select a unit. (%o21) true +@end group +@group (%i22) kg*m/s^2; kg m (%o22) ---- 2 s +@end group +@group (%i23) kg*m^2/s^2; 2 kg m (%o23) ----- 2 s +@end group +@group (%i24) setunits([dyn,eV]); (%o24) done +@end group +@group (%i25) kg*m/s^2; (%o25) (100000) (dyn) +@end group +@group (%i26) kg*m^2/s^2; (%o26) (6241509596477042688) (eV) +@end group +@group (%i27) uforget([dyn,eV]); (%o27) [false, false] +@end group +@group (%i28) kg*m/s^2; (%o28) N +@end group +@group (%i29) kg*m^2/s^2; (%o29) J +@end group +@group (%i30) kill(usersetunits); (%o30) done +@end group +@group (%i31) uforget([dyn,eV]); (%o31) [false, false] +@end group +@group (%i32) kg*m/s^2; kg m (%o32) ---- 2 s +@end group +@group (%i33) kg*m^2/s^2; 2 kg m (%o33) ----- 2 s +@end group @end example Unfortunately this wide variety of options is a little confusing at first, but once the user grows used to them they should find they have very full @@ -497,7 +675,7 @@ @c One other significant customization option available is the @code{setunitprefix} @c command. Normally, abbreviations used in this package are as close to those @c used in standard texts as possible. Some people, however, prefer to use those -@... symbols for normal work and have units labeled in some other fasion. +@c symbols for normal work and have units labeled in some other fasion. @c @code{setunitprefix} is provided for this case. Here is an example of its use: @opencatbox @@ -513,6 +691,7 @@ prefixes the user wishes defined. The arguments are as follows, with each higher number defining all lower numbers' units: @example +@group 0 - none. Only base units 1 - kilo, centi, milli (default) 2 - giga, mega, kilo, hecto, deka, deci, centi, milli, @@ -520,6 +699,7 @@ 3 - peta, tera, giga, mega, kilo, hecto, deka, deci, centi, milli, micro, nano, pico, femto 4 - all +@end group @end example Normally, Maxima will not define the full expansion since this results in a very large number of units, but @code{metricexpandall} can be used to @@ -528,7 +708,7 @@ @c This should be made configurable as a maxima-init.mac controllable option. @opencatbox -@...{Package unit} +@category{Package unit} @closecatbox @end deffn ```

 [Maxima-commits] CVS: maxima/doc/info unit.texi,1.6,1.7 From: Alexey Beshenov - 2008-12-31 17:58:14 ```Update of /cvsroot/maxima/maxima/doc/info In directory 23jxhf1.ch3.sourceforge.com:/tmp/cvs-serv3764 Modified Files: unit.texi Log Message: @group stuff Index: unit.texi =================================================================== RCS file: /cvsroot/maxima/maxima/doc/info/unit.texi,v retrieving revision 1.6 retrieving revision 1.7 diff -u -d -r1.6 -r1.7 --- unit.texi 28 Nov 2007 03:36:55 -0000 1.6 +++ unit.texi 31 Dec 2008 17:58:01 -0000 1.7 @@ -1,6 +1,6 @@ @menu -* Introduction to Units:: -* Functions and Variables for Units:: +* Introduction to Units:: +* Functions and Variables for Units:: @end menu @node Introduction to Units, Functions and Variables for Units, unit, unit @@ -15,45 +15,47 @@ allowing the user to readily identify the units associated with a particular answer. It will allow a user to simplify an expression to its fundamental Base Units, as well as providing fine control over simplifying to derived units. -Dimensional analysis is possible, and a variety of tools are available to -manage conversion and simplification options. In addition to customizable -automatic conversion, @emph{units} also provides a traditional manual -conversion option. +Dimensional analysis is possible, and a variety of tools are available to +manage conversion and simplification options. In addition to customizable +automatic conversion, @emph{units} also provides a traditional manual +conversion option. -Note - when unit conversions are inexact Maxima will make approximations resulting +Note - when unit conversions are inexact Maxima will make approximations resulting in fractions. This is a consequence of the techniques used to simplify units. -The messages warning of this type of substitution are disabled by default in +The messages warning of this type of substitution are disabled by default in the case of units (normally they are on) since this situation occurs frequently and the warnings clutter the output. (The existing state of ratprint is restored -after unit conversions, so user changes to that setting will be preserved -otherwise.) If the user needs this information for units, they can set -@...{unitverbose:on} to reactivate the printing of warnings from the unit +after unit conversions, so user changes to that setting will be preserved +otherwise.) If the user needs this information for units, they can set +@emph{unitverbose:on} to reactivate the printing of warnings from the unit conversion process. @emph{unit} is included in Maxima in the share/contrib/unit directory. It obeys normal Maxima package loading conventions: @example +@group (%i1) load("unit")\$ -******************************************************************* -* Units version 0.50 * -* 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... +******************************************************************* +* Units version 0.50 * +* 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... WARNING: DEFUN/DEFMACRO: redefining function TOPLEVEL-MACSYMA-EVAL ... WARNING: DEFUN/DEFMACRO: redefining function MSETCHK ... WARNING: DEFUN/DEFMACRO: redefining function KILL1 ... WARNING: DEFUN/DEFMACRO: redefining function NFORMAT ... -Initializing unit arrays... +Initializing unit arrays... Done. +@end group @end example The WARNING messages are expected and not a cause for concern - they indicate -the @emph{unit} package is redefining functions already defined in Maxima proper. +the @emph{unit} package is redefining functions already defined in Maxima proper. This is necessary in order to properly handle units. The user should be aware that if other changes have been made to these functions by other packages those changes will be overwritten by this loading process. @@ -68,7 +70,7 @@ There are probably lots of bugs. Let me know. @code{float} and @code{numer} don't do what is expected. -TODO : dimension functionality, handling of temperature, +TODO : dimension functionality, handling of temperature, showabbr and friends. Show examples with addition of quantities containing units. @@ -84,80 +86,112 @@ By default, the @emph{unit} package does not use any derived dimensions, but will convert all units to the seven fundamental dimensions using MKS units. @example +@group (%i2) N; kg m (%o2) ---- 2 s +@end group +@group (%i3) dyn; 1 kg m (%o3) (------) (----) 100000 2 s +@end group +@group (%i4) g; 1 (%o4) (----) (kg) 1000 +@end group +@group (%i5) centigram*inch/minutes^2; 127 kg m (%o5) (-------------) (----) 1800000000000 2 s +@end group @end example In some cases this is the desired behavior. If the user wishes to use other units, this is achieved with the @code{setunits} command: @example +@group (%i6) setunits([centigram,inch,minute]); (%o6) done +@end group +@group (%i7) N; 1800000000000 %in cg (%o7) (-------------) (------) 127 2 %min +@end group +@group (%i8) dyn; 18000000 %in cg (%o8) (--------) (------) 127 2 %min +@end group +@group (%i9) g; (%o9) (100) (cg) +@end group +@group (%i10) centigram*inch/minutes^2; %in cg (%o10) ------ 2 %min +@end group @end example The setting of units is quite flexible. For example, if we want to get back to kilograms, meters, and seconds as defaults for those dimensions we can do: @example +@group (%i11) setunits([kg,m,s]); (%o11) done +@end group +@group (%i12) centigram*inch/minutes^2; 127 kg m (%o12) (-------------) (----) 1800000000000 2 s +@end group @end example Derived units are also handled by this command: @example +@group (%i17) setunits(N); (%o17) done +@end group +@group (%i18) N; (%o18) N -(%i19) dyn; +@end group +@group +(%i19) dyn; 1 (%o19) (------) (N) 100000 +@end group +@group (%i20) kg*m/s^2; (%o20) N +@end group +@group (%i21) centigram*inch/minutes^2; 127 (%o21) (-------------) (N) 1800000000000 +@end group @end example Notice that the @emph{unit} package recognized the non MKS combination @@ -165,32 +199,44 @@ to Newtons. This is how Maxima works in general. If, for example, we prefer dyne to Newtons, we simply do the following: @example +@group (%i22) setunits(dyn); (%o22) done +@end group +@group (%i23) kg*m/s^2; (%o23) (100000) (dyn) +@end group +@group (%i24) centigram*inch/minutes^2; 127 (%o24) (--------) (dyn) 18000000 +@end group @end example To discontinue simplifying to any force, we use the uforget command: @example +@group (%i26) uforget(dyn); (%o26) false +@end group +@group (%i27) kg*m/s^2; kg m (%o27) ---- 2 s +@end group +@group (%i28) centigram*inch/minutes^2; 127 kg m (%o28) (-------------) (----) 1800000000000 2 s +@end group @end example -This would have worked equally well with @code{uforget(N)} or +This would have worked equally well with @code{uforget(N)} or @code{uforget(%force)}. See also @code{uforget}. To use this function write first @code{load("unit")}. @@ -202,26 +248,34 @@ @end deffn @deffn {Function} uforget (@var{list}) -By default, the @emph{unit} package converts all units to the +By default, the @emph{unit} package converts all units to the seven fundamental dimensions using MKS units. This behavior can be changed with the @code{setunits} command. After that, the user can restore the default behavior for a particular dimension by means of the @code{uforget} command: @example +@group (%i13) setunits([centigram,inch,minute]); (%o13) done +@end group +@group (%i14) centigram*inch/minutes^2; %in cg (%o14) ------ 2 %min +@end group +@group (%i15) uforget([cg,%in,%min]); (%o15) [false, false, false] +@end group +@group (%i16) centigram*inch/minutes^2; 127 kg m (%o16) (-------------) (----) 1800000000000 2 s +@end group @end example @code{uforget} operates on dimensions, @@ -231,7 +285,7 @@ See also @code{setunits}. To use this function write first @code{load("unit")}. @opencatbox -@...{Package unit} +@category{Package unit} @closecatbox @end deffn @@ -249,16 +303,21 @@ simplify to a Derived Dimension. @example +@group (%i2) kg*m/s^2; kg m (%o2) ---- 2 s +@end group +@group (%i3) convert(kg*m/s^2,[g,km,s]); g km (%o3) ---- 2 s +@end group +@group (%i4) convert(kg*m/s^2,[g,inch,minute]); `rat' replaced 39.37007874015748 by 5000/127 = 39.37007874015748 @@ -266,35 +325,59 @@ (%o4) (-----------) (-----) 127 2 %min +@end group +@group (%i5) convert(kg*m/s^2,[N]); (%o5) N +@end group +@group (%i6) convert(kg*m^2/s^2,[N]); (%o6) m N +@end group +@group (%i7) setunits([N,J]); (%o7) done +@end group +@group (%i8) convert(kg*m^2/s^2,[N]); (%o8) m N +@end group +@group (%i9) convert(kg*m^2/s^2,[N,inch]); `rat' replaced 39.37007874015748 by 5000/127 = 39.37007874015748 5000 (%o9) (----) (%in N) 127 +@end group +@group (%i10) convert(kg*m^2/s^2,[J]); (%o10) J +@end group +@group (%i11) kg*m^2/s^2; (%o11) J +@end group +@group (%i12) setunits([g,inch,s]); (%o12) done +@end group +@group (%i13) kg*m/s^2; (%o13) N +@end group +@group (%i14) uforget(N); (%o14) false +@end group +@group (%i15) kg*m/s^2; 5000000 %in g (%o15) (-------) (-----) 127 2 s +@end group +@group (%i16) convert(kg*m/s^2,[g,inch,s]); `rat' replaced 39.37007874015748 by 5000/127 = 39.37007874015748 @@ -302,12 +385,13 @@ (%o16) (-------) (-----) 127 2 s +@end group @end example See also @code{setunits} and @code{uforget}. To use this function write first @code{load("unit")}. @opencatbox -@...{Package unit} +@category{Package unit} @closecatbox @end deffn @@ -317,9 +401,9 @@ Default value: none If a user wishes to have a default unit behavior other than that described, -they can make use of @emph{maxima-init.mac} and the @emph{usersetunits} -variable. The @emph{unit} package will check on startup to see if this variable -has been assigned a list. If it has, it will use setunits on that list and take +they can make use of @emph{maxima-init.mac} and the @emph{usersetunits} +variable. The @emph{unit} package will check on startup to see if this variable +has been assigned a list. If it has, it will use setunits on that list and take the units from that list to be defaults. @code{uforget} will revert to the behavior defined by usersetunits over its own defaults. For example, if we have a @emph{maxima-init.mac} file containing: @@ -328,53 +412,83 @@ @end example we would see the following behavior: @example +@group (%i1) load("unit")\$ -******************************************************************* -* Units version 0.50 * -* 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... +******************************************************************* +* Units version 0.50 * +* 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... WARNING: DEFUN/DEFMACRO: redefining function TOPLEVEL-MACSYMA-EVAL ... WARNING: DEFUN/DEFMACRO: redefining function MSETCHK ... WARNING: DEFUN/DEFMACRO: redefining function KILL1 ... WARNING: DEFUN/DEFMACRO: redefining function NFORMAT ... -Initializing unit arrays... -Done. -User defaults found... +Initializing unit arrays... +Done. +User defaults found... User defaults initialized. +@end group +@group (%i2) kg*m/s^2; (%o2) N +@end group +@group (%i3) kg*m^2/s^2; (%o3) J +@end group +@group (%i4) kg*m^3/s^2; (%o4) J m +@end group +@group (%i5) kg*m*km/s^2; (%o5) (1000) (J) +@end group +@group (%i6) setunits([dyn,eV]); (%o6) done +@end group +@group (%i7) kg*m/s^2; (%o7) (100000) (dyn) +@end group +@group (%i8) kg*m^2/s^2; (%o8) (6241509596477042688) (eV) +@end group +@group (%i9) kg*m^3/s^2; (%o9) (6241509596477042688) (eV m) +@end group +@group (%i10) kg*m*km/s^2; (%o10) (6241509596477042688000) (eV) -(%i11) uforget([dyn,eV]); +@end group +@group +(%i11) uforget([dyn,eV]); (%o11) [false, false] +@end group +@group (%i12) kg*m/s^2; (%o12) N +@end group +@group (%i13) kg*m^2/s^2; (%o13) J +@end group +@group (%i14) kg*m^3/s^2; (%o14) J m +@end group +@group (%i15) kg*m*km/s^2; (%o15) (1000) (J) +@end group @end example Without @code{usersetunits}, the initial inputs would have been converted to MKS, and uforget would have resulted in a return to MKS rules. Instead, @@ -386,109 +500,173 @@ @code{kill(usersetunits)} will completely remove all knowledge of the user defaults from the session. Here are some examples of how these various options work. @example +@group (%i2) kg*m/s^2; (%o2) N +@end group +@group (%i3) kg*m^2/s^2; (%o3) J +@end group +@group (%i4) setunits([dyn,eV]); (%o4) done +@end group +@group (%i5) kg*m/s^2; (%o5) (100000) (dyn) +@end group +@group (%i6) kg*m^2/s^2; (%o6) (6241509596477042688) (eV) +@end group +@group (%i7) uforget([dyn,eV]); (%o7) [false, false] +@end group +@group (%i8) kg*m/s^2; (%o8) N +@end group +@group (%i9) kg*m^2/s^2; (%o9) J +@end group +@group (%i10) dontusedimension(N); (%o10) [%force] +@end group +@group (%i11) dontusedimension(J); (%o11) [%energy, %force] +@end group +@group (%i12) kg*m/s^2; kg m (%o12) ---- 2 s +@end group +@group (%i13) kg*m^2/s^2; 2 kg m (%o13) ----- 2 s +@end group +@group (%i14) setunits([dyn,eV]); (%o14) done +@end group +@group (%i15) kg*m/s^2; kg m (%o15) ---- 2 s +@end group +@group (%i16) kg*m^2/s^2; 2 kg m (%o16) ----- 2 s +@end group +@group (%i17) uforget([dyn,eV]); (%o17) [false, false] +@end group +@group (%i18) kg*m/s^2; kg m (%o18) ---- 2 s +@end group +@group (%i19) kg*m^2/s^2; 2 kg m (%o19) ----- 2 s +@end group +@group (%i20) usedimension(N); Done. To have Maxima simplify to this dimension, use -setunits([unit]) to select a unit. +setunits([unit]) to select a unit. (%o20) true +@end group +@group (%i21) usedimension(J); Done. To have Maxima simplify to this dimension, use -setunits([unit]) to select a unit. +setunits([unit]) to select a unit. (%o21) true +@end group +@group (%i22) kg*m/s^2; kg m (%o22) ---- 2 s +@end group +@group (%i23) kg*m^2/s^2; 2 kg m (%o23) ----- 2 s +@end group +@group (%i24) setunits([dyn,eV]); (%o24) done +@end group +@group (%i25) kg*m/s^2; (%o25) (100000) (dyn) +@end group +@group (%i26) kg*m^2/s^2; (%o26) (6241509596477042688) (eV) +@end group +@group (%i27) uforget([dyn,eV]); (%o27) [false, false] +@end group +@group (%i28) kg*m/s^2; (%o28) N +@end group +@group (%i29) kg*m^2/s^2; (%o29) J +@end group +@group (%i30) kill(usersetunits); (%o30) done +@end group +@group (%i31) uforget([dyn,eV]); (%o31) [false, false] +@end group +@group (%i32) kg*m/s^2; kg m (%o32) ---- 2 s +@end group +@group (%i33) kg*m^2/s^2; 2 kg m (%o33) ----- 2 s +@end group @end example Unfortunately this wide variety of options is a little confusing at first, but once the user grows used to them they should find they have very full @@ -497,7 +675,7 @@ @c One other significant customization option available is the @code{setunitprefix} @c command. Normally, abbreviations used in this package are as close to those @c used in standard texts as possible. Some people, however, prefer to use those -@... symbols for normal work and have units labeled in some other fasion. +@c symbols for normal work and have units labeled in some other fasion. @c @code{setunitprefix} is provided for this case. Here is an example of its use: @opencatbox @@ -513,6 +691,7 @@ prefixes the user wishes defined. The arguments are as follows, with each higher number defining all lower numbers' units: @example +@group 0 - none. Only base units 1 - kilo, centi, milli (default) 2 - giga, mega, kilo, hecto, deka, deci, centi, milli, @@ -520,6 +699,7 @@ 3 - peta, tera, giga, mega, kilo, hecto, deka, deci, centi, milli, micro, nano, pico, femto 4 - all +@end group @end example Normally, Maxima will not define the full expansion since this results in a very large number of units, but @code{metricexpandall} can be used to @@ -528,7 +708,7 @@ @c This should be made configurable as a maxima-init.mac controllable option. @opencatbox -@...{Package unit} +@category{Package unit} @closecatbox @end deffn ```