Complex contour integral and partial fractions

I'm doing complex integration and I'm trying to evaluate:

$$\int_C \frac{\cos{z}}{z^2 + 1} dz$$

Where $C$ is the clockwise boundary of a parallelogram with vertices $3i$, $2$, $-3i$, $-2$ (i.e. a diamond centered on $0$). I've found that the poles of the function are at $i$ and $-i$ since $\cos{z}$ is holomorphic everywhere, and so I used partial fractions to split the integrand as follows:

$$\frac{\cos{z}}{z^2 + 1} = \frac{\frac{i}{2} \cos{z}}{z + i} - \frac{\frac{i}{2} \cos{z}}{z - i}$$

And then I integrated each separately, using Cauchy's integral theorem, which I argued is applicable since each integrand is now of the form $f(z) / (z - z_0)$ with $z_0 = \pm i$, with each pole (and the contour) being inside the parallelogram and $f$ holomorphic everywhere. Using the theorem I found that both integrals were equal to $\pi \cosh{1}$. So the two cancel out and I concluded that:

$$\int_{\gamma} \frac{\cos{z}}{z^2 + 1} dz = 0$$

Is this correct? Also, is there some kind of easy way to check if a contour integral result makes sense, perhaps some intuitive interpretation of them, or a systematic way to reduce them to a real-valued integral that could be fed to a computer? I'm having issues saying "ok I got this one" and moving on because I can't check my work at all on my own, so this would really help. Thanks!

Is this correct?

Yes, that's completely correct. The result and the way to obtain the result.

For this integral, you can see that the value is $0$ also by symmetry. The integrand is an even function, and the contour is symmetric about the origin, so at any two parts of the contour obtained from each other by reflection in the origin/rotation by $\pi$, the function values are the same, and the differential $dz$ differs only by a factor $-1$, whence they cancel.

Borrowing from the future, for an even (holomorphic) function $f$, the residues are related by

$$\operatorname{Res}\left(f, -\zeta\right) = - \operatorname{Res}\left( f,\zeta\right),$$

so the residues in points symmetric with respect to the origin cancel. For and odd (holomorphic) function $g$, the relation is (as one may expect)

$$\operatorname{Res}\left(g,-\zeta\right) = \operatorname{Res}\left(g,\zeta\right).$$

These relations often simplify the evaluation of contour integrals.

• We haven't done the residue method yet (next week I think) and your comment on the integrand being an even function is very helpful, I think I understand it better now. Thanks! – Thomas May 27 '14 at 11:27