Ask Your Question
2

integrate sqrt(1-cos(x)), integr.interval from 0 to 2*pi

asked 7 years ago

rewolf gravatar image

updated 2 years ago

tmonteil gravatar image

The result equals zero. This ist wrong!

Preview: (hide)

2 Answers

Sort by » oldest newest most voted
2

answered 7 years ago

Emmanuel Charpentier gravatar image

Indeed, the integral of a function positive on (0 2π)-{π} can't be null.

The problem is with the primitive choosen by maxima :

sage: integrate(sqrt(1-cos(x)),x)
-2*sqrt(2)/sqrt(sin(x)^2/(cos(x) + 1)^2 + 1)

i. e. 22sin(x)2(cos(x)+1)2+1.

This function brutally changes the sign of its derivative for x=π. This smell of an error in manipulating an absolute value.

Indeed, one can (more or less easily) show that :

sage: ((cos(2*x)==cos(2*x).trig_expand().subs(cos(x)^2==1-sin(x)^2))*-1)
....: .subs(x==x/2)+1
-cos(x) + 1 == 2*sin(1/2*x)^2

Therefore, we are trying to compute 2π02sin(x/2)dx, which is :

with assuming(x,"real"):integrate(sqrt(2*sin(x/2)^2).simplify(),x,0,2*pi,h
....: old=True)
integrate(sqrt(2)*abs(sin(1/2*x)), x, 0, 2*pi)

i. e. 2π02|sin(12x)|dx.

since x[=(0 2π)sin(x/2)>0, this should be evaluated as

sage: integrate(sqrt(2)*sin(x/2),x,0,2*pi,hold=True)==integrate(sqrt(2)*sin(x/2)
....: ,x,0,2*pi)
integrate(sqrt(2)*sin(1/2*x), x, 0, 2*pi) == 2^(5/2)

But it's not.

What other possibilities do we have ? Both sympy and giac fail to find a primitive of 1cos(x) or the definite integral. But fricas does find a primitive :

sage: integrate(sqrt(1-cos(x)),x, algorithm="fricas")
-2*(cos(x) + 1)*sqrt(-cos(x) + 1)/sin(x)

i. e. 2(cos(x)+1)cos(x)+1sin(x).

which can be differentiated back to the original expression :

sage: integrate(sqrt(1-cos(x)),x, algorithm="fricas").diff(x).expand().trig_simp
....: lify()
sqrt(-cos(x) + 1)

But fricas fails to find the definite integral, which we have to find by hand :

sage: foo=integrate(sqrt(1-cos(x)),x, algorithm="fricas")
sage: (foo.limit(x=2*pi,dir="-")-foo.limit(x=0,dir="+")).simplify()
4*sqrt(2)

maple finds a quite different expression :

sage: maple.integrate(sqrt(1-cos(x)),x).sage()
4*(cos(1/2*x)^2 - 1)*cos(1/2*x)/(sqrt(-2*cos(1/2*x)^2 + 2)*sin(1/2*x))

i. e. 4(cos(12x)21)cos(12x)2cos(12x)2+2sin(12x)

whch can been redifferentiated to (something close to) the form we have seen when solving manually in order to understand maxima's error :

sage: maple.integrate(sqrt(1-cos(x)),x).sage().diff(x).trig_expand().factor().tr
....: ig_simplify()
sqrt(2)*sin(1/2*x)^2/sqrt(sin(1/2*x)^2)

i. e. 2sin(12x)2sin(12x)2.

Again, since x(0 2π), this amounts to 2sin(x/2), which we used previously.

maple fails to find the definite integral, which may be recomuted by taking the limits at the bounds.

mathematica gives yet another form :

sage: mathematica.Integrate(sqrt(1-cos(x)),x).sage()
-2*sqrt(-cos(x) + 1)*cot(1/2*x)

i. e. 2cos(x)+1cot(12x).

which can also be redifferentiated to the same form as maple's result :

sage: mathematica.Integrate(sqrt(1-cos(x)),x).sage().subs(1-cos(x)==2*sin(x/2)^2
....: ).diff(x).trig_simplify()
sqrt(2)*sin(1/2*x)^2/sqrt(sin(1/2*x)^2)

i. e. 2sin(12x)2sin(12x)2.

mathematica finds the definite integral :

sage: mathematica.Integrate(sqrt(1-cos(x)),[x,0,2*pi]).sage()
4*sqrt(2)

Not seen : the plots of the integrand and of the various solutions are also helpful to understand the problem, understand the possible errors of the various CASes and to check them against one another (hint : plot two finctions to be compared with a slight vertical shift alowing to separate them).

Numerical integration may also help...

Preview: (hide)
link
0

answered 7 years ago

tmonteil gravatar image

updated 7 years ago

Thanks for reporting, this is now trac ticket 24587 !

Preview: (hide)
link

Comments

It is not fixed in 8.2.beta3 :

sage: integrate(sqrt(1-cos(x)),x,0,pi)
2^(3/2)

Indeed. But :

sage: integrate(sqrt(1-cos(x)),x,0,2*pi)
0

Plotting the primitive proposzed by maxima is enough to understand the problem.

Emmanuel Charpentier gravatar imageEmmanuel Charpentier ( 7 years ago )

Hmm, apparently, i made a copy-paste typo, i updated my answer, reported the issue and added a confirmed_bug tag.

tmonteil gravatar imagetmonteil ( 7 years ago )

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

Stats

Asked: 7 years ago

Seen: 1,790 times

Last updated: Jan 23 '18