Grouping by units over add - progress, and a couple questions



Hi all!  Well, because it was annoying me, I finally have gotten a
routine put together for grouping units over the + operator.  It's
still fragile, and anything beyond algebraic expressions like those
show will break it, but it's getting closer and may already be useful.

In connection with the desire to make this robust, I have a couple
questions, or rather I would like to confirm these statements are true:

In general, it is meaningless to pose an expressin a^b where b is a
quantity with units.

In general, it is meaningless to evaluate a trigonometic function with
a unit bearing argument, e.g. sin(a*b), where b is a unit other than
rad or deg or some other numerical factor.

These are the immediate concerns I have for making unit handling robust
- if these are in fact meaningless, a way should be found to take this
into account.  

I am going to essentially special case a rather wide range of cases as
was done in dimension.mac (only perhaps considerably more so :-( and
this will likely be done over time as the limitations become apparent.

I doubt this is ready for prime time, so the default will remain to
have the groupadd function disabled, but it is there if it can be
useful.

Note - as of now the only way to make this work seems to be to add it
to post_eval_functions.

CY

Most of these are nonsense, but a few like (a) (s) + c or (a + b) (s)
are clearly legitimate.  The others will primarily be of use to
highlight dimensional inconsistencies.

(%i3) a*kg/s+b*N+c*kg/s+d*N+e*kg/s;
                                    kg             kg m
(%o3)                  (e + c + a) (--) + (d + b) (----)
                                    s                2
                                                    s
(%i4) 1/60*kg/s+a*kg/s+b*kg/s+c*kg/s^2+d*kg/s^2;
                                1    kg             kg
(%o4)                  (b + a + --) (--) + (d + c) (--)
                                60   s               2
                                                    s
(%i5) a/60*kg/s+a*kg/s+b*kg/s+c*kg/s^2+d*kg/s^2;
                             61 a   kg             kg
(%o5)                   (b + ----) (--) + (d + c) (--)
                              60    s               2
                                                   s
(%i6) (a/60)*kg/s+a*b*kg/s;
                                       a    kg
(%o6)                           (a b + --) (--)
                                       60   s
(%i7) a5 : a+c*s;
(%o7)                             (c) (s) + a
(%i8) a6 : a*kg/s+c;
                                      kg
(%o8)                            (a) (--) + c
                                      s
(%i9) a7 : a*kg/s+c*kg/s;
                                          kg
(%o9)                            (c + a) (--)
                                          s
(%i10) a8 : a*kg/s+c*kg/s+d*kg/s;
                                            kg
(%o10)                         (d + c + a) (--)
                                            s
(%i11) a9 : a*kg*m/s^2+c;
                                     kg m
(%o11)                          (a) (----) + c
                                       2
                                      s
(%i12) a10 : a*kg*m/s^2+c*kg*m/s^2;
                                         kg m
(%o12)                          (c + a) (----)
                                           2
                                          s
(%i13) a11 : a*kg*m/s^2+c*kg*m/s^2+d*kg*m/s^2;
                                           kg m
(%o13)                        (d + c + a) (----)
                                             2
                                            s
(%i14) a12 : a*kg/s+c*kg/s+d*kg*m/s^2;
                                    kg         kg m
(%o14)                     (c + a) (--) + (d) (----)
                                    s            2
                                                s
(%i15) a13 : a*kg/s+c*kg*m/s^2+d*kg*m/s^2;
                                kg             kg m
(%o15)                     (a) (--) + (d + c) (----)
                                s                2
                                                s
(%i16) a14 : a*kg*m/s^2+b*N*J+c*kg/s+d*N*J-e*kg*m/s^2;
                                                        2  3
                      kg             kg m             kg  m
(%o16)           (c) (--) + (a - e) (----) + (d + b) (------)
                      s                2                 4
                                      s                 s
(%i17) a*kg*m/s^2+b*kg*m/s^2+c*kg/s+d+e;
                            kg             kg m
(%o17)                 (c) (--) + (b + a) (----) + e + d
                            s                2
                                            s




		
Yahoo! Mail
Stay connected, organized, and protected. Take the tour:
http://tour.mail.yahoo.com/mailtour.html