# Result of simple integral refuses to simplify

Posted 1 month ago
489 Views
|
7 Replies
|
1 Total Likes
|
 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 a Sqrt[a^2 + 2 z^2]] - Log[a^2 + 2 I a z + 4 z^2 - Sqrt a Sqrt[a^2 + 2 z^2]] + Log[-a^2 + 2 I a z - 4 z^2 + Sqrt a Sqrt[a^2 + 2 z^2]] + Log[a^2 + 2 I a z + 4 z^2 + Sqrt 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! Answer
7 Replies
Sort By:
Posted 1 month 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 z Sqrt[a^2 + 2 z^2])/a^2])/z *) Answer
Posted 1 month 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. Answer
Posted 1 month ago
 Take a look at this and related posts on MSE. Answer
Posted 1 month ago
 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 Answer
Posted 1 month 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 a Sqrt[a^2 + 2 z^2]] + I Log[-a^2 + 2 I a z - 4 z^2 + Sqrt a Sqrt[a^2 + 2 z^2]] - I Log[a^2 - 2 I a z + 4 z^2 + Sqrt a Sqrt[a^2 + 2 z^2]] + I Log[a^2 + 2 I a z + 4 z^2 + Sqrt a Sqrt[a^2 + 2 z^2]]) Any idea why this may be happening? Answer
Posted 1 month ago
 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 Answer
Posted 1 month ago
 Thank you so much for the reply! I'll definitely check it out. Answer