(FPCore (x) :precision binary64 (- (/ 1.0 (sqrt x)) (/ 1.0 (sqrt (+ x 1.0)))))
(FPCore (x) :precision binary64 (/ (/ (+ 1.0 (- x x)) (+ (sqrt x) (hypot 1.0 (sqrt x)))) (hypot (sqrt x) x)))
double code(double x) {
return (1.0 / sqrt(x)) - (1.0 / sqrt((x + 1.0)));
}
double code(double x) {
return ((1.0 + (x - x)) / (sqrt(x) + hypot(1.0, sqrt(x)))) / hypot(sqrt(x), 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 ((1.0 + (x - x)) / (Math.sqrt(x) + Math.hypot(1.0, Math.sqrt(x)))) / Math.hypot(Math.sqrt(x), x);
}
def code(x): return (1.0 / math.sqrt(x)) - (1.0 / math.sqrt((x + 1.0)))
def code(x): return ((1.0 + (x - x)) / (math.sqrt(x) + math.hypot(1.0, math.sqrt(x)))) / math.hypot(math.sqrt(x), 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(Float64(1.0 + Float64(x - x)) / Float64(sqrt(x) + hypot(1.0, sqrt(x)))) / hypot(sqrt(x), 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 - x)) / (sqrt(x) + hypot(1.0, sqrt(x)))) / hypot(sqrt(x), 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[(N[(1.0 + N[(x - x), $MachinePrecision]), $MachinePrecision] / N[(N[Sqrt[x], $MachinePrecision] + N[Sqrt[1.0 ^ 2 + N[Sqrt[x], $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[Sqrt[N[Sqrt[x], $MachinePrecision] ^ 2 + x ^ 2], $MachinePrecision]), $MachinePrecision]
\frac{1}{\sqrt{x}} - \frac{1}{\sqrt{x + 1}}
\frac{\frac{1 + \left(x - x\right)}{\sqrt{x} + \mathsf{hypot}\left(1, \sqrt{x}\right)}}{\mathsf{hypot}\left(\sqrt{x}, x\right)}




Bits error versus x
Results
| Original | 19.7 |
|---|---|
| Target | 0.6 |
| Herbie | 0.3 |
Initial program 19.7
Applied egg-rr19.7
Applied egg-rr5.7
Applied egg-rr0.3
Applied egg-rr0.3
Final simplification0.3
herbie shell --seed 2022148
(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)))))