<s>[INST] A simple way to evaluate $\int_{-a}^a \frac{x^2}{x^4+1} \, \mathrm dx$? I am currently trying to show that $\int_{-\infty}^\infty \cos(x^2) \, \mathrm dx = \sqrt{\frac{\pi}{2}}$ and the last integral I have to evaluate is
$$\int_{-a}^a \frac{x^2}{x^4+1} \, \mathrm dx.$$
Now of course I'm familiar with wolframalpha, however the way it solves this integral seems very awkward and also not elegant to me, even though the function to me looks quite simple. So, is there a simpler way to solve this integral or is the way described on wolframalpha already (one of) the simplest approach(es)? I ask this because often wolframalpha doesn't see tricks (occurred to me when I wanted to find a formula for the n-th derivative of some function) which a human eye might see.
Thanks for any answers in advance.
 [/INST] I'm late to the party, but here's a simple way to derive the result shown in W|A without knowing before hand that $x^4+1$ factors as $(x^2-\sqrt{2}x+1)(x^2+\sqrt{2}x+1)$. We have that $$\int_{-a}^a\dfrac{x^2}{x^4+1}\,\mathrm dx=\int_{-a}^a\dfrac{\tfrac1{x^2}\cdot x^2}{\tfrac1{x^2}\cdot \left(x^4+1\right)}\,\mathrm dx=\int_{-a}^a\dfrac{1}{x^2+\tfrac1{x^2}}\,\mathrm dx.$$ Now here's the trick, since $\left(x+\tfrac1x\right)^2=x^2+2+\tfrac1{x^2}$ it follows that $x^2+\tfrac1{x^2}=\left(x+\tfrac1x\right)^2-\sqrt{2}^2$. Hence the fraction decomposes nicely as follows, $$\begin{align}          \frac{1}{\tfrac1{x^2}+x^2}&=\frac{1}{\left(\tfrac{1}x+x\right)^2-2}         \\&=\dfrac{1}               {\left               (\tfrac{1}{x}+x+\sqrt{2}\right)\left(\tfrac{1}{x}+x-\sqrt{2}\right)}\\&=       \dfrac{A}{\tfrac{1}{x}+x+\sqrt{2}}+\dfrac{B}{\tfrac{1}{x}+x-\sqrt{2}}.        \end{align}$$ Using standard techniques we find that $A=\tfrac{-1}{2\sqrt{2}}$ and $B=\tfrac{1}{2\sqrt{2}}$, and so the last expression can be reduced to, $$\dfrac{x}{2\sqrt{2}\left(x^2+\sqrt{2}x+1\right)}-\dfrac{x}{2\sqrt{2}\left(x^2-\sqrt{2}x+1\right)}.$$ The rest will be messy but still pretty straightforward. 
</s>