Choosing a contour to integrate over. What are the guidelines for choosing a contour?
For example to integrate a real function with a singularity somewhere.
What type of contour from
Square, keyhole, circle, etc should be chosen for integration? 
(1) In what cases would you choose square?
(2) In what cases would you choose a circle?
(3) In what cases would you choose a keyhole etc....?
In general, what are the guidelines?
Thanks!

Here are some brief general guidelines for the three contours you mentioned:


*

*The circular contour is used when we have an integral from $0$ to $2\pi$, with the integrand consisting of trigonometric functions, such as sin and cosine. Thinking about the polar coordinates, Euler's identity ($e^{ix}=\cos(x)+i\sin(x)$) and the circumference of a circle of radius $1$ (ie, $2\pi\times 1$), the unit circle is the most natural contour to use.  

*Using the square contour really depends on the nature of the poles and residues of your function. If $\cosh z$ is the denominator of the integrand, then this has infinitely many poles given by $z=i(\frac{\pi}{2}+n\pi)$ with $n$ an integer. Hence you choose the contour such that you enclose a finite, rather than an infinite number of poles. 

*We use the keyhole contour when we have branch cuts (an arbitrarily small circuit around a point in $\mathbb{C}$ across which an analytic and multivalued function is discontinuous). For example, take the integral
\begin{equation*}
\int^{\infty}_{x=0}\frac{x^{-s}}{x+1}dx,~0<s<1.
\end{equation*}
The numerator of the integrand can be written $e^{-s\ln x}$ which has a discontinuity at $x=0$. 
