# integration of rational function of sine and cosine

 $\displaystyle\int\!R(\sin{x},\,\cos{x})\,dx,$ (1)

where the integrand is a rational function of $\sin{x}$ and $\cos{x}$, changes via the Weierstrass substitution

 $\displaystyle\tan\frac{x}{2}\;=\;t$ (2)

to a form having an integrand that is a rational function of $t$.  Namely, since  $x=2\arctan{t}$,  we have

 $\displaystyle dx\;=\;2\cdot\frac{1}{1\!+\!t^{2}}\,dt,$ (3)

and we can substitute

 $\displaystyle\sin{x}\;=\;\frac{2t}{1\!+\!t^{2}},\quad\cos{x}\;=\;\frac{1\!-\!t% ^{2}}{1\!+\!t^{2}},$ (4)

getting

 $\int\!R(\sin{x},\,\cos{x})\,dx\;=\;2\int\!R\!\left(\frac{2t}{1\!+\!t^{2}},\,% \frac{1\!-\!t^{2}}{1\!+\!t^{2}}\right)\frac{dt}{1\!+\!t^{2}}.$

Proof of the formulae (4):  Using the double angle formulas of sine and cosine and then dividing the numerators and the denominators by  $\cos^{2}\frac{x}{2}$  we obtain

 $\sin{x}\;=\;\frac{2\sin\frac{x}{2}\cos\frac{x}{2}}{\sin^{2}\frac{x}{2}+\cos^{2% }\frac{x}{2}}\;=\;\frac{2\tan\frac{x}{2}}{1+\tan^{2}\frac{x}{2}}\;=\;\frac{2t}% {1+t^{2}},$
 $\cos{x}\;=\;\frac{\cos^{2}\frac{x}{2}-\sin^{2}\frac{x}{2}}{\sin^{2}\frac{x}{2}% +\cos^{2}\frac{x}{2}}\;=\;\frac{1-\tan^{2}\frac{x}{2}}{1+\tan^{2}\frac{x}{2}}% \;=\;\frac{1-t^{2}}{1+t^{2}}.$

Example.  The above formulae give from  $\displaystyle\int\frac{dx}{\sin{x}}$  the result

 $\int\frac{dx}{\sin{x}}\;=\;\int\frac{1\!+\!t^{2}}{2t}\cdot 2\cdot\frac{1}{1\!+% \!t^{2}}\;dt=\int\frac{dt}{t}\;=\;\ln|t|+C\;=\;\ln\left|\tan\frac{x}{2}\right|+C$

(which can also be expressed in the form $-\ln|\csc{x}+\cot{x}|+C$; see the goniometric formulas).

Note 1.  The substitution (2) is sometimes called the ‘‘universal trigonometric substitution’’ (http://planetmath.org/UniversalTrigonometricSubstitution).  In practice, it often gives rational functions that are too complicated.  In many cases, it is more profitable to use other substitutions:

• In the case  $\int\!R(\sin{x})\cos{x}\,dx$  the substitution  $\sin{x}=t$  is simpler.

• Similarly, in the case  $\int\!R(\cos{x})\sin{x}\,dx$  the substitution  $\cos{x}=t$  is simpler.

• If the integrand depends only on $\tan{x}$, the substitution  $\tan{x}=t$  is simpler.

• If the integrand is of the form  $R(\sin^{2}{x},\,\cos^{2}{x})$,  one can use the substitution  $\tan{x}=t$; then
$\displaystyle\cos^{2}{x}=\frac{1}{1+\tan^{2}{x}}=\frac{1}{1+t^{2}}$,   $\displaystyle\sin^{2}{x}=1-\cos^{2}{x}=\frac{t^{2}}{1+t^{2}}$,   $\displaystyle dx=\frac{dt}{1+t^{2}}.$

Example.  The integration of  $\displaystyle\int\!\frac{dx}{\cos^{4}{x}}\,dx$  is of the last case:

 $\int\!\frac{dx}{\cos^{4}{x}}\,dx=\int\!\frac{1}{(\cos^{2}{x})^{2}}\,dx=\int\!(% 1+t^{2})^{2}\cdot\frac{dt}{1+t^{2}}=\int\!(1+t^{2})\,dt=\frac{t^{3}}{3}+t+C=% \frac{1}{3}\tan^{3}{x}+\tan{x}+C.$

Example.  The integral$\displaystyle I=\int\!\frac{dx}{\cos^{3}{x}}\,dx=\int\!\sec^{3}{x}\,dx$  is a peculiar case in which one does not have to use the substitutions mentioned above, as integration by parts is a simpler method for evaluating this integral. Thus,

 $u=\sec{x}\;\Rightarrow\;du=\sec{x}\;\tan{x}\,dx;\qquad dv=\sec^{2}{x}\,dx\;% \Rightarrow\;v=\tan{x}.$

Therefore,

$\begin{array}[]{rl}I&\displaystyle=\int\!\sec^{3}{x}\,dx\\ &\displaystyle=\sec{x}\;\tan{x}-\int\!\sec{x}\;\tan^{2}{x}\,dx\\ &\displaystyle=\sec{x}\;\tan{x}-\int\!\sec{x}\;(\sec^{2}{x}-1)\,dx\\ &\displaystyle=\sec{x}\;\tan{x}-I+\int\!\sec{x}\,dx,\end{array}$

and consequently

 $\int\!\frac{dx}{\cos^{3}{x}}\,dx\;=\;\frac{1}{2}\big{(}\sec{x}\;\tan{x}\;+\ln% \;|\sec{x}+\tan{x}|\big{)}+C.$

Note 2.  There is also the ‘‘universal hyperbolic substitution’’ for integrating rational functions of hyperbolic sine and cosine:

 $\tanh\frac{x}{2}\;=\;t,\quad dx\;=\;\frac{2dt}{1\!-\!t^{2}},\quad\sinh{x}\;=\;% \frac{2t}{1\!-\!t^{2}},\quad\cosh{x}\;=\;\frac{1\!+\!t^{2}}{1\!-\!t^{2}}$

## References

• 1 Л. Д. Кдрячев: Математичецкии  анализ.  Издательство  ‘‘ВүсшаяШкола’’. Москва (1970).
 Title integration of rational function of sine and cosine Canonical name IntegrationOfRationalFunctionOfSineAndCosine Date of creation 2013-03-22 17:05:15 Last modified on 2013-03-22 17:05:15 Owner pahio (2872) Last modified by pahio (2872) Numerical id 29 Author pahio (2872) Entry type Topic Classification msc 26A36 Synonym universal trigonometric substitution Related topic GoniometricFormulae Related topic SubstitutionForIntegration Related topic WeierstrassSubstitutionFormulas Related topic EulersSubstitutionsForIntegration Related topic ErrorsCanCancelEachOtherOut Defines universal hyperboloc substitution