# Indefinite Integral with "sin" and "cos": $\int\frac{3\sin(x) + 2\cos(x)}{2\sin(x) + 3\cos(x)} \; dx$

Indefinite Integral with sin/cos

I can't find a good way to integrate: $$\int\dfrac{3\sin(x) + 2\cos(x)}{2\sin(x) + 3\cos(x)} \; dx$$

• If all else fails, this will do it: en.wikipedia.org/wiki/Tangent_half-angle_substitution ${}\qquad{}$ Apr 3, 2015 at 18:49
• This is probably as bad as $\displaystyle\int\sec x\,dx$, and probably for the same reason. Maybe I'll post an answer later when I have some time. ${}\qquad{}$ Apr 3, 2015 at 18:51
• I did this a really weird way. I expressed integrand with top as $\sin(x+A)$ and bottom as $\cos(x-A)$ where I had a right triangle whose $\sin(A)=\frac{2}{\sqrt{13}}$ and $\cos(A)=\frac{3}{\sqrt{13}}$. I then rewrote the top as $\sin(x-A+2A)$ and then expanded that. This actually worked but you have an answer below way shorter than this method. Apr 3, 2015 at 19:06
• I might post it but I definitely won't latex it all. I will probably write it all and submit an image if you are interested that is? I have a scribble of it all but I have to rewrite it to make it all neat. Please let me know if you are interested in seeing it. Apr 3, 2015 at 19:09
• math.stackexchange.com/questions/571054/… Apr 4, 2015 at 15:02

It is a pity you did not have a minus-sign in the numerator, since $$D\ln(3\cos x+2\sin x)=\frac{2\cos x-3\sin x}{3\cos x+2\sin x},$$ but let us see how we can use this fact anyways.

Let us aim at writing $$\frac{2\cos x+3\sin x}{3\cos x+2\sin x}=c_1 \frac{2\cos x-3\sin x}{3\cos x+2\sin x}+c_2 \frac{3\cos x+2\sin x}{3\cos x+2\sin x}$$ since both those terms are easy to integrate. This leads us to the linear equations $2=2c_1+3c_2$ and $3=-3c_1+2c_2$. The solution to this system is $c_1=-5/13$ and $c_2=12/13$. Thus $$\int\frac{2\cos x+3\sin x}{3\cos x+2\sin x}\,dx = -\frac{5}{13}\int \frac{2\cos x-3\sin x}{3\cos x+2\sin x}\,dx +\frac{12}{13}\int \frac{3\cos x+2\sin x}{3\cos x+2\sin x}\,dx.$$ I guess you can take it from here?

• This is a well-known method where I'm from. Apr 6, 2015 at 1:12

We can split this into two integrals:

$$3 \int \frac{\sin(x)}{2\sin(x)+3\cos(x)}dx + 2 \int \frac{\cos(x)}{2\sin(x)+3\cos(x)}dx.$$

Focusing on the second integral we find:

$$\int \frac{\cos(x)}{2\sin(x)+3\cos(x)}dx = \int \frac{1}{2\tan(x)+3}dx$$

Make the substitution $u=2\tan(x)+3$ which makes $$du = 2\sec^2(x)dx = 2(\tan^2(x)+1)dx = 2(u^2+1)dx.$$

Thus we have $$\int \frac{\cos(x)}{2\sin(x)+3\cos(x)}dx = \frac12 \int \frac{1}{u(u^2+1)} du = \frac12 \int \left(\frac{1}{u} - \frac{u}{u^2+1}\right) du.$$

This integral can be computed by another substitution:

$$\int \frac{\cos(x)}{2\sin(x)+3\cos(x)}dx=\frac12 \left(\ln|2\tan(x)+3| - \frac12 \ln|(2\tan(x)+3)^2+1|\right) + C.$$

That completes the second integral. The first can be handled in a similar manner.

![The method I was speaking of if anyone especially OP is interested.... ][1]

[1]: http://i.stack.imgur.com/r05sp.jpg $$\text{ Let there be a right triangle with angle A (not with measurement 90 deg) } \\ \text{ whose adjacent has measurement } 3 \text{ and whose opposite has measurement } 2. \\ \text{ Therefore the hypotenuse of the triangle has measurement } \sqrt{13}. \\ \text{ So this means } \sin(A)=\frac{2}{\sqrt{13}} \text{ and } \cos(A)=\frac{3}{\sqrt{13}} . \\ \text{ } \\ \text{ } \\ 3 \sin(x)+2 \cos(x)=\sqrt{13}(\frac{3}{\sqrt{13}} \sin(x)+\frac{2}{\sqrt{13}} \cos(x)) \\ =\sqrt{13}(\cos(A) \sin(x)+\sin(A) \cos(x)) =\sqrt{13} \sin(x+A) \\ \text{ } \\ \text{ } 2 \sin(x)+3 \cos(x) = \sqrt{13}(\frac{2}{\sqrt{13}} \sin(x)+\frac{3}{\sqrt{13}} \cos(x)) \\ \text{ } \\ \text{ } =\sqrt{13}(\sin(A) \sin(x)+\cos(A) \cos(x)) =\sqrt{13} \cos(x-A) \\ \text{… } \\ \int \frac{ 3 \sin(x)+2 \cos(x)}{ 2 \sin(x)+3 \cos(x) } dx= \int \frac{\sqrt{13} \sin(x+A) }{\sqrt{13} \cos(x-A) } dx \\ =\int \frac{ \sin(x-A+2A)} {\cos(x-A)} dx=\int \frac{ \sin(x-A) \cos(2A)+ \sin(2A) \cos(x-A)}{\cos(x-A)} dx \\ =\cos(2A) \int \frac{ \sin(x-A)}{\cos(x-A)} dx+ \sin(2A) \int \frac{\cos(x-A)}{\cos(x-A)} dx\\ =(\cos^2(A)-\sin^2(A)) \int \frac{\sin(x-A)}{\cos(x-A)} dx+2 \sin(A) \cos(A) \int 1 dx \\ =((\frac{3}{\sqrt{13}})^2-(\frac{2}{\sqrt{13}})^2) \int \frac{-du}{u} +2 \frac{2}{\sqrt{13}} \frac{3}{\sqrt{13}} x +C \\ \text{ (note: where } u=\cos(x-A) \text{ and so } du=-\sin(x-A) dx \text{ ) } \\ =(\frac{9}{13}-\frac{4}{13}) (- \ln|u|)+\frac{12}{13} x+C \\ =- \frac{5}{13} \ln|\cos(x-A)| +\frac{12}{13}x+C \\ =-\frac{5}{13} \ln|\cos(x) \cos(A)+\sin(x) \sin(A)|+\frac{12}{13}x+C \\ =-\frac{5}{13} \ln|\cos(x) \frac{3}{\sqrt{13}}+ \sin(x) \frac{2}{\sqrt{13}}|+\frac{12}{13}x+C \\ =-\frac{5}{13} \ln| \frac{1}{\sqrt{13}} (3 \cos(x)+2 \sin(x))| +\frac{12}{13}x+C \\ =-\frac{5}{13} \ln|\frac{1}{\sqrt{13}}|-\frac{5}{13} \ln|3 \cos(x)+2 \sin(x)|+\frac{12}{13}x+C \\ =-\frac{5}{13} \ln|3 \cos(x)+2 \sin(x)|+\frac{12}{13}x-\frac{5}{13} \ln|\frac{1}{\sqrt{13}}|+C \\ =-\frac{5}{13} \ln|3 \cos(x)+2 \sin(x)|+\frac{12}{13}x+K \\$$

Use this trigonometric identity: $$\frac{3\sin x+2\cos x}{2\sin x+3\cos x} = \overbrace{\frac{12}{13} + \frac5{13}\tan\left( x - \varphi \right)}^{\text{So integrate this function.}} \text{ where }\varphi = \arctan\frac 2 3.$$ NOTE: I initially mislaid the denominator in $5/13$ and just had $5$ as the coefficient. @robjohn pointed out the error in comments below.

Proof: The graph looks like a tangent function with period $\pi$ except that the inflection point is higher than the $x$-axis and the asymptotes are not at $\pm\pi/2$. The asymptotes occur where the denominator is $0$, so at those points $2\sin x+3\cos x=0$, so $\tan x = -3/2$. Hence the inflection points are at $$\frac\pi2 -\arctan\frac 3 2 = \arctan\frac 2 3.$$ We have $$\frac{3\sin x+2\cos x}{2\sin x+3\cos x} = \frac{3\tan x + 2}{2\tan x + 3}$$ and when $\tan x = \dfrac 2 3$ this simplifies to $\dfrac{12}{13}$. So we want $$\frac {12}{13} + c\tan(x-\varphi) = \frac{12}{13} + c\frac{\tan x - \frac 2 3}{1+ \frac 2 3 \tan x} = \frac {12}{13} + c\frac{3\sin x - 2\cos x}{3\cos x + 2\sin x}.$$ We need to find the value of $c$ for which we get the right function, and a bit of algebra tells us $c=5/13$.

• Unless I've made an error, I believe that $$\frac{3\sin(x)+2\cos(x)}{2\sin(x)+3\cos(x)} =\frac{12}{13}+\frac5{13}\tan(x-\varphi)$$ I used $3\cos(x)+2\sin(x) =\sqrt{13}\cos(x-\varphi)$ where $\varphi =2\arctan\left(\frac2{3+\sqrt{13}}\right)$. Then $$\sin(x) =\frac3{\sqrt{13}}\sin(x-\varphi) +\frac2{\sqrt{13}}\cos(x-\varphi)$$ and $$\cos(x) =\frac3{\sqrt{13}}\cos(x-\varphi) -\frac2{\sqrt{13}}\sin(x-\varphi)$$
– robjohn
Apr 4, 2015 at 0:52
• aha! I mislaid the denominator along the way. ${}\qquad{}$ Apr 4, 2015 at 1:28

HINT: One way is to use /reduce half angle tan formulas like $\cos(x) = \dfrac{1-t^2}{1+t^2}$ with $dx.$

$$\int \frac{3\sin(x)+2\cos(x)}{2\sin(x)+ 3\cos(x)} \, dx$$

Multiply top and bottom by $\sec^{3}(x)$

\begin{align} & \int \frac{3\tan(x)\sec^2(x)+2\sec^2(x)}{2\tan(x)\sec^2(x)+ 3\sec^2(x)} dx \\[10pt] & \int \frac{(3\tan(x)+2)\sec^2(x)}{(2\tan(x)+ 3)\sec^2(x)} \, dx \\[10pt] & \int \frac{(3\tan(x)+2)\sec^2(x)}{(2\tan(x)+ 3)(\tan^2(x)+1)} \, dx \end{align}

Substitute $u = \tan(x)$ and $du = \sec^2(x)dx$

$$\int \frac{3u+2}{(2u+3)(u^2+1)}du$$

Use partial fractions to write

$$\int \left(\frac{5u+12}{13(u^2+1)}-\frac{10}{13(2u+3)}\right) \, du$$

$$\frac{1}{13}\int \left(\frac{5u}{u^2+1} + \frac{12}{u^2+1}-\frac{10}{2u+3}\right) \, du$$

for first term, substitute $s = u^2+1$ and $ds = 2u \, du$

$$\frac{1}{13}\int \left(\frac{5}{2s} + \frac{12}{u^2+1}-\frac{10}{2u+3}\right) \, du$$

the integral of $\frac{1}{s} = \ln s$ and the integral of $\frac{1}{u^2+1} = \tan^{-1}u$ turns it into

$$\frac{1}{13} \left(\frac{5\ln s}{2} + 12 \tan^{-1}u- \int \frac{10}{2u+3} \, du\right)$$

Substitute $p=2u+3$ and $dp = 2 \, du$

$$\frac{1}{13}(\frac{5\ln s}{2} + 12 \tan^{-1}u- \int \frac{5}{p} \, dp)$$

$$\frac{1}{13}(\frac{5\ln s}{2} + 12 \tan^{-1}u- 5\ln p)$$

Substituting back for $s = u^2 +1$ and $p = 2u+3$ and $u=\tan(x)$

$$\frac{1}{13} \left(\frac{5\ln (\tan^2(x)+1)}{2} + 12 \tan^{-1}(\tan(x))- 5\ln{(2\tan x+3)}\right)$$

$$\frac{1}{13}(\frac{5\ln (\sec^2(x))}{2} + 12x- 5\ln{(2\tan x+3)})$$

$$\frac{1}{13}(5\ln (\sec(x)) + 12x- 5\ln{(2\tan x+3)})$$

$$= \frac{1}{13}(12x - 5\ln{(2\sin(x)+3\cos(x))}) + \text{constant}$$

Use Technique: $$Numerator=A(diff(denominator))+B(denominator)$$ This will solve your issue for sure.