Need some help



Actually, now that I think about it, the default behavior of
tellsimpafter is not going to work at all for this problem.  In my
example, I had:

(%i8) kg*m^2/s^2;

The first return, from a debugging statement included when I was
attempting a two step simplification, was 

                    2
 processunits1( kg m  ) 

In other words, tellsimpafter was looking only at the numerator.  This
is a fundamental problem, because kg*m^2 is also a perfectly legitimate
input, and there is no way I am aware of to force tellsimpafter to send
the ENTIRE expression without looking at the components first. 
Possibly the right matchdeclare setup would work, but I haven't got a
clue about the details of that behavior.

The result isn't surprising:
                2
 resultof1  kg m  

since there were no derived units in this subsection.  But, now it
tries processunits2, also on this subexpression:

                    2
 processunits2( kg m  ) 

this is disasterous:
 
 `rat' replaced 15.43235835294143 by 16883//1094 = 15.43235831809872
                       2
            84415000 cm  gr
 resultof2  --------------- 
                  547

now the form of the numerator has changed.  And when a recursive call
now finally sends the whole expression:

                  2
                cm  gr
 processunits1( ------ ) 
                   2
                  s

the form does not match any the MKS based derived unit rules will
catch.  And so, not surprisingly:

              2
            cm  gr
 resultof1  ------ 
               2
              s

Now it deals with the denominator (the order of this whole process is
still a bit confusing to me):

                1
 processunits2( -- ) 
                 2
                s

which results in:

                1
 resultof2  ---------- 
                     2
            3600 %min

Of course, by this point it is already too late.  The returned
expression isn't necessarily incorrect, but it does not simplify as
intended.

                                           2
                                  422075 cm  gr
 (%o8)                            -------------
                                            2
                                   9846 %min
 
This is why a straight call to processunits works, either with letsimp
or with the apply1 superstructure - it is evaluating the whole
expression with one ruleset after another, not piece by piece. 
Something about tellsimpafter seems to look at pieces first, then the
whole, which just isn't going to work.  The only thing I can think of
is to try and find some way to get tellsimp to work only on the
complete expression, but tellsimpafter won't accept atoms as arguments
on which to apply rules.  (why??)  Perhaps there are good reasons for
this but as you can see the unintended consequences of the tellsimp
system are sometimes a real pain in the neck.  I guess tellsimp wasn't
intended to allow automatic of user input, so perhaps I'm being unfair.

CY


		
__________________________________ 
Do you Yahoo!? 
Yahoo! Small Business - Try our new resources site!
http://smallbusiness.yahoo.com/resources/