Services & Resources / Wolfram Forums
MathGroup Archive
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

MathGroup Archive 2005

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

Search the Archive

Re: The strange behaviour of NIntegrate

  • To: mathgroup at
  • Subject: [mg53531] Re: The strange behaviour of NIntegrate
  • From: Bill Rowe <readnewsciv at>
  • Date: Sat, 15 Jan 2005 21:08:14 -0500 (EST)
  • Sender: owner-wri-mathgroup at

On 1/15/05 at 1:44 AM, Z.Burq at (Zaeem Burq) wrote:

>I am trying to NIntegrate a nice function (which I know is
>integrable), of the form

>K[s] = h[s]/[(1-s)^1.5] from 0 to 1.

>The function is real, but Mathematica spits out a COMPLEX answer!!
>Admittedly, the complex part is very small, and if I truncate the
>integral just below 1, the complex bit disappears and changes the
>real part very slightly.

>It seems obvious that Math'ca is choosing the last s value just
>beyond 1, producing the Sqrt of a negative number in the

>If interested, here are the calculations and results. Read on if
>you think you can help. Thanx.

>x_] := \[ExponentialE]\^\(\(-x\^2\)/2\)\/\@\(2  \[Pi]\);\)\n
>\(K[s_] := \(\(\ \)\(\((1 - \@s)\)\ \[CurlyPhi][\(1 - \@s\)\/\@\(1
>s\)]\)\ \)\/\((1 - s)\)\^1.5`;\)\)

>NIntegrate[K[s], {s, 0, 1}]

>gives \!\(\(\(0.4206155890394436`\)\(\[InvisibleSpace]\)\) - 
>3.304807577181973`*^-49\ \[ImaginaryI]\)


>NIntegrate[K[s], {s, 0, .999999}]

>results in


>Any thoughts?

The most likely explanation for this result isn't that Mathematica is sampling the function beyond the specified range. Instead, it is likely due to using machine precision numbers and the issues asscociated with them. One of the simplest solutions is to use Chop to truncate small terms


\[CurlyPhi][x_] := 1/(E^(x^2/2)*
K[s_] := ((1 - Sqrt[s])*
     \[CurlyPhi][(1 - Sqrt[s])/
       Sqrt[1 - s]])/
    (1 - s)^1.5; 

NIntegrate[K[s], {s, 0, 1}]

"5.1 for Mac OS X (October 25, 2004)"
To reply via email subtract one hundred and four

  • Prev by Date: Re: cubic quarternion group
  • Next by Date: Re: The strange behaviour of NIntegrate
  • Previous by thread: Re: The strange behaviour of NIntegrate
  • Next by thread: Re: The strange behaviour of NIntegrate