Work at SourceForge, help us to make it a better place! We have an immediate need for a Support Technician in our San Francisco or Denver office.

Close

#2737 Incorrect simplification: trigsimp(integrate(sqrt(4 - cosh(x)^2),x))

None
open
nobody
5
2014-05-28
2014-05-28
Peter Bruin
No

In Maxima 5.33.0 with GCL 2.6.10, after loading abs_simplify, the following incorrectly returns cosh(x):

trigsimp(integrate(sqrt(4 - cosh(x)^2),x));

(The integral is returned unevaluated without abs_simplify, and the correct answer involves an elliptic integral.)

As far as I can see, something goes wrong in ratsubst. After adding the following debugging code to trgsmp.mac:

--- a/share/trigonometry/trgsmp.mac
+++ b/share/trigonometry/trgsmp.mac
@@ -119,10 +119,15 @@ improve(expn,subsofar,listoftrigsq):=
        for alt in first(listoftrigsq) do 
             subsofar:
            improve(subsofar,
-                   ratsubst(get(inpart(alt,0),'unitcof)
-                            +get(piece,'complement_cof)
-                             *get(piece,'complement_function)(first(alt))^2,
-                             alt^2,subsofar),
+                    block([a, b, c, r],
+                          a: get(inpart(alt,0),'unitcof)
+                             +get(piece,'complement_cof)
+                             *get(piece,'complement_function)(first(alt))^2,
+                          b: alt^2,
+                          c: subsofar,
+                          r: ratsubst(a, b, c),
+                          print("ratsubst(", a, ",", b, ",", c, ") ->", r),
+                          r),
                    rest(listoftrigsq)),
        subsofar)$

one gets (after loading abs_integrate)

(%i11) trigsimp(integrate(sqrt(4 - cosh(x)^2),x));
              2              2                   2                       2
ratsubst( sinh (x) + 1 , cosh (x) , sqrt(4 - cosh (x)) ) -> sqrt(3 - sinh (x)) 
              2              2                   2                       2
ratsubst( sinh (x) + 1 , cosh (x) , sqrt(4 - cosh (x)) ) -> sqrt(3 - sinh (x)) 
              2              2                   2                       2
ratsubst( sinh (x) + 1 , cosh (x) , sqrt(4 - cosh (x)) ) -> sqrt(3 - sinh (x)) 
              2              2                   2                       2
ratsubst( sinh (x) + 1 , cosh (x) , sqrt(4 - cosh (x)) ) -> sqrt(3 - sinh (x)) 
              2              2                   2                       2
ratsubst( sinh (x) + 1 , cosh (x) , sqrt(4 - cosh (x)) ) -> sqrt(3 - sinh (x)) 
              2              2                   2                       2
ratsubst( sinh (x) + 1 , cosh (x) , sqrt(4 - cosh (x)) ) -> sqrt(3 - sinh (x)) 
              2              2                   2                       2
ratsubst( sinh (x) + 1 , cosh (x) , sqrt(4 - cosh (x)) ) -> sqrt(3 - sinh (x)) 
              2              2                   2                       2
ratsubst( sinh (x) + 1 , cosh (x) , sqrt(4 - cosh (x)) ) -> sqrt(3 - sinh (x)) 
              2              2                   2                       2
ratsubst( sinh (x) + 1 , cosh (x) , sqrt(4 - cosh (x)) ) -> sqrt(3 - sinh (x)) 
              2              2                   2
ratsubst( sinh (x) + 1 , cosh (x) , sqrt(4 - cosh (x)) ) -> sinh(x) 
(%o11)                              cosh(x)

Note that the 10th call to ratsubst suddenly gives a wrong result (which is then integrated to produce the answer cosh(x) for the original integral).

This was originally reported at http://ask.sagemath.org/question/2577/integrate-with-elliptic-integral-special-function; there is a corresponding ticket in the Sage bug tracker at http://trac.sagemath.org/ticket/14591.

Discussion