Finding a definite integral by residue integration? I have a probability distribution of the form
$$\frac{k_1}{(k_2 x^2+k_3 x+k_4)^n}$$
and I want to find the mean and variance—but am running into problems with that.
The mean would be
$$\int_{-\infty}^\infty \frac{k_1 x\,dx}{(k_2 x^2+k_3 x+k_4)^n}$$
and the variance would be similar stuff. The quadratic form in the denominator is guaranteed to have to complex roots, by the way, and $k_2>0$, so it's a positive parabola with a minimum which is greater than $0$ (and it's also to the $n$th power, where $n$ is a natural number), and of course $k_1$ is such that the whole thing integrates to $1$. Obviously if $n=1$, then it's just a skip, hop and a jump away from the integral of the arctangent, but that doesn't help me when $n>1$. I not only have not had success with integrating it using substitution, but I went to the wolfram online integrator and it gave me a reference to something I can't find out information about that I need. But it's just a definite integral I want anyway, I want the mean and variance, that's all I want. For all I know this is a well known probability distribution and its mean and variance are known and I don't need to figure out anything. I also was thinking residue integration could do the job, I remember doing things like finding $$\int_{-\infty}^\infty \frac{dx}{x^4+1},$$ which is kind of up the same alley, but I can't for the life of me remember how this is done and I can't understand any of the explanations I find in the first page of search results on how to find integrals using residue integration. Can someone tell me if this is a probability distribution that actually has a name, or help me either solving the integral or just tell me what the mean and variance are?
 A: As you observe, it suffices to compute the integral
$$I_n=\int_{-\infty}^\infty \dfrac{dx}{(x^2+1)^n}$$
for integral $n>0$, which turns out to evaluate nicely:
$$I_n=\dfrac{\pi}{2^{2n-2}}\binom{2n-2}{n-1}.$$
This is indeed a standard application of residue calculus.  The denominator factors as $(x+i)^n(x-i)^n$, so the integrand $f(x)$ has poles at $-i$ and $i$.  Select a contour consisting of a line segment from $-R$ to $R$, followed by a semicircular arc of radius $R$ in the upper half-plane connecting $R$ back to $-R$.  The only pole enclosed is at $z=i$, and the arc contribution to the integral is negligible as $R\to\infty$, so $$I_n=2\pi i\, \textrm{Res}_{z=i} f(z).$$
Computing the residue is straightforward: 
$$\begin{eqnarray}
\textrm{Res}_{z=i} f(z) &=& \lim_{z\to i}\dfrac{1}{(n-1)!}\dfrac{d^{n-1}}{dz^{n-1}}\left((z-i)^n f(z)\right)\\
&=& \dfrac{1}{(n-1)!}\dfrac{d^{n-1}}{dz^{n-1}} (z+i)^{-n}\big|_{z=i}\\
&=& \dfrac{1}{(n-1)!} (-n)(-n-1)\cdots(-2n+2) (2i)^{-2n+1}\\
&=& \binom{2n-2}{n-1} \dfrac{-i}{2^{2n-1}}.\\
\end{eqnarray}$$
Multiplying by $2\pi i$ gives the claimed formula for $I_n$.
A: Assume that $n\gt1$ (otherwise the mean does not exist) and $k_2\ne0$ (the case $k_2=0$ being direct), and let $P(x)=k_2x^2+k_3x+k_4$, then $P'(x)=2k_2x+k_3$ hence
$$
\frac{k_1x}{P(x)^n}=\frac{k_1}{2k_2}\frac{P'(x)}{P(x)^n}-\frac{k_3}{2k_2}\frac{k_1}{P(x)^n}.
$$
Since $\displaystyle\int_{-\infty}^{+\infty}\frac{k_1}{P(x)^n}\mathrm dx=1$ and $\displaystyle\int_{-\infty}^{+\infty}\frac{P'(x)}{P(x)^n}\mathrm dx=-\frac1{n-1}\left.\frac1{P(x)^{n-1}}\right|_{-\infty}^{+\infty}=0$ because $n\gt1$, this yields
$$
\int_{-\infty}^{+\infty}\frac{k_1x}{P(x)^n}\mathrm dx=-\frac{k_3}{2k_2}.
$$
A similar decomposition of $x^2$ in the basis $(P(x),P'(x),1)$ yields the variance when $n\gt\frac32$, provided one knows the value of the integral
$$
I_{n-1}=\int_{-\infty}^{+\infty}\frac{\mathrm dx}{P(x)^{n-1}}.
$$
A simple approach to this computation is to express the sum of the series $\sum\limits_{n\geqslant1}t^nI_n$ as the integral
$$
\int_{-\infty}^{+\infty}\frac{t\,\mathrm dx}{P(x)-t},
$$
to compute this integral, to expand the result as a series, and to identify $I_n$ as the coefficient of $t^n$ in this expansion. In the present case, no difficulty is involved, and this route seems at least as direct as the approach based on complex analysis.
