Average Error: 19.7 → 0.3
Time: 4.3s
Precision: binary64
\[\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)} \]
(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)}

Error

Bits error versus x

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

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

Derivation

  1. Initial program 19.7

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

    \[\leadsto \color{blue}{\frac{\sqrt{1 + x} - \sqrt{x}}{\sqrt{x \cdot \left(1 + x\right)}}} \]
  3. Applied egg-rr5.7

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

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

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

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

Reproduce

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