\sqrt{x + 1} - \sqrt{x}
\mathsf{expm1}\left(\mathsf{log1p}\left(\mathsf{log1p}\left(\mathsf{expm1}\left(\frac{1}{\sqrt{1 + x} + \sqrt{x}}\right)\right)\right)\right)
(FPCore (x) :precision binary64 (- (sqrt (+ x 1.0)) (sqrt x)))
(FPCore (x) :precision binary64 (expm1 (log1p (log1p (expm1 (/ 1.0 (+ (sqrt (+ 1.0 x)) (sqrt x))))))))
double code(double x) {
return sqrt(x + 1.0) - sqrt(x);
}
double code(double x) {
return expm1(log1p(log1p(expm1(1.0 / (sqrt(1.0 + x) + sqrt(x))))));
}




Bits error versus x
Results
| Original | 30.3 |
|---|---|
| Target | 0.2 |
| Herbie | 0.2 |
Initial program 30.3
Applied flip--_binary6430.1
Simplified0.2
Simplified0.2
Applied add-sqr-sqrt_binary640.3
Applied log1p-expm1-u_binary640.3
Simplified0.2
Applied expm1-log1p-u_binary640.2
Final simplification0.2
herbie shell --seed 2021344
(FPCore (x)
:name "2sqrt (example 3.1)"
:precision binary64
:herbie-target
(/ 1.0 (+ (sqrt (+ x 1.0)) (sqrt x)))
(- (sqrt (+ x 1.0)) (sqrt x)))