First I must apologize as this thread is a copy of an earlier thread that I posted in the wrong place.

I am having trouble evaluating two improper integrals by applying complex analysis. The two integrals are

(1)

$\displaystyle

\int _{-\infty }^{\infty }\frac{x}{x^{2} -2x+2} dx $

and

(2)

$\displaystyle

\int _{0}^{\infty }\frac{x^{2} }{\left(x^{2} -2x+2\right)^{2} } dx $

The reason I feel (1) is non-trivial is because the degree of the denominator is not 2 or more greater than that of the numerator, so the integration over a semi-circle in the complex plane doesn't really apply. However, using numerical analysis it seems that the Cauchy principle value of (1) is $\displaystyle \pi$ , and if you blindly integrate over the semi-circle ignoring the denominator/numerator problem you will get $\displaystyle \pi$ from the residue theorem. I assume this is just coincidence, however is there someone out there might be able to shed a bit more light? I know that (1) is divergent, but why does it seem to converge to $\displaystyle \pi$?

The problem I am having with (2) is similar. Although there is no problem with the degrees of the denominator and numerator, the limits of integration are not correct to use the semi-circle. Further, it would be okay to use the semi-circle if the function was symmetric but it's not. I looked for a transform that would make it symmetric but I failed. I made a function that is symmetric and has the same values in the positive reals as (2):

(3)

$\displaystyle \int _{-\infty}^{\infty }\frac{x^{2} }{\left(x^{2} -2\left|x\right|+2\right)^{2} } dx$

I had hoped to integrate this over the semi-circle in the complex plane and divide by two at the end since it's symmetric. Unfortunately the abs(x) seems to cause problems. It seems to me that the function is analytic and should work and it's easy to find the poles, but what order are they? Can anyone tell me why (3) doesn't work, or provide an alternate way of evaluating the integral using the residue theorem or something similar?