Evaluate $\int_0^{\pi/2} \frac{1+2\cos x}{(2+\cos x)^2}$ I don’t know how to begin solving. Can I get a hint?
My failed attempt
Let $t =\tan (x/2)$
Then $$I =2 \int_0^1 \frac{(3-t^2)}{(3+t^2)^2 }$$
which I am not able to solve

Continuing from your method is messy but possible:
Let $\frac{(3-t^2)}{(3+t^2)^2 } = \frac{A}{(3+t^2)} + \frac{B}{(3+t^2)^2}$. Then $3-t^2 = (3+t^2)A + B$. When $t = 0, 3 = 3A + B$, and when $t = 1, 2=4A+B$, so $A = -1, B= 6$. Thus:
$$I = -2 \int_0^1 \frac{1}{3+t^2} \ dt + 12 \int_0^1 \frac{1}{(3+t^2)^2} \ dt $$
For the second integral, substitute $t = \sqrt{3} \tan u, dt = \sqrt{3} \sec^2 u$. Then $(3+t^2)^2$ $ =(3(1 + \tan^2 u))^2 = 9 \sec^4 u$, and so:
$$I_2 = \frac{\sqrt{3}}{9} \int_0^1 \cos^2u \ du = \frac{\sqrt3}{18} \int_0^1 1+\cos2u \ du= \left[\frac{\sqrt3}{18} (u+\frac{1}{2} \sin 2u)\right]_0^1 = \left[\frac{\sqrt3}{18} (\tan^{-1} \frac{t}{\sqrt3}+\frac{1}{2} \sin(2(\tan^{-1}\frac{t}{\sqrt3}))\right]_0^1$$
and therefore:
$$I = -2 \left[\frac{1}{\sqrt 3} \tan^{-1} \frac{t}{\sqrt3}\right]_0^1+12\left[\frac{\sqrt3}{18} (\tan^{-1} \frac{t}{\sqrt3}+\frac{1}{2} \sin(2(\tan^{-1}\frac{t}{\sqrt3}))\right]_0^1$$
$$=-2(\frac{1}{6\sqrt3} \pi - 0) + 12 \cdot \frac{\sqrt{3}}{18}(\frac{\pi}{6}+\frac{\sqrt3}{4}-0) = \frac{1}{2}.$$
