MathGroup Archive 2009

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

Search the Archive

Re: Nested numerical integration

  • To: mathgroup at smc.vnet.net
  • Subject: [mg99287] Re: Nested numerical integration
  • From: antononcube at gmail.com
  • Date: Sat, 2 May 2009 05:56:31 -0400 (EDT)
  • References: <200904280845.EAA28624@smc.vnet.net> <gt98ok$oea$1@smc.vnet.net>

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


  • Prev by Date: Re: mathematica newbie trouble
  • Next by Date: Re: New Wolfram Tutorial Collection documentation is ready
  • Previous by thread: Re: MemoryInUse and Print
  • Next by thread: Re: Re: Nested numerical integration