Here's my guess as to what is going on. There are a bunch of terms in the
expansion. Ratexpand is making sure that each one is reduced to lowest terms
(expensive), whereas expand just placed each numerator term over the same
denominator (cheap).
Compare s:(a+b+c)/a^2/(b+1)^2$
expand(s) vs ratexpand(s).
Should this be quite so expensive? If this computation is important,
consider renaming. That is, make 1/(x-p3) into a symbol x3, and removing
all denominators. Implement a rule so that diff(x3,x) -> -x3^2 etc.
Ratexpand is very much faster than expand for polynomials.
I tried to do rat(w) on commercial macsyma. It took 60 seconds, 57 in
garbage collection. Using a different GCD algorithm is probably worse.
Ratexpand run out of memory(!)
RJF
> -----Original Message-----
> From: maxima-bounces at math.utexas.edu [mailto:maxima-
> bounces at math.utexas.edu] On Behalf Of Barton Willis
> Sent: Sunday, November 19, 2006 5:37 AM
> To: Maxima at math.utexas.edu
> Subject: ratexpand limitation
>
>
> I thought that 'ratexpand' was generally more efficient than 'expand.'
> But look at this:
>
> (%i1) gcd : spmod$
> (%i2) f : sum(concat(a,k)/(x-concat(p,k)),k,1,5)$
> (%i3) g : sum(concat(b,k)/(x-concat(p,k)),k,1,5)$
> (%i4) w : f * (diff(g,x) + g^2) - g * (diff(f,x) + f^2)$
> (%i5) showtime : all$
> Evaluation took 0.00 seconds (0.00 elapsed)
> (%i6) ratexpand(w)$
> Maxima encountered a Lisp error:
> Error in PROGN [or a callee]: The storage for CONS is exhausted.
> Currently, 93516 pages are allocated.
>
> This Lisp error happens after much computer whirring (longer
> than the time it took me to pour a cup of coffee). The function
> 'expand' doesn't have this problem:
>
> (%i7) expand(w)$
> Evaluation took 00.30 seconds (00.30 elapsed)
>
> It seems that expand didn't cheat:
>
> (%i8) first(%);
> Evaluation took 0.00 seconds (0.00 elapsed)
> (%o8)
> (2*a3*b4*b5)/(x^3-p5*x^2-p4*x^2-p3*x^2+p4*p5*x+p3*p5*x+p3*p4*x-p3*p4*p5)
>
> Barton
> _______________________________________________
> Maxima mailing list
> Maxima at math.utexas.edu
> http://www.math.utexas.edu/mailman/listinfo/maxima