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




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