Recall cos(z) grows exponentially in imaginary direction:
So we'd have no control over g(z) = cos(7z)/(z^2+9) on C_R:
For integral of cos(7x)/(x^2+9), instead make use of h(z) = exp(i 7z)/(z^2+9):
It's hard to see, but h(z) = exp(i 7z)/(z^2+9) still has a pole at 3i:
Ex. 2: f(z) = exp(i 3z)/(z-2i):
It's hard to see, but f(z) still has a pole at 2i: