# Trouble integrating $\int \frac{\sin(x)}{\cos(x)(1+\cos^2(x))}\mathrm dx$

I am off by a pesky $1/2$ somewhere but I am not sure how what I have done is wrong. Taking $u=\cos(x)\Rightarrow \mathrm du=-\sin(x)\mathrm dx$ yields $$\int \frac{\sin(x)}{\cos(x)(1+\cos^2(x))}\mathrm dx= -\int \frac{1}{u(1+u^2)}\mathrm dx=$$ Which I can solve by partial fractions: $$\frac{1}{u(1+u^2)}=\frac{A}{u}+\frac{Bu+C}{1+u^2}\Rightarrow A=1,\;B=-A=-1$$ Which gives $$-\int \frac{1}{u(1+u^2)}\mathrm dx=-\ln|u|+\ln|1+u^2|=\ln|1+\cos^2(x)|-\ln|\cos(x)|\\ =\ln|\frac{1+\cos^2(x)}{\cos(x)}|$$ But the correct answer is $$\ln|\frac{\sqrt{1+\cos^2(x)}}{\cos(x)}|$$ Any help on how I went wrong would be appreciated!

• When you integrate $\frac{u}{u^2+1}$ there is a $\frac{1}{2}$ that comes out from the u-substitution. So the line $ln|u|+ln|1+u^2|$ ought to be $ln|u|+\frac{1}{2}ln|1+u^2|$, using log rules you get the square root you want. Jun 27, 2016 at 21:24

Hint. Observe that $$\int\frac{u}{1+u^2}du=\frac12\int\frac{2u}{1+u^2}du=\frac12\int\frac{(1+u^2)'}{1+u^2}du=\frac12\log(1+u^2)+C,$$ since $$(u^2)'=2u.$$
• oh doh! I completely forgot to keep the $u$ in the numerator. That was silly. Thank you! Jun 27, 2016 at 21:25
Your answer missed the $\dfrac{1}{2}$ at the coefficient of $\ln(1+u^2)$. It comes from the need to have the $2u$ at the top, so you have to divide by $2$ to stay the same, hence introduce the $\dfrac{1}{2}$.