Formula for calculating residue at a simple pole. Suppose $f=P/Q$ is a rational function and suppose $f$ has a simple pole at $a$. Then a formula for calculating the residue of $f$ at $a$ is 
$$
\text{Res}(f(z),a)=\lim_{z\to a}(z-a)f(z)=\lim_{z\to a}\frac{P(z)}{\frac{Q(z)-Q(a)}{z-a}}=\frac{P(a)}{Q'(a)}.
$$
In the second equality, how does the $Q(z)-Q(a)$ appear? I only see that it would equal $\lim_{z\to a}\frac{P(z)}{\frac{Q(z)}{z-a}}$.

Since the pole at $\,a\,$ is simple we have that 
$$Q(z)=(z-a)H(z)\,\,,\,H(z)\,\,\text{a polynomial}\,\,,\,P(a)\cdot H(a)\neq 0\,$$
Thus, as polynomials are defined and differentiable everywhere:
$$Res_{z=a}(f)=\lim_{z\to a}\frac{P(z)}{H(z)}=\frac{P(a)}{H(a)}$$
and, of course, 
$$Q'(z)=H(z)+(z-a)H'(z)\xrightarrow [z\to a]{}H(a)$$
