# How to compute this integral with a better precision?

As a first step I have a following integral

$$\int _0^n\int _0^n\log \left(x^2+y^2\right) dx dy$$

Symbolic computatition is in this case successfull.

 Assuming[n > 0, Integrate[Log[x^2 + y^2], {x, 0, n}, {y, 0, n}]]
(* 1/2 n^2 (-6 + \[Pi] + Log[4] + 4 Log[n]) *)


Unfortunately, this is not applicable for $$\frac{\int _0^n\int _0^n\int _0^n\log \left(x^2+y^2+z^2\right)dxdydz}{n^3}-2 \log n$$

First approach (takes one minute):

 Exp[With[{n = 10^20}, NIntegrate[Log[x^2 + y^2 + z^2], {x, 0, n}, {y, 0, n}, {z, 0, n}, WorkingPrecision -> 20]/n^3 - 2*Log[n]]]
(* 0.828859579971152074 *)


Only 9 decimals are correct.

The correct value is

 (* 0.828859579669279... *)


but I need much more decimal places.

• How did you obtain the correct value? – MarcoB Mar 1 '19 at 14:26
• During the analysis of the OEIS sequence oeis.org/A324425. Now is this value confirmed by Maple and PARI, currently is my best result 0.828859579669279286697229..., but I continue. – Vaclav Kotesovec Mar 1 '19 at 14:54
• Done (with Maple and PARI). Final result: 0.82885957966927928669722902077510302676910575597712114524404033179571834302214718 – Vaclav Kotesovec Mar 1 '19 at 20:48

The integral can be evaluated step by step analytically by Mathematica(!):

step 1: integration with respect to $$x$$:

ix = Assuming[{1 > x > 0, 1 > y > 0, 1 > z > 0}, Integrate[Log[x^2 + y^2+ z^2], {x, 0, 1} ]]

(*-2 + 2 Sqrt[y^2 + z^2] ArcTan[1/Sqrt[y^2 + z^2]] + Log[1 + y^2 + z^2]*)


step 2: change to polar coordinates {y, z} -> {r, φ} and integration with respect to $$r$$:

ixr = Integrate[(-2 + 2 r ArcTan[1/r] + Log[1 + r^2])*r, {r, 0, 1/Cos[φ]}, Assumptions -> 0 <= φ <= Pi/4]

(*1/6 (Log[1 + Sec[φ]^2] + (-7 + 3 Log[1 + Sec[φ]^2]) Sec[φ]^2 + 2 (π - 2 ArcTan[Sec[φ]]) Sec[φ]^3)*)


step 3: integration with respect to φ (& symmetry)

int = 2 (*symmetry*) Integrate[ixr, {φ, 0, Pi/4}]  (* several minutes...*)
(*...very large expression*)


step 4: numerical result, at 100 digits precision

N[int,100]
(*-0.1877045233940395783616177392988430392679356025497760369025058103474277678950621609128458904668470738 + 0.*10^-101 I*)


That's it.

• I used your output from Step 2 as input into Step 3 and Step 3 finished with a correct result! Great! Thank you! – Vaclav Kotesovec Mar 3 '19 at 17:14
• You're welcome. Meanwhile I tried Integrate[ 2 Log[x^2 + r^2] r, {\[CurlyPhi], 0, Pi/4} , {r, 0, 1/Cos[\[CurlyPhi]]}, {x, 0, 1} ] which evaluates faster! – Ulrich Neumann Mar 3 '19 at 19:08

If I understand your problem right you are looking for the expression Exp[int]

int=NIntegrate[Log[x^2 + y^2 + z^2], {x, 0, 1}, {y, 0, 1}, {z, 0, 1} ,WorkingPrecision -> 20]
(*-0.18770452339341844818*)


which evaluates to

Exp[int]
(*0.82885957966979411640*)


Your initial integral evaluates to Integrate[Log[x^2 + y^2 + z^2], {x, 0, Infinity}, {y, 0, Infinity}, {z, 0,Infinity} ]~n^3(int+2 Log[n])

Addendum The evaluationtime can be reduced by spliting the integration in an analytical part and a numerical part (WorkingPreciosion ->50)

ix=Assuming[{1 > x > 0, 1 > y > 0, 1 > z > 0},Integrate[Log[x^2 + y^2 + z^2], {x, 0, 1} ]]
(*-2 + 2 Sqrt[y^2 + z^2] ArcTan[1/Sqrt[y^2 + z^2]] + Log[1 + y^2 + z^2]*)
int = NIntegrate[ix, {y, 0, 1}, {z, 0, 1} , WorkingPrecision -> 50]
(*-0.18770452339403957762387317912897890450092619079171*)
Exp[int]
(*0.82885957966927928730871566682079393522009653756758*)

• Yes, this is same problem, thank you! But also in your result is only 12 decimal places correct. I need 50-100 decimals. – Vaclav Kotesovec Mar 1 '19 at 13:07
• Now you have 17 decimals correct. Result from Maple (and also from PARI) is 0.8288595796692792866972... – Vaclav Kotesovec Mar 1 '19 at 14:24
• Sorry, I showed you how to increase precision and speed up the calculation, though the rest of the competition is up to you! – Ulrich Neumann Mar 1 '19 at 14:49
• By the way, I found an analytical solution: -0.1877045233940395783616177392988430392679356025497760369025058103474\ 2776789506216091284589046684707384936571455778033531256385218569817235\ 926024308783590613948321678516303541013830245033948915807009883 (*200 decimals*) – Ulrich Neumann Mar 2 '19 at 16:41
• If you have a closed form for this constant, please publish it. – Vaclav Kotesovec Mar 2 '19 at 22:20