MathGroup Archive 2011

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

Search the Archive

Re: Mathematica Weirdness

  • To: mathgroup at smc.vnet.net
  • Subject: [mg116708] Re: Mathematica Weirdness
  • From: Daniel Lichtblau <danl at wolfram.com>
  • Date: Thu, 24 Feb 2011 06:25:02 -0500 (EST)

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 rhsmith.umd.edu
> http://www.rhsmith.umd.edu

It's cancellation error in machine arithmetic.

Breaking into parts

In[5]:= InputForm[ii = Integrate[1000000*Exp[x^2-12*x]*x^14, {x,0,1}]]
Out[5]//InputForm=
(-78125*(-84400018990*E^25 + 69863114844*E^36 + 413182474389*Sqrt[Pi]*
     (Erfi[5] - Erfi[6])))/(4*E^36)

Your numerical result:

In[6]:= InputForm[N[ii]]
Out[6]//InputForm= -0.8133035309472584

If instead you numerically evaluate using precision tracking you will 
get a positive result.

In[7]:= InputForm[N[ii,20]]
Out[7]//InputForm= 2.74821242373456642759753885810434205331`20.

"Mathematica Weirdness" is about as uninformative a subject header as 
one could conjure for this forum.

Daniel Lichtblau
Wolfram Research



  • Prev by Date: Re: Delete elements from list..
  • Next by Date: Re: Mathematica Weirdness
  • Previous by thread: Re: Mathematica Weirdness
  • Next by thread: Re: Mathematica Weirdness