Average Error: 20.1 → 0.2
Time: 3.9s
Precision: binary64
\[\frac{1}{\sqrt{x}} - \frac{1}{\sqrt{x + 1}} \]
\[\frac{1}{\sqrt{x} + \sqrt{1 + x}} \cdot \left({x}^{-0.5} \cdot {\left(1 + x\right)}^{-0.5}\right) \]
(FPCore (x) :precision binary64 (- (/ 1.0 (sqrt x)) (/ 1.0 (sqrt (+ x 1.0)))))
(FPCore (x)
 :precision binary64
 (*
  (/ 1.0 (+ (sqrt x) (sqrt (+ 1.0 x))))
  (* (pow x -0.5) (pow (+ 1.0 x) -0.5))))
double code(double x) {
	return (1.0 / sqrt(x)) - (1.0 / sqrt((x + 1.0)));
}
double code(double x) {
	return (1.0 / (sqrt(x) + sqrt((1.0 + x)))) * (pow(x, -0.5) * pow((1.0 + x), -0.5));
}
real(8) function code(x)
    real(8), intent (in) :: x
    code = (1.0d0 / sqrt(x)) - (1.0d0 / sqrt((x + 1.0d0)))
end function
real(8) function code(x)
    real(8), intent (in) :: x
    code = (1.0d0 / (sqrt(x) + sqrt((1.0d0 + x)))) * ((x ** (-0.5d0)) * ((1.0d0 + x) ** (-0.5d0)))
end function
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.sqrt(x) + Math.sqrt((1.0 + x)))) * (Math.pow(x, -0.5) * Math.pow((1.0 + x), -0.5));
}
def code(x):
	return (1.0 / math.sqrt(x)) - (1.0 / math.sqrt((x + 1.0)))
def code(x):
	return (1.0 / (math.sqrt(x) + math.sqrt((1.0 + x)))) * (math.pow(x, -0.5) * math.pow((1.0 + x), -0.5))
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 / Float64(sqrt(x) + sqrt(Float64(1.0 + x)))) * Float64((x ^ -0.5) * (Float64(1.0 + x) ^ -0.5)))
end
function tmp = code(x)
	tmp = (1.0 / sqrt(x)) - (1.0 / sqrt((x + 1.0)));
end
function tmp = code(x)
	tmp = (1.0 / (sqrt(x) + sqrt((1.0 + x)))) * ((x ^ -0.5) * ((1.0 + x) ^ -0.5));
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[(N[Sqrt[x], $MachinePrecision] + N[Sqrt[N[(1.0 + x), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(N[Power[x, -0.5], $MachinePrecision] * N[Power[N[(1.0 + x), $MachinePrecision], -0.5], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\frac{1}{\sqrt{x}} - \frac{1}{\sqrt{x + 1}}
\frac{1}{\sqrt{x} + \sqrt{1 + x}} \cdot \left({x}^{-0.5} \cdot {\left(1 + x\right)}^{-0.5}\right)

Error

Bits error versus x

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

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

Derivation

  1. Initial program 20.1

    \[\frac{1}{\sqrt{x}} - \frac{1}{\sqrt{x + 1}} \]
  2. Applied egg-rr20.0

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

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

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

    \[\leadsto \color{blue}{\frac{1}{\sqrt{x} + \sqrt{1 + x}} \cdot \left({x}^{-0.5} \cdot {\left(1 + x\right)}^{-0.5}\right)} \]
  6. Final simplification0.2

    \[\leadsto \frac{1}{\sqrt{x} + \sqrt{1 + x}} \cdot \left({x}^{-0.5} \cdot {\left(1 + x\right)}^{-0.5}\right) \]

Reproduce

herbie shell --seed 2022165 
(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)))))