RE: When does x/x not equal 1?
- To: mathgroup at smc.vnet.net
- Subject: [mg32423] RE: [mg32417] When does x/x not equal 1?
- From: "David Park" <djmp at earthlink.net>
- Date: Sat, 19 Jan 2002 19:03:19 -0500 (EST)
- Sender: owner-wri-mathgroup at wolfram.com
Michael, Have you tried using Chop on your expressions? 103.3 + 3.4432 *10^-39 I // Chop 103.3 David Park djmp at earthlink.net http://home.earthlink.net/~djmp/ > From: Michael J Person [mailto:mjperson at MIT.EDU] To: mathgroup at smc.vnet.net > > Greetings all: > > I'm having a bit of a problem with Math 188.8.131.52 on Mac OS 9.1... > > Specifically we have a lot of large planetary > calculations that only > occasionally produce piles of complex numbers of the form: > > 103.3 + 3.4432 *10^-39 I > > These tiny complex pieces then get carried all around in our > calculations and destroy the formatting of our outputs and things > even though the real part seems to be a quite reasonable answer to > our problems. > > Hunting it down piece by piece, we seem to have traced it to places > where we're taking the square roots of things that include ratios of > numbers that should be equaling 1 at the boundaries but aren't. > > Sqrt[1-x/x] -> tiny complex number instead of 0! > > It seem to be that x/x that's causing the problem in our codes, > but as we try to track it down, all sort of mystifying behavior starts > to manefest. Among the worst of it are the following sorts of things: > > In:= > (x = (1.992+$MachineEpsilon)) //FullForm > > Out//FullForm= > 1.9920000000000002` > > In:= > x/x //FullForm > > Out//FullForm= > 0.9999999999999999` > > Now, I'd guess that wonky things start happening when you start > fooling around with numbers near $MachineEpsilon, but shouldn't > x/x = 1? Worse, is when we tried to fix the problem in various ways, > we came up with terribly confusing things like the following: > > In:= > x/x //FullForm > > Out//FullForm= > 0.9999999999999999` > > (*That's just like above.) > > In:= > Divide[x,x] //FullForm > > Out//FullForm= > 1.` > > Ah ha! That's just the sort of thing we want in our calculations. > So we try to see what the difference is.... > > In:= > Divide[a,b] //FullForm > > Out//FullForm= > Times[a, Power[b, -1]] > > In:= > a/b //FullForm > > Out//FullForm= > Times[a, Power[b, -1]] > > They're handled exactly the same way! So, can anyone explain to me > what's going on here, and how I can keep very small complex numbers from > arising in all of those cases when x/x != 1. > > (As I mentioned these problems are completely intermittent. In the > examples given above, they do not occur for 1.991, or 1.994, just 1.992 > and 1.993. Bah!) > > Thanks for anything you can tell me. > > -Michael Person > mjperson at mit.edu > Massachusetts Institute of Technology > Department of Earth, Atmospheric, and Planetary Sciences > > > >