# Stuck with an integral

## Main Question or Discussion Point

Hello everyone

I need some help in performing the following integration (not HW):

$$\int_{0}^{\pi/4}\left(\frac{x}{x\sin x + \cos x}\right)^{2}dx$$

I tried integration by parts, but it leads nowhere. Any suggestions would be appreciated.

Thanks
Vivek
PS--Mathematica gives the answer as $(4-\pi)/(4+\pi)$ but is unable to perform the integration with the $x^2$ term in the numerator replaced by unity.

To solve your integral, you can start by differentiating

$$-\frac{x \sec{x}}{(x \sin{x} + \cos{x})}$$

this will give you

$$-(\frac{x \sec{x} }{x \sin{x} + \cos{x}})^{\prime} = \frac{x^2}{(x \sin{x} + \cos{x})^2} - \frac{(\sec{x} + x \sec{x} \tan{x})}{(x \sin{x} + \cos{x})}$$

Now, you'll recognize the first term on the right hand side as your integrand. To evaluate the second term on the right hand side, you can first take the $$\sec{x}$$ out of the top half to get

$$\frac{(\sec{x} + x \sec{x} \tan{x})}{(x \sin{x} + \cos{x})} = \sec{x} \frac{1 + x \tan{x}}{(x \sin{x} + \cos{x})}$$

Now, divide the bottom half by $$\cos{x}$$ to get

$$\frac{\sec{x}}{\cos{x}} \frac{(1 + x \tan{x})}{(x \tan{x} + 1)} = \sec^2{x}$$

Now, the integral of $$\sec^2{x}$$ is

$$\int{\sec^2{x} dx} = \tan{x} + C$$

$$\int{(\frac{x}{x \sin x + \cos x})^{2} dx} = \tan{x} - \frac{x \sec{x}}{(x \sin{x} + \cos{x})} + C$$

where C is a constant of integration.

Last edited:
Gib Z
Homework Helper
I'm not sure about you Matthew but most people don't have a preset function they know the should differentiate and compare their integral to. Otherwise one might just say to differentiate $$\frac{\sin x - x\cos x}{\cos x - x\sin x}$$ and see what you get.

Fair enough, but it wasn't a guess -- I got there by trying to find out what function, f(x), when divided by $$(x \sin{x} + \cos{x})$$ yields the integrand in part of its derivative. (The answer of course is $$f(x) = -x \sec{x}$$). Then it's a question of seeing if you can integrate the other part(s) of the derivative -- if you can, you have a solution. In this case, it was possible.

Last edited:
Gib Z
Homework Helper
In that case, good work mate :)

No, you're right -- I should have made this clear at the start. Sorry folks.

Thanks Matthew and GibZ

Sorry for the late acknowledgement...I figured out how to do it, by a method similar to that suggested.

GibZ, if I take your function with the minus replaced by plus in the denominator, then the derivative equals the integrand. So thats an equivalent way of doing it.

Thanks again

Last edited: