<s>[INST] Evaluating integrals such as $\int \frac{1+\cos^{2}x}{1+\cos2x}$ We started integrals not too long ago, I understand it for the most part but I always have a problem figuring out how to solve ones involving trig identities. Like this:
$$\int \frac{1+\cos^{2}x}{1+\cos2x}$$
Indefinite integral of $$\frac{ 1 + \cos^2(x)}{ 1 + \cos(2x) }.$$
I tried changing the denominator to $2\cos^2(x)$ but I still can't make a u substitution.
 [/INST] Write $$2\cos^2x = 1+ \cos2x$$
$$\cos^2x= \frac{1+ \cos2x}{2}$$
$$=∫1+\frac{1+ \cos2x}{2} * \frac{1}{1+\cos2x} $$
$$=\int\frac{1}{1+\cos2x}+\int\frac{1}{2}$$
Use $$u=2x$$
$$=\frac{1}{2}[\int\frac{1}{1+\cos(u)}]+\frac{1}{2}x$$
$$=\frac{1}{2}[\int\frac{1-cos(u)}{1-\cos^2u}]$$
$$=\frac{1}{2}[\int\frac{1-cos(u)}{\sin^2u}]$$
$$=\frac{1}{2}[\int\frac{1 }{\sin^2u}du -\int\frac{\cos u}{\sin^2u}du]$$
Use $$v=\sin u$$
$$=\frac{1}{2}[-\cot u + \frac{1}{\sin u}]$$
$$=\frac{1}{2}[-\cot 2x + \frac{1}{\sin 2x}]$$
$$=\frac{1}{2}\tan x$$
$$=\frac{1}{2}\tan x+\frac{1}{2}x$$
</s>