JOIN
 Select a Forum     Round Tables New Member Discussions News Discussions Algorithm Matches Marathon Matches NASA Tournament Lab TopCoder Cookbook High School Matches Sponsor Discussions Development Forums Design Forums Search | Watch Thread  |  My Post History  |  My Watches  |  User Settings View: Flat (newest first)  | Threaded  | Tree Previous Thread  |  Next Thread Forums Tutorial Discussions Representation of Integers and Reals Tutorial Absolute Error and Relative Error
 Absolute Error and Relative Error | Reply I have problems understanding the deference between these two types of errors. Actually I do understand the reasons for the difference but I can't get why the two functions solve these cases. I believe 1e-9 is the EPS to use since misof used it in his latest code for SRM 283:#define EPS (1e-9)then he did:if (abs(X[i]-(*it)) <= D + EPS) now++;I think this is only a test for absolute error. Why he didn't used the other test too?And if you can please give me some source code I can trust when comparing doubles... Before I saw the article I used:#define EQ(a,b) ((fabs(a-b)
 Re: Absolute Error and Relative Error (response to post by vesko) | Reply If the values you compare are greater than one, then an absolute error of 1e-9 is smaller than a relative error of 1e-9. In other words, if a,b>1 and abs(a-b)<1e-9, there is no need to check whether b is between a*(1-1e-9) and a*(1+1e-9), it will always be true.The numbers I was comparing in this task were between sqrt(2)/2 and 1000000*sqrt(2), and they were almost exact. Thus I decided that testing for an absolute error 1e-9 will always be accurate enough. (Note that for these numbers, adding/subtracting 1e-9 changes the value of the variable.)
 Forums Tutorial Discussions Representation of Integers and Reals Tutorial Absolute Error and Relative Error Previous Thread  |  Next Thread