# Integrations done by residues and numericals don't agree

I want to integrate

$$\int_{-\infty}^{\infty} dw \hspace{0.51em}\frac{w^{n} e^{i wt}}{(w^{2}-\Omega^{2})^2 +(\gamma w)^2}$$

I did so using contour integration because it has the poles:

$$w=\mp \frac{i\gamma}{2} \pm \sqrt{\Omega^{2}-\frac{\gamma^{2}}{4}}$$

resulting in:

$$2^{1-n} i \pi \left(\frac{e^{-\frac{1}{2} \tau \left(\gamma +i \sqrt{4\Omega ^2-\gamma ^2}\right)} \left(-\sqrt{4 \Omega ^2-\gamma^2}+i \gamma \right)^n}{\gamma \left(\sqrt{4 \Omega ^2-\gamma^2}-i \gamma \right)+4 i \Omega ^2}-\frac{e^{\frac{1}{2} i \tau \left(\sqrt{4 \Omega ^2-\gamma ^2}+i \gamma \right)}\left(\sqrt{4 \Omega ^2-\gamma ^2}+i \gamma \right)^n}{\gamma \left(\sqrt{4 \Omega^2-\gamma ^2}+i \gamma \right)-4 i \Omega^2}\right)$$

I decided that I wanted to check with the numerical results because I hadn't done contour integration in a while, for that I did the following, I chose $$n = 3, \gamma = 3, \Omega = 4$$, and plotted for $$\tau$$

f[n_, γ_, Ω_, τ_] := I 2^(1 - n) Pi((E^(-(1/2) τ (γ + I Sqrt[
-γ^2 + 4 Ω^2])) (I γ - Sqrt[-γ^2
+ 4 Ω^2])^n)/(4 I Ω^2 + γ (-I γ + Sqrt[-γ^2
+ 4 Ω^2])) - (E^(1/2 I τ (I γ + Sqrt[-γ^2 + 4 Ω^2]))
(I γ + Sqrt[-γ^2 + 4 Ω^2])^n)/(-4 I Ω^2 + γ
(I γ + Sqrt[-γ^2 + 4 Ω^2])))
Plot[f[3, 3, 4, τ], {τ, 0, 5}]


and then tried the same with numerical integration

int[n_, γ_, Ω_, τ_] := γ w^n Exp[I w τ]/((w^2 -
Ω^2)^2 + (γ w)^2)
fau[τ_] := NIntegrate[Im[int[3, 3, 4, τ]], {w, -Infinity, Infinity}]
Plot[fau[τ], {τ, 0, 5}]
fau[τ_] := NIntegrate[Re[int[3, 3, 4, τ]], {w, -Infinity, Infinity}]
Plot[fau[τ], {τ, 0, 5}]


However the obtained results are quite different, so my main question is is it possible that numerical algorithms suffer with these kind of integrals making them divergent when they're not?

• For $n = 3$, your integrand scales asymptotically as $e^{iwt}/w$. I wouldn't expect that to be convergent. Aug 3, 2021 at 13:50
• Also, is the $\Omega$ in the denominator of your integrand supposed to be squared? Aug 3, 2021 at 13:55
• it is supposed to be squared sorry about that Aug 3, 2021 at 13:56
• I mean I maybe deeply confused but $$\int_{-\infty}^{\infty} e^{iwt}/w dw$$ converges, it's proportional to the sign function (inverse fourier transform of 1/w ) Aug 3, 2021 at 13:58
• It is conditionally convergent, behaving like the alternating harmonic series (-1)^n/n. I would not b e surprised if NIntegrate has troubles with it. Aug 3, 2021 at 14:06

You incorrectly found the poles. See the output of

ToRadicals[Solve[((w^2 - \[CapitalOmega]^2)^2 + (\[Gamma] w)^2) == 0, w,
Assumptions -> \[CapitalOmega] > 0 && \[Gamma] > 0],
Assumptions -> \[CapitalOmega] > 0 && \[Gamma] > 0]


Here is its part

$$w\to \fbox{i \left( \begin{array}{cc} \{ & \begin{array}{cc} \frac{1}{2} \left(-\gamma -\sqrt{\gamma ^2-4 \Omega ^2}\right) & \gamma >0\land 0<\Omega \leq \frac{\gamma }{2} \\ \frac{1}{2} \left(\sqrt{\gamma ^2-4 \Omega ^2}-\gamma \right) & \gamma >0\land \Omega =\frac{\gamma }{2} \\ \text{Root}\left[\Omega ^4+\text{\#1}^4+\left(2 \Omega ^2-\gamma ^2\right) \text{\#1}^2\&,1\right] & \text{True} \\ \end{array} \\ \end{array} \right)\text{ if }\gamma >2 \Omega }$$

The symbolic integration

n = 3; \[CapitalOmega] = 4; \[Gamma] = 3; \[Tau] = 1;
Integrate[w^n Exp[I *
w *\[Tau]]/((w^2 - \[CapitalOmega]^2)^2 + (\[Gamma] w)^2), {w,-\Infinity, Infinity}]


(E^(-I Sqrt[ 1/2 (23 - 3 I Sqrt[55])]) (-23 + 3 I Sqrt[55] + (23 + 3 I Sqrt[55]) E^( 1/2 I (Sqrt[46 - 6 I Sqrt[55]] + Sqrt[ 46 + 6 I Sqrt[55]]))) \[Pi])/(6 Sqrt[55])

N[%]

8.88178*10^-16 - 0.980392 I

is in accordance with

NIntegrate[w^n Exp[I * w *\[Tau]]/((w^2 - \[CapitalOmega]^2)^2 + (\[Gamma] w)^2),
{w, \-Infinity, Infinity}, AccuracyGoal -> 4, PrecisionGoal -> 4,
Method -> "ExtrapolatingOscillatory"]


0. - 0.980372 I

• I did have a typo because I wrote $\frac{\gamma}{4}$ instead of $\frac{\gamma}{2}$ but it was right in the code, my bad just edited the question Aug 3, 2021 at 16:08
• @GerardoSuares: Your mistakes are more serious than a typo. Aug 3, 2021 at 16:14
• @GerardoSuares: I think four (even three) parameters are too many for Integrate in this case. Aug 3, 2021 at 16:17
• The integral was found by residue integration rather than using Integrate, and actually no, it was just the typo once I added AccuracyGoal -> 4, PrecisionGoal -> 4, Method -> "ExtrapolatingOscillatory" to NIntegrate the answers agree N[f[3, 3, 4, 1]] gives -2.94118 I while NIntegrate gives -2.94112 I (Including the gamma meaning 3*- 0.980372 I) would you mind telling me how you knew you should include those? and thanks I already marked your answer as correct Aug 3, 2021 at 16:24