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




Bits error versus x
Results
| Original | 20.3 |
|---|---|
| Target | 0.7 |
| Herbie | 0.3 |
Initial program 20.3
Applied egg-rr26.1
Applied egg-rr19.7
Applied egg-rr0.4
Applied egg-rr0.3
Final simplification0.3
herbie shell --seed 2022125
(FPCore (x)
:name "2isqrt (example 3.6)"
:precision binary64
:herbie-target
(/ 1.0 (+ (* (+ x 1.0) (sqrt x)) (* x (sqrt (+ x 1.0)))))
(- (/ 1.0 (sqrt x)) (/ 1.0 (sqrt (+ x 1.0)))))