Average Error: 19.5 → 19.5
Time: 1.3m
Precision: 64
\[\frac{1}{\sqrt{x}} - \frac{1}{\sqrt{x + 1}}\]
\[\frac{1}{\sqrt{x}} - \frac{1}{\mathsf{hypot}\left(\sqrt{x}, 1\right)}\]
\frac{1}{\sqrt{x}} - \frac{1}{\sqrt{x + 1}}
\frac{1}{\sqrt{x}} - \frac{1}{\mathsf{hypot}\left(\sqrt{x}, 1\right)}
double f(double x) {
        double r5050651 = 1.0;
        double r5050652 = x;
        double r5050653 = sqrt(r5050652);
        double r5050654 = r5050651 / r5050653;
        double r5050655 = r5050652 + r5050651;
        double r5050656 = sqrt(r5050655);
        double r5050657 = r5050651 / r5050656;
        double r5050658 = r5050654 - r5050657;
        return r5050658;
}

double f(double x) {
        double r5050659 = 1.0;
        double r5050660 = x;
        double r5050661 = sqrt(r5050660);
        double r5050662 = r5050659 / r5050661;
        double r5050663 = hypot(r5050661, r5050659);
        double r5050664 = r5050659 / r5050663;
        double r5050665 = r5050662 - r5050664;
        return r5050665;
}

Error

Bits error versus x

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original19.5
Target0.6
Herbie19.5
\[\frac{1}{\left(x + 1\right) \cdot \sqrt{x} + x \cdot \sqrt{x + 1}}\]

Derivation

  1. Initial program 19.5

    \[\frac{1}{\sqrt{x}} - \frac{1}{\sqrt{x + 1}}\]
  2. Using strategy rm
  3. Applied *-un-lft-identity19.5

    \[\leadsto \frac{1}{\sqrt{x}} - \frac{1}{\sqrt{x + \color{blue}{1 \cdot 1}}}\]
  4. Applied add-sqr-sqrt19.5

    \[\leadsto \frac{1}{\sqrt{x}} - \frac{1}{\sqrt{\color{blue}{\sqrt{x} \cdot \sqrt{x}} + 1 \cdot 1}}\]
  5. Applied hypot-def19.5

    \[\leadsto \frac{1}{\sqrt{x}} - \frac{1}{\color{blue}{\mathsf{hypot}\left(\sqrt{x}, 1\right)}}\]
  6. Final simplification19.5

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

Reproduce

herbie shell --seed 2019141 +o rules:numerics
(FPCore (x)
  :name "2isqrt (example 3.6)"

  :herbie-target
  (/ 1 (+ (* (+ x 1) (sqrt x)) (* x (sqrt (+ x 1)))))

  (- (/ 1 (sqrt x)) (/ 1 (sqrt (+ x 1)))))