TITLE: How to calculate this definite integral :- $\int_0^\pi \frac{x}{a^2\cos^2x + b^2\sin^2x} \,dx$?
QUESTION [7 upvotes]: This question was in a test I took: calculate the value of the integral $$\int_0^\pi \dfrac{x}{a^2\cos^2x + b^2\sin^2x} \,dx.$$
I was not able to solve it. Now, I've tried to do some substitutions for $x$ but honestly I don't actually know how to proceed with this integral.
As I have not solved such questions before, I don't know the general direction in which I need to go so I don't know which efforts to include here and which to not.
All I know is that those constants a & b are the source of much of the trouble for me but I don't know how to get rid of them. 
I also want to know whether there is only a single way to solve it (which maybe I've not practised enough) or - like many other problems - it can be solved by more than one method.
I would really appreciate if I find different solutions of this problem here but (if you can help it) please don't include any incredibly tough/ esoteric theorems or concepts/ higher-level stuff that I can't be expected to know at my current level. Thanks!

REPLY [3 votes]: \begin{align}
& \int_0^\pi \frac x {a^2\cos^2x+b^2\sin^2x} \, dx = I \\[10pt]
& \int_0^\pi \frac x {a^2\cos^2x+b^2\sin^2x} \, dx = \int_0^\pi \frac {\pi-x} {a^2\cos^2(\pi-x)+b^2\sin^2(\pi-x)} \, dx \\[10pt]
I = {} & \int_0^\pi \frac{\pi-x}{a^2\cos^2x+b^2\sin^2x} \, dx \\[10pt]
= {} & \int_0^\pi \frac \pi {a^2\cos^2x+b^2\sin^2x} \, dx - I \\[10pt]
2I = {} & \frac 1 {a^2} \int_0^\pi \frac{\pi\sec^2 x}{1 + \left( \frac b a \tan x \right)^2} \, dx \\[10pt]
= {} & \left. \frac \pi {ab} \tan^{-1} \left( \frac b a \tan x \right) \right|_0^\pi
\end{align}

The answer using the famous identity