"trigrat" caught in infinite loop - depending on how you call it



trigrat apparently leaves some state around after exiting, which is bad...

Starting from David's example, here is the simplest bad case I could find:

f: 1/(y+sqrt(y))$

[trigrat(f),trigrat(f)]  =>  [ <small expression>, <big expression> ]

This doesn't lead to an infinite loop, but the two results are different
when they should be the same.

Tested in 5.27.0 2012-04-30 11:59:06 i686-apple-darwin11.3.0 SBCL
1.0.55.0-abb03f9

          -s

On Wed, Nov 7, 2012 at 7:28 AM, David Scherfgen
<d.scherfgen at googlemail.com>wrote:

> Hello Maxima users,
>
> I have discovered a very strange bug in Maxima, which I am about to report
> on SourceForge.
> But nevertheless, I want to ask if any of you has come across this one or
> might be able to help me circumvent it.
>
> The following works:
>
> e : 2*x/(sqrt(y)+x) - (x^2/((sqrt(y)+x)^2));
> trigrat(e);
> trigrat(xthru(e));
>
> But when I do this:
>
> ( trigrat(e), trigrat(xthru(e)) )
>
> or
>
> [ trigrat(e), trigrat(xthru(e)) ]
>
> the second "trigrat" call inside will hang, i.e. Maxima will run on 100%
> CPU and will never return.
> So: evaluating both lines separately works, but evaluating them together
> or inside a function will cause the "bug".
>
> Strangely, everything works fine when I swap the expressions:
>
> ( trigrat(e), trigrat(xthru(e)) );   /* loops forever */
> ( trigrat(xthru(e)), trigrat(e) );   /* works */
>
> I can't find a pattern ... it seems very mysterious to me.
> Any idea what might be happening here?
>
> Regards,
> David Scherfgen
> ______________________________**_________________
> Maxima mailing list
> Maxima at math.utexas.edu
> http://www.math.utexas.edu/**mailman/listinfo/maxima<http://www.math.utexas.edu/mailman/listinfo/maxima>;
>