mutiplying partial fractions



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