comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » machine precision
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Return to the default flat view Create a new topic Submit Reply
machine precision [message #66507] Mon, 18 May 2009 04:41
Wout De Nolf is currently offline  Wout De Nolf
Messages: 194
Registered: October 2008
Senior Member
Hi all,

When checking whether two foating point variables are equal, one has
to do this:

pres = (machar()).eps
bequal = abs(f1-f2) lt pres

This can go wrong however, as illustrated by the example below. Do I
need to do error propagation on this? This means that every time f1
and f2 are calculated differently, I have to calculate a different
uncertainty? This seems like a lot of work, not to mention the machine
precision in calculation the propagation of uncertainty... Is there a
more general rule of thumb I can use?

vec1=[1.,2,3,4,5]
vec2=vec1
pres=(machar()).eps
norm1=sqrt(total(vec1^2,1,/pres))
norm2=sqrt(total(vec2^2,1,/pres))
f1=total(vec1*vec2,/pres) ; inner product
f2=norm1*norm2 ; product of the norms
; f1 and f2 must be equal so
if abs(f1-f2) ge pres then print,'wrong wrong wrong...'
[Message index]
 
Read Message
Previous Topic: Google Mini - Next generation version
Next Topic: Re: Simultaneous fitting in IDL

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Fri Oct 10 16:31:21 PDT 2025

Total time taken to generate the page: 1.20298 seconds