Re: floating point issue
- To: mathgroup at smc.vnet.net
- Subject: [mg87081] Re: floating point issue
- From: Bob Hanlon <hanlonr at cox.net>
- Date: Mon, 31 Mar 2008 02:04:41 -0500 (EST)
- Reply-to: hanlonr at cox.net
As shown previously, use 0 as the tolerance (dx) to force rational. g = Rationalize[{-0.7071068, 0., -0.7071068}, 0] Bob Hanlon ---- Jean-Marc Gulliet <jeanmarc.gulliet at gmail.com> wrote: > Bob Hanlon wrote: > > > K = Rationalize[{111.5, 10.5, 1.5}, 0]; > > g = Rationalize[{-0.7071068, 0., -0.7071068}, 0]; > > > > K.Cross[K, g] > > > > 0 > > <smip> > > FWIW, > > On my system v6.0.2 Mac Os X 1.5.2 64-bit, > > g = Rationalize[{-0.7071068, 0., -0.7071068}] > > returns the list unevaluated. To get a list of nice/exact numbers, I > must use *RootApproximant* (and of course K must be rationalized as > well). Only then I can get the value of zero for the dot-cross product. > > > In[1]:= $Version > K = Rationalize at {111.5, 10.5, 1.5} > g = RootApproximant at {-0.7071068, 0., -0.7071068} > K.Cross[K, g] > > Out[1]= "6.0 for Mac OS X x86 (64-bit) (February 7, 2008)" > > Out[2]= {223/2, 21/2, 3/2} > > Out[3]= {-(1/Sqrt[2]), 0, -(1/Sqrt[2])} > > Out[4]= 0 > > In[5]:= K = Rationalize at {111.5, 10.5, 1.5} > g = Rationalize at {-0.7071068, 0., -0.7071068} > K.Cross[K, g] > > Out[5]= {223/2, 21/2, 3/2} > > Out[6]= {-0.707107, 0, -0.707107} > > Out[7]= 3.19744*10^-14 > > In[8]:= K = {111.5, 10.5, 1.5} > g = {-0.7071068, 0., -0.7071068} > K.Cross[K, g] > > Out[8]= {111.5, 10.5, 1.5} > > Out[9]= {-0.707107, 0., -0.707107} > > Out[10]= 3.19744*10^-14 > > > Best regards, > -- > Jean-Marc >