2

I am trying to evaluate this integral but it takes too long without results.

Integrate[1/(x^2 + y^2 + z^2)^(3/2), {x, -L/2, L/2}, {y, -W/2, W/2}]  

and $(W, L, z)> 0$ However, not specifying the limits gives results

In[411]:= Integrate[1/(x^2 + y^2 + z^2)^(3/2), x, y]

Out[411]= -(ArcTan[(x^2 + z^2 - x Sqrt[x^2 + y^2 + z^2])/(y z)]/z)

MMA13
  • 4,664
  • 3
  • 15
  • 21
  • 1
    "Parameters" are assumed to be complex by default. Use your assumptions. Integrate[1/(x^2 + y^2 + z)^(3/2), {x, -L/2, L/2}, {y, -W/2, W/2}, Assumptions -> {W, L, z} > 0] – Domen Jan 16 '23 at 15:05
  • Note, there is a missing ^2 for z in my comment above. – Domen Jan 16 '23 at 15:53

2 Answers2

5
Clear["Global`*"]

You know that {L>0, W>0, z>0}; however, you never told Mathematica. Use ComplexExpand to eliminate the forms containing I. Use Assuming so that the assumptions are available to all of the functions.

Assuming[{L > 0, W > 0, z > 0},
 Integrate[1/(x^2 + y^2 + z^2)^(3/2),
    {x, -L/2, L/2}, {y, -W/2, W/2}] //
   ComplexExpand[#, TargetFunctions -> {Re, Im}] & //
  Simplify]

(* (1/z)2 (2 π + 2 ArcTan[(2 z)/(W - Sqrt[W^2 + 4 z^2])] + 2 ArcTan[(2 z)/(W + Sqrt[W^2 + 4 z^2])] - 2 ArcTan[(2 z)/(-L + W + Sqrt[L^2 + W^2 + 4 z^2])] + ArcTan[L + W - Sqrt[L^2 + W^2 + 4 z^2], -2 z] - ArcTan[L + W - Sqrt[L^2 + W^2 + 4 z^2], 2 z]) *)

Bob Hanlon
  • 157,611
  • 7
  • 77
  • 198
5

Although @BobHanlon's solution is more generally useful, a somewhat simpler expression for your particular case can be obtained by manual substitution $z^2 \mapsto \tilde{z}$, and without the need for ComplexExpand.

Assuming[{L, W, z, zz} \[Element] PositiveReals, 
 Integrate[
    1/(x^2 + y^2 + zz)^(3/2), {x, -L/2, L/2}, {y, -W/2, W/2}] /. 
   zz -> z^2 // Simplify]

(* (4 ArcTan[(L W)/(2 z Sqrt[L^2 + W^2 + 4 z^2])])/z *)

Domen
  • 23,608
  • 1
  • 27
  • 45