       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 = NIntegrate[w^2/(s - w), {s, 1, 5}, {w, -5, -1}]
>
> Out = 25.8364
>
> Step-by-step integration:
>
> In =
>
> Clear[int];
> int[w_?NumericQ] := NIntegrate[w^2/(s - w), {s, 1, 5}];
> NIntegrate[int[w], {w, -5, -1}]
>
> Out = 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:= NIntegrate[w^2/(s - w), {s, 1, 5}, {w, Sqrt[s], -1}]

Out= -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:= NIntegrate[w^2/(s - w)*Boole[ (s - 3)^2 + (w + 3)^2 > 1], {s,
1, 5}, {w, -5, -1}]

Out= 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:= NIntegrate[w^2/(s - w), {s, 1, 5}, {w, -5, -1},
Method -> {"GaussKronrodRule", "LobattoKronrodRule"}]

Out= 25.8364

Here are the sampling points:

In:= 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