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

The result equals zero. This ist wrong!

edit retag close merge delete

Sort by » oldest newest most voted

Indeed, the integral of a function positive on $\left(0\ 2\pi\right)$-{$\pi$} 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. $-\frac{2 \, \sqrt{2}}{\sqrt{\frac{\sin\left(x\right)^{2}}{{\left(\cos\left(x\right) + 1\right)}^{2}} + 1}}$.

This function brutally changes the sign of its derivative for $x=\pi$. 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 $\displaystyle\int_0^{2\pi}\sqrt{2\sin(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. $\int_{0}^{2 \, \pi} \sqrt{2} {\left| \sin\left(\frac{1}{2} \, x\right) \right|}\,{d x}$.

since $x\in[=(0~2\pi)\Rightarrow\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 $\sqrt{1-\cos(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. $-\frac{2 \, {\left(\cos\left(x\right) + 1\right)} \sqrt{-\cos\left(x\right) + 1}}{\sin\left(x\right)}$.

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. $\frac{4 \, {\left(\cos\left(\frac{1}{2} \, x\right)^{2} - 1\right)} \cos\left(\frac{1}{2} \, x\right)}{\sqrt{-2 \, \cos\left(\frac{1}{2} \, x\right)^{2} + 2} \sin\left(\frac{1}{2} \, x\right)}$

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. $\frac{\sqrt{2} \sin\left(\frac{1}{2} \, x\right)^{2}}{\sqrt{\sin\left(\frac{1}{2} \, x\right)^{2}}}$.

Again, since $x\in\left(0~2\pi\right)$, this amounts to $\sqrt{2\sin(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. $-2 \, \sqrt{-\cos\left(x\right) + 1} \cot\left(\frac{1}{2} \, x\right)$.

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. $\frac{\sqrt{2} \sin\left(\frac{1}{2} \, x\right)^{2}}{\sqrt{\sin\left(\frac{1}{2} \, x\right)^{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...

more

Thanks for reporting, this is now trac ticket 24587 !

more

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.

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