How to take $\int_0^{+\infty} \frac{x^2+1}{x^4+1}dx$? The integral:
$$\int_0^{+\infty} \frac{x^2+1}{x^4+1}dx$$
If num were greater than denum I would just devide it normally with long division, but it is not, how should I handle it then?

By symmetry,
$$2\int_0^{+\infty}\frac{x^2+1}{x^4+1}\ dx=\int_{-\infty}^{+\infty}\frac{x^2+1}{x^4+1}\ dx$$
By taking a semi-circle contour in the upper half of the complex plane and applying Cauchy's residue formula, we find that
$$\begin{align}\int_{-\infty}^{+\infty}\frac{x^2+1}{x^4+1}\ dx&=2\pi i\left[\lim_{a\to e^{\pi i/4}}\frac{(a^2+1)(a-e^{\pi i/4})}{a^4+1}+\lim_{b\to e^{3\pi i/4}}\frac{(b^2+1)(b-e^{3\pi i/4})}{b^4+1}\right]\\&=2\pi i\left[\frac{1+i}{4e^{3\pi i/4}}+\frac{1-i}{4e^{9\pi i/4}}\right]\\&=\frac{\pi i}{2\sqrt2}\left[(1-i)^2-(1+i)^2\right]\\&=\sqrt2\pi\end{align}$$
Thus,

$$\int_0^{+\infty}\frac{x^2+1}{x^4+1}\ dx=\frac{\sqrt2\pi}2=\frac\pi{\sqrt2}$$

