Re: Non-deterministic numerical inaccuracies in Mathematica
- To: mathgroup at smc.vnet.net
- Subject: [mg94932] Re: [mg94908] Non-deterministic numerical inaccuracies in Mathematica
- From: DrMajorBob <btreat1 at austin.rr.com>
- Date: Wed, 31 Dec 2008 06:07:01 -0500 (EST)
- References: <200812301053.FAA13049@smc.vnet.net>
- Reply-to: drmajorbob at longhorns.com
I had no failures on my iMac Leopard system: $Version "7.0 for Mac OS X x86 (64-bit) (November 11, 2008)" myMod := Module[{p}, Dot[{0.5018839897852984567457648, 0.544293499215831476457645674576, 0.67220312964800834576456745674567}, {-0.5359693986690249`, \ -0.41257352636613975`, -0.736559494563862`}]*{-0.5359693986690249`, \ -0.41257352636613975`, -0.736559494563862`} - {0.5579131132707782`, 0.2715072333003815`, 0.7842300557273234`}] For[ii = 1, ii <= 250000, ii++, If[myMod =!= myMod, Print["Iteration " <> ToString[ii] <> " fails comparison "]];] (no prints) Bobby On Tue, 30 Dec 2008 04:53:22 -0600, Sjoerd C. de Vries <sjoerd.c.devries at gmail.com> wrote: > Hi all, > > Last week Budgemano posted an issue which involved numerical > inaccuracies in Mathematica 7. Due to the xmas season it hasn't > received much attention, or so it seems. > > Meanwhile, I've been able to drill the problem down to the following > code: > > myMod := Module[ > {p}, > Dot[{0.5018839897852984567457648, 0.544293499215831476457645674576, > 0.67220312964800834576456745674567}, {-0.5359693986690249`, \ > -0.41257352636613975`, -0.736559494563862`}]*{-0.5359693986690249`, \ > -0.41257352636613975`, -0.736559494563862`} - {0.5579131132707782`, > 0.2715072333003815`, 0.7842300557273234`}] > > For[ii = 1, ii <= 250, ii++, > If[myMod =!= myMod, > Print["Iteration " <> ToString[ii] <> " fails comparison "]];] > > As you can see the module myMod is called twice every iteration. Its > calculations only involve constants, so the results should always be > the same. However, on my system (Mathematica 7.WinXP) the results differ > from one > call to the other at seemingly random times. > > This phenomenon crucially depends on the presence of the local > variable p (that isn't used!). With this variable it's there, without > it isn't. In M6 everything is OK, so this is a bug specific to > Mathematica 7. > > Could you check on the various platforms whether you can reproduce > this? > > Cheers -- Sjoerd > -- DrMajorBob at longhorns.com