4
$\begingroup$

I need to evaluate the following integral:

 Integrate[1/Sqrt[(x - x1)^2 + (y - y1)^2 + (z - z1)^2], 
 Element[{x, y, z}, Ball[{0, 0, 0}, R]] , 
 Element[{x1, y1, z1}, Ball[{0, 0, 0}, R1]], 
 Assumptions -> R > 0 && R1 > 0 ]

and Mathematica says the integral is 0, which is obviusly wrong. Am I doing something wrong?

$\endgroup$
13
  • $\begingroup$ Wait, what does this mean? I want a double integral in $x,y,z$ and $x1, y1, z1$, with the former variables in a ball of radius $R$ and the latter in a ball of radius $R1$. In your suggestions, $R1$ doesn't show up $\endgroup$
    – tommy1996q
    Commented Jul 7 at 12:03
  • $\begingroup$ I think his is looking for the gravitational energy between two balls, one placed inside the other—thus the double integral. @tommy1996q, I think there will be a “ball” of singularities in that intégrantd. But, I think your zero is probably not correct. (This comment referred to an earlier but deleted comment—i think the OP’s comment above also referred to the deleted comment) $\endgroup$ Commented Jul 7 at 12:04
  • $\begingroup$ @CraigCarter nope, it's an entirely different problem, but it doesn't really matter. The point is that it's a very simple integration (conceptually at least) and I do not understand how Mathematica could give an answer so wrong. Trivially, I am integrating something which is always greater than 0. $\endgroup$
    – tommy1996q
    Commented Jul 7 at 12:07
  • $\begingroup$ Greater than zero, yes, but infinite at points in the smaller ball—i think. The 0 seems like a bug in any case. $\endgroup$ Commented Jul 7 at 12:09
  • 2
    $\begingroup$ @tommy1996q "The point is that it's a very simple integration..." So what is the correct answer when you know it is very simple? $\endgroup$ Commented Jul 7 at 16:15

1 Answer 1

4
$\begingroup$

Not an answer, but this won't fit in comment:

    Integrate[1/Sqrt[(x - x1)^2 + (y - y1)^2 + (z - z1)^2], 
 Element[{x, y, z}, 
  RegionDifference[Ball[{0, 0, 0}, bigR], Ball[{0, 0, 0}, littleR]]], 
 Element[{x1, y1, z1}, Ball[{0, 0, 0}, littleR]], 
 Assumptions -> 0 < littleR < bigR]  (*gives 0*)

and

Integrate[1/Sqrt[(x - x1)^2 + (y - y1)^2 + (z - z1)^2], 
 Element[{x, y, z}, 
  RegionDifference[Ball[{0, 0, 0}, bigR], 
   Ball[{0, 0, 0}, littleR - epsilon]]], 
 Element[{x1, y1, z1}, Ball[{0, 0, 0}, littleR]], 
 Assumptions -> 0 < littleR < bigR && 0 < epsilon < littleR] (*gives 0*)

and

NIntegrate[1/Sqrt[(x - x1)^2 + (y - y1)^2 + (z - z1)^2], 
 Element[{x, y, z}, 
  RegionDifference[Ball[{0, 0, 0}, 2], Ball[{0, 0, 0}, 1 - 0.1]]],
 Element[{x1, y1, z1}, Ball[{0, 0, 0}, 1 - 0.1]]
 ] (*gives 61.2 but with warnings about accuracy*)

I think that 0 is an incorrect result and worth a bug report.

NIntegrate[1/Sqrt[(x - x1)^2 + (y - y1)^2 + (z - z1)^2], 
 Element[{x, y, z}, Ball[{0, 0, 0}, 1]], 
 Element[{x1, y1, z1}, Ball[{0, 0, 0}, 2]]] (*gives 71.6 with warnings*)

but I don't trust that result at all.

$\endgroup$
1
  • $\begingroup$ Thanks! Later I'll look more into it. Unluckily I'd really need some analytic solution. But yeah, 0 is most defnitily wrong. I'll report the bug $\endgroup$
    – tommy1996q
    Commented Jul 7 at 15:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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