Computing $\int_{|z|=2} {dz \over z^2 + 1}$ Goal: To compute
$$
\int_{|z|=2} {dz \over z^2 + 1}
$$
by decomposition of the integrand in partial fractions.
Attempt:


*

*Let $\gamma$ be the circle around the origin of radius $2$.  Let us parameterize $\gamma$ as 
$$
\gamma(t) = 2e^{t i} \text{ s.t. } 0 \le t \le 2 \pi
$$
so that we immediately have
$$
\gamma'(t) = 2i e^{{it}}
$$

*We have that
$$
z^2 + 1 = (z-i)(z+i)
$$

*Using this fact, we can decompose ${1 \over z^2 + i}$ as
$$
{1 \over z^2 + 1} = \left({0.5 \over z^2 - iz}\right) + \left({0.5 \over (z^2+iz)}\right)
$$
Question: This decomposition looks very ugly, so I'm not sure that this is the best way to go about it.  Is there a better way to tackle this problem?
 A: Let's try that decomposition again.  In particular, we can find $A,B$ such that
$$
\frac{1}{z^2+1} = \frac A{z-i} + \frac B{z+i} \implies\\
1 = A(z+i) + B(z-i)
$$
There are different ways to solve form this point.  I like to solve by plugging in the roots of the denominator for $z$.
$$
1 = A(-i + i) + B(-i -i) \implies 1 = -2Bi\\
1 = A(i + i) + B(i -i) \implies 1 = 2Ai
$$
So we have
$$
\frac{1}{z^2 + 1} = \frac{1}{2i}\left( \frac{1}{z-i} - \frac{1}{z+i} \right)
$$
A: You don't really need to do any partial fraction decomposition. 
The integrand $\frac{1}{z^2+1}$ has two poles at $\pm i$, both of them are inside the contour $|z| = 2$. Since the integrand is analytic on the rest of complex plane, one can evaluate it by deforming the contour to a large circle of radius $R$. We have following estimate:
$$\left|\oint_{|z| = 2} \frac{dz}{z^2+1}\right|
= \left|\oint_{|z| = R} \frac{dz}{z^2+1}\right|
\le \oint_{|z| = R} \left|\frac{dz}{z^2+1}\right|
\le \frac{2\pi R}{R^2-1}$$
Since $R$ can be arbitrary large, we can take the limit $R \to \infty$ and conclude
$$\oint_{|z|=2}\frac{dz}{z^2+1} = 0.$$
Update
If you really want to do partial fraction decomposition of $\frac{p(x)}{q(x)}$ where $p(x)$, $q(x)$ are polynomials with $\deg p(x) < \deg q(x)$. In the special case
where all the roots of $q(x)$ are simple, there is a simple way to figure out the coefficients. Let's say
$$q(x) = q_0 (x-\lambda_1)(x-\lambda_2)\cdots(x-\lambda_n)$$
with $\lambda_i$ all distinct. We know $\frac{p(x)}{q(x)}$ can be decomposed into
the form:
$$\frac{p(x)}{q(x)} = \sum_{i=1}^n \frac{\mu_i}{x-\lambda_i}$$
If you multiply both sides by $x-\lambda_j$ for a specific $j$ and take the limit $x \to \lambda_j$, you will obtain
$$\mu_j = \lim_{x\to\lambda_j} \frac{p(x)}{\frac{q(x)-q(\lambda_j)}{x-\lambda_j}} = \frac{p(\lambda_j)}{q'(\lambda_j)}
$$
As a result, one find in such special cases
$$\frac{p(x)}{q(x)} = \sum_{i=1}^n \frac{p(\lambda_i)}{q'(\lambda_i)(x-\lambda_i)}$$
Apply this to $\frac{1}{z^2+1}$, one obtain
$$\frac{1}{z^2+1} = \frac{1}{(2i)(z-i)} + \frac{1}{(2(-i))(z-(-i))}
= \frac{1}{2i}\left(\frac{1}{z-i} - \frac{1}{z+i}\right)
$$
A: Calculating the residues, $i$ and $-i$ which are inside the contour. Both are simple poles... This should give that $\Sigma Res = 1/(2i) + 1/(-2i) = 0$. We verify this now.
Let $z = 2e^{it}$ and $dz = i z dt$, which gives $1/i\cdot \int_{[0,2\pi]} 1/(2z)\cdot \frac{i}{z+i} + \frac{-i}{z-i} = 1/2\cdot \int_{[0,2\pi]} \frac{1}{z^2+iz} - \frac{1}{z^2-iz} = i/2 \int_{[0,2\pi]} \frac{-i}{z} + \frac{i}{z+i} + \frac{i}{z} + \frac{-i}{z-i} = \int_{[0,2\pi]} 1/(4e^{it}+1) dt = 0.$
