x - \sqrt{x \cdot x - \varepsilon}
\frac{1}{\frac{x + \sqrt{x \cdot x - \varepsilon}}{\varepsilon}}
(FPCore (x eps) :precision binary64 (- x (sqrt (- (* x x) eps))))
(FPCore (x eps) :precision binary64 (/ 1.0 (/ (+ x (sqrt (- (* x x) eps))) eps)))
double code(double x, double eps) {
return x - sqrt(((x * x) - eps));
}
double code(double x, double eps) {
return 1.0 / ((x + sqrt(((x * x) - eps))) / eps);
}




Bits error versus x




Bits error versus eps
Results
| Original | 24.1 |
|---|---|
| Target | 0.3 |
| Herbie | 0.4 |
Initial program 24.1
Applied egg-rr24.3
Taylor expanded in x around 0 0.4
Applied egg-rr0.4
Final simplification0.4
herbie shell --seed 2022130
(FPCore (x eps)
:name "ENA, Section 1.4, Exercise 4d"
:precision binary64
:pre (and (and (<= 0.0 x) (<= x 1000000000.0)) (and (<= -1.0 eps) (<= eps 1.0)))
:herbie-target
(/ eps (+ x (sqrt (- (* x x) eps))))
(- x (sqrt (- (* x x) eps))))