Message Boards Message Boards

0
|
3448 Views
|
7 Replies
|
1 Total Likes
View groups...
Share
Share this post:

Result of simple integral refuses to simplify

Posted 3 years ago

I am using a trial version of Mathematica 12.2.0.0 on a 64-bit version of Windows 10. I am trying to evaluate simple integrals that come up in classical electrodynamics. In the first case, I evaluate

Integrate[1/(x^2 + y^2 + z^2)^(3/2), {x, -a, a}, {y, -a, a}, Assumptions -> a > 0 && z > 0]

and get a reasonable result:

(4 ArcTan[a^2/(z Sqrt[2 a^2 + z^2])])/z

If I rename the limits of integration under a basic transformation (a -> a/2), as such:

Integrate[1/(x^2 + y^2 + z^2)^(3/2), {x, -a/2, a/2}, {y, -a/2, a/2}, 
 Assumptions -> a > 0 && z > 0]

I get the following result:

(1/z)I (-Log[-a^2 + 2 I a z - 4 z^2 - Sqrt[2] a Sqrt[a^2 + 2 z^2]] - 
   Log[a^2 + 2 I a z + 4 z^2 - Sqrt[2] a Sqrt[a^2 + 2 z^2]] + 
   Log[-a^2 + 2 I a z - 4 z^2 + Sqrt[2] a Sqrt[a^2 + 2 z^2]] + 
   Log[a^2 + 2 I a z + 4 z^2 + Sqrt[2] a Sqrt[a^2 + 2 z^2]])

Frustratingly, FullSimplify, Simplify, FunctionExpand, all with Assumptions -> a > 0 && z > 0, do not seem to simplify the expression satisfactorily. Neither do TrigToExp and ExpToTrig, unfortunately. I even tried:

Integrate[1/(x^2 + y^2 + z^2)^(3/2), {x, -a/2, a/2}, {y, -a/2, a/2}, 
 Assumptions -> 
  a \[Element] Reals && x \[Element] Reals && y \[Element] Reals && 
   a > 0 && z > 0]

with no luck. Does anybody know how to prevent this behavior, or how to convert this result into a reasonable one? The standard tricks don't seem to work. Thanks!

POSTED BY: Matt B
7 Replies

Matt,

Also, Rubi for Mathematica works well on this problem -- it solves it instantly for both cases. Once it is installed you can do:

<< Rubi`
Assuming[a > 0 && z > 0, 
 Int[Int[1/(x^2 + y^2 + z^2)^(3/2), {x, -a, a}], {y, -a, a}]]

and

Assuming[a > 0 && z > 0, 
 Int[Int[1/(x^2 + y^2 + z^2)^(3/2), {x, -a/2, a/2}], {y, -a/2, a/2}]]

Regards,

Neil

POSTED BY: Neil Singer
Posted 3 years ago

Thank you so much for the reply! I'll definitely check it out.

POSTED BY: Matt B
Posted 3 years ago

Hi Matt,

Use Surd to force real valued roots

Integrate[1/Surd[(x^2 + y^2 + z^2)^3, 2], {x, -a/2, a/2}, {y, -a/2, a/2}, 
  Assumptions -> a > 0 && z > 0]

(* (4 ArcCot[(2 Sqrt[2] z Sqrt[a^2 + 2 z^2])/a^2])/z *)
POSTED BY: Rohit Namjoshi
Posted 3 years ago

Thank you so much! I really appreciate it. This problem has been bothering me for a few days now. Those types of integrals come up a lot in the study of electrodynamics, so I really wanted to make sure that I understood the solution so that this doesn't happen again.

On a slightly different note, is there a way that I can get

Integrate[1/x, x, Assumptions -> x \[Element] Reals]

to return ln|x| rather than ln(x)? This has also been a recurring problem for me, and required me to do a fairly complex problem partly by hand. It seems that both of my problems occurred because Mathematica really wants to treat everything as complex, even when I tell it that the answer is real.

Thanks again for your help, and sorry for the elementary questions.

POSTED BY: Matt B
Posted 3 years ago

Take a look at this and related posts on MSE.

POSTED BY: Rohit Namjoshi

You can make a replacement in the output using RealAbs instead of Abs, but then check that the result is correct:

f = 1/(x (x - 1));
Integrate[f, x] /. Log[u_] :> Log[RealAbs[u]]
FullSimplify[%, Element[x, Reals]] /. Abs -> RealAbs
Simplify[D[%, x]] == f
POSTED BY: Gianluca Gorni
Posted 3 years ago

I can't believe, but all of the sudden, Mathematica is returning the sub-optimal answer again!

Integrate[
 1/Surd[(x^2 + y^2 + z^2)^3, 2], {x, -a/2, a/2}, {y, -a/2, a/2}, 
 Assumptions -> a > 0 && z > 0]

Result

(1/z)(2 \[Pi] - 
  I Log[-a^2 - 2 I a z - 4 z^2 + Sqrt[2] a Sqrt[a^2 + 2 z^2]] + 
  I Log[-a^2 + 2 I a z - 4 z^2 + Sqrt[2] a Sqrt[a^2 + 2 z^2]] - 
  I Log[a^2 - 2 I a z + 4 z^2 + Sqrt[2] a Sqrt[a^2 + 2 z^2]] + 
  I Log[a^2 + 2 I a z + 4 z^2 + Sqrt[2] a Sqrt[a^2 + 2 z^2]])

Any idea why this may be happening?

POSTED BY: Matt B
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract