(FPCore (x) :precision binary64 (- (/ 1.0 (sqrt x)) (/ 1.0 (sqrt (+ x 1.0)))))
(FPCore (x) :precision binary64 (/ (pow (+ 1.0 x) -0.5) (+ x (hypot x (sqrt x)))))
double code(double x) {
return (1.0 / sqrt(x)) - (1.0 / sqrt((x + 1.0)));
}
double code(double x) {
return pow((1.0 + x), -0.5) / (x + hypot(x, sqrt(x)));
}
public static double code(double x) {
return (1.0 / Math.sqrt(x)) - (1.0 / Math.sqrt((x + 1.0)));
}
public static double code(double x) {
return Math.pow((1.0 + x), -0.5) / (x + Math.hypot(x, Math.sqrt(x)));
}
def code(x): return (1.0 / math.sqrt(x)) - (1.0 / math.sqrt((x + 1.0)))
def code(x): return math.pow((1.0 + x), -0.5) / (x + math.hypot(x, math.sqrt(x)))
function code(x) return Float64(Float64(1.0 / sqrt(x)) - Float64(1.0 / sqrt(Float64(x + 1.0)))) end
function code(x) return Float64((Float64(1.0 + x) ^ -0.5) / Float64(x + hypot(x, sqrt(x)))) end
function tmp = code(x) tmp = (1.0 / sqrt(x)) - (1.0 / sqrt((x + 1.0))); end
function tmp = code(x) tmp = ((1.0 + x) ^ -0.5) / (x + hypot(x, sqrt(x))); end
code[x_] := N[(N[(1.0 / N[Sqrt[x], $MachinePrecision]), $MachinePrecision] - N[(1.0 / N[Sqrt[N[(x + 1.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
code[x_] := N[(N[Power[N[(1.0 + x), $MachinePrecision], -0.5], $MachinePrecision] / N[(x + N[Sqrt[x ^ 2 + N[Sqrt[x], $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\frac{1}{\sqrt{x}} - \frac{1}{\sqrt{x + 1}}
\frac{{\left(1 + x\right)}^{-0.5}}{x + \mathsf{hypot}\left(x, \sqrt{x}\right)}




Bits error versus x
Results
| Original | 19.8 |
|---|---|
| Target | 0.7 |
| Herbie | 0.2 |
Initial program 19.8
Applied egg-rr19.7
Applied egg-rr19.1
Applied egg-rr5.4
Applied egg-rr0.2
Final simplification0.2
herbie shell --seed 2022144
(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)))))