Average Error: 20.3 → 0.3
Time: 5.2s
Precision: binary64
\[\frac{1}{\sqrt{x}} - \frac{1}{\sqrt{x + 1}} \]
\[\begin{array}{l} t_0 := {\left(x + 1\right)}^{-0.5}\\ \left({x}^{-0.5} \cdot t_0\right) \cdot \frac{\frac{1}{\mathsf{hypot}\left(\sqrt{x}, x\right)}}{{x}^{-0.5} + t_0} \end{array} \]
\frac{1}{\sqrt{x}} - \frac{1}{\sqrt{x + 1}}
\begin{array}{l}
t_0 := {\left(x + 1\right)}^{-0.5}\\
\left({x}^{-0.5} \cdot t_0\right) \cdot \frac{\frac{1}{\mathsf{hypot}\left(\sqrt{x}, x\right)}}{{x}^{-0.5} + t_0}
\end{array}
(FPCore (x) :precision binary64 (- (/ 1.0 (sqrt x)) (/ 1.0 (sqrt (+ x 1.0)))))
(FPCore (x)
 :precision binary64
 (let* ((t_0 (pow (+ x 1.0) -0.5)))
   (*
    (* (pow x -0.5) t_0)
    (/ (/ 1.0 (hypot (sqrt x) x)) (+ (pow x -0.5) t_0)))))
double code(double x) {
	return (1.0 / sqrt(x)) - (1.0 / sqrt((x + 1.0)));
}
double code(double x) {
	double t_0 = pow((x + 1.0), -0.5);
	return (pow(x, -0.5) * t_0) * ((1.0 / hypot(sqrt(x), x)) / (pow(x, -0.5) + t_0));
}

Error

Bits error versus x

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

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

Derivation

  1. Initial program 20.3

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

    \[\leadsto \color{blue}{\frac{\frac{1}{x} - \frac{-1}{\sqrt{1 + x}} \cdot \frac{-1}{\sqrt{1 + x}}}{{x}^{-0.5} - \frac{-1}{\sqrt{1 + x}}}} \]
  3. Applied egg-rr19.7

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

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

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

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

Reproduce

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