MathGroup Archive 2008

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

Search the Archive

Re: floating point issue

  • To: mathgroup at
  • Subject: [mg86780] Re: floating point issue
  • From: Szabolcs Horvát <szhorvat at>
  • Date: Thu, 20 Mar 2008 05:49:49 -0500 (EST)
  • Organization: University of Bergen
  • References: <frt59r$sma$>

Chris Scullard wrote:
> Hi everyone,
> I wonder if I can get some opinions on the best way to deal with this 
> precision issue I am having. I define the vectors:
> K = {111.5, 10.5, 1.5}
> g={-0.7071068, 0., -0.7071068}
> And I need this:
> K.Cross[K, g]
> to be 0 in accordance with a vector identity. The answer comes out to 
> around 1.3 x 10^(-13), which is certainly close to 0 but not close 
> enough for what I'm doing. I've tried various things like writing out 
> the cross product explicitly without using the functions but the result 
> is the same. And using N in various places doesn't seem to help either. 
> What's the standard solution for this kind of thing?

I can't reproduce the problem with versions 5.2 or 6.

But you could consider using exact numbers or symbols instead of machine 
precision numbers.

Also, avoid using identifiers starting with capital letters to prevent 
collisions with built-in names.  "K" is a built-in symbol.

  • Prev by Date: RE: finding positions of elements in a list
  • 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: Re: floating point issue