Hacker News
new
|
past
|
comments
|
ask
|
show
|
jobs
|
submit
login
russfink
6 months ago
|
parent
|
context
|
favorite
| on:
Herbie detects inaccurate expressions and finds mo...
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.
Piezoid
6 months 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.
Guidelines
|
FAQ
|
Lists
|
API
|
Security
|
Legal
|
Apply to YC
|
Contact
Search: