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?

$$\int_{0}^{1}\frac{x^2+1}{x^4+1}\,dx + \int_{1}^{+\infty}\frac{x^2+1}{x^4+1}\,dx = 2\int_{0}^{1}\frac{1+x^2}{1+x^4}\,dx = 2\int_{0}^{1}\frac{1+x^2-x^4-x^6}{1-x^8}\,dx$$
hence the value of the integral is provided by the (Dirichlet) series
$$ 2\sum_{k\geq 0}\left(\frac{1}{8k+1}+\frac{1}{8k+3}-\frac{1}{8k+5}-\frac{1}{8k+7}\right) $$
that can be computed through the digamma reflection formula. Its value is just
$$ \boxed{I = \color{red}{\frac{\pi}{\sqrt{2}}}} .$$
The given integral is straightforward to compute through the residue theorem, too.
