Section 6.2, Question 1: By the identity sin theta = cos pi/2 - theta and the change of variables alpha = pi/2 - theta, the integral is equal to the integral of 1/(2 - cos alpha) from -3pi/2 to pi/2, which is the same as the integral from 0 to 2 pi, which is 2 pi/sqrt(3) by Example 2 of Section 6.2. (Yes, you could do it by residue calculus, and you should, but sometimes you can cheat too).

Question 4: We can use residue calculus immediately, but we can save some effort by noting that 1 + sin^2 theta = (1 + (1 - cos 2 theta)/2) = (3 - cos 2 theta)/2, and rewriting the integral as

int_{-pi}^{pi} 2 dtheta / (3 - cos 2theta) = int_{-2pi}^{2pi} 
dalpha / (3 - cos alpha).
Using the change of variables z = e^{i alpha} we get
 int_Gamma (dz/iz) / (3 - (z + 1/z)/2) = 2i int_Gamma dz/(z^2 - 6z + 1)
where Gamma is the unit circle traversed twice anticlockwise.
The intgrand has poles at 3+sqrt(8) and 3-sqrt(8); the pole at 3+sqrt(8)
is outside the contour and is therefore irrelevant.  At 3-sqrt(8) the
residue is -1/(2sqrt(8)), so the integral as a whole is -4pi i /(2 sqrt(8)),
(remember that the contour winds around the pole twice), so the final answer
is 2i (-4 pi i/(2 sqrt(8))) = pi sqrt(2).

Question 5: We make the usual change of variables z = e^{i theta} and rewrite the integral as

 int_Gamma (dz/iz) 1/(1 + a (z + 1/z)/2) = 2i int_Gamma dz / (az^2 + 2z
+ a).
This has simple poles at (-1 + sqrt(1-a^2))/a and (-1 - sqrt(1-a^2))/a. The latter pole is obviously outside the unit circle, since -1 -sqrt(1-a^2) is outside the circle and 1/a has magnitude > 1. The former pole is the reciprocal of the latter pole and is therefore inside the unit circle. The residue at this pole is -1/[2sqrt(1-a^2)], so the integral is -2pi i/[2 sqrt(1 - a^2)], and the final answer is 2i [-2pi i/[2 sqrt(1 - a^2)]] = 2 pi / sqrt(1 - a^2).

Section 6.3, Question 1. We compute the integral of dz/(z^2 + 2z + 2) from -R to R. We may add and subtract the contour C^R_+, the upper anticlockwise semicircular contour of radius R. When you add C^R_+, the contour becomes closed, and we can use residue theory to work out the integral; the poles are at i-1 and -i-1, and the residue at i-1 (which is the only one that we care about) is 1/(2i), so the integral is 2pi i/2i = pi. We still have the error term to deal with, which is negative the integral over C^R_+, but that goes to zero by Lemma 1 of Section 6.3. (You may quote this lemma in the final). So the final integral is pi.

Question 3: By symmetry we may replace the limits of integration with -R and R, and remember to halve the answer at the end. We use the method of upper semicircular contours as in Question 1. The integrand has simple poles at (+- 1 +- i)/sqrt(2) [remember the stuff from Section 1.5?] but we only care about the ones at (i-1)/sqrt(2) and (1+i)/sqrt(2). The residues at these places are both -i/2sqrt(2), so the integral on the closed contour is 2 pi i * 2 * (-i/2sqrt(2)) = 2pi/sqrt(2). The integral on the semi-circle goes to zero by the lemma, and so the integral from -infinity to infinity is 2pi/sqrt(2), which means that the original integral was pi/sqrt(2) as claimed.

Question 9. If you integrate the function exp(2z)/cosh(pi z) around the designated contour you get 2 pi i(exp(i)/ pi sinh(pi i/2)) = 2 exp(i), since the only singularity inside the rectangle is at i/2, and it is a simple pole with residue exp(i)/(pi sinh(pi i/2)). The integral on the rectangle can be broken up into four integrals on straight line contours. The one on the real axis (let's call it I) is the one that we want. The ones on either end of the rectangle go to zero; for instance, on the contour from rho to rho+i, exp(2z) has magnitude exp(2 rho), whereas cosh(pi z) = [exp(pi z) + exp(- pi z)]/2 has magnitude at least [exp(pi rho) - exp(- pi rho)]/2, so the integrand (and thus the integral) has magnitude at most

 2 exp(2 rho) / [exp(pi rho) - exp(- pi rho)],
which goes to zero as rho goes to infinity. Similarly for the left edge of the rectangle.

The integral on the upper edge is more interesting. We can write this integral as - int_gamma exp(2z)/cosh(pi z) dz, where gamma is the straight line contour from -rho + i to rho + i. However, we may change variables z = w + i and rewrite this expression as

 - int_{-rho}^rho exp(2(w+i))/cosh(pi (w+i)) dw,
which simplifies to
 + exp(2i) int_{-rho}^rho exp(2w)/cosh(pi w) dw = exp(2i) I,
since cosh(pi w + pi i) = - cosh(pi w). So in the limit as rho -> infinity we obtain
 I + 0 + exp(2i) I + 0 = 2 exp(i),
and if we solve for I we obtain
 I = 2 / (exp(i) + exp(-i)) = 1/cos(1) = sec(1).

Section 6.4, Question 3. The integrand is continuous on the real line, so there is no need to indent the contour. Because the phase is positive (3>0), we need to use an upper semicircular contour. The integrand exp(3 i z)/(z-2i) has a simple pole at 2i with residue exp(-6), so the integral on the usual closed contour in the upper half-plane is 2 pi i exp(-6). By Jordan's lemma the contribution of the upper semicircle goes to zero, and so the answer is just 2 pi i exp(-6).

Question 9. We have to break the cosine up into two complex exponentials. If there was no i in the expression, we would only have to deal with one of these exponentials and take the real part afterwards, but the presence of the i in the denominator means that this shortcut is not available. So we write the integral as

 1/2 int exp(2 i z)/(z-3i) dz + 1/2 int exp(-2iz)/(z-3i) dz.
For the first integral we have to take an upper semi-circular contour, and by the same reasoning as in the previous question we obtain an answer of 2 pi i exp(-6) for the integral. For the second integral we have to take a lower semi-circular contour, but the integrand has no singularities in this contour and so this integral simply vanishes. So the final answer is 1/2 (2 pi i exp(-6)) = pi i exp(-6).

Section 6.5, Question 3. The integrand has two singularities on the real line, at -1 and at -2, and so to close the contour we need one large semi-circle and two small semi-circles. Because the phase is positive, the large semi-circle has to be in the upper half-plane. As for the small semi-circles, we can take them either in the upper or in the lower half-plane (we get the same answer in either case, of course); let's take the upper semi-circle because that means that there will be no singularities inside the contour. The sum of all four contour integrals is zero. The integral on the large semi-circle goes to zero by Jordan's lemma. The integral on the semi-circle around 1 goes to -pi i Res(1) = +pi i e^i, because the integral on the full (clockwise) circle is -2 pi i Res(1), and Lemma 4 of Section 6.5 says that the integral on any partial circle converges to the corresponding fraction of the integral on the full circle as the radius tends to zero. Similarly the integral on the semi-circle around 2 goes to -pi i Res(2) = -pi i e^{2i}, and so we obtain in the limit

 [desired integral] + 0 + pi i e^i - pi i e^{2i} = 0,
which gives the desired formula.
Section 6.6, Question 2.  The first step is to convert the real
integral into a complex integral.  The trick is to select the right branch
of z^{alpha - 1}; let us pick the branch f(z) = exp((alpha - 1) L_0(z)).
For us, the important properties of f are that it is analytic everywhere
except at 0 and on the positive real axis, and that for z = x (or z =
x + epsilon i) we have f(z) = x^{alpha - 1}.  On the other hand,
for z = x - epsilon i we have f(z) = e^{2 pi i (alpha - 1)} x^{alpha - 1},
because the imaginary part of L_0(z) jumps from 0 to 2 pi i as you cross
the positive real axis.

Now we consider the integral of f(z)/(z+1) on the contour in Figure 6.21. The only singularity inside the contour is at -1, and the residue is f(-1) = e^{pi i (alpha - 1)}, so the integral on the contour is 2 pi i exp(pi i (alpha - 1)). The integral on the large circle goes to zero, because when |z| = rho, f(z) has magnitude rho^{alpha - 1}, and (z+1) has magnitude at least rho-1, so the integrand has magnitude at most rho^{alpha - 1}/(rho - 1). Thus the integral has magnitude at most

 2 pi rho rho^{alpha - 1}/(rho - 1),
which goes to zero as rho tends to infinity (recall that 0 < alpha < 1 by hypothesis).

Similarly, the integral on the small circle goes to zero, because when |z| = epsilon, f(z) has magnitude epsilon^{alpha - 1}, and (z+1) has magnitude at least 1-epsilon, so the integrand has magnitude at most epsilon^{alpha - 1}/(1-epsilon). Thus the integral has magnitude at most

 2 pi epsilon epsilon^{alpha - 1}/(1-epsilon),
which goes to zero as epsilon tends to zero.

The integral just above the real axis is the one that we want; let's call it I. If f did not have the branch cut on the real axis, the integral just below the real axis would be -I, and the two integrals would cancel, yielding no information about I. However, because of the branch cut, the integral just below the real axis is not -I, but is equal to -exp(2 pi i (alpha - 1)) I, because the function f(z) gets multiplied by exp(2 pi i(alpha - 1)) when one crosses the positive real axis.

So, in the limit rho->infinity, epsilon -> 0, we get

 I + 0 - exp(2 pi i (alpha - 1)) I + 0 = 2 pi i exp(pi i (alpha - 1)),
which, since exp(2pi i) = 1 and exp(pi i) = -1, simplifies to
 I = 2 pi i (-exp(pi i alpha)) / (1 - exp(2 pi i alpha))
 = 2 pi i / (exp(pi i alpha) - exp(- pi i alpha)
 = pi / sin(pi alpha),
as desired.