MathGroup Archive 2009

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

Search the Archive

Re: Nested numerical integration

tsg.moore at wrote:
> Hi, I'd like to compute a nested integral like,
> NIntegrate[ w^2 * NIntegrate[1/(s-w), {s, 1, 5}], {w, -5, -1}]
> Unfortunately, mathematica gives me an error (NIntegrate::inumr) and
> it also outputs the wrong value. Is there a way to do these types of
> integrals?

Can use one NIntegrate, to avoid the inner one having a "symbolic" 
parameter w.

In[3]:= NIntegrate[ w^2 * 1/(s-w), {s, 1, 5}, {w, -5, -1}]
Out[3]= 25.8364

Alternatively, define a black box integrand that only is computable for 
numeric input.

In[4]:= f[w_Real] := NIntegrate[1/(s-w), {s, 1, 5}]

In[5]:= NIntegrate[w^2*f[w], {w, -5, -1}]
Out[5]= 25.8364

Daniel Lichtblau
WOlfram Research

  • Prev by Date: Re: text book style sheets
  • Next by Date: Re: Nested numerical integration
  • Previous by thread: Nested numerical integration
  • Next by thread: Re: Nested numerical integration