       Re: NIntegrate bug in Mathematica 6?

• To: mathgroup at smc.vnet.net
• Subject: [mg84178] Re: [mg84168] NIntegrate bug in Mathematica 6?
• From: Bob Hanlon <hanlonr at cox.net>
• Date: Wed, 12 Dec 2007 19:59:34 -0500 (EST)

```Integrate works fine

\$Version

6.0 for Mac OS X x86 (32-bit) (June 19, 2007)

Clear[logdist1, pdfLog1, m, s]

logdist1 = LogNormalDistribution[(m - s^2/2), s];

pdfLog1[x_] := PDF[logdist1, x]

m = 5/100;
s = 2/10;

Integrate[Min[100, 100 b]*pdfLog1[b], {b, 0, 5}]

50*(Erf[3/(20*Sqrt)] +
Erf[(-3 + 100*Log)/
(20*Sqrt)] + E^(1/20)*
Erfc[7/(20*Sqrt)])

% // N

94.14071318790147

Integrate[Min[100, 100 b]*pdfLog1[b], {b, 0, 500}]

50*(Erf[3/(20*Sqrt)] +
Erf[(-3 + 100*Log)/
(20*Sqrt)] + E^(1/20)*
Erfc[7/(20*Sqrt)])

% // N

94.14071318790161

Integrate[Min[100, 100 b]*pdfLog1[b], {b, 0, 10000}]

50*(Erf[3/(20*Sqrt)] +
Erf[(-3 + 100*Log)/
(20*Sqrt)] + E^(1/20)*
Erfc[7/(20*Sqrt)])

% // N

94.14071318790161

Integrate[Min[100, 100 b]*pdfLog1[b], {b, 0, Infinity}]

50*(1 + Erf[3/(20*Sqrt)] +
E^(1/20)*Erfc[7/(20*Sqrt)])

% // N

94.14071318790161

m = 0.05;
s = 0.2;

Integrate[Min[100, 100 b]*pdfLog1[b], {b, 0, 5}]

94.14071318790148

Integrate[Min[100, 100 b]*pdfLog1[b], {b, 0, 500}]

94.14071318790162

Integrate[Min[100, 100 b]*pdfLog1[b], {b, 0, 10000}]

94.14071318790162

Integrate[Min[100, 100 b]*pdfLog1[b], {b, 0, Infinity}]

94.14071318790164

Bob Hanlon

---- vlad <volodymyr.babich at gmail.com> wrote:
> The following code in Mathematica 6:
>
> Clear[logdist1, pdfLog1, \[Mu]1, \[Sigma]1]
> logdist1 =
>  LogNormalDistribution[(\[Mu]1 - \[Sigma]1^2/2), \[Sigma]1];
> pdfLog1[x_] := PDF[logdist1, x]
>
> \[Mu]1 = 0.05;
> \[Sigma]1 = 0.2;
>
> NIntegrate[Min[100, 100 b1]*pdfLog1[b1], {b1, 0, 5}]
> NIntegrate[Min[100, 100 b1]*pdfLog1[b1], {b1, 0, 500}]
> NIntegrate[Min[100, 100 b1]*pdfLog1[b1], {b1, 0, 10000}]
> NIntegrate[Min[100, 100 b1]*pdfLog1[b1], {b1, 0, +\[Infinity]}]
>
>
>
> Produces the following output:
>
> 94.1407
>
> 38.1789
>
> 38.1789
>
> 94.1407
>
>
> Note that the first and the last integrals have upper bounds of 5 and
> \
> [Infinity]
>
> The middle ones have bounds 500 and 10000
>
> All of the answers should be the same (we are way in the tail of the
> random variable density).  I get no warnings or errors.
>
> Shouldn't Mathematica send me some warning that it has difficulty with
> convergence?   Can I get Mathematica to send me a warning?   If not,
> can I trust the numerical integration routines?
>
> Incidentally, Mathematica 5.2 give the correct answer of 94.1407 in
> all four cases.
>
>

```

• Prev by Date: Re: Implementing own data functions
• Next by Date: Expanding powers of cosine
• Previous by thread: NIntegrate bug in Mathematica 6?
• Next by thread: Re: NIntegrate bug in Mathematica 6?