       Re: Integrals involving square roots

• To: mathgroup at smc.vnet.net
• Subject: [mg73940] Re: Integrals involving square roots
• From: Bhuvanesh <lalu_bhatt at yahoo.com>
• Date: Sat, 3 Mar 2007 01:12:59 -0500 (EST)

```This is because it's doing the integrations one at a time. If you evaluate:

Integrate[1/Sqrt[R^2 - x^2], {x, -R, R}]

you will see that there are two so-called "branches", one for R>0 and another for R<=0. One of these gets picked up and used for the outer integration with respect to z. So, for example, the 5.0 result was incorrect for R<0:

\$Version      = 5.0.1 for Microsoft Windows (November 18, 2003)
\$TopDirectory = C:\...\Mathematica\5.0.1

In:= Integrate[z^2/Sqrt[R^2 - x^2], {z, 0, 2}, {x, -R, R}] //InputForm

Out//InputForm= (8*Pi*Sqrt[R^(-2)]*Sqrt[R^2])/3

In:= % /. R->-2.

Out= 8.37758

In:= With[{R=-2}, NIntegrate[z^2/Sqrt[R^2 - x^2], {z, 0, 2}, {x, -R, R}]] //Chop

Out= -8.37758

To get a result correct for R>0, you could provide an assumption:

In:= Integrate[z^2/Sqrt[R^2 - x^2], {z, 0, 2}, {x, -R, R}, Assumptions->R>0] //InputForm

Out//InputForm= (8*Pi)/3

Or, to get a result correct for R>0 as well as R<0:

In:= Integrate[z^2/Sqrt[R^2 - x^2], {z, 0, 2}, {x, -R, R}, GenerateConditions->True] //InputForm

Out//InputForm=
(8*If[R > 0, Pi, Integrate[1/Sqrt[R^2 - x^2], {x, -R, R},
Assumptions -> R <= 0]])/3

In:= PiecewiseExpand[%] //InputForm

Out//InputForm= Piecewise[{{(-8*Pi)/3, R <= 0}}, (8*Pi)/3]

(Note: in the inputs above, I have removed constants such as R for simplicity.)

Bhuvanesh,
Wolfram Research

```

• Prev by Date: Re: Number of digits
• Next by Date: Re: ReadList and columns
• Previous by thread: Re: Integrals involving square roots
• Next by thread: Re: Integrals involving square roots