# Integrating $\int \frac{-\sin x}{1+\cos x}\, dx$, I get $\ln(1 + \cos x)$. WolframAlpha gives $2 \ln(\cos \frac x 2)$. Is WA wrong?

So, I'm watching a tutorial on differential equations, where I encountered this little trick:

$$\int \frac{y'}{y}\, dx = \ln(y)$$ It seems perfectly logical and easy to justify, but something fishy happens to this integral:

$$\int \frac{-\sin x}{1+\cos x}\, dx$$

The trick gives $$\int \frac{-\sin x}{1+\cos x}\, dx = \ln(1 + \cos x)$$

while WolframAlpha gives $$\int \frac{-\sin x}{1+\cos x}\, dx = 2 \ln(\cos \frac x 2)$$.

You guys who know this stuff - does WolframAlpha mess up here or is it something I've missed? Taking the derivative of $$2 \ln(\cos \frac x 2)$$ gives me $$-\tan \frac x 2$$, so I don't see how WA may be right.

• Remember that $\cos{2x}=2\cos^2x-1$ – Don Thousand Aug 12 at 11:57
• They are different in terms of their symbols, but they give you exactly the same values. What you have is a trigonometric identity. – Pixel Aug 12 at 12:01
• As others have mentioned, the key here is to use a trig identity to bridge the two solutions. ... Often, the trickiest part of Calculus is remembering your Pre-Calculus. :) – Blue Aug 12 at 12:03
• For future reference, you can always check your (or WA's) answer by differentiating it and checking it against the expression you're integrating (the integrand). If they match up then you know your answer is correct (up to a constant), even if you don't know any trig! – Ben Aug 12 at 12:05

## 5 Answers

$$1+\cos x = 2\cos^2\frac{x}{2}$$

$$\ln (1+\cos x )=\ln( 2\cos^2\frac{x}{2})=\ln2+2\ln\cos\frac{x}{2}$$

And this $$\ln2$$ adds together with the arbitrary constant $$c$$ in indefinite integral and gets cancelled in definite integral.

• Thank you so much! This makes perfect sense! – Seigemann Aug 12 at 11:58
• You're welcome! – Ak19 Aug 12 at 11:58

As Ben suggested in comments, it's always good to check an integral by taking the derivative:

$$\dfrac d {dx} \ln(1+\cos x)=\dfrac{-\sin x}{1+\cos x}=\dfrac{-2\sin\dfrac x2 \cos \dfrac x2}{2\cos^2\dfrac x2}=\dfrac{-\sin\dfrac x2}{\cos \dfrac x2}=\dfrac d {dx} 2 \ln \cos \dfrac x2$$

• N.B. The expressions are undefined when $x=\pi$ – J. W. Tanner Aug 12 at 13:11

$$1+\cos \, x=2\cos^{2}(\frac x 2)$$ so $$\ln (1+\cos \, x)=2 \ln (\cos (\frac x 2))+\ln 2$$ . Also, $$-\tan (\frac x 2)$$ is same as $$-\frac {\sin \, x} {1+\cos \, x}$$ because $$\sin \,x =2 \sin (\frac x 2)\cos (\frac x 2)$$ and $$1+\cos \, x=2\cos^{2}(\frac x 2)$$.

$$2\ln\cos\frac x2=\ln\cos^2\frac x2=\ln\frac{1+\cos x}2=\ln(1+\cos x)-\ln2$$ by the half-angle formula, so your answer and WA's are the same up to the integration constant.

When you do the one integral $$I(x)$$ by different methods you get different expressions $$I_1(x),I_2(x),I_3(x),.....$$, however the difference between any two of these is a constant independent of $$x$$. For instance $$I(x)=\int \sin \cos x dx =\frac{1}{2}\int \sin 2x~ dx =-\frac{1}{4} \cos 2x +C_1 =I_1(x).$$

Next if you do integration by parts you get $$I=\sin ^2x -\int \sin x \cos \Rightarrow I=\frac{1}{2} \sin^2 x +C_2=I_2(x).$$

Further I you use a substitution $$\cos x =-t$$, then $$I(x)=-\frac{1}{2}\cos^2 x +C_3=I_3(x).$$

Now check that the difference between any two of $$I_1,I_2,I_3$$ is just a constant.

As pointed in other solutions the thing stated above is happening in your case as well.