Residue theorem for integral of real sinusodial function
I've seen a few examples but don't understand how the contour is chosen.
We use the substitution z=e^(i*theta)
If the integral is over -pi to pi, or over 0 to 2*pi, then the contour is the unit circle centred on the origin.
2.) What would the contour be if we were integrating over 0 to pi?
My attempts at answers:
1.) Is it because the subtitution we use is the usual parameterization of the unit circle? (I read that somewhere but to be honest I don't really understand what it means). Or is it a full circle because we are integrating over a full circle (0 to 2*pi) in the original limits of integration? In which case why is it a unit circle, why couldn't its radius be larger or smaller? How do we chose the radius of the circle contour?
2.) Would it be a unit semi-circle centred on the origin? If so which 2 quartiles of the imaginary plane would it cover? Or would it still be a unit circle centred on the axis?
Also I think the Cauchy theorem tells us that any integral over a closed contour in the complex plane is equal to zero if the function is regular on or within that contour. If there are singularities (poles) within the contour then we apply the residue theorem and find the value of the integral equal to 2*pi*i * [sum of residues of the poles]. Right?
All very well, but some integrals have several poles, and depending on which contour you choose you may or may not enclose these singularities. You have to choose a contour that is regular at all points for that function. But in all the examples I looked at they chose the unit circle centred on the radius, and in one of them this meant the pole at z = 2 wasn't enclosed, but they could have chosen a circle of radius 3 or 4 or even infinity and the function would still be regular at all points on the contour. I'm confused.
Any answers/help/hints/tips would be much appreciated. Thanks.