# Issues with Nintegrate - different methods yielding different values (both giving warnings)

I am integrating the following function

$$\begin{equation} \frac{1}{2d^{2}}\times\frac{\sqrt{\omega_{c}\left|t_1-t_2\right|}-\sqrt{\pi}e^{\frac{1}{\omega_{c}\left|t_1-t_2\right|}}\text{erfc}\left(\frac{1}{\sqrt{\omega_{c}\left|t_1-t_2\right|}}\right)}{\left(\omega_{c}\left|t_1-t_2\right|\right){}^{3/2}} \end{equation}$$

\[Delta]Et\[Delta]E0[t1_,t2_,\[Omega]c_,d_]:=(1/(2*d^2))*((Sqrt[Abs[t1-t2]*\[Omega]c]-E^(1/(Abs[t1-t2]*\[Omega]c))*Sqrt[Pi]*Erfc[1/Sqrt[Abs[t1-t2]*\[Omega]c]])/(Abs[t1-t2]*\[Omega]c)^(3/2))


with $$\omega_c=1$$ and $$d=1$$, yielding the following limits

Limit[\[Delta]Et\[Delta]E0[t1, t2, 1, 1] /. t1 - t2 -> t, t -> 0]
(*1/4*)
Limit[\[Delta]Et\[Delta]E0[t1, t2, 1, 1] /. t1 - t2 -> t, t ->Infinity]
(*0*)


The integral is given by

Nint[(t_)?NumericQ,(\[CapitalOmega]_)?NumericQ] := NIntegrate[\[Delta]Et\[Delta]E0[t1, t2, \[Omega]ca, da]*E^(I*\[CapitalOmega]*(t1-t2)),{t1,zero,t},{t2,zero,t}, AccuracyGoal -> 8,PrecisionGoal -> 8, MaxRecursion -> 50, WorkingPrecision -> 100]


However, for the "DoubleExponential" method, I am getting the message: On the other hand, if I choose to not declare any particular method, I obtain Note: it is also interesting to note that different Methods are yielding different values for this integral. So I do not know which result I should trust.

As suggested by @Akku14's answer, I could use the following alternative integral instead

Ninta[t_, \[CapitalOmega]_] := 2*NIntegrate[\[Delta]Et\[Delta]E0[t1, t2, 1, 1]*Cos[\[CapitalOmega]*(t1 - t2)], {t1, 0, t}, {t2, 0, t1}, Exclusions -> t1 == t2]
Ninta[10, 1]


However, this is also giving me some warnings/errors • In view of the output of Normal[Series[(1/(2*d^2))*((Sqrt[RealAbs[t1 - t2]*\[Omega]c] - E^(1/(Abs[t1 - t2]*\[Omega]c))*Sqrt[Pi]* Erfc[1/Sqrt[RealAbs[t1 - t2]*\[Omega]c]])/(RealAbs[ t1 - t2]*\[Omega]c)^(3/2)) /. t1 - t2 -> x, {x, 0, 1}]] i.e. $\frac{\sqrt{\pi } \left(\frac{1}{\text{$\omega $c}}\right)^{3/2} e^{\frac{1}{x \text{$\omega $c}}}}{2 d^2 x^{3/2}}-\frac{\sqrt{\pi } e^{\frac{1}{x \text{$\omega $c}}}}{2 d^2 x^{3/2} \text{$\omega $c}^{3/2}}$ if $x>0$, there are strong doubts about the convergence of this improper integral at the origin. Sep 29 at 12:29
• @user64494 I took the limit of this function, and I have $\rightarrow 1$ for $x\rightarrow 0$ and $\rightarrow 0$ for $x\rightarrow \infty$. So what do you mean by improper integral at the origin? Sep 29 at 12:42
• People here generally like users to post complete, working Mathematica code (an MWE). It makes it convenient for them and more likely you will get someone to help you. Sep 29 at 13:01
• @sined: Can you support your claim " I have →1 for x→0" by code? TIA. Sep 29 at 13:21
• @sined: Sorry, you still don't present any Mathematica code for your claim " I have →1 for x→0". BTW, there is no x in the codes from your question. Sep 29 at 18:35

Since the real part of the integrand is symmetric about t1==t2, simply double the integral and integrate t2 from zero to t1 with no problems.The imaginary part is antisymmetric and disappears. Therefore work only with Cos

By the way, this is no improper integral, as limit t2->t1 is a finite number. Limit[\[Delta]Et\[Delta]E0[t1, t2, 1, 1]*E^(I*1*(t1 - t2)), t2 -> t1] is 1/4

Edit

Add exclusions to avoid overflow at t1==t2 where only limit is defined.

Nint[t_, \[CapitalOmega]_] :=
2 NIntegrate[\[Delta]Et\[Delta]E0[t1, t2, 1, 1]*Cos[\[CapitalOmega] (t1 - t2)], {t1,
0, t}, {t2, 0, t1}, Exclusions -> t1 == t2]

Nint[10, 1]

(*   1.73825   *)

• Just to make sure I am following, are you using the following identity? $\frac{1}{2}\int_{t_{0}}^{t}dt_{1}\int_{t_{0}}^{t}dt_{2}V_{I}\left(t_{1}-t_{2}\right)e^{i\Omega\left(t_{1}-t_{2}\right)}=\int_{t_{0}}^{t}dt_{1}\int_{t_{0}}^{t_{1}}dt_{2}V_{I}\left(t_{1}-t_{2}\right)e^{i\Omega\left(t_{1}-t_{2}\right)}$ Sep 29 at 20:36
• This is only valid for the given integrand. Have al look with Plot3D[\[Delta]Et\[Delta]E0[t1, t2, 1, 1]*Cos[(t1 - t2)], {t1, 0, 10}, {t2, 0, 10}]  and for imaginary part with Sin instead Cos. Sep 29 at 20:36
• I have tried to perform the integration as suggested by you, but I'm still encountering some issues. Sep 29 at 21:01
• i am working with version "8.0 for Microsoft Windows (32-bit) (December 9, 2010)". May be other versions react different. Sep 29 at 21:04
• What is if you try integrate t2 from t1 to t Nint[t_, \[CapitalOmega]_] := 2 NIntegrate[\[Delta]Et\[Delta]E0[t1, t2, 1, 1]* Cos[\[CapitalOmega] (t1 - t2)], {t1, 0, t}, {t2, t1, t}, Exclusions -> t1 == t2]  Sep 29 at 21:07