Re: floating point issue

*To*: mathgroup at smc.vnet.net*Subject*: [mg86788] Re: [mg86748] floating point issue*From*: Sseziwa Mukasa <mukasa at jeol.com>*Date*: Fri, 21 Mar 2008 01:52:26 -0500 (EST)*References*: <200803200753.CAA29210@smc.vnet.net>

On Mar 20, 2008, at 3:53 AM, 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? Chop The larger issue is K and g don't have enough precision to satisfy your identity, but g looks like it came from some trigonometric identities: g = {Cos[3 Pi/4],0,Cos[3 Pi/4]} and K's entries can be expressed as rational numbers: K = {223/2,21/2,3/2} So that's your other option, don't take floating point approximations to the entries in K and g. In[215]:= {223/2,21/2,3/2}.Cross[{223/2,21/2,3/2},{Cos[3 Pi/4],0,Cos [3 Pi/4]}] Out[215]= 0 Regards, Ssezi

**References**:**floating point issue***From:*Chris Scullard <scullard@uchicago.edu>