Re: Weirdness from double integrals?

*To*: mathgroup at smc.vnet.net*Subject*: [mg95719] Re: Weirdness from double integrals?*From*: Jean-Marc Gulliet <jeanmarc.gulliet at gmail.com>*Date*: Sun, 25 Jan 2009 21:47:12 -0500 (EST)*Organization*: The Open University, Milton Keynes, UK*References*: <glhjr1$mh$1@smc.vnet.net>

In article <glhjr1$mh$1 at smc.vnet.net>, Erik Max Francis <max at alcyone.com> wrote: > I'm new to Mathematica 7 (fiddling with a trial version) and I've bumped > into something that's confusing me. > > Just to make sure I understand Mathematica, I'm playing with finding the > gravitational field around extended objects using integration. So far > I've had no problem (e.g., lines, rings, planes, even Newton's shell > theorem popped out easily enough), but I'm getting something that's > confusing about double definite integration the Integrate that's leaving > me puzzled. Here's the (cleaned-up) transcript from math: > > In[1]:= p = {0, 0, h} > > Out[1]= {0, 0, h} > > In[2]:= s = {x, y, 0} > > Out[2]= {x, y, 0} > > In[3]:= q = p - s > > Out[3]= {-x, -y, h} > > In[4]:= dm = rho (* dx dy *) > > Out[4]= rho > > In[5]:= integrand = -G * dm * q/(q.q)^(3/2) > > G rho x G rho y G h rho > Out[5]= {-----------------, -----------------, -(-----------------)} > 2 2 2 3/2 2 2 2 3/2 2 2 2 3/2 > (h + x + y ) (h + x + y ) (h + x + y ) > > In[7]:= Integrate[integrand, {x, -x0, x0}, {y, -y0, y0}] > > Out[7]= {0, 0, 0} > > In[9]:= Integrate[Integrate[integrand, {x, -x0, x0}, Assumptions -> x0 > > 0 && h > 0], {y, -y0, y0}, Assumptions -> x0 > 0 && y0 > 0 && h > 0] > > x0 y0 > Out[9]= {0, 0, -2 G rho (Pi - 2 ArcCot[----------------------])} > 2 2 2 > h Sqrt[h + x0 + y0 ] > > It would seem to me, less assumptions, that Out[7] and Out[9] should be > the same, but Out[7] is clearly wrong (read: "not what I expected" :-) > -- while the x and y components of the integration are zero by symmetry, > the z component clearly should not be. Out[9] looks correct, but I > thought these would have been the same computation; converting In[7] to > traditional form in the front end appears to confirm my understanding > that it does indeed represent a double definite integral over the integrand. > > So what is there about doing double definite integrals with Integrate > that I'm missing? Why aren't these computations the same? > > Thanks. Several things might occur here. First, platform/system dependency since on my system the results are identical. Second, to get consistent results, you should apply the same assumptions to each computation. Third, keep in mind that Mathematica has its own way to do things and in the case of multiple integration the leftmost variable written in the Integrate command is indeed the outermost integration variable in the mathematical expression. In other words, In[7] integrates first for y from -y0 to y0, then for x from -x0 to x0. To get the same result as in In[9], you must write Integrate[integrand, {y, -y0, y0}, {x, -x0, x0}] Having said that, here is what I got on my system: In[1]:= p = {0, 0, h} Out[1]= {0, 0, h} In[2]:= s = {x, y, 0} Out[2]= {x, y, 0} In[3]:= q = p - s Out[3]= {-x, -y, h} In[4]:= dm = rho Out[4]= rho In[5]:= integrand = -G*dm*q/(q.q)^(3/2) Out[5]= G rho x G rho y G h rho {-----------------, -----------------, -(-----------------)} 2 2 2 3/2 2 2 2 3/2 2 2 2 3/2 (h + x + y ) (h + x + y ) (h + x + y ) In[6]:= Integrate[integrand, {x, -x0, x0}, {y, -y0, y0}, Assumptions -> x0 > 0 && y0 > 0 && h > 0] Out[6]= x0 y0 {0, 0, -4 G rho ArcTan[----------------------]} 2 2 2 h Sqrt[h + x0 + y0 ] In[7]:= Integrate[integrand, {y, -y0, y0}, {x, -x0, x0}, Assumptions -> x0 > 0 && y0 > 0 && h > 0] Out[7]= x0 y0 {0, 0, -2 G rho (Pi - 2 ArcCot[----------------------])} 2 2 2 h Sqrt[h + x0 + y0 ] In[8]:= Integrate[ Integrate[integrand, {x, -x0, x0}, Assumptions -> x0 > 0 && h > 0], {y, -y0, y0}, Assumptions -> x0 > 0 && y0 > 0 && h > 0] Out[8]= x0 y0 {0, 0, -2 G rho (Pi - 2 ArcCot[----------------------])} 2 2 2 h Sqrt[h + x0 + y0 ] In[9]:= $Version Out[9]= 6.0 for Mac OS X x86 (64-bit) (May 21, 2008) Regards, --Jean-Marc