A comparison of floating point numbers x and y in practical code is typically gi
ID: 3885301 • Letter: A
Question
A comparison of floating point numbers x and y in practical code is typically given by |x y| < E, for some user-chosen value of E > 0, to replace testing for exact equality by “Does x = y”?. The indicated comparison is not an equivalence relation between x and y.
1Ai. Which needed property fails to hold? (2 pts)
1Aii. Give a specific example of this failure to be an equivalence relation. (3 pts)
A comparison of floating point numbers r and y in practical code is typically given by for some user-chosen value ofe > 0, to replace testing for exact equality by "Does x = y. The indicated comparison is not an equivalence relation between r and y. 1Ai. Which needed property fails to hold? (2 pts) 1Aii. Give a specific example of this failure to be an equivalence relation. (3 pts)Explanation / Answer
The equality relation that x and y are equal if |x - y| < E is not an equivalence relation.
Equivalence relation means it has to be refelexive, symmetric and transitive.
The transitive propert does not hold here.
If we take x = 2.5 y = 2.6 and z = 2.7 and E = 0.11
so x and y are equal as per the relation becuase the difference between them is 0.1 < E
so y and z are equal as per the relation becuase the difference between them is 0.1 < E
but this does not mean that x = z because in current case x is not equal to z. The difference between x and z is 0.2 > E. Transitivity fails and that is why this relation is not equivalence realtion.
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.