Maple Units package



On Tuesday 29 March 2005 15:03, C Y wrote:

[snip]
> > ----------------------------------------------
> > Good:
> > - Units have an own namespace without too much typing.
> > This refers to the "standard" units environment. I find the
> > "natural" environment where units appear in the global namespace
> > impractical.
> >
> > >3*Unit(cm/h);
> >
> >                   1/120000*Unit([m/s])
>
> Hmm.  Can you tell me when this would be better than something like
> 3*cm/h?  I assume there is some utility but this would most likely
> not be trivial (is it even possible to have different namespaces in
> Maxima using such a mechanism?) and I would need to understand the
> desirability of it in order to do it right.  That might have to be
> one of those "down the road" things.


I want to use m, l, s ... as variable names (formula symbols). 
Otherwise I'd have to use something like: var_m, var_l, var_s. I 
think it would be quite confusing when many commonly used symbols 
would suddenly have a special meaning as unit names. 

An easy workaround would be using a common prefix like: unit_m, 
unit_l, unit_s.


>
> > - Easy creation of more specialized units. (Alternative
> > description: supports the usual notation of chemists.)
> >
> > >m_mol_O2 = 2*16 * Unit(g(O2)/mol(O2));
> >
> >              m_mol_O2 = 4/125*Unit([kg(O2)/mol(O2)])
>
> Hmm.  I take it you are refering to the inclusion of O2 to keep
> track of specific elements?  That might require some thought.


Yes, chemical reactions are always present as ratios in mol/mol or 
g/g. As mol(O2)/mol(H2) the units are much more usefull. 

I consider this an advanced feature, which can wait. In Maple, the way 
I use it seems not to be documented.


>
> > - Systems of base units can be created and manipulated. You can
> > tell the system to always convert volumes to liters. (I think)
>
> That, at least, should be readily doable in Maxima.

Great! 

>
> > - (Partial) integration into the rest of Maple. Many functions,
> > most notably int() and diff(), know of units.
>
> Can you give an example of what it means for them to "know" about
> units?  How are they treated differently?


Here it is:
>diff((5/2*t^2 + 2*t)*Unit(m), t);          #wrong
              (5*t+2)*Unit([m])
>diff((5/2*t^2 + 2*t)*Unit(m), t*Unit(s));  #right
              (5*t+2)*Unit([m/s])
I don't know how usefull this is. To me this seems like a workaround 
for the fact that variables (symbols) can not be associated with a 
dimension.

Trigonometric functions know of units too:
>sin(Pi*Unit(rad)); sin(180*Unit(deg));
       0
       0


>
> > -----------------------------------------------------------------
> >---- Bad:
> > - Only partial integration into the rest of Maple. The plot()
> > function for example does unfortunately not know of units.
>
> What features were you hoping for/expecting?  I must confess I'm
> not sure what about units would be special in a plot.


I think this should produce a plot:
>plot(2*Unit(m/s)*t, t=0..1*Unit(s));
There are offcourse several problems to solve. What should e.g. happen 
here? Two axises?
>plot([Unit(m/s)*t, Unit(m/s^2)*t], t=0..1*Unit(s));

This offcourse works:
>convert(2*Unit(m/s)*t,unit_free): #remove units
>plot(%, t=0..1);


>
> > - Instead much energy was spent on many exotic units eg.: US dry
> > barrels (there are hundreds of them). This is surely an
> > anglo-saxon speciality.
>
> My take on those is if someone needs them, they can add them.  I'm
> not opposed to including them, but it is not high on my priority
> list.

I  think this is reasonable.

>
> > - The program gets easylie confused with expressions where only
> > some terms contain units eg.:
> >      e_2 := s = 1/2*a*t^2+1/12*Unit([m/s])*t+20*Unit([cm])
> > It is impossible to simplify such an expression. It would be nice
> > if there were a way to tell the program that "t" is a time, "a"
> > is an acceleration, and "s" is a distance. (And a sensible way to
> > display this.)
>
> I think that can be partially addressed in Maxima.  By simplify, do
> you mean combine like terms or group by quantity?  Or alternately,
> what would you like to simplify the above expression to?


I gave a bad example. Maple's simplify returns an error with the above 
expression. In the following example simplify should combine the two 
terms that contain units (I think), but it gives an error message:
>simplify(2*Unit(m/s)+3*Unit(km/h)+v1);
   Error, (in Units:-Standard:-+) the units `m/s` and `1` have
   incompatible dimensions

The problem is: Maple is too picky. I can't even assign this 
expression to a variable. I get the same error as above.
>e_5:=2*Unit(m/s)+3*Unit(km/h)+v;

An annoying error is that even removing units does not always work:
>convert(v=2*Unit(m/s), unit_free);
       v = 2*Unit([m/s])

But this works:
>convert(2*Unit(m/s), unit_free);
       2

Basicly an expression needs to have the following for Maple to work 
reliably:
 * Unit( ..... )

[snip]


Thanks for considering my suggestions, and excuse me for the late 
answer.

Yours,
Eike.

-- 
Snail:                             Phone:
Eike Welk                          xx49-241-4127686
Stolberger Str. 72
52068 Aachen                       Mail:
Germany                            eike.welk@post.rwth-aachen.de