(FPCore (x) :precision binary64 (- (/ 1.0 (sqrt x)) (/ 1.0 (sqrt (+ x 1.0)))))
(FPCore (x) :precision binary64 (let* ((t_0 (hypot x (sqrt x)))) (/ (/ 1.0 t_0) (* t_0 (+ (/ 1.0 (sqrt x)) (/ 1.0 (sqrt (+ 1.0 x))))))))
double code(double x) {
return (1.0 / sqrt(x)) - (1.0 / sqrt((x + 1.0)));
}
double code(double x) {
double t_0 = hypot(x, sqrt(x));
return (1.0 / t_0) / (t_0 * ((1.0 / sqrt(x)) + (1.0 / 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) {
double t_0 = Math.hypot(x, Math.sqrt(x));
return (1.0 / t_0) / (t_0 * ((1.0 / Math.sqrt(x)) + (1.0 / Math.sqrt((1.0 + x)))));
}
def code(x): return (1.0 / math.sqrt(x)) - (1.0 / math.sqrt((x + 1.0)))
def code(x): t_0 = math.hypot(x, math.sqrt(x)) return (1.0 / t_0) / (t_0 * ((1.0 / math.sqrt(x)) + (1.0 / 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) t_0 = hypot(x, sqrt(x)) return Float64(Float64(1.0 / t_0) / Float64(t_0 * Float64(Float64(1.0 / sqrt(x)) + Float64(1.0 / sqrt(Float64(1.0 + x)))))) end
function tmp = code(x) tmp = (1.0 / sqrt(x)) - (1.0 / sqrt((x + 1.0))); end
function tmp = code(x) t_0 = hypot(x, sqrt(x)); tmp = (1.0 / t_0) / (t_0 * ((1.0 / sqrt(x)) + (1.0 / sqrt((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_] := Block[{t$95$0 = N[Sqrt[x ^ 2 + N[Sqrt[x], $MachinePrecision] ^ 2], $MachinePrecision]}, N[(N[(1.0 / t$95$0), $MachinePrecision] / N[(t$95$0 * N[(N[(1.0 / N[Sqrt[x], $MachinePrecision]), $MachinePrecision] + N[(1.0 / N[Sqrt[N[(1.0 + x), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\frac{1}{\sqrt{x}} - \frac{1}{\sqrt{x + 1}}
\begin{array}{l}
t_0 := \mathsf{hypot}\left(x, \sqrt{x}\right)\\
\frac{\frac{1}{t_0}}{t_0 \cdot \left(\frac{1}{\sqrt{x}} + \frac{1}{\sqrt{1 + x}}\right)}
\end{array}




Bits error versus x
Results
| Original | 20.1 |
|---|---|
| Target | 0.7 |
| Herbie | 0.3 |
Initial program 20.1
Applied flip--_binary6420.1
Simplified20.1
Simplified20.1
Applied frac-sub_binary6419.5
Simplified5.6
Simplified5.5
Applied *-un-lft-identity_binary645.5
Applied add-sqr-sqrt_binary645.6
Applied add-cube-cbrt_binary645.6
Applied times-frac_binary645.5
Applied times-frac_binary645.5
Simplified5.5
Simplified0.4
Applied frac-times_binary640.3
Final simplification0.3
herbie shell --seed 2022129
(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)))))