# Calculating $\int \frac{dx}{1+3\sin x+\cos x}$

Can I get a detailed answer on integrating this? I am currently stumped.

$$\int \frac{dx}{1+3\sin x+\cos x}$$

Thanks.

• Wolfram Alpha has a "show steps" button. – NKS Jun 7 '12 at 2:16
• I asked on SE. Not Wolfram. – Mob Jun 7 '12 at 2:18
• Well, why not?${}$ – Dylan Moreland Jun 7 '12 at 2:23
• Why why not? . . . – Mob Jun 7 '12 at 2:27
• Let $f$ be any rational function of $\sin x$ and/or $\cos x$. The above substitution is the standard universal method for integrating $f$. It is very closely related to the fact that every point $(x,y)$ on the unit circle except $(-1,0)$ can be written as $x=\frac{1-t^2}{1+t^2}$, $y=\frac{2t}{1+t^2}$. This is the very important rational parametrization of the unit circle. – André Nicolas Jun 7 '12 at 3:53

We can solve this example by taking trigonometric substitution. Let $$\tan{\frac{x}{2}}=t$$ $$\therefore\frac{1}{2}\sec^{2}{\frac{x}{2}}dx=dt$$ $$\Rightarrow dx=\frac{2dt}{1+t^{2}}$$ Now, $$\sin x=\frac{2\tan{\frac{x}{2}}}{1+\tan^{2}\frac{x}{2}}=\frac{2t}{1+t^{2}}$$ and $$\cos x=\frac{1-\tan^{2}\frac{x}{2}}{1+\tan^{2}\frac{x}{2}}=\frac{1-t^{2}}{1+t^{2}}.$$ Therefore our integral becomes, $$\int \frac{\frac{2dt}{1+t^{2}}}{1+\frac{6t}{1+t^{2}}+\frac{1-t^{2}}{1+t^{2}}}$$ Thus $$\int \frac{2dt}{1+t^{2}+6t+1-t^{2}}$$ $$\Rightarrow \int\frac{2dt}{2+6t}=\frac{1}{3}\int\frac{dt}{\frac{1}{3}+t}=\frac{1}{3}\log |t+\frac{1}{3}|+C=\frac{1}{3}\log|\tan\frac{x}{2}+\frac{1}{3}|+C.$$

• Our answers are the same, but the form of yours is much simpler! (+1) – robjohn Jun 7 '12 at 13:22

The Weierstrass substitution used by DonAntonio and Kns is absolutely the right approach. However, we can pull a special trick out of the hat.

Note that $\cos x=2\cos^2(x/2)-1$, and $\sin x=2\sin(x/2)\cos(x/2)$. So we are trying to find $$\int\frac{dx}{6\sin(x/2)\cos(x/2)+2\cos^2(x/2)}.$$ Pleasantly, the constant term at the bottom disappeared! To save typing, let $x/2=y$. Then $dx=2\,dy$ and we want $$\int\frac{dy}{3\sin y\cos y+\cos^2y}.$$

Divide top and bottom by $\cos^2 y$. On top we get $\sec^2 y$. At the bottom we get $3\tan y+1$. So we want $$\int \frac{\sec^2 y}{3\tan y+1}\,dy.$$ Now we have the obvious substitution $u=3\tan y+1$. Thus $du=3\sec^2 y\,dy$, and our integral becomes $$\int \frac{du}{3u}.$$

Trigonometric substitution:$$u=\tan\frac{x}{2}\Longrightarrow du=\frac{1}{2}\frac{1}{\cos^2x}\,\,,\,\,\sin x=\frac{2u}{1+u^2}\,\,,\,\cos x=\frac{1-u^2}{1+u^2}$$and your integral becomes $$\int 2du\frac{(1-u^2)^2}{(1+u^2)^2}\frac{1}{1+3\frac{2u}{1+u^2}+\frac{1-u^2}{1+u^2}}$$This looks ugly (it indeed is ugly), but play around a little with it algebraically and it is a rational function's integral.

Let $y=x+\arctan(1/3)$, then because $\sin(x+\arctan(1/3))=\frac{3}{\sqrt{10}}\sin(x)+\frac{1}{\sqrt{10}}\cos(x)$ $$\int\frac{\mathrm{d}x}{1+3\sin(x)+\cos(x)}=\int\frac{\mathrm{d}y}{1+\sqrt{10}\sin(y)}\tag{1}$$ The standard substitution $z=\tan(y/2)$ yields $\sin(y)=\dfrac{2z}{1+z^2}$ and $\mathrm{d}y=\dfrac{2\mathrm{d}z}{1+z^2}$. Therefore, \begin{align} \int\frac{\mathrm{d}y}{1+\sqrt{10}\sin(y)} &=\int\frac{2\mathrm{d}z}{1+z^2+2\sqrt{10}\,z}\\ &=\int\frac{2\mathrm{d}z}{(z+\sqrt{10})^2-9}\\ &=\frac13\int\frac{\mathrm{d}z}{z+\sqrt{10}-3}-\frac13\int\frac{\mathrm{d}z}{z+\sqrt{10}+3}\\ &=\frac13\log\left(\frac{z+\sqrt{10}-3}{z+\sqrt{10}+3}\right)+C\tag{2} \end{align} Putting $(1)$ and $(2)$ together and reversing the substitutions, we get $$\int\frac{\mathrm{d}x}{1+3\sin(x)+\cos(x)}=\frac13\log\left(\frac{\tan(x/2+\arctan(1/3)/2)+\sqrt{10}-3}{\tan(x/2+\arctan(1/3)/2)+\sqrt{10}+3}\right)+C\tag{3}$$