MathGroup Archive 2011

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

Search the Archive

Re: Mathematica Weirdness

  • To: mathgroup at
  • Subject: [mg116701] Re: Mathematica Weirdness
  • From: Mark Adler <madler at>
  • Date: Thu, 24 Feb 2011 06:23:46 -0500 (EST)
  • References: <ik2nab$9kk$>

On 2011-02-23 02:25:15 -0800, Steve Heston said:
> My question is why I get a negative integral of a positive
> function?
> Integrate[1000000*Exp[x^2-12*x]*x^14,{x,0,1}]//N

Not too hard to track down.  There is an extremely delicate
cancellation in the result that fails at normal precision, but works at
higher precision.

The result contains:

-1293761386 + 15303054607 DawsonF[6]

where the second term evaluates to:

15303054607 DawsonF[6] // N // FullForm

So you can see that the result depends critically on the last two
digits of the 16-digit value.  The more correct result (in those last
few digits) is:

15303054607 DawsonF[6] // N[#, 20] &

The difference between 0.000058 and 0.000061 is enough to swing the
sign of the result, due to yet another cancellation, though not nearly
so delicate as the first.  So:

Integrate[1000000*Exp[x^2 - 12*x]*x^14, {x, 0, 1}] // N[#, 20] &

which agrees with the numerical integrations.


  • Prev by Date: Bug in definite integral over Gamma function?
  • Next by Date: Re: Mathematica Weirdness
  • Previous by thread: Re: Mathematica Weirdness
  • Next by thread: Re: Mathematica Weirdness