Using Lisp complex



On Tue, Aug 2, 2011 at 06:38, R Fateman <fateman at eecs.berkeley.edu> wrote:

> On 8/1/2011 10:34 PM, Robert Dodier wrote:
>
>> On 8/1/11, Stavros Macrakis<macrakis at alum.mit.edu**>  wrote:
>>
>>> format1 (called by subst, part, displa, etc.) does
>>> conversions like ((mexpt) x -1) =>  ((mquotient) 1 x); ...
>>
>>  matching programs do not call format1.  I never use part if time is of
> any concern.
> Inpart, which does not call format1, is much much much much faster.  I was
> not aware that
> subst called format1....


You're right, sorry.  subst(x,1,1/y) => x/y and subst(a,2,1/y^2) =>
1/y^a; but subst('f,'sqrt,sqrt(x)) => sqrt(x) (not f(x)) and
subst('f,"/",x/y) => x/y, not f(x,y).  Interestingly, subst(a,-2,1/y^2) =>
y^a but subst(a,-1,1/y) => 1/y.  So there is some special cleverness around
exponents/division in subst -- not format1.

I agree that part is slow precisely because of format1, but I'd bet that the
vast majority of users do not use inpart, and in the vast majority of
applications, the convenience and clarity of not needing to understand the
internal form are far more important than the speed difference.

             -s