help evaluating tricky contour integral I am a 16 year old in Sweden learning complex analysis and I'm trying to evaluate the integral (I've checked that it converges)
$$ I = \int_{0}^{\infty}\frac{e^{ix}}{x^3+x^2+x+1}\ dx $$
($e^{ix}$ to give the answer to both the integrals with $\cos(x)$ and $\sin(x)$)
Taking $f(z) = \frac{e^{iz}}{z^3+z^2+z+1} = \frac{e^{iz}}{(z+1)(z+i)(z-i)}$ with poles at $z=-i,\ z=i,\ z=-1\ $ as the integrand I constructed a counter-clockwise oriented contour C not enclosing any singularity as a quarter circle with radius R centered on the origin, C being made up of the a circular arc $\Gamma $, the real number line from $0$ to R named $\Lambda$, the semicircular arc with radius $\epsilon$ around the right side of the singularity at $z=i$ named $\gamma $, and the imaginary number line from $0$ to $i$R, broken up by $\gamma $ called $\psi_1$ and $\psi_2$, $\psi_1$ being the one from $i-i\epsilon$ to $0$ and $\psi_2$ being from $i$R to $i+i\epsilon$.
Summarized: $$\oint_{C}^{}f(z)\ dz = \int_{\Gamma }^{}f(z)\ dz + \int_{\gamma }^{}f(z)\ dz + \int_{\Lambda }^{}f(z)\ dz + \int_{\psi_1}^{}f(z)\ dz + \int_{\psi_2}^{}f(z)\ dz$$
By Cauchy's residue theorem the integral over C equals $0$ as it doesn't enclose any poles.
Using Jordan's Lemma i found the intgral over $\Gamma$ to be $0$ as R approaches infnity, likewise
the integral over $\Lambda$ yields the answer $I$ I'm looking for as R approaches infinity.
Since $\gamma$ is a right-facing semicircle with radius $\epsilon$ centered at the point $z=i$ I parametarized it in the following way: $$z=\epsilon e^{i(\frac{\pi}{2}-t)}+i,\ t \in [0, \pi]$$
$$dz=-i\epsilon e^{i(\frac{\pi}{2}-t)}\ dt$$
The integrand after factorizing the denominator and is therefore
$$\frac{e^{i(\epsilon e^{i(\frac{\pi}{2}-t)}+i)}}{(\epsilon e^{i(\frac{\pi }{2}-t)}+i+i)(\epsilon e^{i(\frac{\pi }{2}-t)}+i-i)(\epsilon e^{i(\frac{\pi }{2}-t)}+i+1)}(-i\epsilon e^{i(\frac{\pi }{2}-t)})\ dt$$
silplifying:
$$(-i)\frac{e^{i(\epsilon e^{i(\frac{\pi }{2}-t)}+i)}}{(\epsilon e^{i(\frac{\pi }{2}-t)}+2i)(\epsilon e^{i(\frac{\pi }{2}-t)}+i+1)}\ dt$$ making the integral over $\gamma$ equal to $$-i\int_{0}^{\pi }\frac{e^{i(\epsilon e^{i(\frac{\pi }{2}-t)}+i)}}{(\epsilon e^{i(\frac{\pi }{2}-t)}+2i)(\epsilon e^{i(\frac{\pi }{2}-t)}+i+1)} \ dt$$
in the limit as $\epsilon$ goes to $0$, the integral approaches $$-i\int_{0}^{\pi } \frac{e^{-1}}{1+3i}\ dt = \frac{-\pi}{e}\left (\frac{3+i}{10}  \right )$$
However I am unsure how to evaluate the integrals over $\psi_1$ and $\psi_2$, if you can combine them into one integral when $\epsilon$ approaches zero since it would integrate over all numbers from $i$R to $0$ except for $z=i$ or if there's some obscure theorem or something I don't know about, otherwise I don't know if there's anything I can do except integrate it non-elementary which defeats the entire purpouse of contour integrating in the first place.
 A: I don't know if this is the kind of answer you're looking for, but there is a way to "avoid" integrating over $\psi_1$ and $\psi_2$ by evaluating the Cauchy Principal Value (P.V.). I decided to add it as an answer because there's not enough space in the comments, so feel free to say this post doesn't help or downvote it.
(Answer) Let's use the same $f(z)$ you defined. By Cauchy's Residue Theorem and by following the counterclockwise direction you defined in your post, you can rewrite $\oint_C f(z)dz$ as
$$0 = \int_{\Lambda}f(z)dz + \int_{\Gamma}f(z)dz + \text{P.V.}\int_{iR}^0 f(z)dz - i\pi\text{Res}(f(z), z=i),$$
which we can reorganize as
$$\int_{\Lambda}f(z)dz = 0  + \text{P.V.}\int_{0}^{iR} f(z)dz + i\pi\text{Res}(f(z), z=i).$$
(Notice by the Squeeze Theorem that the integral over $\Gamma$ converges to $0$ as $R\to\infty$. I can fill out the proof for that if you  need me to.)
Calculating that residue, we get
$$i\pi\text{Res}(f(z), z=i) = i\pi\lim_{z\to i}(z-i)\frac{e^{iz}}{(z+1)(z+i)(z-i)} = \frac{\pi}{4e}(1-i).$$
Next comes the tricky part, which is the Principal Value integral. (Notice without the P.V., that integral diverges). Letting $z=iu$, we can rewrite that integral as
$$\text{P.V.}\int_{0}^{iR} f(z)dz = \text{P.V.}\int_{0}^{R}\frac{ie^{-u}}{-iu^{3}-u^{2}+iu+1}du = \lim_{\epsilon\to 0^+}\left(\int_{0}^{1-\epsilon}\frac{ie^{-u}}{-iu^{3}-u^{2}+iu+1}du + \int_{1+\epsilon}^{\infty}\frac{ie^{-u}}{-iu^{3}-u^{2}+iu+1}du\right).$$
The reason why I say this post might not be helpful and why I put "avoid" in quotation marks is that I have no idea how to calculate those last two integrals. If someone could help me in the comments with that, that'd be great and I would credit you for it if I edit my post.
But I decided to rely on WolframAlpha and this is what I got:
https://www.wolframalpha.com/input?i=%28%281%2F4+-+i%2F4%29+%CF%80%29%2Fe+%2B+i%28integral+e%5E%28-x%29+%2F+%28-ix%5E3-x%5E2%2Bix%2B1%29+from+0+to+0.9999999%29+%2B+i%28integral+e%5E%28-x%29+%2F+%28-ix%5E3-x%5E2%2Bix%2B1%29+from+1.0000001+to+infinity%29
WolframAlpha also approximates the original integral as
https://www.wolframalpha.com/input?i=integral+e%5E%28ix%29+%2F+%28x%5E3%2Bx%5E2%2Bx%2B1%29+from+0+to+infinity
So just by numerical approximations, my process seems correct.
(Thoughts) If you wanted to evaluate $\int_{0}^{\infty}\frac{\sin\left(x\right)}{x^{3}+x^{2}+x+1}dx$ (or $\int_{0}^{\infty}\frac{\cos\left(x\right)}{x^{3}+x^{2}+x+1}dx$), the process would be the same except you'd be taking the imaginary (or real) part of each integral. I didn't try it out because I don't know if you want to try that.
