Better HN
top
new
best
ask
show
jobs
Log in
Sign up
Better HN
Comment
by
russfink
· 1y ago · 0 comments
Can someone explain why sqrt(x+1) - sqrt(x) is “inaccurate” for all x>1? Inaccurate how, and why, and why is 1/(…) any better? Thanks.
Comments
[–]
Piezoid
1y ago
Close floating-point subtraction loses precision: when x >> 1, sqrt(x+1) ≈ sqrt(x), so their difference suffers cancellation and end up rounding to zero. In contrast, sqrt(x+1) + sqrt(x) approaches 2*sqrt(x) smoothly.