1
$\begingroup$

I want to evaluate an integral that involves two disjoint unit disks $D_1$ and $D_2$. $D_1$ is centered at $(-2,0)$ and $D_2$ is centered at $(0,2)$. The integral I want to compute is

$$I = \int_{D_1} \int_{D_2} \log|x-y| dy dx.$$

I looked at the in-built Python integration methods and also the quadpy library but although they have lots of options for integration over a single disk, I couldn't find anything that can help me with integrating over two disjoint disks.

Is it possible to evaluate this integral in Mathematica? I don't need an optimum method, I just need to obtain the value of this integral.

$\endgroup$
2
  • 2
    $\begingroup$ The exact value of the integral under consideration is $\pi^2\log 4$. The function $\log |x-y|$ is harmonic and the mean value property can be twice applied (see en.wikipedia.org/wiki/Harmonic_function). $\endgroup$
    – user64494
    Feb 2, 2019 at 21:18
  • $\begingroup$ Mathematica calculates the integral under consideration, producing $\frac{1}{4} \pi ^2 (-1+2 i \pi +\log (16)) $. A bug was submitted by me. $\endgroup$
    – user64494
    Feb 3, 2019 at 18:51

1 Answer 1

5
$\begingroup$
NIntegrate[
 Log[Norm[{x1, x2} - {y1, y2}]], 
 {x1, x2} ∈ Disk[{-2, 0}, 1], 
 {y1, y2} ∈ Disk[{2, 0}, 1]
 ]

13.6822

(the actual result being 13.682176919165677),

In order to enter , just type Esc e l Esc.

In order to increase the precision, use the option PrecisionGoal.

Edit

Another possibility that relieves Mathematica from the need to discretize the disks and that allows her to use higher-order quadrature formulas is to employ polar coordinates on each of the disks:

NIntegrate[
 Log[Norm[{r1 Cos[θ1] - 2,r1 Sin[θ1]} - {r2 Cos[θ2] + 2,r2 Sin[θ2]}]] r1 r2,
 {r1, 0, 1}, {θ1, -Pi, Pi},
 {r2, 0, 1}, {θ2, -Pi, Pi},
 Method -> "LocalAdaptive"
 ]
$\endgroup$
13
  • $\begingroup$ Whoah, that's very nice thanks! I actually just managed to get it going in with some manual change of variables in Python with nquad and I got the result $13.682176927714263$ $\endgroup$ Feb 2, 2019 at 15:55
  • $\begingroup$ You're welcome. $\endgroup$ Feb 2, 2019 at 15:57
  • $\begingroup$ Great, I just needed a decent approximation, even the first 4 decimals places would suffice but there's no harm being even more accurate! $\endgroup$ Feb 2, 2019 at 15:57
  • $\begingroup$ You can also lower the PrecisionGoal for more speed... $\endgroup$ Feb 2, 2019 at 15:58
  • $\begingroup$ Use of Norm is not a good idea since this equals Sqrt[Abs[x1 - x2]^2 + Abs[y1 - y2]^2]. $\endgroup$
    – user64494
    Feb 2, 2019 at 20:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.