rtoy / maxima

A Clone of Maxima's repo
Other
0 stars 0 forks source link

diff of result of integral not the original function #3327

Open rtoy opened 2 months ago

rtoy commented 2 months ago

Imported from SourceForge on 2024-07-07 20:53:33 Created by lukacsarpad on 2019-03-22 15:37:49 Original: https://sourceforge.net/p/maxima/bugs/3544


One of Moses's examples is:

(%i1) f:sqrt(a^2+b^2*sin(x)^2)/sin(x);
                                   2    2       2
                             sqrt(b  sin (x) + a )
(%o1)                        ---------------------
                                    sin(x)
(%i2) g:integrate(f,x);
Is a zero or nonzero?

nonzero;
    4    2  2
Is b  + a  b  positive or zero?

positive;
Is b zero or nonzero?

nonzero;
                                   2    2        2    2           2
                 2 abs(a) sqrt((- b  cos (x)) + b  + a )       2 a         2
      abs(a) log(--------------------------------------- + ------------ - b )
                              2 cos(x) + 2                 2 cos(x) + 2
(%o2) -----------------------------------------------------------------------
                                         2
                                2    2        2    2           2
              2 abs(a) sqrt((- b  cos (x)) + b  + a )       2 a         2
   abs(a) log(--------------------------------------- + ------------ + b )
                           2 - 2 cos(x)                 2 - 2 cos(x)
 - -----------------------------------------------------------------------
                                      2
                   2
                  b  cos(x)
 - abs(b) asin(----------------)
                     4    2  2
               sqrt(b  + a  b )
(%i3) diff(g,x)-f;
               2    2       2
         sqrt(b  sin (x) + a )
(%o3) (- ---------------------) + (abs(a)
                sin(x)
                    2    2        2    2
  4 abs(a) sqrt((- b  cos (x)) + b  + a ) sin(x)
 (----------------------------------------------
                               2
                 (2 cos(x) + 2)
                       2                                2
             2 abs(a) b  cos(x) sin(x)               4 a  sin(x)
 + --------------------------------------------- + ---------------))
                           2    2        2    2                  2
   (2 cos(x) + 2) sqrt((- b  cos (x)) + b  + a )   (2 cos(x) + 2)
                       2    2        2    2           2
     2 abs(a) sqrt((- b  cos (x)) + b  + a )       2 a         2
/(2 (--------------------------------------- + ------------ - b ))
                  2 cos(x) + 2                 2 cos(x) + 2
                                 2    2        2    2
               4 abs(a) sqrt((- b  cos (x)) + b  + a ) sin(x)
 - (abs(a) ((- ----------------------------------------------)
                                            2
                              (2 - 2 cos(x))
                       2                                2
             2 abs(a) b  cos(x) sin(x)               4 a  sin(x)
 + --------------------------------------------- - ---------------))
                           2    2        2    2                  2
   (2 - 2 cos(x)) sqrt((- b  cos (x)) + b  + a )   (2 - 2 cos(x))
                       2    2        2    2           2
     2 abs(a) sqrt((- b  cos (x)) + b  + a )       2 a         2
/(2 (--------------------------------------- + ------------ + b ))
                  2 - 2 cos(x)                 2 - 2 cos(x)
              2
             b  abs(b) sin(x)
 + -------------------------------------
                              4    2
         4    2  2           b  cos (x)
   sqrt(b  + a  b ) sqrt(1 - ----------)
                              4    2  2
                             b  + a  b
(%i4) %,a=1.3,b=0.4,x=2.3;
(%o4)                         0.04485309515590674

Maxima 5.41.0 using Lisp GNU Common Lisp (GCL) GCL 2.6.12 on Ubuntu 18.04.

rtoy commented 2 months ago

Imported from SourceForge on 2024-07-07 20:53:34 Created by richardgobeli on 2019-03-25 05:52:22 Original: https://sourceforge.net/p/maxima/bugs/3544/#07e9


I get this for the integral when using Macsyma 2.4. This does give zero when diff(g,x)-f is executed and simplified.

Attachments:

rtoy commented 2 months ago

Imported from SourceForge on 2024-07-07 20:53:38 Created by lukacsarpad on 2019-03-25 21:56:37 Original: https://sourceforge.net/p/maxima/bugs/3544/#bc22


If I am not mistaken, the difference is the sign of the b^2 term in the first log(). If I change that, and evaluate the derivative minus the original function at some random points numerically, I get indeed zero.

Also, it evaluates to zero now, if I use factor, then exponentialize, and then radcan.

rtoy commented 2 months ago

Imported from SourceForge on 2024-07-07 20:53:41 Created by robert_dodier on 2019-03-27 23:28:04 Original: https://sourceforge.net/p/maxima/bugs/3544/#1940


Diff:


--- old
+++ new
@@ -1,4 +1,5 @@
 One of Moses's examples is:
+~~~~
 (%i1) f:sqrt(a^2+b^2*sin(x)^2)/sin(x);
                                    2    2       2
                              sqrt(b  sin (x) + a )
@@ -75,6 +76,6 @@
                              b  + a  b
 (%i4) %,a=1.3,b=0.4,x=2.3;
 (%o4)                         0.04485309515590674
-
+~~~~

 Maxima 5.41.0 using Lisp GNU Common Lisp (GCL) GCL 2.6.12 on Ubuntu 18.04.