Chapter 2: Problem 27
Type in the following code and run it: eps = 1.0 while 1.0 != 1.0 + eps: print ’...............’, eps eps = eps/2.0 print ’final eps:’, eps Explain with words what the code is doing, line by line. Then examine the output. How can it be that the "equation" \(1 \neq 1+\) eps is not true? Or in other words, that a number of approximately size \(10^{-16}\) (the final eps value when the loop terminates) gives the same result as if eps \(^{9}\) were zero? Name of program file: machine_zero.py. If somebody shows you this interactive session >>> 0.5 + 1.45E-22 0.5 and claims that Python cannot add numbers correctly, what is your answer? \(\diamond\)
Short Answer
Step by step solution
Key Concepts
These are the key concepts you need to understand to accurately answer the question.