Re: Re: Nested numerical integration
- To: mathgroup at smc.vnet.net
- Subject: [mg99358] Re: [mg99287] Re: Nested numerical integration
- From: Leonid Shifrin <lshifr at gmail.com>
- Date: Sun, 3 May 2009 05:25:07 -0400 (EDT)
- References: <200904280845.EAA28624@smc.vnet.net> <gt98ok$oea$1@smc.vnet.net>
Hi Anton, Thanks, I was not aware of that (despite having worked with NIntegrate quite a bit - there are always things to learn). Taking my words back, and sorry for the confusion. Regards, Leonid On Sat, May 2, 2009 at 2:56 AM, <antononcube at gmail.com> wrote: > On Apr 29, 6:05 am, Leonid Shifrin <lsh... at gmail.com> wrote: > > Hi, > > > > direct 2D integration: > > > > In[1] = NIntegrate[w^2/(s - w), {s, 1, 5}, {w, -5, -1}] > > > > Out[1] = 25.8364 > > > > Step-by-step integration: > > > > In[2] = > > > > Clear[int]; > > int[w_?NumericQ] := NIntegrate[w^2/(s - w), {s, 1, 5}]; > > NIntegrate[int[w], {w, -5, -1}] > > > > Out[2] = 25.8364 > > > > The second method is more flexible since you may use it for > > non-rectangular domains. > > This statement is not correct. Using the multi-dimentional NIntegrate > specfication gives more flexibility. > > 1. Multi-dimensional NIntegrate can be used non-rectangular domains. > In the example below the second variable has functional boundary: > > In[2]:= NIntegrate[w^2/(s - w), {s, 1, 5}, {w, Sqrt[s], -1}] > > Out[2]= -5.07779 > > You can use sampling points plot to see what the domain looks like: > > Needs["Integration`NIntegrateUtilities`"] > NIntegrateSamplingPoints[NIntegrate[w^2/(s - w), {s, 1, 5}, {w, Sqrt > [s], -1}]] > > > 2. Multi-dimensional NIntegrate can be used for integration over parts > of the integration region (or their exclusion). > In the example below a disk with center {3,-3} and radius 1 is > excluded from the integration: > > In[12]:= NIntegrate[w^2/(s - w)*Boole[ (s - 3)^2 + (w + 3)^2 > 1], {s, > 1, 5}, {w, -5, -1}] > > Out[12]= 21.0579 > > Again you can see the integration domain with > > NIntegrateSamplingPoints[ > NIntegrate[ > w^2/(s - w)*Boole[ (s - 3)^2 + (w + 3)^2 >= 1], {s, 1, > 5}, {w, -5, -1}]] > > > 3. The examples above used a mutlti-dimensional integration rule. If > want to use one dimensional rule or, moreover, if you want to use > different one-dimensional rule in each dimension, you can specify this > with the Method option. This specification is closer to an integration > with nested NIntegrate's. > > In[19]:= NIntegrate[w^2/(s - w), {s, 1, 5}, {w, -5, -1}, > Method -> {"GaussKronrodRule", "LobattoKronrodRule"}] > > Out[19]= 25.8364 > > Here are the sampling points: > > In[20]:= NIntegrateSamplingPoints[ > NIntegrate[w^2/(s - w), {s, 1, 5}, {w, -5, -1}, > Method -> {"GaussKronrodRule", "LobattoKronrodRule"}]] > > > Anton Antonov > >