Average Error: 19.4 → 0.7
Time: 4.5s
Precision: binary64
\[\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} \]
(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}

Error

Bits error versus x

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original19.4
Target0.7
Herbie0.7
\[\frac{1}{\left(x + 1\right) \cdot \sqrt{x} + x \cdot \sqrt{x + 1}} \]

Derivation

  1. Initial program 19.4

    \[\frac{1}{\sqrt{x}} - \frac{1}{\sqrt{x + 1}} \]
  2. Applied egg-rr19.6

    \[\leadsto \color{blue}{\frac{1}{\frac{{x}^{-0.5} + {\left(1 + x\right)}^{-0.5}}{\frac{1}{x} - \frac{1}{1 + x}}}} \]
  3. Applied egg-rr5.6

    \[\leadsto \frac{1}{\color{blue}{\frac{{x}^{-0.5} + {\left(1 + x\right)}^{-0.5}}{1 + \left(x - x\right)} \cdot \left(x + x \cdot x\right)}} \]
  4. Applied egg-rr0.7

    \[\leadsto \color{blue}{{\left(\mathsf{hypot}\left({\left(x + 1\right)}^{-0.25}, {x}^{-0.25}\right) \cdot \mathsf{hypot}\left(x, \sqrt{x}\right)\right)}^{-1} \cdot {\left(\mathsf{hypot}\left({\left(x + 1\right)}^{-0.25}, {x}^{-0.25}\right) \cdot \mathsf{hypot}\left(x, \sqrt{x}\right)\right)}^{-1}} \]
  5. Applied egg-rr0.7

    \[\leadsto {\left(\mathsf{hypot}\left({\left(x + 1\right)}^{-0.25}, {x}^{-0.25}\right) \cdot \mathsf{hypot}\left(x, \sqrt{x}\right)\right)}^{-1} \cdot \color{blue}{\frac{\frac{1}{\mathsf{hypot}\left({\left(x + 1\right)}^{-0.25}, {x}^{-0.25}\right)}}{\mathsf{hypot}\left(x, \sqrt{x}\right)}} \]
  6. Final simplification0.7

    \[\leadsto {\left(\mathsf{hypot}\left({\left(x + 1\right)}^{-0.25}, {x}^{-0.25}\right) \cdot \mathsf{hypot}\left(x, \sqrt{x}\right)\right)}^{-1} \cdot \frac{\frac{1}{\mathsf{hypot}\left({\left(x + 1\right)}^{-0.25}, {x}^{-0.25}\right)}}{\mathsf{hypot}\left(x, \sqrt{x}\right)} \]

Reproduce

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)))))