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




Bits error versus x
Results
| Original | 19.4 |
|---|---|
| Target | 0.7 |
| Herbie | 0.7 |
Initial program 19.4
Applied egg-rr19.6
Applied egg-rr5.6
Applied egg-rr0.7
Applied egg-rr0.7
Final simplification0.7
herbie shell --seed 2022156
(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)))))