MathGroup Archive 2005

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Integrate and Boole problems

  • To: mathgroup at smc.vnet.net
  • Subject: [mg58452] Re: Integrate and Boole problems
  • From: Jean-Marc Gulliet <jeanmarc.gulliet at gmail.com>
  • Date: Sun, 3 Jul 2005 03:57:03 -0400 (EDT)
  • Organization: The Open University, Milton Keynes, England
  • References: <da0bq0$fm8$1@smc.vnet.net>
  • Sender: owner-wri-mathgroup at wolfram.com

On 7/1/05, Chris Becker <topher at csh.rit.edu> wrote:
 > I'm sorry, it must have pasted incorrectly, it wasn't an equal sign, 
it was
 > a less than or equal.
 >
 > Integrate[Boole[((x - 1)^2 + y^2 + z^2 - 3^2)*((x + 1)^2 + y^2 + z^2 
- 3^2)
 > <= 0], {x, -Infinity, Infinity}, {y, -Infinity, Infinity}, {z, -
 >             Infinity, Infinity}]
 >
 >
 > Mathematica 5.1 is able to integrate over Boolean defined regions, so in
 > effect if you can define a region with inequalities, integrating over it
 > will return it's area (if two dimensional) or volume (as is the case 
above).
 > More about it can be found here:
 >
 > 
http://www.wolfram.com/products/mathematica/newin51/integrationregions.html
 >
 > Chris
 >
Hi Chris,

Now I understand what you are doing :-) Unfortunately, with the correct 
inequality I get the same result as yours: there is a discrepancy of 
roughly a factor two between the numerical evaluation of the symbolic 
solution and the direct numerical integration.

More puzzling, I have had the good (bad?) idea to use the *Timing* 
function and the symbolic expression returned by *Integrate* is _not_ 
the same that the expression return by the command use alone (although 
the numerical evaluation of both expression yields the same value).

So I am wondering why, or in which way, the *Timing* command would 
interfere with the algorithms used by *Integrate* while *Timing* is 
suppose just to keep tract of the consumed CPU time?

First, without the timing

In[1]:=
Integrate[Boole[((x - 1)^2 + y^2 + z^2 - 3^2)*
      ((x + 1)^2 + y^2 + z^2 - 3^2) <= 0],
   {x, -Infinity, Infinity}, {y, -Infinity, Infinity},
   {z, -Infinity, Infinity}]

Out[1]=
(56*Pi)/3 - (4/135)*(315*Pi -
     2*(1008*EllipticE[-(1/2)] -
       I*(39*Sqrt[6]*EllipticE[2/3] -
         78*EllipticE[3/2] - 417*I*EllipticK[-(1/2)] -
         13*Sqrt[6]*EllipticK[2/3] + 900*Sqrt[2]*
          EllipticPi[-1, (1/2)*I*Log[2 + Sqrt[3]],
           -2] - 315*Sqrt[2]*EllipticPi[2,
           (1/2)*I*Log[2 + Sqrt[3]], -2]))) +
   (2/135)*(585*Pi - 2*(1008*EllipticE[-(1/2)] -
       I*(39*Sqrt[6]*EllipticE[2/3] -
         78*EllipticE[3/2] - 417*I*EllipticK[-(1/2)] -
         13*Sqrt[6]*EllipticK[2/3] + 900*Sqrt[2]*
          EllipticPi[-1, (1/2)*I*Log[2 + Sqrt[3]],
           -2] - 315*Sqrt[2]*EllipticPi[2,
           (1/2)*I*Log[2 + Sqrt[3]], -2]))) +
   2*Integrate[(1/2)*Pi*(-2 + x)*(4 + x) +
      2*Sqrt[(-(-2 + x))*x*(4 + x)] -
      (-4 + x)*(2 + x)*ArcCot[2/Sqrt[-2 + 8/x - x]],
     {x, 0, 2}] +
   2*Integrate[(1/2)*((-Pi)*(-4 + x)*(2 + x) -
       4*Sqrt[(-(-2 + x))*x*(4 + x)] +
       2*(-4 + x)*(2 + x)*ArcCot[
         2/Sqrt[-2 + 8/x - x]]), {x, 0, 2}] +
   Integrate[(1/2)*(-4*Sqrt[(-4 + x)*x*(2 + x)] -
      Pi*(-2 + x)*(4 + x) - 2*(-2 + x)*(4 + x)*
       ArcTan[Sqrt[(-4 + x)*x*(2 + x)]/(2*x)]),
    {x, -2, 0}]

In[2]:=
N[%]

Out[2]=
55.04761032732088 + 5.3618391912432685*^-8*I

In[3]:=
Chop[%]

Out[3]=
55.04761032732088 + 5.3618391912432685*^-8*I

In[4]:=
NIntegrate[Boole[((x - 1)^2 + y^2 + z^2 - 3^2)*
      ((x + 1)^2 + y^2 + z^2 - 3^2) <= 0],
   {x, -Infinity, Infinity}, {y, -Infinity, Infinity},
   {z, -Infinity, Infinity}]

Out[4]=
108.90854533339399 - 2.749275252793041*^-29*I

In[5]:=
Chop[%]

Out[5]=
108.90854533339399

Now with the *Timing* function

In[1]:=
Timing[sol = Integrate[
     Boole[((x - 1)^2 + y^2 + z^2 - 3^2)*
        ((x + 1)^2 + y^2 + z^2 - 3^2) <= 0],
     {x, -Infinity, Infinity}, {y, -Infinity,
      Infinity}, {z, -Infinity, Infinity}]]

Out[1]=
{646.094*Second, (56*Pi)/3 -
    (2/45)*(315*Pi - 2*(1008*EllipticE[-(1/2)] -
        I*(39*Sqrt[6]*EllipticE[2/3] -
          78*EllipticE[3/2] - 417*I*EllipticK[-(1/2)] -
          13*Sqrt[6]*EllipticK[2/3] + 900*Sqrt[2]*
           EllipticPi[-1, (1/2)*I*Log[2 + Sqrt[3]],
            -2] - 315*Sqrt[2]*EllipticPi[2,
            (1/2)*I*Log[2 + Sqrt[3]], -2]))) +
    (2/45)*(585*Pi - 2*(1008*EllipticE[-(1/2)] -
        I*(39*Sqrt[6]*EllipticE[2/3] -
          78*EllipticE[3/2] - 417*I*EllipticK[-(1/2)] -
          13*Sqrt[6]*EllipticK[2/3] + 900*Sqrt[2]*
           EllipticPi[-1, (1/2)*I*Log[2 + Sqrt[3]],
            -2] - 315*Sqrt[2]*EllipticPi[2,
            (1/2)*I*Log[2 + Sqrt[3]], -2]))) +
    (1/135)*(-630*Pi - 4*I*Sqrt[2]*
       (39*Sqrt[3]*EllipticE[2/3] - 39*Sqrt[3]*
         EllipticE[ArcCsc[Sqrt[2/3]], 2/3] +
        13*Sqrt[3]*EllipticF[(1/2)*(Pi +
            I*(Log[2] - 2*Log[1 + Sqrt[3]])), 2/3] -
        663*EllipticF[I*(-(Log[2]/2) +
            Log[1 + Sqrt[3]]), -2] - 13*Sqrt[3]*
         EllipticK[2/3] + 900*EllipticPi[-1,
          I*(-(Log[2]/2) + Log[1 + Sqrt[3]]), -2] -
        315*EllipticPi[2, I*(-(Log[2]/2) +
            Log[1 + Sqrt[3]]), -2]) +
      405*Sqrt[6]*Pi^(3/2)*
       (-((2*Hypergeometric2F1[-(5/4), -(1/4), 1/2,
            1/9])/(Gamma[-(3/4)]*Gamma[9/4])) +
        Hypergeometric2F1[-(3/4), 1/4, 3/2, 1/9]/
         (Gamma[-(1/4)]*Gamma[7/4]))) +
    Integrate[(1/2)*(-4*Sqrt[(-4 + x)*x*(2 + x)] -
       Pi*(-2 + x)*(4 + x) - 2*(-2 + x)*(4 + x)*
        ArcTan[Sqrt[(-4 + x)*x*(2 + x)]/(2*x)]),
     {x, -2, 0}]}

In[2]:=
Timing[N[sol]]

Out[2]=
{6.719000000000051*Second, 53.2858037103929 +
    3.8298848235073785*^-9*I}

In[3]:=
Timing[numsol = NIntegrate[
     Boole[((x - 1)^2 + y^2 + z^2 - 3^2)*
        ((x + 1)^2 + y^2 + z^2 - 3^2) <= 0],
     {x, -Infinity, Infinity}, {y, -Infinity,
      Infinity}, {z, -Infinity, Infinity}]]

Out[3]=
{6.467999999999961*Second, 108.90854533339399 -
    2.749275252793041*^-29*I}

In[4]:=
Chop[numsol]

Out[4]=
108.90854533339399

In[6]:=
$Version

Out[6]=
"5.1 for Microsoft Windows (October 25, 2004)"

Best regards,
/J.M.


  • Prev by Date: Re: Re: Can't assign value to symbols
  • Next by Date: Re: TimeSeries installation problem on Mac
  • Previous by thread: Re: Integrate and Boole problems
  • Next by thread: Re: poly question