mutiplying partial fractions



I think that if you wanted to make this run faster you would have to
be more specific about the acceptable data. For example, is it
the sum of terms of the form

a/(x-b)^n ?   in which case you could encode the whole expression
as a list of triples,   [a,b,n]
and then you would have rules like   [a1,b,n1]*[a2,b,n2] --> 
[a1*a2,b,n1+n2],
... note same point...

note that some rules would produce multiple terms, and that the
list would have to be sorted.  Or it could be a hashed array that
used b as a key.

If the denominators could be more elaborate, not necessarily linear,
the situation changes.


RJF

Wolfgang Jenkner wrote:

>Barton Willis  writes:
>
>  
>
>>(defun $pfmult (f g x)
>>  (let ((acc 0))
>>    (setq f (if (op-equalp f 'mplus) (margs f) (list f)))
>>    (setq g (if (op-equalp g 'mplus) (margs g) (list g)))
>>    (dolist (fi f acc)
>>      (dolist (gi g)
>>         (setq acc (add ($partfrac (mul fi gi) x) acc))))))
>>    
>>
>
>A maxima language version of the same idea does not seem to be less
>efficient.
>
>/* Just a sketch.  Works only if p and q are of the right form ;-) */
>pfmult_by_distrib(p,q,x):=
>  map(lambda([exp],partfrac(exp,x)),distrib(p*q))$
>compile(pfmult_by_distrib)$
>
>In order to produce timings that could be checked I fed things to
>telnet://maxima.franz.com and got
>
>(C6) a:pfmult(p,q,x)$
>
>Evaluation took 6.19 seconds (6.53 elapsed)
>(C7) b:pfmult_by_distrib(p,q,x)$
>
>Evaluation took 6.16 seconds (6.88 elapsed)
>(C8) a-b;
>
>Evaluation took 0.08 seconds (0.09 elapsed)
>(D8)                                   0
>
>Wolfgang
>
>