Calculate $\int_{-\infty}^{\infty}\;\left( \frac{x^2}{1+4x+3x^2-4x^3-2x^4+2x^5+x^6}\right) \;dx$

Let $F(x) = \frac{x^2}{P(x)}$ where $$P(x) = x^6+2x^5-2x^4-4x^3+3x^2+4x+1 = (x^3+x^2-2x-1)^2 + (x^2+x)^2$$

Change variable to $u = \frac{1}{x+1} \iff x = \frac{1}{u}-1$. The integral at hand becomes

$$\int_{-\infty}^\infty F(x) dx = \left(\int_{-\infty}^{-1^{-}} + \int_{-1^{+}}^\infty\right) F(x) dx = \left(\int_{0^{-}}^{-\infty} + \int_{+\infty}^{0^{+}}\right) F\left(\frac{1}{u} - 1\right)\left(-\frac{du}{u^2}\right)\\ = \int_{-\infty}^\infty \frac{1}{u^2} F\left(\frac{1}{u}-1\right) du $$ By direct substitution, we have $$\frac{1}{u^2}F\left(\frac{1}{u}-1\right) = \frac{(u^2-u)^2}{u^6-2u^5-2u^4+4u^3+3u^2-4u+1} = \frac{(u^2-u)^2}{(u^3-u^2-2u+1)^2+(u^2-u)^2}$$ Notice the function defined by $$g(u) \stackrel{def}{=} \frac{u^3-u^2-2u+1}{u^2-u} = u - \frac{1}{u}-\frac{1}{u-1}$$ has the form where Glasser's Master Theorem applies, we get

$$\int_{-\infty}^\infty F(x) dx = \int_{-\infty}^\infty \frac{du}{g(u)^2 + 1} = \int_{-\infty}^\infty \frac{dx}{x^2+1} = \pi $$

NOTE

Please note that the statement about Glasser's Master theorem in above link is slightly off. The coefficient $|\alpha|$ in front of $x$ there need to be $1$. Otherwise, there will be an extra scaling factor on RHS of the identity. When in doubt, please consult the original paper by Glasser,

Glasser, M. L. "A Remarkable Property of Definite Integrals." Math. Comput. 40, 561-563, 1983.

and an online copy of that paper can be found here.


There is an inner structure that enable this integral to be evaluated into such nice form.


Let $$f(x) = 1+4x+3x^2-4x^3-2x^4+2x^5+x^6$$ The first miracle is: $f(x)$ factorizes nicely in $\mathbb{Q}[i]$: $$f(x) = \underbrace{\left(x^3+(1-i) x^2-(2+i) x-1\right)}_{g(x)} \underbrace{\left(x^3+(1+i) x^2-(2-i) x-1\right)}_{h(x)}$$


The second miracle is: the root of $g(x)$ all lie in the same half plane. In this case, all roots of $g$ are in the upper plane. Denote them by $\alpha_1, \alpha_2, \alpha_3$, by contour integration $$I:=\int_{-\infty}^\infty \frac{x^2}{f(x)}dx = 2\pi i\left[ {\frac{{{\alpha _1}^2}}{{g'({\alpha _1})h({\alpha _1})}} + \frac{{{\alpha _2}^2}}{{g'({\alpha _2})h({\alpha _2})}} + \frac{{{\alpha _3}^2}}{{g'({\alpha _3})h({\alpha _3})}}} \right]$$ Now the right hand side is symmetric in $\alpha_i$, which are roots of $g$. Since $g,h\in \mathbb{Q}[i][x]$, we have $$\frac{I}{\pi} \in \mathbb{Q}$$ This explain the nice result of the integral. Note that the numerator $x^2$ can be replaced by any polynomial in $\mathbb{Q}[x]$, $I/\pi$ is still rational.


Using similar construction, we obtain the analogous integrals:

Let $$f(x) = 4 + 8x - 11{x^2} - 18{x^3} + 13{x^4} + 8{x^5} + {x^6}$$ then $f$ satisfies the above two "mircales" so we have $$\int_{ - \infty }^\infty {\frac{1}{{f(x)}}dx} = \frac{{5\pi }}{6} \qquad \int_{ - \infty }^\infty {\frac{x}{{f(x)}}dx} = - \frac{\pi }{3} \qquad \int_{ - \infty }^\infty {\frac{{{x^2}}}{{f(x)}}dx} = \frac{\pi }{3}$$

Another example with

$$f(x) = 4 + 12x - 6{x^2} - 26{x^3} + 11{x^4} + 8{x^5} + {x^6}$$ $$\int_{ - \infty }^\infty {\frac{1}{{f(x)}}dx} = \frac{{3\pi }}{4} \qquad \int_{ - \infty }^\infty {\frac{x}{{f(x)}}dx} = - \frac{\pi }{4} \qquad \int_{ - \infty }^\infty {\frac{{{x^2}}}{{f(x)}}dx} = \frac{\pi }{4}$$

An octic example:

$$f(x) = 13 + 12 x + 7 x^4 + 2 x^5 - 3 x^6 + x^8$$ $$\int_{ - \infty }^\infty {\frac{1}{{f(x)}}dx} = \frac{{487\pi }}{4148} \qquad \int_{ - \infty }^\infty {\frac{x}{{f(x)}}dx} = - \frac{325\pi }{4148} \qquad \int_{ - \infty }^\infty {\frac{{{x^2}}}{{f(x)}}dx} = \frac{515\pi }{4148}$$


More of a hint, but it might work:

Use the formula

$$\int_{-\infty}^{\infty}\frac{l (x +a)+ c}{(x+a)^2 + b^2}dx= \frac{c \pi}{b}$$

if $b>0$. Write $$\frac{x^{2}}{1+4x+3x^{2}-4x^{3}-2x^{4}+2x^{5}+x^{6}} = \sum_{k=1}^3 \frac{l_k (x +a_k)+ c_k}{(x+a_k)^2 + b_k^2}$$

where the $l_k$, $a_k$, $b_k$, $c_k$ satisfy some (symmetric) equalities.

Show that these equalities imply $\sum_{k=1}^3 \frac{c_k}{b_k} = 1$

This might not be hopeless with some software. One could show that at least one of the expressions $\sum_{k=1}^3 \pm\frac{c_k}{b_k} - 1$ is zero, or equivalently, their product. Now this is an algebraic thing that could be show to follow from the equations for the coefficients. As for showing that the one with all $+$ equals $1$, some approximations would be useful, say like the ones from the answer of @Dr. Sonnhard Graubner:

${\bf Added:}$ Just to see what happens with other cases, the slightly modified integral $$\int_{-\infty}^{\infty}\frac{x^{2}}{1+4x+4x^{2}-4x^{3}-2x^{4}+2x^{5}+x^{6}}dx=2 \pi \sqrt{ t}=1.442791771994468\ldots$$ where $t$ is the root of the equation

$$(2^{26}\cdot53^6\cdot419^6)t^{10}-714086275692025123245183700303872 t^9+17223872258514797331184452894720 t^8-95944433146175550843118419968 t^7+1052704800953003893513568256 t^6-112701726213711713166176256 t^5+2130836339803327583245568 t^4-5118952508328476790656 t^3-21564414502323395600 t^2-1183162373726451992 t+45434497^2 =0 $$ and $t \approx 0.0527288$

All these integrals are $\pi \times $ some algebraic number that can be in principle determined.