# Integrate $\int {\dfrac{x^2+\left(n-1\right)n}{\left(x\sin x+n\cos x\right)^2}}dx$

$$\int {\dfrac{x^2+\left(n-1\right)n}{\left(x\sin\left(x\right)+n\cos\left(x\right)\right)^2}}dx$$

My Try:

I multiple $$x^{2n-2}$$ to both N and D, then took D as $$u$$ and then solved to get $$\dfrac{n\sin\left(x\right)-x\cos\left(x\right)}{x\sin\left(x\right)+n\cos\left(x\right)} + C$$ as answer.

My teacher told that this would have been much easier if we had applied linearity and written question as

$$={\displaystyle\int}\dfrac{x\sin\left(x\right)+\left(n-1\right)\cos\left(x\right)}{x\sin\left(x\right)+n\cos\left(x\right)}\,\mathrm{d}x-{\displaystyle\int}\dfrac{\left(\left(1-n\right)\sin\left(x\right)+x\cos\left(x\right)\right)\left(n\sin\left(x\right)-x\cos\left(x\right)\right)}{\left(x\sin\left(x\right)+n\cos\left(x\right)\right)^2}\,\mathrm{d}x$$

I didn't get it, how did we write the above statement? I mean, please explain the method or steps for reaching to this part.

• What is exactly tour doubt on that? Maybe how can we guess that manipilation?
– user
Oct 29, 2019 at 14:12
• Yes, how can we guess that manipulation? Oct 29, 2019 at 14:20
• He basically wrote the numerator in the form of $c_1*$denominator$+c_2$, and obtained $c_1$ and $c_2$ by comparison. Oct 29, 2019 at 14:42
• I tried it, but there is no trigonometric term in the N. Please write a solution if you were able to solve it. Oct 29, 2019 at 14:59
• @Zenix The trick is aimed to use integration by parts of course it not seems so obviuos to see but of course in this way the solution is straightforward.
– user
Oct 29, 2019 at 15:08

Use the shorthands $$s= \sin x$$ and $$c=\cos x$$, along with $$s’= c, \>\>\> c’=-s, \>\>\>s^2+c^2 = 1$$ to reexpress the integrand

\begin{align} & {\dfrac{x^2+(n-1)n}{(x\sin x+n\cos x)^2}} \\ =&\ \frac{x^2+(n-1)n}{(xs+nc)^2} = \frac{x^2(s^2+c^2)+(n-1)n(s^2+c^2)}{(xs+nc)^2} \\ =& \ \frac{[xs+(n-1)c](xs+nc)-[(1-n)xs+xc](ns-xc) }{(xs+nc)^2}\\ = & \ \frac{xs+(n-1)c}{xs+nc}- \dfrac{[(1-n)xs+xc](ns-xc)}{\left(xs+nc\right)^2} \\ = & \ \frac{d}{dx}\left( \dfrac{n s-x c}{x s+n c} \right) = \frac{d}{dx}\left( \dfrac{n\sin x-x\cos x}{x\sin x+n\cos x} \right) \\ \end{align}

Thus

$$\int {\dfrac{x^2+(n-1)n}{(x\sin x+n\cos x)^2}} = \dfrac{n\sin x-x\cos x}{x\sin x+n\cos x} +C$$

• Interestingly, dividing the final fraction's numerator and denominator by $n\cos x$ converts it to $\frac{\tan x-x/n}{1+\frac{x}{n}\tan x}=\tan(x-\arctan\tfrac{x}{n})$.
– J.G.
Oct 10, 2020 at 18:01
• @J.G. See my answer here for the same integral but a different approach I took which shows why your observation is true.
– Ty.
Oct 10, 2020 at 18:02
• How did you figure out the split in the third step?
– Babu
Oct 12, 2020 at 13:12

$$x\sin x+n\cos x=\sqrt{x^2+n^2}\left(\frac{x}{\sqrt{x^2+n^2}}\sin x+\frac{n}{\sqrt{x^2+n^2}}\cos x\right)$$$$=\sqrt{x^2+n^2}\cos \left(x-\arctan(\frac{x}{n})\right)$$

$$\int {\dfrac{x^2+\left(n-1\right)n}{\left(x\sin\left(x\right)+n\cos\left(x\right)\right)^2}}dx=\int\frac{x^2+n(n-1)}{(x^2+n^2)\cos^2\left(x-\arctan(\frac{x}{n})\right)}dx$$

Put $$t=x-\arctan(\frac{x}{n})\Rightarrow\tan t=\frac{\tan x-\frac{x}{n}}{1+(\tan x)(\frac{x}{n})}=\frac{n\sin x-x\cos x}{x\sin x+n\cos x}$$

and$$\frac{dt}{dx}=\frac{x^2+n(n-1)}{x^2+n^2}$$

$$\int {\dfrac{x^2+\left(n-1\right)n}{\left(x\sin\left(x\right)+n\cos\left(x\right)\right)^2}}dx=\int\frac{x^2+n(n-1)}{(x^2+n^2)\cos^2\left(x-\arctan(\frac{x}{n})\right)}dx=\int\sec^2t \;dt$$$$=\tan t +c=\frac{n\sin x-x\cos x}{x\sin x+n\cos x}+c$$

• (+1) that's very nice Aug 9, 2023 at 6:11

It seems that your teacher is taking

$$u=\dfrac{1}{x\sin\left(x\right)+n\cos\left(x\right)}$$

$$v'=x\sin\left(x\right)+\left(n-1\right)\cos\left(x\right) \implies v=n\sin x-x\cos x$$

then by parts

$$\int uv' + \int u'v=uv$$