Menu ▾ ▴

#4178 Infinite loop in Risch integration

None
closed
nobody
5
2 days ago
2023-08-30
laurent
No

The simplest case found by Richard Fateman is :

integrate(r(x)*sqrt(r(x)^2+5)/(r(x)^2+9),r(x));

Comment from Robert Dodier :

Looking at TRYRISCH1, I see that it peels off the last item on VARLIST (global list of variables) and then tries something. The stack overflow occurs because VARLIST gets peeled down to NIL but TRYRISCH1 keeps trying.

TRYRISCH1 is called from several places, and only one of them (TRYRISCH) verifies that VARLIST is nonnull before calling TRYRISCH1. Either TRYRISCH1 has to be modified to give up if VARLIST is null, or every caller needs to check VARLIST before calling TRYRISCH1.

I tried returning NIL from TRYRISCH1 if VARLIST is null, but that runs into a different error -- 0 is not a list or something. I wonder what is a suitable "I don't know" result for TRYRISCH1.

Discussion

  • laurent

    laurent - 2023-08-31

    from Robert Dodier : I tried fixing up TRYRISCH1 to return ((0 . 1)) when VARLIST is null, but I get "0 is not of type LIST".

     

    Last edit: laurent 2023-08-31
  • Dan Gildea

    Dan Gildea - 3 days ago

    in current git:

    (%i2) integrate(r(x)*sqrt(r(x)^2+5)/(r(x)^2+9),r(x));
    (%o2) (r(x)^2*sqrt(r(x)^2+5))/(2*r(x)^2+18)
    

    compare with a simple variable:

    (%i3) integrate(r*sqrt(r^2+5)/(r^2+9),r);
    (%o3) sqrt(r^2+5)-2*atan(sqrt(r^2+5)/2)
    
     
  • David Scherfgen

    David Scherfgen - 2 days ago
    • status: open --> closed
     
  • David Scherfgen

    David Scherfgen - 2 days ago

    Fixed by commit [b2ebd8]. integrate and risch now replace non-atomic variables of integration with a gensym, while previously integrate did that only for subscripted variables (and not the r(x) here in this case) and risch didn't replace anything, but didn't work well with non-atomic variables.

     

    Related

    Commit: [b2ebd8]


Log in to post a comment.