Is the handling of the units broken or what am I missing?
load(ezunits);
σ_N: 10000`N/(50`mm*10`mm);
newts: 123`kg*m/s^3; newts `` N; newts + 321 `kg*m/s^2;
produces not what one would have hoped for:
(%i1) load(ezunits);
(%o1) "C:/maxima-5.43.2/share/maxima/5.43.2/share/ezunits/ezunits.mac"
(%i2) σ_N: 10000`N/(50`mm*10`mm);
(σ_N) 10000 ` (N/500 ` 1/mm^2)
(%i5) newts: 123`kg*m/s^3; newts `` N; newts + 321 `kg*m/s^2;
(newts) 123 ` (kg*m)/s^3
(%o4) 123/s ` N
(%o5) 321 ` (kg*m)/s^2+123 ` (kg*m)/s^3
Should be:
σ_N= 20 N/mm^2
newts= 123 N/s
For the first part, you have to use parentheses to indicate the grouping you want. When you write a ` b/c
, it is interpreted as a ` (b/c)
, but in this case you want (a ` b)/c
. (Grouping works that way because it's assumed that stuff like x ` m/s
is more common than (x ` m)/s
.)
(%i2) σ_N: (10000`N)/(50`mm*10`mm);
N
(%o2) 20 ` ---
2
mm
Just for fun, let's check the dimensions of this quantity. I guess it should be force/area.
(%i3) dimensions (%);
mass
(%o3) ------------
2
length time
(%i4) dimensions (N);
length mass
(%o4) -----------
2
time
(%i5) dimensions (mm);
(%o5) length
Looks right to me.
For the second part, I don't understand what you're trying to so. The variable newts
has units equivalent to N/s
, so I don't understand why you're trying to convert it to N
, and I don't understand why you're trying to add N/s
to N
. Anyway here's what I can make of it.
(%i6) newts: 123`kg*m/s^3;
kg m
(%o6) 123 ` ----
3
s
(%i7) newts `` N/s;
N
(%o7) 123 ` -
s
When quantities with different dimensions are added, ezunits
just lets it stand; it doesn't produce an error or anything.
(%i8) newts + 321 ` kg*m/s^2;
kg m kg m
(%o8) 321 ` ---- + 123 ` ----
2 3
s s
The motivation for that is that it allows for stuff like 3`sheep + 2`horse
or x`hour + y`dollar
-- the conversion rate can be determined after the fact. In general, allowing for expressions to be reinterpreted after the fact is, I believe, the mathematical attitude.