MathGroup Archive 2011

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

Search the Archive

Re: Mathematica Weirdness

  • To: mathgroup at
  • Subject: [mg116688] Re: Mathematica Weirdness
  • From: Andrzej Kozlowski <akoz at>
  • Date: Thu, 24 Feb 2011 06:21:25 -0500 (EST)

Well, nothing is really strange here except for the usual "strangeness" of machine precision arithmetic. Look at the exact answer to the first computation (before you apply N to it):

 a = Integrate[1000000*Exp[x^2 - 12*x]*x^14, {x, 0, 1}]

 (78125*(-413182474389*DawsonF[5] +
         27*E^11*(15303054607*DawsonF[6] - 1293761386) + 42200009495))/

You see subtraction involving some pretty large numbers and, with machine precision this sort of thing often spells trouble (this sort of thing is said to be "ill conditioned") Indeed, you get:



which is completely wrong and misleading but not unexpected. If you use arbitrary precision arithmetic, even asking for just two digits, you will get a positive answer:

 N[a, 2]


Andrzej Kozlowski

On 23 Feb 2011, at 11:23, Steve Heston wrote:

> 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
> Integrate[1000000*Exp[x^2-12*x]*x^14,{x,0.,1}]//N
> NIntegrate[1000000*Exp[x^2-12*x]*x^14,{x,0,1}]
> The first line gives a negative answer, while the second two lines give
> identical positive answers.  Something is strange here.
> Steve
> Steven L. Heston
> Associate Professor
> Finance Department
> Robert H. Smith School of Business
> 4447 Van Munching Hall Van Munching Hall
> University of Maryland
> College Park, MD 20742-1815
> 301-405-9686 TEL
> 301-405-0359 FAX
> sheston at

  • Prev by Date: Re: Mathematica Weirdness
  • Next by Date: Re: outputting C code
  • Previous by thread: Re: Mathematica Weirdness
  • Next by thread: Re: Mathematica Weirdness