Re: Mathematica Weirdness
- To: mathgroup at smc.vnet.net
- Subject: [mg116701] Re: Mathematica Weirdness
- From: Mark Adler <madler at alumni.caltech.edu>
- Date: Thu, 24 Feb 2011 06:23:46 -0500 (EST)
- References: <ik2nab$9kk$1@smc.vnet.net>
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 1.293761386000058`*^9 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] & 1.2937613860000614037*10^9 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] & 2.7482124237345664276 which agrees with the numerical integrations. Mark