<s>[INST] Calculate $\int_{-\infty}^{\infty}\;\left( \frac{x^2}{1+4x+3x^2-4x^3-2x^4+2x^5+x^6}\right) \;dx$ 
Calculate $$\displaystyle \int_{-\infty}^{\infty}\;\left(
\frac{x^{2}}{1+4x+3x^{2}-4x^{3}-2x^{4}+2x^{5}+x^{6}}\right) \;dx$$

The answer given is $\pi$. How does one calculate this?
 [/INST] 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.
</s>