How to know the contour of any function for the Cauchy integral formula When any one solves an integral using the Cauchy integral formula, it depends on the contour of the function.
So my question is: 
How to know the contour of any function?
For example: 
$$f(z)=\frac {\ e^{itz}} {z^2+1}$$
 
Example 2:$$f(z)=\frac {\sinh(az)} {e^{bz}-1} $$
 
 A: It depends on the integral you want to solve, there isn't a general method to choose. However there are some typical examples. Often you will have to integrate on rectangles, circles, half-circles (as in your first example), double circles (one circle oriented in positive direction, one in negative direction contained in the first one) and similar stuff. The important things to remember are:


*

*You don't want any singularities on the path on which you're integrating.

*You want to get the integral you were set to solve somehow, so you will have to set your path of integration such that you can eliminate the parts you don't want (by explicit computation of by passing to the limit, usually).

*You want to get a contour on which it is easy to integrate.


Also note that sometimes you will have to change slightly the function you're integrating to get your result.
A: Just for refernce, here's the formal theorem:

Let $f$ be analytic everywhere on and within a positively oriented simple closed contour $C$. For any point $z_0$ interior to $C$:
  $$
f(z_0) = \frac{1}{2\pi i}\int_C\frac{f(z)}{z-z_0}dz.
$$

By rearranging,  you can see that the integral can be evaluating simply by finding the value of the function at a certain point:
$$
\int_C\frac{f(z)}{z-z_0}dz = 2\pi if(z_0)
$$
From here, the $z_0$ and $f(z)$ required may not be easily visible, so you may need to manipulate the function (split the function into a product, algebraic manipulation, etc.) to see them.
For example, assume $C : |z-2i|=4$ and
$$
\int_C\frac{z}{z^2+9}dz = \int_C\frac{z}{(z+3i)(z-3i)}dz = \int_C\frac{z}{(z+3i)}\frac{1}{(z-3i)}dz
$$
$z_0$ must be $3i$ because it lies within $C$ (a requirement of the theorem), so $(z-z_0) = (z-3i)$, which implies 
$$
f(z)=\frac{z}{(z+3i)}
$$
