# NIntegrate does not evaluate this finite integral composed of divergent parts

I would like to numerically evaluate the following integral:

$$I = \int_{-\infty}^\infty d\tau_3 \int_{-\infty}^\infty d\tau_4 \frac{1}{1+\tau_3^2} \left\lbrace \frac{2}{1+\tau_4^2} \log (\tau_3 - \tau_4)^2 + \left(\frac{1}{1+\tau_3^2} + \frac{1}{1+\tau_4^2} \right) \phi(\tau_3,\tau_4) \right\rbrace \tag{1}$$

with $$\phi(r,s)$$ a complicated function as defined in the code below. Note that the first term with the log is divergent, but that this divergence is canceled by another divergence present in the 2nd term with the $$\phi$$-function. When I try to evaluate the integral, NIntegrate stays unevaluated. Why is that, and what is the numerical value of this integral?

Here is the code I used so far:

R[τ3_, τ4_] := (1 + τ4^2)/(1 + τ3^2);
S[τ3_, τ4_] := (τ3 - τ4)^2/(1 + τ3^2);
a[τ3_, τ4_] := 1/4 Sqrt[4*R[τ3, τ4]*S[τ3, τ4] - (1 - R[τ3, τ4] - S[τ3, τ4])^2] ;
F[τ3_, τ4_] := I Sqrt[-((1 - R[τ3, τ4] - S[τ3, τ4] - 4 I*a[τ3, τ4])/(1 - R[τ3, τ4] - S[τ3, τ4] + 4 I*a[τ3, τ4]))];
phi[τ3_, τ4_] := 1/a[τ3, τ4] Im[PolyLog[2, F[τ3, τ4]*Sqrt[R[τ3, τ4]/S[τ3, τ4]]] + Log[Sqrt[R[τ3, τ4]/S[τ3, τ4]]] Log[1 - F[τ3, τ4]*Sqrt[R[τ3, τ4]/S[τ3, τ4]]]];
NIntegrate[1/(1^2 + τ3^2) (2/(1^2 + τ4^2)Log[(τ3 - τ4)^2] + (1/(1^2 + τ3^2) + 1/(1^2 + τ4^2)) phi[τ3, τ4]), {τ3, -∞, ∞}, {τ4, -∞, ∞}]


UPDATE 1:

I think I understand now where the problem comes from. When I plot the integrand, the line $$\tau_3 = \tau_4$$ seems indeterminate (as can be seen in the image below), and that is also what Mathematica returns when I try to naively evaluate the integrand at this set of values. However I don't believe that this is the case; I think that the function is continuous at those points, but that is not so easy to show/check. Any idea how I could proceed?

UPDATE 2:

Adding Exclusions -> {τ3 == τ4} in NIntegrate gives the result 69.6141. Is it okay to just remove that line, if I know that the integral is finite? I am not completely sure what happens at that line still, but I expect the function to be smooth everywhere. Is this result trustworthy?

Changing the working precision to $$10$$, I now get 92.30343541 so I am not sure what to believe anymore...

• Note the I in the definition of F is the imaginary unit $i$. I am not sure why it turned out to be a capital $I$ when I copy-pasted it. – Jxx Mar 15 '20 at 18:46
• Captial I is the symbol for the imaginary unit. – Michael E2 Mar 15 '20 at 19:32

You could use Exclusions and an open rule one the cartesian product:

NIntegrate[
1/(1^2 + τ3^2) (2/(1^2 + τ4^2) Log[(τ3 - τ4)^2] + (1/(1^2 + τ3^2) +
1/(1^2 + τ4^2)) phi[τ3, τ4]),
{τ3, -∞, ∞}, {τ4, -∞, ∞},
Exclusions -> τ3 == τ4, Method -> "GaussKronrodRule"]

(*  92.3037  *)

• So you think that the result you quote is trustworthy? What is the method you are using for the numerical integration exactly? What happens if you increase the working precision? – Jxx Mar 15 '20 at 19:34
• Without specifying the method, I obtain 92.3035943050 by working precision 12, but 80.958876366673 by working precision 14... And 92.30374811447302 again by working precision 16! What could that mean? – Jxx Mar 15 '20 at 19:37
• The oscillations between the results at different working precisions is actually a lot milder with GaussKronrodRule, but still of the order $\sim 0.0001$ between working precision 14 and 16. I guess I cannot expect too high precision with such a complicated integrand. – Jxx Mar 15 '20 at 19:45
• @Jxx I was going to ask how accurate to you want the result to be? I don't think I would lower the precision below \$MachinePrecision. The error rule is in a sense estimating zero, which suffers from subtractive-cancellation round-off error. Lowering the precision probably lowers the reliability of the error estimate. A few ways to test stability at machine precision: (1) Asymmetric subdivision of interval: {\[Tau]3, -\[Infinity], 1, \[Infinity]} (2) Force extra subdivision: e.g. MinRecursion -> 2 or higher. (3) Tweak PrecisionGoal (you will run into numerical difficulties around 10) – Michael E2 Mar 15 '20 at 20:09
• Nice advices, I will play with these settings and see how far I can take the precision. I do not have a precision goal really, but if I am lucky I can guess a closed form for the result (it has to be added with other results first though). – Jxx Mar 15 '20 at 21:04