\sqrt{x + 1} - \sqrt{x}
\begin{array}{l}
t_0 := \sqrt{1 + x}\\
{\left(\mathsf{fma}\left(t_0, \sqrt{x}, 1 + x\right) + \mathsf{fma}\left(t_0, \sqrt{x}, x\right)\right)}^{-0.5}
\end{array}
(FPCore (x) :precision binary64 (- (sqrt (+ x 1.0)) (sqrt x)))
(FPCore (x) :precision binary64 (let* ((t_0 (sqrt (+ 1.0 x)))) (pow (+ (fma t_0 (sqrt x) (+ 1.0 x)) (fma t_0 (sqrt x) x)) -0.5)))
double code(double x) {
return sqrt(x + 1.0) - sqrt(x);
}
double code(double x) {
double t_0 = sqrt(1.0 + x);
return pow((fma(t_0, sqrt(x), (1.0 + x)) + fma(t_0, sqrt(x), x)), -0.5);
}




Bits error versus x
| Original | 30.0 |
|---|---|
| Target | 0.2 |
| Herbie | 0.1 |
Initial program 30.0
Applied flip--_binary6429.7
Simplified0.2
Simplified0.2
Applied add-sqr-sqrt_binary640.3
Applied inv-pow_binary640.3
Applied sqrt-pow1_binary640.3
Applied inv-pow_binary640.3
Applied sqrt-pow1_binary640.3
Applied pow-prod-down_binary640.2
Applied distribute-rgt-in_binary640.2
Simplified0.1
Simplified0.1
Final simplification0.1
herbie shell --seed 2022121
(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)))