Converting the TeX source when the DOM is ready

This page contains some inline TeX expressions like <span class="tex">\int_{a}^b f(x) d x = F(b) - F(a)</span> (inline mode) or <div class="tex">\int_0^{\pi} 2 \cos(\theta) - 3 \sin(\theta) d\theta = \left[ 2 \sin(\theta) + 3 \cos(\theta) \right]_{\theta=0}^\pi = -6</div> (display mode) that are converted into MathML by TeXZilla when the DOM is ready.

Copyright

    Copyright (C) 2013 Frédéric Wang

    Permission is granted to copy, distribute and/or modify this document
    under the terms of the GNU Free Documentation License, Version 1.3
    or any later version published by the Free Software Foundation;
    with no Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts.
    A copy of the license is included in the section entitled "GNU
    Free Documentation License".

Basic Integration

Ideas

If F is a primitive of f then \int_{a}^b f(x) d x = F(b) - F(a), provided the integrand and integral have no singularities on the path of integration. As a consequence, we can use a table of derivatives:

FunctionDerivative
Linearity a f + b g a f' + b g'
Leibniz rule f g f' g + g f'
Reciprocal rule \frac{1}{f} -\frac{f'}{f^2}
Chain Rule f \circ g (f' \circ g) g'
Inverse function rule f^{-1} \frac{1}{f' \circ f^{-1}}
Elementary power rule x^n n x^{n-1}
Generalized power rule f^g = e^{g \ln(f)} f^g \left( f' \frac{g}{f} + g' \ln(f) \right)
Exponential \exp x \exp x
Logarithm \ln x \frac{1}{x}
Sine \sin x \cos x
Cosine \cos x -\sin x
Tangent \tan x \frac{1}{\cos^2 x} = 1+\tan^2 x

Examples

Using linearity and elementary power rule:

\int_0^{1} u^4 - 2u^3 + 5u^2 + 4 du = \left[ \frac{u^5}{5} - 2 \frac{u^4}{4} + 5 \frac{u^3}{3} + 4u \right]_{u=0}^1 = \frac{161}{30}

Using linearity and sine/cosine:

\int_0^{\pi} 2 \cos(\theta) - 3 \sin(\theta) d\theta = \left[ 2 \sin(\theta) + 3 \cos(\theta) \right]_{\theta=0}^\pi = -6

Using Leibniz rule, Chain rule and Exponential/Power:

\int_{0}^{2} 2x e^{-3x} - 3 x^2 e^{-3x} d x = \left[ x^2 e^{-3x} \right]_0^2 = \frac{4}{e^{12}}

Using the inverse function rule and tangent:

\int_{0}^{1} \frac{1}{1 + x^2} d x = \int_{0}^{1} \frac{1}{\tan'(\arctan(x))} d x = \left[ \arctan(x) \right]_0^1 = \frac{\pi}{4}

Using linearity, reciprocal rule and logarithm:

\int_{2}^{3} \frac{1}{v (\ln(v))^2} d v = - \int_{2}^{3} - \frac{\frac{1}{v}}{(\ln(v))^2} d v = - \left[ \frac{1}{\ln(v)} \right]_2^3 = \frac{1}{\ln 2} - \frac{1}{\ln 3}

Using the power rules and chain rule:

\int_{0}^1 \frac{3t^2}{(t^3+1)^5} d t = -\frac{1}{4} \int_0^1 (t^3+1)^{-4} \left( 3t^2 \frac{-4}{t^3+1} + 0 \right) d t = -\frac{1}{4} \left[ (t^3+1)^{-4} \right]_0^1 = \frac{15}{64}

Integration by Substitution

Idea

Do a substitution x = g(y) to simplify an integral. We have \frac{dx}{dy} = g'(y) and \int f(x) dx = \int f(g(y)) g'(y) dy: this is the chain rule!

Example 1

\int_{0}^1 x (x^2 - 1) dx

Let y = x^2 - 1, dy = 2 x dx then we get

\frac{1}{2} \int_{y=-1}^0 y dy = \left[\frac{y^2}{4}\right]_{y=-1}^0 = -\frac{1}{4}

We find the same result as

\int_{0}^1 x^3 - x dx = \left[ \frac{x^4}{4} - \frac{x^2}{2} \right]_{x=0}^1 = \frac{1}{4} - \frac{1}{2} = -\frac{1}{4}

Example 2

Consider

\int_2^3 6x^2 \cos(x^3 - 2) d x

Let y = x^3 - 2, dy = 3x^2 dx so

\int_{2}^{3} 6 x^2 \cos(x^3 - 2) d x = 2 \int_{y=6}^{25} \cos(y) d y = 2 [\sin(y)]_{y=6}^{25} = 2 \sin(25) - 2 \sin(6)

Example 3

Consider

\int_{v=1}^2 \frac{dv}{v^3 e^{\frac{1}{v^2}}}

Let u = -\frac{1}{v^2}, du = \frac{2}{v^3} dv:

\int_{v=1}^2 \frac{dv}{v^3 e^{\frac{1}{v^2}}} = \frac{1}{2} \int_{u=-1}^{-\frac{1}{4}} e^{u} du = \frac{1}{2} \left(\frac{1}{\sqrt[4]{e}} - \frac{1}{e}\right)

Example 4

Consider

\int_{-\sqrt{2}}^{-1} \frac{5t}{\sqrt{4 - t^2}} d t

Let t = 2 \sin \theta and so dt = 2 \cos \theta d \theta. We have

\int_{\frac{3\pi}{4}}^{\frac{7\pi}{6}} \frac{10 \sin \theta}{\sqrt{4 - 4\sin^2 {\theta}}} 2 \cos \theta d \theta = 10 \int_\frac{3\pi}{4}^{\frac{7\pi}{6}} \sin \theta \frac{\cos \theta}{\sqrt{\cos^2 \theta}} d \theta

We have -1 < \cos \theta < 0 on \left[\frac{3\pi}{4},\frac{7\pi}{6}\right] and so

\int_{-\sqrt{2}}^{-1} \frac{5t}{\sqrt{4 - t^2}} d t = -10 \int_\frac{3\pi}{4}^{\frac{7\pi}{6}} \sin \theta d \theta = 10 \left[\cos \theta\right]_\frac{3\pi}{4}^{\frac{7\pi}{6}} = 5 (\sqrt{2} - \sqrt{3})

Example 5

Consider

\int_{\frac{3}{2}}^{+\infty} \frac{dx}{2x^2 - 6x + 7}

We first write

2x^2 - 6x + 7 = 2\left(x^2 - 3x + \frac{7}{2}\right) = 2\left( \left(x - \frac{3}{2}\right)^2 + \frac{5}{4} \right) = \frac{5}{2} \left( \left(\frac{x - \frac{3}{2}}{\sqrt{\frac{5}{4}}}\right)^2 + 1 \right)

Now doing the substitution y = \frac{x - \frac{3}{2}}{\sqrt{\frac{5}{4}}}, dy = \frac{dx}{\sqrt{\frac{5}{4}}} we get

\int_0^{+\infty} \frac{\sqrt{\frac{5}{4}} dy}{\frac{5}{2}(y^2+1)} = \frac{1}{\sqrt{5}} \int_0^{+\infty} \frac{dy}{y^2+1}

But we have already met this integral in the basic methods:

\int_{\frac{3}{2}}^{+\infty} \frac{dx}{2x^2 - 6x + 7} = \frac{1}{\sqrt{5}} [\arctan y]_{y=0}^{\infty} = \frac{\pi}{2 \sqrt{5}}

Example 6

Consider

\int_{\frac{\pi}{6}}^{\frac{\pi}{3}} \tan\left(\frac{\theta}{2}\right) \frac{{(1 + \cos \theta)}^2}{\sin^3 \theta} d \theta

We do the substitution t = \tan\left(\frac{\theta}{2}\right). We have d \theta = \frac{2 dt}{1+t^2}, \cos \theta = \frac{1-t^2}{1+t^2} and \sin \theta = \frac{2t}{1+t^2}. Also, we have

\tan\left(\frac{\pi}{12}\right) = \frac{1-\cos\left(\frac{\pi}{6}\right)}{1-\sin\left(\frac{\pi}{6}\right)} = 2 - \sqrt{3}

and so

\int_{2 - \sqrt{3}}^{\frac{1}{\sqrt{3}}} t \frac{\left(\frac{2}{1+t^2}\right)^2}{\left( \frac{2t}{1+t^2}\right)^3} \frac{2 dt}{1+t^2} = \int_{2 - \sqrt{3}}^{\frac{1}{\sqrt{3}}} \frac{1}{t^2} dt = \left[ -\frac{1}{t} \right]_{2 - \sqrt{3}}^{\frac{1}{\sqrt{3}}} = \frac{1}{2-\sqrt{3}}-\sqrt{3}

and finally

\int_{\frac{\pi}{6}}^{\frac{\pi}{3}} \tan\left(\frac{\theta}{2}\right) \frac{{(1 + \cos \theta)}^2}{\sin^3 \theta} d \theta = 2

Integration by parts

Idea

Given a two function f, g we have

\int f g' = f g - \int f' g

this is Leibniz rule!

Example 1

Consider

\int_{0}^{+\infty} (x^2 + x + 1) e^{-3x} d x

We consider f(x) = x^2 + x + 1 and g(x) = \frac{e^{-3x}}{-3} that is f'(x) = 2x+1 and g'(x) = e^{-3x}. The integral can be written \int f g' dx and hence we get

\left[(x^2 + x + 1) \frac{e^{-3x}}{-3}\right]_{0}^{+\infty} - \int_{0}^{+\infty} (2x+1) \frac{e^{-3x}}{-3} d x = \frac{1}{3} + \frac{1}{3} \int_{0}^{+\infty} (2x+1) e^{-3x} d x

We now consider h(x) = 2x+1, h'(x)=2 the second integral can be written \int h g' dx and hence

\int_{0}^{+\infty} (2x+1) e^{-3x} d x = \left[(2x + 1) \frac{e^{-3x}}{-3}\right]_{0}^{+\infty} - \int_{0}^{+\infty} 2 \frac{e^{-3x}}{-3} d x = \frac{1}{3} + \frac{2}{3} \int_{0}^{+\infty} e^{-3x} d x

We now recognize g' in the last integral and so

\int_{0}^{+\infty} e^{-3x} d x = \left[ \frac{e^{-3x}}{-3}\right]_{0}^{+\infty} = \frac{1}{3}

Finally,

\int_{0}^{+\infty} (x^2 + x + 1) e^{-3x} d x = \frac{1}{3} + \frac{1}{3} \times \left( \frac{1}{3} + \frac{2}{3} \times \frac{1}{3} \right) = \frac{14}{27}

Example 2

\int_1^2 x^3 (2\ln x + 7\arctan x) d x

We let f(x) = 2\ln x + 7\arctan x and g(x) = \frac{x^3}{3}. Hence f'(x) = \frac{2}{x} + \frac{7}{1+x^2} and g'(x) = x^3. The integration by parts gives:

\left[\frac{x^3}{3} \left(2\ln x + 7\arctan x\right) \right]_1^2 - \int_1^2 \frac{x^3}{3} \left(\frac{2}{x} + \frac{7}{1+x^2}\right) d x

The integral can be written

\int_1^2 \frac{2}{3} x^2 + \frac{7}{3} \frac{x(x^2+1) - x}{x^2+1} dx = \int_2^2 \frac{2}{3} x^2 + \frac{7}{3} x - \frac{7}{6} \frac{2x}{x^2+1} dx

Finally

\int_1^2 x^3 (2\ln x + 7\arctan x) d x = \left[\frac{x^3}{3} \left(2\ln x + 7\arctan x\right) - \frac{2}{9} x^3 -\frac{7}{6} x^2 + \frac{7}{6} \ln (x^2 + 1) \right]_1^2 = \frac{28}{9} \ln(5) + \frac{89}{18} \ln(2) + \frac{56}{3} \arctan(2) - \frac{7 \pi}{12} - \frac{301}{18}

Example 3

Consider

I =\int_{0}^{\frac{\pi}{2}} \sin(3 \theta) e^{2 \theta} d \theta

We do an integration by parts with f(\theta) = \sin(3 \theta) and g'(\theta) = e^{2 \theta}:

I = \left[\sin(3 \theta) \frac{e^{2 \theta}}{2}\right]_{0}^{\frac{\pi}{2}} - \frac{3}{2} \int_{0}^{\frac{\pi}{2}} \cos(3 \theta) e^{2 \theta} d \theta

We repeat a similar integration by parts on the remaining integral:

\int_{0}^{\frac{\pi}{2}} \cos(3 \theta) e^{2 \theta} d \theta = \left[\cos(3 \theta) \frac{e^{2 \theta}}{2}\right]_{0}^{\frac{\pi}{2}} + \frac{3}{2} \int_{0}^{\frac{\pi}{2}} \sin(3 \theta) e^{2 \theta} d \theta

We note that we found the initial integral I. We get:

I = \left[\sin(3 \theta) \frac{e^{2 \theta}}{2} -\frac{3}{4} \cos(3 \theta) e^{2 \theta} \right]_{0}^{\frac{\pi}{2}} - \frac{9}{4} I

Finally,

I =\int_{0}^{\frac{\pi}{2}} \sin(3 \theta) e^{2 \theta} d \theta = \frac{4}{13} \left[\left(\frac{1}{2} \sin(3 \theta) -\frac{3}{4} \cos(3 \theta)\right) e^{2 \theta} \right]_{0}^{\frac{\pi}{2}} = \frac{3 - 2 e^\pi}{13}

Integration by Partial Fraction Decomposition

Idea

Given a rational function \frac{P}{Q}, write its partial fraction decomposition and integrate each term.

Example 1

\int_{x=2}^{3} \frac{2x^4-6x^3+41x^2-44x+12}{6x^5-18x^4+18x^3-6x^2} d x

Clearly, we have 6x^5-18x^4+18x^3-6x^2 = 6 x^2 (x^3-3x^2+3x-1) and 1 is a trivial root of the second factor so we can factor it by (x-1) and obtain:

6x^5-18x^4+18x^3-6x^2 = 6 x^2 (x-1) (x^2-2x+1) = 6x^2 (x-1)^3

Hence we search a decomposition of

F(x) = \frac{2x^4-6x^3+41x^2-44x+12}{6 x^2 (x^3-3x^2+3x-1)} = \frac{A}{x} + \frac{B}{x^2} + \frac{C}{x-1} + \frac{D}{(x-1)^2} + \frac{E}{(x-1)^3}

for some constants A, B, C, D, E \in \mathbb{R}. We have

\lim_{x \rightarrow 1} (x - 1)^3 F(x) = E = \frac{2 - 6 + 41 - 44 + 12}{6} = \frac{5}{6}
\lim_{x \rightarrow 0} x^2 F(x) = B = \frac{12}{-6} = -2
\lim_{x \rightarrow 0} (x^2 F(x))' = A = \frac{-44 \times -1 - 12 \times 3}{6} = \frac{4}{3}
\lim_{x \rightarrow +\infty} x F(x) = A + C = \frac{2}{6} \rightarrow C = \frac{2}{6} - \frac{4}{3} = -1
F(2) = \frac{A}{2} + \frac{B}{4} + C + D + E = \frac{2\times16 - 6\times8+41\times4-44\times2+12}{6 \times 4} = 3 \rightarrow D = 3 - \frac{2}{3} + \frac{1}{2} + 1 - \frac{5}{6} = 3

Finally,

\int_{x=2}^{3} F(x) d x = \left[ \frac{4}{3} \ln |x| + \frac{2}{x} - \ln |x - 1| - \frac{3}{x-1} - \frac{5}{12} \frac{1}{(x-1)^2} \right]_{x=2}^3 = \frac{4}{3} \ln(3) - \frac{7}{3} \ln(2) + \frac{71}{48}

Example 2

\int_{u=1}^{5} \frac{2u^4-5u^3+24u^2-26u+50}{u^5-4u^4+14u^3-20u^2+25u} d u

The denominator can be written u^5-4u^4+14u^3-20u^2+25u = u(u^4-4u^3+14u^2-20u+25). Evaluating the second factor at 0, \pm1, \pm2 we don't find any trivial roots. Hence we try to convert it to a depressed quartic by setting u = v - \frac{-4}{4} = v + 1. We find (u^4-4u^3+14u^2-20u+25) = v^4 + 8v^2 + 16 = (v^2 + 4)^2 = (u^2-2u+5)^2. The discriminant of u^2-2u+5 is 4(1-5) < 0 so we have the decomposition in irreducible factors:

u^5-4u^4+14u^3-20u^2+25u = u (u^2-2u+5)^2

We now try to find A, B, C, D, E \in \mathbb{R} such that

F(u) = \frac{2u^4-5u^3+24u^2-27u+50}{u (u^2-2u+5)^2} = \frac{A}{u} + \frac{Bu+C}{u^2-2u+5} + \frac{Du+E}{(u^2-2u+5)^2}
\lim_{u \rightarrow 0} uF(u) = A = \frac{50}{3 \times 25} = 2
\lim_{u \rightarrow +\infty} uF(u) = A + B = 2 \rightarrow B = 0
\lim_{u \rightarrow +\infty} u^2\left(F(u) - \frac{A}{u}\right) = C = \lim_{u \rightarrow +\infty} u^2 \frac{2 u^4 - 5u^3 - 2(u^4-4u^3)}{u \times u^4} = 3
F(1) = \frac{11}{4} = 2 + \frac{3}{4} + \frac{D+E}{16} \rightarrow D+E = 44 - 32 - 12 = 0
F(2) = \frac{42}{25} = 1 + \frac{3}{5} + \frac{2D+E}{25} \rightarrow 2D + E = 42 - 25 - 15 = 2

From the two last equalities, we immediately get D = 2 and E = -2. Finally,

F(u) = \frac{2}{u} + \frac{3}{u^2-2u+5} + \frac{2u - 2}{(u^2-2u+5)^2}

We have

\int_{u=1}^{5} \frac{2}{u} d u= \left[ 2 \ln|u| \right]_{u=1}^5 = 2 \ln(5)
\int_{u=1}^{5} \frac{3}{u^2-2u+5} d u= \frac{3}{4} \int_{u=1}^{5} \frac{d u}{(\frac{u-1}{2})^2+1} = \frac{3}{2} \int_{v=0}^{2} \frac{d v}{v^2+1} = \frac{3}{2} \arctan(2)
\int_{u=1}^{5} \frac{2u - 2}{(u^2-2u+5)^2} d u = \left[ - \frac{1}{u^2-2u+5} \right]_{u=1}^5 = \frac{1}{5}

hence

\int_{u=1}^5 F(u) d u = 2 \ln(5) + \frac{3}{2} \arctan(2) + \frac{1}{5}

Example 3

\int_{t=2}^{17} \frac{t^6-2t^5-3t^4+15t^3+4t^2-17}{t^4+2t^3-t-2} d t

By polynomial long division we find that

X^6-2x^5-3X^4+15X^3+4X^2-17 = (X^2-4X+5)(X^4+2X^3-X-2)+6X^3+2X^2-3X-7

and so

\frac{t^6-2t^5-3t^4+15t^3+4t^2-17}{t^4+2t^3-t-2} = t^2-4t+5+\frac{6t^3+2t^2-3t-7}{t^4+2t^3-t-2}

The integral of the first term is:

\int_{t=2}^{17} t^2-4t+5 d t = {\left[\frac{t^3}{3} - 2t^2 + 5t\right]}_{t=2}^{17} = 1140

First we search trivial roots for the denominator. If we evaluate t^4+2t^3-t-2 at t=0,-1,1,-2,2 we find respectively -2, -2, 0, 0, 28. So we can factor X^4+2X^4-X-2 by (X - 1)(X + 2). We get

X^4+2X^3-X-2 = (X - 1)(X + 2)(X^2+X+1)

The polynomial X^2+X+1 is irreducible on \mathbb{R} because its discrimant is 1 - 4 = -3 < 0. Hence we search a decomposition of

F(t) = \frac{6t^3+2t^2-3t-7}{(t - 1)(t + 2)(t^2+t+1)} = \frac{A}{t - 1} + \frac{B}{t + 2} + \frac{C t + D}{t^2+t+1}

for some constants A, B, C, D \in \mathbb{R}. We have

\lim_{t \rightarrow 1} (t - 1)F(t) = A = \frac{6+2-3-7}{3 \times 3} = - \frac{2}{9}
\lim_{t \rightarrow -2} (t + 2)F(t) = B = \frac{6\times-8+2\times4+3\times2-7}{-3 \times (4-2+1)} = \frac{41}{9}
\lim_{t \rightarrow +\infty} t F(t) = A + B + C = 6 \rightarrow C = 6 + \frac{2}{9} - \frac{41}{9} = \frac{5}{3}
F(0) = -A + \frac{B}{2} + D = \frac{-7}{-1 \times 2 \times 1} \rightarrow D = \frac{7}{2} -\frac{2}{9} - \frac{41}{18} = 1

So

F(t) = -\frac{2}{9(t - 1)} + \frac{41}{9(t + 2)} + \frac{\frac{5}{3} t + 1}{t^2+t+1}

The integral of the two first terms is easy to compute:

\int_{t=2}^{17} -\frac{2}{9(t - 1)} + \frac{41}{9(t + 2)} d t = -\frac{2}{9} \left[\ln|t-1|\right]_{2}^{17} + \frac{41}{9} \left[\ln|t+2|\right]_{2}^{17} = -\frac{2}{9} \ln(16) + \frac{41}{9} \ln(19) - \frac{41}{9} \ln(4)

The last term can be split into two parts:

\frac{\frac{5}{3} t + 1}{t^2+t+1} = \frac{5}{6} \frac{2t+1}{t^2+t+1} + \frac{1}{6} \times \frac{4}{3} \frac{1}{\left( \frac{t+\frac{1}{2}}{\sqrt{\frac{3}{4}}} \right)^2 + 1}

We have

\int_{t=2}^{17} \frac{5}{6} \frac{2t}{t^2+t+1} d t = \frac{5}{6} \left[ \ln |t^2 + t + 1| \right]_{t=2}^{17} = \frac{5}{6} \ln(307) - \frac{5}{6} \log(7)

and

\int_{t=2}^{17} \frac{2}{9} \frac{d t}{\left( \frac{t+\frac{1}{2}}{\sqrt{\frac{3}{4}}} \right)^2 + 1} = \frac{2}{9} \int_{u=\frac{5}{\sqrt{3}}}^{\frac{35}{\sqrt{3}}} \frac{\sqrt{\frac{3}{4}} d u}{u^2 + 1} = \frac{1}{3 \sqrt{3}} \left[ \arctan u \right]_{u=\frac{5}{\sqrt{3}}}^{\frac{35}{\sqrt{3}}}

Finally we get

\int_{t=2}^{17} \frac{t^6-2t^5-3t^4+15t^3+4t^2-17}{t^4+2t^3-t-2} d t = 1140 -\frac{2}{9} \ln(16) + \frac{41}{9} \ln(19) - \frac{41}{9} \ln(4) + \frac{5}{6} \ln(307) - \frac{5}{6} \log(7) + \frac{1}{3 \sqrt{3}} \arctan\left(\frac{35}{\sqrt{3}}\right) - \frac{1}{3 \sqrt{3}} \arctan\left(\frac{5}{\sqrt{3}}\right)

Alternatively, we can write

G(t) = \frac{\frac{5}{3} t + 1}{t^2+t+1} = \frac{E}{t - t^+} + \frac{F}{t - t^-}

where t^\pm = \frac{-1\pm i \sqrt{3}}{2} are the complex roots of t^2+t+1. We have

\lim_{t \rightarrow t^+} (t-t^+) G(t) = E = \frac{5\sqrt{3}+i}{6 \sqrt{3}}
\lim_{t \rightarrow t^-} (t-t^-) G(t) = F = \frac{5\sqrt{3}-i}{6 \sqrt{3}}

We have

\int_{2}^{17} G(t) d t = \left[ E \left( \ln |t - t^+| + i \arctan \frac{t - \Re(t^+)}{\Im(t^+)} \right) + F \left( \ln |t - t^-| + i \arctan \frac{t - \Re(t^-)}{\Im(t^-)} \right) \right]_{2}^{17}

After simplification, we get

\int_{2}^{17} G(t) d t = \frac{5}{6} \ln(307) - \frac{5}{6} \log(7) + \frac{1}{3 \sqrt{3}} \arctan\left(\frac{35}{\sqrt{3}}\right) - \frac{1}{3 \sqrt{3}} \arctan\left(\frac{5}{\sqrt{3}}\right)

as we already found above.

Contour Integration

Idea

Consider contour integral \oint_\gamma f(z) d z along paths in complex plane to deduce integral along the real line.

Example 1

Consider the integral

\int_{0}^{2 \pi} \frac{6 \cos(2 \theta)}{4 \sin(\theta) - 5} d\theta

Write z = e^{i \theta}, d z = i z d \theta. The integral becomes

\oint_{\gamma} \frac{3 (z^2 + z^{-2})}{-2 i (z - z^{-1}) - 5} \frac{d z}{i z} = \oint_{\gamma} \frac{3(z^4+1)}{2 z^2 (z - 2 i)\left(z - \frac{i}{2}\right)} d z

where \gamma is the unit circle traversed counterclockwise. f : z \mapsto \frac{3(z^4+1)}{2 z^2 (z - 2 i)\left(z - \frac{i}{2}\right)} has two singularities inside that circle: 0 and \frac{i}{2}. Hence the integral is the 2 \pi i times the sum of the residues of f at these points:

\mathrm{Res}(f, 0) = \lim_{z \rightarrow 0} \frac{d \left( z^2 f(z) \right)}{dz} = \frac{15 i}{4}
\mathrm{Res}(f, \frac{i}{2}) = \lim_{z \rightarrow 0} \left( z - \frac{i}{2} \right) f(z) = -\frac{17 i}{4}

Hence

\int_{0}^{2 \pi} \frac{6 \cos(2 \theta)}{4 \sin(\theta) - 5} d\theta = \oint_{\gamma} f(z) d z = 2 \pi i \left( \frac{15 i}{4} -\frac{17 i}{4} \right) = \pi

Example 2

We want to know the value of the integral

\int_{-\infty}^{+\infty} \frac{16 \sin(2x+\pi)}{5(x^2+2x+5)^2} dx

For that purpose, we introduce the function

f(z) = \frac{16 e^{-2\pi z}}{5(z^2+2z+5)^2}

We note that x \mapsto \Im(f(x)) is the integrand above. We also note that the poles of f are z^\pm = -1 \pm 2 i. By choosing the right contour, one can show that

\int_{-\infty}^{+\infty} f(x) dx = -2 i \pi \sum_{\stackrel{z \text{residue}}{\Im(z) < 0}} \mathrm{Res}(f, z)

We have

\mathrm{Res}(f, z^-) = \lim_{z \rightarrow z⁻} \frac{d \left( (z - z^-)^2 f(z) \right)}{dz} = \frac{i e^{2 i}}{2 e^4}

Hence

\int_{-\infty}^{+\infty} \frac{16 \sin(2x+\pi)}{5(x^2+2x+5)^2} dx = \Im\left(\int_{-\infty}^{+\infty} f(x) dx\right) = \Im\left(-2 i \pi \frac{i e^{2 i}}{2 e^4}\right) = \Im\left(\frac{\pi e^{2 i}}{e^4}\right)

Finally

\int_{-\infty}^{+\infty} \frac{16 \sin(2x+\pi)}{5(x^2+2x+5)^2} dx = \frac{\pi \sin(2)}{e^4}