So I was in the search for a general formula of $$\int_{-\infty}^\infty\frac{1}{1+x^n}dx$$I haven't found one yet, but I realized that for odd $n$ this is $0$. For even $n$, I decided to try a few cases first. Everyone knows the case of $n=2$, so I tried $n=4$. That is, we are calculating $$\int_{-\infty}^\infty\frac{1}{1+x^4}dx$$ The only obvious way to do this is to use the Residue theorem.
Consider a semicircle contour with radius $R$. There is a pole of $\frac{1}{1+x^4}$ at $x=\sqrt{i}=\frac{1}{\sqrt2}+\frac{1}{\sqrt2}i$ (use binomial theorem). Another pole is at $x=(-1)^{3/4}$ (note that we are considering poles above the real axis). The residue of this pole is the same as the residue of the other pole (which is $-\frac{1}{4\sqrt2}+\frac{1}{4\sqrt2}i$). Plugging these into the residue theorem formula, we get $\frac{-\pi}{\sqrt2}$.
This seems contradictory, since the function is greater than $0$ (because the denominator has no real roots). So this means that if the integral exists, it should be positive. I put this into a graphing calculator called GraphCalc and it put the same negative answer (up to four decimal places). Then I put it in desmos and did the absolute value of our answers.
So who is right? Is it possible for a function that is always positive to have an integral that is negative? Or do we have to take the absolute value of the answer (if the function is positive) before we call it a day?
Edit: As a note, the GraphCalc app makes the answer negative, whatever the bounds of integration are.
Really? For odd $n$, the integral doesn't exist. That's because $1+(-1)^n=0$.
Moving on, here you can find a more general integral. Your integral becomes that one with $m=0$ and noting that, if $x$ is even, the integrand is also even so we may as well integrate from $0\to\infty$.
A function with integrand $\ge0$ on the whole domain cannot integrate to a strictly negative quantity (unless you're doing Riemann integration and you've integrated, e.g. $\int_2^1$ instead of $\int_1^2$).
To find the residues, let's use the limit formula (these are simple poles): $$\frac{z-\zeta}{1+z^4}\to\frac{1}{4\zeta^3}$$By L'Hopital's rule, where $\zeta$ is a pole. The two poles you need to consider are $e^{\pi i/4}$ and $e^{3\pi i/4}$. The residue theorem tells: $$\frac{1}{4}2\pi i\cdot(e^{-3\pi i/4}+e^{-9\pi i/4})=\frac{\pi i}{2}e^{-6\pi i/4}(e^{3\pi i/4}+e^{-3\pi i/4})=\pi ie^{-3\pi i/2}(\cos(3\pi /4))=\frac{\pi}{\sqrt{2}}$$
And all is well. I'm not sure where you went wrong, but check your signs carefully.
Exercise: show that: $$\mathrm{P.V.}\,\,\int_\Bbb R\frac{1}{1+x^n}\,\mathrm{d}x=\begin{cases}\frac{2\pi}{n}\csc\left(\frac{\pi}{n}\right)&n\text{ is even }\\\frac{2\pi}{n}\csc\left(\frac{\pi}{n}\right)\cos^2\left(\frac{\pi}{2n}\right)&n\text{ is odd }\end{cases}$$
Holds true for all integers $n\ge2$, using a residue method.