MathGroup Archive 2011

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

Search the Archive

Re: NIntegrate and speed

On 2/27/11 at 4:35 AM, marco.masi at (Marco Masi) wrote:

>I have the following problems with NIntegrate.

>1) I would like to make the following double numerical integral
>converge without errors

>R = 8000; Z = 1; rd = 3500; NIntegrate[Exp[-k Abs[Z]]/(1 + (k
>rd)^2)^1.5 (NIntegrate[Cos[k R Sin[\[Theta]]], {\[Theta], 0,
>\[Pi]}]), {k, 0, \[Infinity]}]

>It tells non numerical values present and I don't understand why,
>since it evaluates finally a numerical value? 0.000424067

You are getting an error since when the inner integral is
initially sampled, k hasn't been assigned a value. You can do
the double integral without the error by doing:

In[3]:= NIntegrate[
  Exp[-k Abs[Z]]/(1 + (k rd)^2)^1.5 Cos[k R Sin[\[Theta]]], {\[Theta],
   0, \[Pi]}, {k, 0, \[Infinity]}]

Out[3]= 0.000424068

That is, to do a double integral you do not need to type
NIntegrate twice. And by using this syntax, the algorithm being
used can immediately see k is to be assigned numerical values
during the integration.

  • Prev by Date: Re: Emacs with Mathematica
  • Next by Date: Re: Formatting a Cell Programmatically
  • Previous by thread: NIntegrate and speed
  • Next by thread: Re: NIntegrate and speed