Help in evaluating integral using elementary methods I have the following integral:
$\int\limits_{0}^{\pi/2}\frac{x\sin x \cos x}{a^2 \cos^2x+ b^2\sin^2x} \ dx$, for $a,b \geq 0$, both not zero.
I have tried several substitutions without any success at all. How can this be tackled?
Thanks.
 A: First we deal with the case $b= a$, then:
$$I(a,a)=\int\limits_{0}^{\pi/2}\frac{x\sin x \cos x}{a^2 \cos^2x+ a^2\sin^2x} \ dx=\frac{1}{a^2} \int\limits_{0}^{\pi/2} x\sin x \cos x dx$$
Now we use integration by parts with:
$$u=x,\qquad dv=\sin x \cos x dx$$
$$v=\int \sin x \cos x dx=\frac{1}{4} \int \sin 2x d2x=-\frac{\cos 2x}{4} $$
$$uv \bigg|_0^{\pi/2}=\frac{\pi}{8}$$
$$I(a,a)=\frac{\pi}{8a^2}+\frac{1}{4a^2} \int\limits_{0}^{\pi/2} \cos 2x ~dx=\frac{\pi}{8a^2}+\frac{1}{8a^2} \int\limits_{0}^{\pi} \cos 2x ~d2x=\frac{\pi}{8a^2}$$

Now we assume $a \neq b$. We use the same method of integration by parts:
$$u=x,\qquad dv=\frac{\sin x \cos x}{a^2 \cos^2x+ b^2\sin^2x} dx$$
Suprisingly, $v$ has a simple form, which I'm not going to derive here, as it can be checked by direct differentiation:
$$v=-\frac{\log \left(a^2+b^2+(a^2-b^2) \cos 2x \right)}{2(a^2-b^2)}$$
$$uv \bigg|_0^{\pi/2}=-\frac{\pi \log \left(2 b^2 \right)}{4(a^2-b^2)} $$
So:
$$I(a,b)=-\frac{\pi \log \left(2 b^2 \right)}{4(a^2-b^2)}+\frac{1}{4(a^2-b^2)}\int\limits_{0}^{\pi}\log \left(a^2+b^2+(a^2-b^2) \cos u \right) du=$$
$$=\frac{\pi \left(\log \left(a^2+b^2\right)- \log \left(2 b^2 \right) \right)}{4(a^2-b^2)}+\frac{1}{4(a^2-b^2)}\int\limits_{0}^{\pi}\log \left(1+p \cos u \right) du$$
Where $p=\frac{a^2-b^2}{a^2+b^2}$ and thus $|p|<1$.

Going further, we can expand the logarithm as Taylor series, then express the integrals as Beta function, and then find a closed form for the resulting series. The latter I have done with the help of Wolfram Alpha.
This way turns out to be quite tedious. Maybe it's better to expand the original integral as a series in $p$ right from the start. However, I will write the final answer I obtained (which can be confirmed by numerical experiments):

$$I(a,b)=\int\limits_{0}^{\pi/2}\frac{x\sin x \cos x}{a^2 \cos^2x+ b^2\sin^2x} \ dx= \frac{\pi}{2} \frac{\log (a+b)-\log b- \log 2}{a^2-b^2}$$
$$a \neq b$$


Remark: while the methods here are not completely elementary, neither is this integral. The best way to evaluate integrals like this is contour integration.
A: $\newcommand{\bbx}[1]{\,\bbox[15px,border:1px groove navy]{\displaystyle{#1}}\,}
 \newcommand{\braces}[1]{\left\lbrace\,{#1}\,\right\rbrace}
 \newcommand{\bracks}[1]{\left\lbrack\,{#1}\,\right\rbrack}
 \newcommand{\dd}{\mathrm{d}}
 \newcommand{\ds}[1]{\displaystyle{#1}}
 \newcommand{\expo}[1]{\,\mathrm{e}^{#1}\,}
 \newcommand{\ic}{\mathrm{i}}
 \newcommand{\mc}[1]{\mathcal{#1}}
 \newcommand{\mrm}[1]{\mathrm{#1}}
 \newcommand{\pars}[1]{\left(\,{#1}\,\right)}
 \newcommand{\partiald}[3][]{\frac{\partial^{#1} #2}{\partial #3^{#1}}}
 \newcommand{\root}[2][]{\,\sqrt[#1]{\,{#2}\,}\,}
 \newcommand{\totald}[3][]{\frac{\mathrm{d}^{#1} #2}{\mathrm{d} #3^{#1}}}
 \newcommand{\verts}[1]{\left\vert\,{#1}\,\right\vert}$
\begin{align}
&\bullet\mbox{When}\ a \not= 0\ \mbox{and}\ b = 0,
\\
&\phantom{\bullet\,\,\,\,}\mbox{the integral}\ diverges\ \mbox{because}\
\tan\pars{x} \sim {1 \over \pi/2 - x}\ \mbox{as}\
{x \to \pars{\pi \over 2}^{-}}.
\\[3mm]
&
\bullet\mbox{When}\ \verts{a} = \verts{b} \not= 0,\
\mbox{the integration yields}\ {\pi \over 8a^{2}}.\label{1}\tag{1}
\end{align}

Hereafter, I'll consider the case $\ds{\verts{a} \not= \verts{b} \not= 0}$. With $\ds{\mu \equiv \verts{a \over b} \not= 1}$:

\begin{align}
&\bbox[10px,#ffd]{\ds{\int_{0}^{\pi/2}\!\!\!\!\!{x\sin\pars{x}\cos\pars{x} \over a^{2}\cos^{2}\pars{x} + b^{2}\sin^{2}\pars{x}}\,\dd x}} =
{1 \over b^{2}}\int_{0}^{\pi/2}\!\!\!\!\!{\tan\pars{x} \over \tan^{2}\pars{x} + 1}{x \over \tan^{2}\pars{x} + \mu^{2}}\,\sec^{2}\pars{x}\,\dd x
\\[5mm] \stackrel{\tan\pars{x}\ \mapsto\ x}{=}\,\,\, &\
{1 \over b^{2}}\int_{0}^{\infty}{x \over
\pars{x^{2} + 1}\pars{x^{2} +  \mu^{2}}}\,\arctan\pars{x}\,\dd x
\\[5mm] = &\
{1 \over b^{2}}\,{1 \over \mu^{2} - 1}\int_{0}^{\infty}
\pars{{x \over x^{2} + 1} - {x \over x^{2} + \mu^{2}}}\,\arctan\pars{x}\,\dd x
\\[5mm] \stackrel{\mrm{IBP}}{=}\,\,\, &\
{1 \over 2\pars{a^{2} - b^{2}}}\bracks{%
\int_{0}^{\infty}{\ln\pars{x^{2} + \mu^{2}} \over x^{2} + 1}\,\dd x -
\int_{0}^{\infty}{\ln\pars{x^{2} + 1} \over x^{2} + 1}\,\dd x} 
\end{align}

$\ds{\int_{0}^{\infty}
{\ln\pars{x^{2} + \mu^{2}} \over x^{2} + 1}\,\dd x = \pi\ln\pars{1 + \mu}}$.

It can be evaluated as
\begin{align}
\int_{0}^{\infty}
{\ln\pars{x^{2} + \mu^{2}} \over x^{2} + 1}\,\dd x & =
2\,\Re\int_{0}^{\infty}
{\ln\pars{x + \mu\ic} \over x^{2} + 1}\,\dd x
\\[5mm] & =
\Im\lim_{\Lambda \to \infty}\bracks{%
\int_{0}^{\Lambda}{\ln\pars{x + \mu\ic} \over x - \ic}\,\dd x -
\int_{0}^{\Lambda}{\ln\pars{x + \mu\ic} \over x + \ic}\,\dd x}
\end{align}

which involves the Polylogarithm Function.

Then,
$$
\bbx{\bbox[10px,#ffd]{\ds{\int_{0}^{\pi/2}{x\sin\pars{x}\cos\pars{x} \over a^{2}\cos^{2}\pars{x} + b^{2}\sin^{2}\pars{x}}\,\dd x}} =
{\pi \over 2}\,{\ln\pars{\verts{a} + \verts{b}} - \ln\pars{\verts{b}} - \ln\pars{2} \over a^{2} - b^{2}}}
$$

Note that it 'goes to' $\ds{\to {\pi \over 8a^{2}}}$ when
  $\ds{b \to a \not= 0}$ in agreement wit \eqref{1}.

