0
$\begingroup$

I was trying to Integrate the gravitational potential at r = x produced by a uniform sphere positioned at the origin. I wrote the following code:

potentialOfSphere[x_] = Integrate[
  Integrate[
  Integrate[
  -m/(4/3 Pi r^3)*g/Sqrt[(x-r1 Cos[ϕ])^2+(r1 Sin[ϕ])^2]*r1^2 Sin[ϕ], 
  {ϕ, 0, Pi}], 
  {θ, 0, 2 Pi}], {r1, 0, r}, Assumptions -> {x > 0, r > 0}]

The output on my computer is:

enter image description here

Based on my understanding, the second solution should only appear when x < r. Why does Mathematica skip that condition? Moreover, in the assumptions in my code, I already specified that x > 0, why does Mathematica still keep the x <= 0 condition in the first solution?

Thanks in advance!

$\endgroup$
  • $\begingroup$ The second solution does only appear when x<r. Because if that was not so, the condition for the first solution would be satisfied. AFAIK, the option Assumptions does not mean "give solutions restricted to a specific domain", rather it prevents the output of long constructions with ConditionalExpression. I'd be hard pressed to elaborate further though. $\endgroup$ – LLlAMnYP Mar 13 '15 at 22:02
  • $\begingroup$ @LLlAMnYP Thank you! I understand why won't it work now. Is there any way to let Mathematica to give solutions restricted to a specific domain? $\endgroup$ – fanmingyu212 Mar 13 '15 at 22:08
  • $\begingroup$ I can direct you to the documentation for Refine, but I'm afraid, I can't test this out myself right now, as I don't have Mathematica at home. $\endgroup$ – LLlAMnYP Mar 13 '15 at 22:21
  • $\begingroup$ FYI your Assumptions only apply to the outermost Integrate. Try setting $Assumptions (or better make it one triple integral). (cant test here,,) Also if all else fails you can wrap the whole thing in Simplify with your assumptions as an argument. $\endgroup$ – george2079 Mar 13 '15 at 23:32
  • $\begingroup$ @LLlAMnYP Thanks! I found Refine function really helpful. $\endgroup$ – fanmingyu212 Mar 14 '15 at 0:10
1
$\begingroup$
potentialOfSphere[x_] = Integrate[
  -m/(4/3 Pi r^3)*g/Sqrt[(x - r1 Cos[ϕ])^2 +
      (r1 Sin[ϕ])^2]*r1^2 Sin[ϕ],
  {r1, 0, r}, {θ, 0, 2 Pi}, {ϕ, 0, Pi},
  Assumptions -> {x > 0, r > 0}]

(gm(-2*r^3 + (r - x)^2*(2*r + x)* HeavisideTheta[r - x]))/ (2*r^3*x)

For x > r, this reduces to

potentialOfSphere[x] // Simplify[#, x > r] &

-((g*m)/x)

For x < r, this reduces to

potentialOfSphere[x] // Simplify[#, r > x] &

(gm(-3*r^2 + x^2))/(2*r^3)

For x == r

potentialOfSphere[r]

-((g*m)/r)

| improve this answer | |
$\endgroup$

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.