Integrating the expression sin(2 * x) * x ^ 2 in a numeric manner does not work properly. We tried to evaluate the following expression:
ev(integrate(sin(2 * x)*x^2, x, 0, %pi), numer);
and received an error message:
rat: replaced 3.141592653589793 by 103993/33102 = 3.141592653011903
rat: replaced 3.141592653589793 by 103993/33102 = 3.141592653011903
rat: replaced 3.141592653589793 by 103993/33102 = 3.141592653011903
rat: replaced 3.141592653589793 by 103993/33102 = 3.141592653011903
rat: replaced 3.141592653589793 by 103993/33102 = 3.141592653011903
rat: replaced 3.141592653589793 by 103993/33102 = 3.141592653011903
rat: replaced 3.141592653589793 by 103993/33102 = 3.141592653011903
rat: replaced 3.141592653589793 by 103993/33102 = 3.141592653011903
rat: replaced 1.0 by 1/1 = 1.0
rat: replaced 0.125 by 1/8 = 0.125
rat: replaced 1.0 by 1/1 = 1.0
rat: replaced 0.125 by 1/8 = 0.125
context: too many contexts.
-- an error. To debug this try debugmode(true);
We are using the newest Maxima version:
Maxima version: 5.19.2
Maxima build date: 8:55 8/31/2009
host type: i686-pc-mingw32
lisp-implementation-type: GNU Common Lisp (GCL)
lisp-implementation-version: GCL 2.6.8
Raymond Toy
2009-10-29
I don't see this problem with the latest CVS code. Lots of messages from rat, but the final answer is close to the exact answer.
I think the typical use is to float(integrate(...)), not ev(...). This gives a better result.
Or if you want a numerical result, use quad_qag or other numerical integration method.
Nobody/Anonymous
2009-10-30
Thank you for your fast response and really helpful hints. We just used ev() because wxMaxima uses this method when clicking on "Numeric"->"Toggle Numeric Output".
Dieter Kaiser
2009-10-30
As already posted the reported bug is no longer present in Maxima CVS:
(%i17) ratprint:false$
(%i18) integrate(sin(2 * x)*x^2, x, 0, %pi),numer;
(%o18) -4.934802158273381
The symbolic and exact answer is:
(%i19) ratsimp(integrate(sin(2 * x)*x^2, x, 0, %pi));
(%o19) -%pi^2/2
(%i20) %,numer;
(%o20) -4.934802200544679
Closing this bug report as "works for me".
Dieter Kaiser
Dieter Kaiser
2009-10-30