Given: $\int f(x)\sin x \cos x dx = \log(f(x)){1\over 2( b^2 - a^2)}+C$, find $f(x)$. 
$$\int f(x)\sin x \cos x dx = \log(f(x)){1\over 2( b^2 - a^2)}+C$$


On differentiating, I get,
$$f(x)\sin x\cos x  = {f^\prime(x)\over f(x)}{1\over 2( b^2 - a^2)}$$  
$$\sin 2x (b^2 - a^2) = {f^\prime( x)\over (f(x))^2} $$
On integrating, 
$${-1\over f(x)} = {-(b^2 - a^2)\cos 2x\over 2} \implies f(x) = { 2\over(b^2 - a^2)\cos 2x}$$
The answer given is $\displaystyle f(x) = {1\over a^2 \sin^2 x + b^2 \cos^2 x}$.
I am unable to get the given result, the closest I got is, $$f(x) = {2\over b^2 \cos^2x -b^2\sin^2 x- a^2\cos^2x+ a^2\sin^2 x}$$.
How to simplify further to get the given answer ?
Related but not duplicate.
 A: On differentiating you get indeed
$$
f(x)\sin x\cos x=\frac{f'(x)}{f(x)}\frac{1}{2(b^2-a^2)}
$$
so the differential equation
$$
\frac{f'(x)}{f(x)^2}=(b^2-a^2)\sin2x
$$
Integrating it you get
$$
-\frac{1}{f(x)}=-\frac{1}{2}(b^2-a^2)\cos2x+c
$$
hence
$$
f(x)=\frac{2}{(b^2-a^2)\cos2x-2c}
$$
You can expand $\cos2x=\cos^2x-\sin^2x$ and $2c=2c\cos^2x+2c\sin^2x$, so
$$
(b^2-a^2)\cos2x-2c=
(b^2-a^2-2c)\cos^2x+(a^2-b^2-2c)\sin^2x
$$
We can try for
$$
\begin{cases}
a^2-b^2-2c=2a^2 \\[4px]
b^2-a^2-2c=2b^2
\end{cases}
$$
which is valid for $-2c=a^2+b^2$, but I see no reason for choosing this particular solution. The only limitation is that
$$
(b^2-a^2)\cos2x-2c>0
$$
as far as I can see.
Is there any other condition in your problem?
A: $f(x) = {2\over b^2 \cos^2x -b^2\sin^2 x- a^2\cos^2x+ a^2\sin^2 x}$
$= {2\over b^2 \cos^2x -b^2(1-\cos^2 x)- a^2(1-\sin^2x)+ a^2\sin^2 x}$
$= {2\over b^2 \cos^2x -b^2 + b^2\cos^2 x- a^2 +a^2\sin^2x+ a^2\sin^2 x}$
$= {2\over -(a^2 + b^2 ) + 2b^2\cos^2x +2a^2\sin^2x}$
As you can see one extra term $-(a^2+b^2)$ in denominator and its not possible to eliminate it. 
Edit -
From @mickep comment as you have constant term after integration. If we consider $= {2\over -(a^2 + b^2 )}$ as constant term which is possible we get expected result.
A: The solutions are OK (contrary to what I first wrote). After integrating, you can check that you have
$$
\frac{1}{f}=\frac{(b^2-a^2)\cos 2x}{2}
$$
and, according to the solution in the book,
$$
\frac{1}{f}=a^2\sin^2x+b^2\cos^2x.
$$
The difference should be a constant (the integrating constant). And indeed,
$$
\frac{(b^2-a^2)\cos 2x}{2}-\bigl(a^2\sin^2x+b^2\cos^2x\bigr)=-\frac{a^2+b^2}{2}.
$$
Thus, everything is in order.
