I was tasked to calculate the series expansion of$$f(z)=\frac{z+1}{(1-z)^2(z+2)}$$ around $z_0=0$. And I should do it with Cauchy's formula by using a circle of radius $R$ and then take $R\rightarrow \infty$.
What I did:
I know that the Taylor expansion is $\sum_{n=0}^{\infty} \frac{f^{(n)}(a)}{n!}(x-a)^n$. So what I need to find is $f^{(n)}(0)$, right? I used Cauchy integral formula and computed:
$f^{(n)}(0)=\frac{n!}{2\pi i} \oint_C \frac{f(z)}{z^{n+1}} dz =\frac{n!}{2\pi i} \int_0^{2\pi} \frac{z+1}{(1-z)^2(z+2)z^{n+1}} dz$.
Here I tried to calculate the integral by using residue theorem. I get... $$n!\cdot (\lim_{z\rightarrow 1} \frac{z+1}{(z+2)z^{n+1}} + \lim_{z\rightarrow -2} \frac{z+1}{(1-z)^2z^{n+1}} + \lim_{z\rightarrow 0} \frac{1}{n!}(\frac{d}{dz})^n\frac{z+1}{(1-z)^2(z+2)}) $$
However, when I plug in values for $n$ I always get $0$.
The expansion should be $$1/2 + (5 z)/4 + (15 z^2)/8 + (41 z^3)/16 + (103 z^4)/32 + ...$$
So I noticed that
$$-(\lim_{z\rightarrow 1} \frac{z+1}{(z+2)z^{n+1}} + \lim_{z\rightarrow -2} \frac{z+1}{(1-z)^2z^{n+1}}) \textbf{ is equal to } \lim_{z\rightarrow 0} \frac{1}{n!}(\frac{d}{dz})^n\frac{z+1}{(1-z)^2(z+2)})$$
But why? They both compute the right coefficient for $f^{(n)}$, but since they're adding up to $0$, I must have done something wrong.
Ideally, I could use the simpler of them both, namely
$$n!\cdot (\lim_{z\rightarrow 1} \frac{z+1}{(z+2)z^{n+1}} + \lim_{z\rightarrow -2} \frac{z+1}{(1-z)^2z^{n+1}})$$ to compute the coefficient. But I need to know why I can only use this and why is has the wrong sign.
It is easier to do the following trick which relies on the geometric series:
We can write $$f(z)=\frac{1}{(1-z)^2}-\frac{1}{(1-z)^2(2+z)}.$$ My aim is to expand both $\frac{1}{(1-z)^2}$ and $\frac{1}{2+z}$ around $0$.
Firstly, notice that $$\left(\frac{1}{1-z}\right)'=\frac{1}{(1-z)^2}.$$ Therefore, we expand $\frac{1}{1-z}$ as a geometric series and use the fact that you can swap derivation and infinite summation for power series. So $$\frac{1}{(1-z)^2}=1+2z+3z^2+\cdots$$ On the other hand, $$\frac{1}{2+z}=\frac{1}{2}\frac{1}{1-(-z/2)}.$$ This yields the following geometric series $$\frac{1}{2}\left(1-\frac{z}{2}+\frac{z^2}{4}-\cdots\right).$$ Now, to get the expansion of $f$ \begin{align*}\frac{1}{(1-z)^2(2+z)}=\frac{1}{2}\left(1+2z+3z^2+\cdots\right)\left(1-\frac{z}{2}+\frac{z^2}{4}-\cdots\right).\end{align*} Can you follow from here?