# NIntegrate fails to converge for oscillating improper double integral with pole

How to properly numerically integrate this double integral? I get always errors like NIntegrate failed to converge....

NIntegrate[Exp[(I*t-t^2)/(3*t^2+1)+I*t*x]*x/(3*t^2+1),{t,-\[Infinity],\[Infinity]},{x,-\[Infinity],\[Infinity]}]


I tested different options, like Exclusions -> (3*t^2 + 1 == 0), Method -> "GlobalAdaptive", Method -> "LocalAdaptive", Method -> "Trapezoidal", WorkingPrecision -> 20, without success. If I approach the infinite integration boundaries by $$\pm50$$, or $$\pm 100$$, or $$\pm200$$ I always get the result $$-6.28319$$ close to $$-2\pi$$.

MMA 13

• The correct answer is $-2\pi$, never mind what @user64494 says (s/he does not understand this kind of integral). The trick is to use $\int_{-\infty}^{\infty} e^{i t x}x dx = -2\pi i\delta'(t)$ where $\delta'$ is the first derivative of the Dirac $\delta$-function. Commented Jan 18, 2022 at 17:37
• Note that @MariuszIwaniuk switch the order of x and t. This is important, as the integral in the other order diverges. (Fubini's theorem does not apply.) -- oops, Mariusz deleted his comment.... Commented Jan 18, 2022 at 17:59
• @user64494 Once again, you need to read and understand Bracewell. Commented Jan 18, 2022 at 18:41
• @user64494 I can only lead the horse to water but cannot make it drink. If you don't want to see why these integrals are the way they are, feel free to believe whatever you like. Commented Jan 18, 2022 at 19:35
• @user64494 Maybe you will believe your friends at MSE. math.stackexchange.com/questions/556567/dirac-delta-symmetry. Take the derivative of both sides of the well accepted equation mentioned there and you will get Roman's equation. Commented Jan 19, 2022 at 3:31

@Granular: Using Roman and Bill's hints:

$$\delta(t)=\frac{1}{2 \pi}\int_{-\infty}^{\infty} e^{i t x}dx$$ then via Leibniz's rule we have: $$\delta'(t)=\frac{i}{2\pi}\int_{-\infty}^{\infty} xe^{i t x} dx$$ so that we can write the double integral as:

$$I=\int_{-\infty}^{\infty}\int_{-\infty}^{\infty}\left(\frac{1}{3 t^2+1} e^\frac{-t^2+i t}{3 t^2+1}\right)xe^{itx}{\rm d}x{\rm d}t$$ so that $$I=-2\pi i\int_{-\infty}^{\infty}\frac{1}{3t^2+1}e^{\frac{-t^2+it}{3t^2+1}}\delta'(t){\rm d}t$$ and the last integral is easily evaluated analytically by Mathematica:

Integrate[
1/(3 t^2 + 1)
Exp[(-t^2 + I t)/(3 t^2 + 1)] D[DiracDelta[t],
t], {t, -\[Infinity], \[Infinity]}]
(* -i *)


or $$I=-2\pi$$

• The double improper integral $$I=\int_{-\infty}^{\infty}\int_{-\infty}^{\infty}\left(\frac{1}{3 t^2+1} e^\frac{-t^2+i t}{3 t^2+t}\right)xe^{itx}\,dx\,dt$$ does not exist in traditional math. If the one exists, then both iterated integrals should exist, but this is not true (see my comment to the question). All your formal transformations are built on the sand. Commented Jan 19, 2022 at 17:27
• Can you explain which steps in the analysis above you feel are wrong? Surely the first statement is correct. Is the application of Leibniz's rule ok?
– josh
Commented Jan 19, 2022 at 17:47
• @user64494. Traditional or Non-traditional math it is still math. Commented Jan 19, 2022 at 17:58
• @MariuszIwaniuk: If you have arguments, please, state those instead of emotional ungrounded words. Commented Jan 19, 2022 at 18:18
• @user64494 What do you mean by "traditional math"? In the kind of math I use most frequently, we have been using delta functions for about 90 years, and the related Heaviside functions for about 130 years. The fact that you haven't studied it does not make it wrong or even non-traditional. The fact that you are reading this is testimony to its usefulness, since the data links that transmit these words to you depend on engineering that employs this math. Commented Jan 19, 2022 at 18:38

The integrals, where $$f(x,t)$$ is the OP's integrand, $$\int_{{\Bbb R}^2} f(x,y) \; dA \,, \qquad \int_{-\infty}^{\infty}\left(\int_{-\infty}^{\infty}f(x,t)\;dx\right)\,dt \,,$$ are, strictly speaking, divergent; however, the following seems to converge: $$\int_{-\infty}^{\infty}\left(\int_{-\infty}^{\infty}f(x,t)\;dt\right)\,dx \,. \tag{1}$$ So if there is a way to assign a value to the integral, it should be the value in (1). How to assign values to divergent or improper integrals has been extensively discussed for a century but goes back further to rather famous work by Euler and Cauchy on sums and integrals. Those interested in the mathematics are encouraged to ask their questions on math.SE.

Here's the fastest way I found to compute (1), although due to how long things took, my explorations were limited. I was about to post it when @MariuszIwaniuk posted a comment that seemed similar, which was soon deleted. Nonetheless I waited, thinking an answer might be forthcoming, but soon another similar comment appeared.

integrand = Exp[(I t - t^2)/(3*t^2 + 1) + I*t*x]*x/(3*t^2 + 1);
liRe = NIntegrateLevinIntegrandReduce[
integrand /. {{x -> x}, {x -> -x}} // Mean // (* symmetrized *)
Re // ComplexExpand // Simplify             (* real part only *)
, t];
levinopts =
Normal@KeyDrop[liRe@"Rules", "Variables"] /.
HoldPattern["DifferentialMatrices" -> {dm_, ___}] :>
"DifferentialMatrix" -> dm;
lRe[x0_?NumericQ] := Block[{x = x0},
NIntegrate[
ifunc[x, t] (* ignored when full Levin Rule options are given *),
{t, -Infinity, Infinity},
Method -> {"LevinRule", Sequence @@ levinopts},
PrecisionGoal -> 6, MaxRecursion -> 20]
];


The value (of the real part) of (1) agrees with $$2\pi$$ to seven digits in this approximation:

PrintTemporary@Dynamic@{Clock[Infinity]}; (* running timer *)
2 NIntegrate[
lRe[x],
{x, 0, Infinity}, PrecisionGoal -> 4] // AbsoluteTiming
Last[%] + 2 Pi
(*  {77.6966, -6.28319}  *)
(*  3.29801*10^-8        *)

• Is this a numerical integration without warning messages or were the warning messages suppressed? Would be nice to give a reference about improper integrals of this type. Commented Jan 18, 2022 at 21:19
• @granularbastard I got no messages (V13.0). Commented Jan 18, 2022 at 21:20
• The code fails if we double the values for both PrecisionGoal. Why is it so instable? Commented Jan 18, 2022 at 21:35
• @granularbastard The integral is oscillatory, which invites numerical instability. The Levin rule tries to handle that in the $t$ integral. However, the maximum magnitude of the integrand (over $t$) is roughly proportional to $x$ as $x \rightarrow \infty$. As $x$ grows, numerical instability seems to return (that's my guess). Theoretically, it should be handled by increasing WorkingPrecision`, but the computations take too long for me to verify it. Commented Jan 18, 2022 at 21:48
• @user64494 (1) For a given $x$, the $dt$ integral converges, so strictly speaking the approximates the value, not the principal value. Do not let the numerical tricks fool you. They are done for speed and accuracy. (2) I already said the double integral diverges, and I don't understand why it needs repeating. (3) Your last action shows what a jerk you can be. Commented Jan 18, 2022 at 22:04