I haven't checked your residue calculations, I'll assume those are correct, but you aren't done yet. The contour integral over isn't supposed to be equal to the real integral you're trying to evaluate... you haven't dealt with the branch cut yet. You have two pieces of the contour that lie along the real axis, the one just above and the one just below; the integral over both of them should be equal to , but what you're trying to evaluate is just the integral along as R goes to infinity. You should be able to show that the integral on is some constant factor times the integral on , so you can solve for the integral on using the fact that their sum is .