       Re: Mathematica Weirdness

• To: mathgroup at smc.vnet.net
• Subject: [mg116688] Re: Mathematica Weirdness
• From: Andrzej Kozlowski <akoz at mimuw.edu.pl>
• 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 +
27*E^11*(15303054607*DawsonF - 1293761386) + 42200009495))/
(2*E^11)

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:

N[a]

-0.909408

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]

2.7

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

```

• 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