Mathematica 9 is now available
Services & Resources / Wolfram Forums / MathGroup Archive
-----

MathGroup Archive 2008

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: floating point issue

  • To: mathgroup at smc.vnet.net
  • Subject: [mg87077] Re: floating point issue
  • From: Jean-Marc Gulliet <jeanmarc.gulliet at gmail.com>
  • Date: Mon, 31 Mar 2008 02:03:54 -0500 (EST)
  • Organization: The Open University, Milton Keynes, UK
  • References: <frvmb1$i4q$1@smc.vnet.net>

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



  • Prev by Date: Re: floating point issue
  • Next by Date: RE: Fast way to select those elements from a list that are in another
  • Previous by thread: Re: floating point issue
  • Next by thread: finding positions of elements in a list