Double floating precision exercise today I had to deal with this exercise:


  If $x \approx y$, we might expect some cancellation in computing $log(x)- log(y)$. On the other hand, $log(x) - log(y) = log(\frac{x}{y})$, and the latter involves no cancellation. Does this mean that computing $log(\frac{x}{y})$ is likely to give a better result? (Hint: For what value is the log
  function sensitive (highly elastic)?)


I would assume that in double precision the second expression would be more accurate, but replicating the calculations in R did not show any differences between these two expressions. 

x1 &lt;- (1/0.999999999999)
y1 &lt;- (1/0.99999999999999)

log(x1)-log(y1)
log((x1/y1))
1/log(1.00000001)
Assume that every single operation has a relative error ≤ eps. Starting with this, what if x = 1.001 and y = 0.999, or x = 10.01 and y = 9.99, or x = 1,001,000,000 and y = 999,000,000? How is log (x / y) affected, and how is log (x) - log (y) affected?