<s>[INST] Is there any mistake in my approach for solving $ \int_0^{\pi/2} \frac{ \cos x}{3 \cos x + \sin x} \, dx $ ?? I had to evaluate this integral .
$$
\int_0^{\pi/2} \frac{\cos x}{3 \cos x + \sin x} \, dx
$$
Here is how I proceeded 
Dividing $N^r$ And $D^r$ by $\cos^3 x$
$$
\int_0^{\pi/2} \frac{ \sec^2 x}{3 \sec^2 x + \tan x \sec^2 x}\, dx \\
$$
Substituting $\tan x = t$
$$
\int_0^\infty \frac{ 1 }{(1+t^2)(t+3)} \, dt \\
$$
Then by using Partial Fractions , I got the answer as 
$$
\frac{1}{10} \log (t+3) - \frac{1}{20} \log (t^2 + 1) + \frac{3}{10} \arctan (t)  \biggr|_{0}^{\infty}
$$
But while substituting the limits , the answer comes out be be infinity which is wrong .
Is there any mistake in my approach ??
 [/INST] A simple method to avoid using partial fractions and improper integrals. Let
$$ A=\int_0^{\pi/2} \frac{\cos x}{3 \cos x + \sin x} \, dx, B=\int_0^{\pi/2} \frac{\sin x}{3 \cos x + \sin x} \, dx. $$
Clearly 
$$ 3A+B=\frac{\pi}{2}. \tag{1}$$
Noting that
$$  A=\int_0^{\pi/2} \frac{1}{3 \cos x + \sin x} \, d\sin x, B=-\int_0^{\pi/2} \frac{1}{3 \cos x + \sin x} \, d\cos x $$
it is easy to see
$$ -3B+A=\int_0^{\pi/2} \frac{1}{3 \cos x + \sin x} \, d(3\cos x+\sin x)=\ln(3\cos x+\sin x)\bigg|_0^{\frac\pi2}=-\ln 3.\tag{2} $$
From (1) and (2), one has 
$$A=\frac{3\pi}{20}-\frac{1}{10}\ln3.$$
</s>