# Trouble with basic integration

I'm doing the something that results in following integral: $$f(z) = \int_{-\infty}^\infty \frac{1}{2\pi}x\exp\left(\frac{-x^2}{2}\left(1+z^2\right)\right) dx$$ Then since $f(z)$ is even we get: $$f(z) = \int_{0}^\infty \frac{1}{\pi}x\exp\left(\frac{-x^2}{2}\left(1+z^2\right)\right) dx$$ Which gives $$f(z) = \frac{1}{\pi} \frac{1}{1+z^2}$$

I can't seem to understand why would I get $0$ if I evaluate the first line directly and substituting in the limits as $\infty$ and ${-\infty}$ without using the fact that the function is even? Am I missing something trivial?

PS. This calculation is from calculating the ratio distribution of X/Y where X, Y IID standard normal. The working agrees with my lecturer's notes & the answer's supposed to Cauchy(0,1)

PPS. Thanks for the replies so far. I got as far as that $f(z)$ is even as a function of $z$ but the integrand is odd as a function of $x$. So why is the answer Cauchy (0,1) and not $0$ (according to my professor & online sources eg wiki)?

-
The integrand as a function of $x$ is odd, not even. Rewrite it as $ax\exp(-bx^2)$ and the oddness becomes transparent. – J. M. Dec 1 '11 at 17:09
So, your second displayed equation is not correct. – David Mitra Dec 1 '11 at 17:13
This is just $\mathrm{Const}\cdot\mathsf E(\xi)$ with $\xi\sim \mathscr N(0,1/(1+z^2))$ – S.D. Dec 1 '11 at 17:14

$f$ is even. It's the integrand that's odd. – David Mitra Dec 1 '11 at 17:15