What is the solution for $\int_{0}^{\pi/2}\frac{\cos^2x}{\cos^2x+4\sin^2x}\,dx$ I used the rule :$$\int_{0}^{a}f(x) = \int_{0}^{a}f(a-x)\,dx$$
And got :$$\int_{0}^{\pi/2}\frac{\sin^2x}{\sin^2x+4\cos^2x}\,dx$$
Then, I added both the question and the above integrand, and I got :$$\int_{0}^{\pi/2}\frac{dx}{5}$$
Solving the above, I finally got the answer as $$\frac{\pi}{20}$$
But, according to my textbook, the answer is $$\frac{\pi}{6}$$
Where did I go wrong?
 A: So what you have done is apparently wrong.  The equality you used is true, the problemes lies elsewhere.
In fact when you add the two terms you found :
$$A =\frac{\cos^2x}{\cos^2x+4\sin^2x}$$
$$B =\frac{\sin^2x}{\sin^2x+4\cos^2x}$$
$$\implies A + B = \frac {3 \cos(x)^4 + 3 \sin(x)^4+1}{(3 \sin(x)^2 +1) \cdot (3 \cos(x)^2 + 1)} $$
Here is an attempt to solve the exercice: 
$$I = \int_{0}^{\pi/2}\frac{\cos^2x}{\cos^2x+4\sin^2x}dx = \int_{0}^{\pi/2}\frac{1}{1+4\tan^2x}dx $$
we can do this because the interval of integration permits it.
Then we change the variable of integration ; the substitution is the following :
$$ u = \tan x$$
we get :
$$I =\int_{0}^{\infty}\frac{1}{(1 +4u^2)(1 + u^2)}du = \int_{0}^{\infty} \frac {4}{3(4u^2 + 1)} - \frac {1}{3(u^2+1)}   du $$ 
from there we can easily conclude. 
In fact you just have to know this formula : 
$$\int \frac 1 {x^2 + a^2} = \frac 1 {|a|} \arctan \left(\frac x a \right) + C $$
Where $C$ is the constant of integration. 
And thus we get : 
$$\int_{0}^{\infty} \frac {4}{3(4u^2 + 1)} du = \frac 2 3 \arctan(2u)\bigg\rvert_0^{\infty} = \pi / 3$$
$$\int_{0}^{\infty} \frac {1}{3(u^2+1)}   du = \frac 1 3 \arctan u \bigg\rvert_0^{\infty} = \pi/6 $$
