(no subject)



 from http://www.math.utexas.edu/pipermail/maxima/2012/027370.html
 Problem. Compute inntegrate(f,x,-1,2), where
(%i1) f:exp(-signum(x-1)*x^3);
(%o1) %e^(-x^3*signum(x-1))

 Solving with step by step and test:
(%i2) wxplot2d([f], [x,-1,2])$
(%t2)  << Graphics >>
 Let
integrate(f,x,-1,2)=
integrate(f,x,-1,0)+integrate(f,x,0,1)+integrate(f,x,1,2)=
S1+S2+S3

(%i3) S1:'integrate(exp(x^3),x,-1,0);
(%o3) integrate(%e^x^3,x,-1,0)
(%i4) ev(%, nouns);
(%o4) (gamma(1/3)-gamma_incomplete(1/3,1))/3
(%i5) sol1:float(%);
(%o5) 0.807511182139671
(%i6) /* test*/
first(quad_qags(exp(x^3),x,-1,0));
(%o6) 0.807511182139671

(%i7) S2:'integrate(exp(x^3),x,0,1);
(%o7) integrate(%e^x^3,x,0,1)
(%i8) changevar(S2, y=x^3, y, x);
(%o8) ((sqrt(3)*%i-1)*integrate(%e^y/y^(2/3),y,0,1))/6
(%i9) ev(%, nouns);
(%o9) ((sqrt(3)*%i-1)*(gamma_incomplete(1/3,-1)-gamma(1/3)))/6
(%i10) expand(float(%));
(%o10) 1.34190441797742-1.4802973661668753*10^-16*%i
(%i11) sol2:realpart(%);
(%o11) 1.34190441797742
(%i12) /* test*/
first(quad_qags(exp(x^3),x,0,1));
(%o12) 1.34190441797742

 Note that  integral S2 direct Maxima compute wrong.
The correct formula is

integrate(exp(x^k),x,0,1)=
(gamma(1/k)-gamma_incomplete(1/k,-1))*%e^(-(%i*%pi)/k))/k,

where k is natural number.

 Proof.
(%i13) S:'integrate(exp(x^k),x,0,1);
(%o13) integrate(%e^x^k,x,0,1)
(%i14) assume(k>0)$ declare(k,integer)$
(%i16) changevar(S, y=x^k, y, x);
(%o16) integrate(%e^y/y^((k-1)/k),y,0,1)/k
(%i17) ev(%, nouns),factor;
(%o17) -(gamma_incomplete(1/k,-1)-gamma(1/k))/(k*(-1)^(1/k))
(%i18) subst(-1=polarform(-1),%),ratsimp;
(%o18) -((gamma_incomplete(1/k,-1)-gamma(1/k))*%e^(-(%i*%pi)/k))/k
 q. e. d.

(%i19) define(F(k),%);
(%o19) F(k):=-((gamma_incomplete(1/k,-1)-gamma(1/k))*%e^(-(%i*%pi)/k))/k

 Next we compute S2 using this formula:
(%i20) F(3);
(%o20) -((1/2-(sqrt(3)*%i)/2)*(gamma_incomplete(1/3,-1)-gamma(1/3)))/3
(%i21) float(%),expand; realpart(%);
(%o21) 1.34190441797742-3.33066907387547*10^-16*%i
(%o22) 1.34190441797742

(%i23) S3:'integrate(exp(-x^3),x,1,2);
(%o23) integrate(%e^(-x^3),x,1,2)
(%i24) ev(%, nouns);
(%o24) (gamma_incomplete(1/3,1)-gamma_incomplete(1/3,8))/3
(%i25) sol3:float(%), numer;
(%o25) 0.085442332154205
(%i26) /* test*/
first(quad_qags(exp(-x^3),x,1,2));
(%o26) 0.0854423321542049

 Answer:
(%i27) ans:sol1+sol2+sol3;
(%o27) 2.234857932271296
(%i28) /* test again*/
first(quad_qags(f,x,-1,2));
(%o28) 2.234857932271401

(%i29) build_info()$
Maxima version: 5.25.1
Maxima build date: 9:23 9/6/2011
Host type: i686-pc-mingw32
Lisp implementation type: Clozure Common Lisp
Lisp implementation version: Version 1.7-r14925M  (WindowsX8632)

 Aleksas Domarkas