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.
 A: You'll want to make use of the fact that the polynomial $x^4+1$ is reducible and can be factored as $x^4+1=(x^2-\sqrt{2}x+1)(x^2+\sqrt{2}x+1)$. From here, you'll use a partial fraction decomposition.
A: Here's a cleaner way to get it:
Euler's Identity gives us $e^{-i x^2}=\cos(-x^2)+i\sin(-x^2)$.
Since cosine is even and sine is odd, this becomes $e^{-i x^2}=\cos(x^2)-i\sin(x^2)$.
Integrating yields $\int_{-\infty}^\infty e^{-i x^2}\;dx=\int_{-\infty}^\infty\cos(x^2)\;dx-i\int_{-\infty}^\infty\sin(x^2)\;dx$.
Thus $\int_{-\infty}^\infty\cos(x^2)\;dx = Re(\int_{-\infty}^\infty e^{-i x^2}\;dx)$.
Now you can use a substitution on the right and the fact that $\int_{-\infty}^\infty e^{- x^2}\;dx=\sqrt{\pi}$ to obtain the value of your integral.
A: A bit late to the game, but in more generality this is a Mellin Transform.
First, use the fact that $\cos(x^2)$ is even to get an integral from $0$ to $\infty$.  We can actually evaluate $$I=\int_0^\infty \cos(x^a)\mathrm dx$$ for $a>1$.  Let $u=x^a$, $dx=\frac1{a}u^{\frac1{a}-1}$ so that $$I=\frac{1}{a}\int_0^\infty \cos(u)u^{1/a-1}\mathrm du=\frac1{a}\mathcal{M}\left(\cos(t)\right)\left(\frac1{a}\right).$$  We can evaluate this Mellin transform by using a pizza-slice contour integral in the complex plane to find that for $0 < z < 1$ we have $$\mathcal{M}\left(\cos(t)\right)(z)=\Gamma(z)\cos\left(\frac{\pi z}{2}\right).$$  Consequently, for $a > 1$, $$\int_0^\infty \cos(x^a)\mathrm dx=\frac1{a}\Gamma\left(\frac1{a}\right)\cos\left(\frac{\pi}{2a}\right).$$  
Hope that helps,
Remark: If desired, I can upload the full explanation of the pizza slice contour. It is worth mentioning that an identical proof gives the mellin transform for $\sin(t)$.
A: This answer addresses the question of finding the indefinite integral, and tries to show that there is less to the Wolfram Alpha answer than meets the eye.
Part of the reason the integral is frightening is that when we factor $x^4+1$, we run into a bunch of $\sqrt{2}$.  Then completing the square, so natural with simpler numbers, suddenly becomes worrisome.  We, who are so rational,  are confronted by too many irrationals.
Here is a simple suggestion.  Make the change of variable $x=y/\sqrt{2}$.  Very quickly, we arrive at 
$$\int \frac{\sqrt{2}\,y^2}{y^4+4}dy$$
Why this change of variable?  Maybe we recall from a contest the question about $n^4+4$ being hardly ever prime. The solution hinges on the fact that the polynomial $y^4+4$ factors nicely:
$$y^4+4=(y^2-2y+2)(y^2+2y+2)$$
The factorization is an application of the fundamental result:
$$2+2=2\times 2$$
We will forget about the $\sqrt{2}$ until the end.  And because fractions can be so fractious, we look at the integral
$$\int \frac{8y^2}{y^4+4}dy$$
Note that
$$\frac{8y^2}{y^4+4}=\frac{2y}{y^2-2y+2} +\frac{-2y}{y^2+2y+2}$$
To integrate the first summand, note that we want
$$\int\frac{(2y-2)+2}{y^2-2y+2}dy$$
The integral of $\frac{2y-2}{y^2-2y+2}$ is easy, the derivative of the bottom is sitting on top.  The integral of $\frac{2}{y^2-2y+2}$ is almost as unthreatening, since completing the square is irresistible.  
The other integral can be done in the same way. But it is  more virtuous to recycle. Let $y=-z$ and notice that we get something familiar.
A: I think one might turn wckronholm's answer into a correct argument along the following lines (though the following is by no means more than a heuristic argument as it stands):
Define $F(t) = \int_{-\infty}^\infty \exp(-tx^2) \, dx$. Then 
\begin{align*}
\frac{d}{dt} F(t) &= \int_{-\infty}^\infty -x^2 \exp(-tx^2) \, dx \\
&= \int_{-\infty}^\infty \frac{x}{2t} \left(-2tx \exp(-tx^2)\right)\, dx \\
&= \frac{-1}{2t} \int_{-\infty} \exp(-tx^2) \, dx \\
&= \frac{-1}{2t} F(t)
\end{align*}
This differential equation is satisfied by $F(t) = C \exp\left(-\frac{1}{2}\log(t)\right)$ for some constant $C$. Since our $F$ should satisfy $F(1) = \sqrt{\pi}$, we must have
$$F(t) = \sqrt{\pi} \exp\left(\frac{-1}{2}\log(t)\right)$$
So in particular for $t = -i$ we get
\begin{align*}
F(-i) &= \sqrt{\pi} \exp\left(\frac{-1}{2}\log(-i)\right) \\
&= \sqrt{\pi} \exp\left(\frac{-1}{2} \cdot\frac{-\pi i} 2\right) \\
&= \sqrt{\pi} \left(\frac1{\sqrt2} + \frac i {\sqrt{2}}\right)
\end{align*}
Which would mean that 
$$\int_{-\infty}^\infty \cos(x^2) \, dx + i\cdot \int_{-\infty}^\infty  \sin(x^2) \, dx =  \int_{-\infty}^\infty  e^{ix^2} \, dx = F(-i) = \sqrt{\frac{\pi}2} + i \sqrt{\frac{\pi}2}$$
A: $\newcommand{\+}{^{\dagger}}
 \newcommand{\angles}[1]{\left\langle\, #1 \,\right\rangle}
 \newcommand{\braces}[1]{\left\lbrace\, #1 \,\right\rbrace}
 \newcommand{\bracks}[1]{\left\lbrack\, #1 \,\right\rbrack}
 \newcommand{\ceil}[1]{\,\left\lceil\, #1 \,\right\rceil\,}
 \newcommand{\dd}{{\rm d}}
 \newcommand{\down}{\downarrow}
 \newcommand{\ds}[1]{\displaystyle{#1}}
 \newcommand{\expo}[1]{\,{\rm e}^{#1}\,}
 \newcommand{\fermi}{\,{\rm f}}
 \newcommand{\floor}[1]{\,\left\lfloor #1 \right\rfloor\,}
 \newcommand{\half}{{1 \over 2}}
 \newcommand{\ic}{{\rm i}}
 \newcommand{\iff}{\Longleftrightarrow}
 \newcommand{\imp}{\Longrightarrow}
 \newcommand{\isdiv}{\,\left.\right\vert\,}
 \newcommand{\ket}[1]{\left\vert #1\right\rangle}
 \newcommand{\ol}[1]{\overline{#1}}
 \newcommand{\pars}[1]{\left(\, #1 \,\right)}
 \newcommand{\partiald}[3][]{\frac{\partial^{#1} #2}{\partial #3^{#1}}}
 \newcommand{\pp}{{\cal P}}
 \newcommand{\root}[2][]{\,\sqrt[#1]{\vphantom{\large A}\,#2\,}\,}
 \newcommand{\sech}{\,{\rm sech}}
 \newcommand{\sgn}{\,{\rm sgn}}
 \newcommand{\totald}[3][]{\frac{{\rm d}^{#1} #2}{{\rm d} #3^{#1}}}
 \newcommand{\ul}[1]{\underline{#1}}
 \newcommand{\verts}[1]{\left\vert\, #1 \,\right\vert}
 \newcommand{\wt}[1]{\widetilde{#1}}$
$\ds{\int_{-a}^{a}{x^{2} \over x^{4} + 1}\,\dd x:\ {\large ?}.\qquad
     a \in {\mathbb R}}$.
$$
\color{#c00000}{\int_{-a}^{a}{x^{2} \over x^{4} + 1}\,\dd x}
=2\sgn\pars{a}\int_{0}^{\verts{a}}{x^{2} \over x^{4} + 1}\,\dd x
$$

With
  $\ds{t \equiv {1 \over x^{4} + 1}\quad\imp\quad x = \pars{{1 \over t} - 1}^{1/4}}$:
  \begin{align}
&\color{#c00000}{\int_{-a}^{a}{x^{2} \over x^{4} + 1}\,\dd x}
=
2\sgn\pars{a}\int_{1}^{1/\pars{a^{4} + 1}}t\pars{{1 \over t} - 1}^{1/2}
\bracks{{1 \over 4}\,\pars{{1 \over t} - 1}^{-3/4}\,\pars{-\,{1 \over t^{2}}}\,\dd t}
\\[3mm]&=\half\,\sgn\pars{a}\int^{1}_{1/\pars{a^{4} + 1}}
t^{-3/4}\pars{1 - t}^{-1/4}\,\dd t
\\[3mm]&=\half\,\sgn\pars{a}\bracks{%
\int^{1}_{0}t^{-3/4}\pars{1 - t}^{-1/4}\,\dd t
-
\int_{0}^{1/\pars{a^{4} + 1}}t^{-3/4}\pars{1 - t}^{-1/4}\,\dd t}
\\[3mm]&=\half\,\sgn\pars{a}\bracks{%
{\rm B}\pars{{1 \over 4},{3 \over 4}}
-{\rm B}\pars{{1 \over a^{4} + 1};{1 \over 4},{3 \over 4}}}
\end{align}
  where $\ds{{\rm B}}$'s are Beta Functions.

Moreover,
$\ds{{\rm B}\pars{{1 \over 4},{3 \over 4}} = \Gamma\pars{1 \over 4}
\Gamma\pars{3 \over 4} = {\pi \over \sin\pars{\pi/4}} = \root{2}\,\pi}$.
$\ds{\Gamma\pars{z}}$ is the
Gamma Function and we used well known properties of $\ds{\rm B}$'s and $\ds{\Gamma}$'s.

$$
\color{#00f}{\large\int_{-a}^{a}{x^{2} \over x^{4} + 1}\,\dd x
=\half\,\sgn\pars{a}\bracks{\root{2}\pi
-{\rm B}\pars{{1 \over a^{4} + 1};{1 \over 4},{3 \over 4}}}}
$$

A: I can show you a method to solve this integral and a somewhat larger class of functions. 
The technique is taken from my notes on integration and is the most elementary method I know. This is somewhat of a sketch and I leave it to you to fill in any holes, if you do have a specific question, feel free to leave a comment below. In the very samme document there is a proof for the Fresnel Integrals see page 133. I am working on including an alternative proof, but alas this will use a fair bit of complex analysis.
Lemma 1
The following integrals converge
\begin{align}
      \frac12 \int_{0}^{\infty} \frac{1+x^{n-2}}{1+x^n}\mathrm{d}x
    =         \int_{0}^{\infty} \frac{\mathrm{d}x}{1+x^n}
    =         \int_{0}^{\infty} \frac{x^{n-2}}{1+x^n} \mathrm{d}x \tag{1}
\end{align}
Given that $n$ is a real number greater than one $1$.
Taking this lemma for granted and letting $n=2$ in $(1)$ we get
$$
      \int_{0}^{\infty} \frac{x^2}{1+x^4} \mathrm{d}x
    = \frac{1}{2}\int_{0}^{\infty} \frac{1+x^{2}}{1+x^4} \mathrm{d}x
$$
Note that $n$ is an even number and hence the integrands are even. We can then write
$$
      \int_{-\infty}^{\infty} \frac{x^2}{1+x^4} \mathrm{d}x
    = \int_{0}^{\infty} \frac{1+x^{2}}{1+x^4} \mathrm{d}x
$$
I deliberately use the limits over the entire plane instead of $-a$ to $a$ since you
say that you are using this integral to compute the Fresnel integrals. The integral on the right is easier to integrate and we have
$$
      \int_{0}^{\infty} \frac{1+x^{2}}{1+x^4} \mathrm{d}x
    = \int_0^\infty \frac{1+1/x^2}{x^2+1/x^2}\mathrm{d}x
    = \int_0^\infty \frac{1+1/x^2}{(x-x^{-1})^2 + 2} \mathrm{d}x
$$
To compute the last integral let $u \mapsto x-x^{-1}$ so $\mathrm{d}u= (1+1/x^2)\mathrm{d}x$
and the limits now becomes $(-\infty,\infty)$
$$  
      \int_{0}^{\infty} \frac{1+x^{2}}{1+x^4} \mathrm{d}x
    = \int_{-\infty}^\infty \frac{\mathrm{d}u}{u^2 + 2}
    = \frac{1}{\sqrt{2}}\int_{-\infty}^\infty \frac{\mathrm{d}y}{y^2 + 1}
$$
Hence we can finally conclude that
$$
      \int_{-\infty}^{\infty} \frac{  x^2}{1+x^4} \mathrm{d}x
    = \int_{0}^{\infty}       \frac{1+x^2}{1+x^4} \mathrm{d}x
    = \frac{1}{\sqrt{2}}\int_{-\infty}^\infty \frac{\mathrm{d}y}{y^2 + 1}
    = \frac{\pi}{\sqrt{2}}
$$
where one recognizes the last integral as the anti-derivative of the $\arctan x$ function.
A proof of the lemma can be found on page 40 in my documents and is easily proven.
proof.
By using the substitution $x \mapsto 1/x$ on the integral
$\int 1/(1+x^n)\mathrm{d}x$ we have
$$
       \int_{0}^{\infty} \frac{\mathrm{d}x}{1+x^n}
    = -\int_{0}^{\infty} \frac{1}{1+x^{-n}} \frac{x^n}{x^n}\frac{\mathrm{d}x}{x^2}
    =  \int_{0}^{\infty} \frac{x^{n-2}}{1+x^n}\mathrm{d}x \tag{2}
$$
and this establishes the first equality in lemma 1. These two integrals have
the same value and addition gives
$$
      \int_{0}^{\infty} \frac{\mathrm{d}x}{1+x^n} 
    + \int_{0}^{\infty} \frac{x^{n-2}}{1+x^n}\mathrm{d}x
    = \int_{0}^{\infty} \frac{1+x^{n-2}}{1+x^n} \mathrm{d}x
$$
dividing by $2$ and using $(2)$ finishes the proof. 
A: 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. 
A: $\int_{-a}^a\dfrac{x^2}{x^4+1}~dx$
$=\int_{-a}^a\dfrac{1}{x^2+\dfrac{1}{x^2}}~dx$
$=\dfrac{1}{2}\int_{-a}^a\dfrac{1+\dfrac{1}{x^2}}{x^2+\dfrac{1}{x^2}}~dx+\dfrac{1}{2}\int_{-a}^a\dfrac{1-\dfrac{1}{x^2}}{x^2+\dfrac{1}{x^2}}~dx$
$=\dfrac{1}{2}\int_{-a}^a\dfrac{1+\dfrac{1}{x^2}}{\left(x-\dfrac{1}{x}\right)^2+2}~dx+\dfrac{1}{2}\int_{-a}^a\dfrac{1-\dfrac{1}{x^2}}{\left(x+\dfrac{1}{x}\right)^2-2}~dx$
$=\dfrac{1}{2}\int_{-a}^a\dfrac{d\left(x-\dfrac{1}{x}\right)}{\left(x-\dfrac{1}{x}\right)^2+2}+\dfrac{1}{2}\int_{-a}^a\dfrac{d\left(x+\dfrac{1}{x}\right)}{\left(x+\dfrac{1}{x}\right)^2-2}$
$=\dfrac{1}{2\sqrt2}\left[\tan^{-1}\dfrac{x-\dfrac{1}{x}}{\sqrt2}\right]_{-a}^a-\dfrac{1}{2\sqrt2}\left[\tanh^{-1}\dfrac{x+\dfrac{1}{x}}{\sqrt2}\right]_{-a}^a$
$=\dfrac{1}{\sqrt2}\tan^{-1}\dfrac{a-\dfrac{1}{a}}{\sqrt2}-\dfrac{1}{\sqrt2}\tanh^{-1}\dfrac{a+\dfrac{1}{a}}{\sqrt2}$
