How can we use Cauchy on a contour with repeated roots? So according to this question, we can essentially solve a contour integral without using integration, using Cauchy.
So this question is, how can we use the same method with repeated roots?  In other words, can we solve (without integration):
$$\int_C{\frac{z^4}{(z-1)^2(z+1)}}$$
...where C is a contour about the origin?
Originally, the method seems to be to get the integral and break it into pieces:
$$\int_C{\frac{z^4}{(z-1)^2(z+1)}}$$
$$=2 \pi i \left( \lim_{z \to -1}{\frac{z^4}{(z-1)^2}} + \lim_{z \to 1}{\frac{z^4}{(z+1)}} \right)$$
Where am I going wrong?
Please refer to the question linked above for details of the method.  It doesn't seem to give the correct answer.  By integration, it should give $4 \pi i$, but I get $3 \pi i / 2$.
 A: First you break the integrand up into three parts using partial fraction decomposition:
$$
\dfrac{z^4}{(z-1)^2(z+1)} = \dfrac{z^4}{4(z+1)} - \dfrac{z^4}{4(z-1)} + \dfrac{z^4}{2(z-1)^2}
$$
and so you can rewrite the integral as
$$
\int_C \dfrac{z^4}{4(z+1)}\,dz - \int_C \dfrac{z^4}{4(z-1)} \,dz + \int_C\dfrac{z^4}{2(z-1)^2} \,dz.
$$
The first two can be solved using Cauchy's theorem with the functions $f(z) = z^4/4$ evaluated at $z = -1$ and $1$ respectively, which actually turns out to give zero. For the last integral we can use the more generalized version:
$$
f'(a) = \dfrac{1}{2\pi i} \int_C \dfrac{f(z)}{(z-a)^2} \,dz.
$$
This says that the third integral is equal to 
$$
2\pi i f'(1)
$$
with $f(z) = z^4/2$, which gives you the answer you're looking for.
A: To get the residue at $z=1$, you have to take the derivative of the piece of the function analytic at $z=1$.  That is, the residue there is equal to
$$\left [ \frac{d}{dz} \frac{z^4}{z+1}\right]_{z=1} = \left [ \frac{3 z^4 + 4 z^3}{(z+1)^2}\right]_{z=1} = \frac{7}{4}$$
so the integral is
$$i 2 \pi \left ( \frac14 + \frac{7}{4}\right ) = i 4 \pi$$
To see why this is so, imagine a function $p(z)/q(z)$, where $q(z) \sim (z-z_0)^2$ near $z=z_0$ and $p(z)$ is analytic at $z=z_0$.  Then $p(z) = p(z_0)+p'(z_0) (z-z_0)$ near $z=z_0$, and the integral about the contour $C$ is
$$\oint_C dz \left ( \frac{p(z_0)}{(z-z_0)^2} + \frac{p'(z_0)}{z-z_0}\right)$$
Note that the first piece is z\integrates to zero, while the second piece is
$$i 2 \pi p'(z_0)$$
as was to be demonstrated.
