Average Error: 19.7 → 0.4
Time: 13.9s
Precision: 64
\[\frac{1}{\sqrt{x}} - \frac{1}{\sqrt{x + 1}}\]
\[\frac{1}{\sqrt{x + 1} + \sqrt{x}} \cdot \frac{1}{\sqrt{x + 1} \cdot \sqrt{x}}\]
\frac{1}{\sqrt{x}} - \frac{1}{\sqrt{x + 1}}
\frac{1}{\sqrt{x + 1} + \sqrt{x}} \cdot \frac{1}{\sqrt{x + 1} \cdot \sqrt{x}}
double f(double x) {
        double r2972623 = 1.0;
        double r2972624 = x;
        double r2972625 = sqrt(r2972624);
        double r2972626 = r2972623 / r2972625;
        double r2972627 = r2972624 + r2972623;
        double r2972628 = sqrt(r2972627);
        double r2972629 = r2972623 / r2972628;
        double r2972630 = r2972626 - r2972629;
        return r2972630;
}

double f(double x) {
        double r2972631 = 1.0;
        double r2972632 = x;
        double r2972633 = r2972632 + r2972631;
        double r2972634 = sqrt(r2972633);
        double r2972635 = sqrt(r2972632);
        double r2972636 = r2972634 + r2972635;
        double r2972637 = r2972631 / r2972636;
        double r2972638 = r2972634 * r2972635;
        double r2972639 = r2972631 / r2972638;
        double r2972640 = r2972637 * r2972639;
        return r2972640;
}

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.4
\[\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. Using strategy rm
  3. Applied frac-sub19.7

    \[\leadsto \color{blue}{\frac{1 \cdot \sqrt{x + 1} - \sqrt{x} \cdot 1}{\sqrt{x} \cdot \sqrt{x + 1}}}\]
  4. Simplified19.7

    \[\leadsto \frac{\color{blue}{\sqrt{x + 1} - \sqrt{x}}}{\sqrt{x} \cdot \sqrt{x + 1}}\]
  5. Using strategy rm
  6. Applied flip--19.4

    \[\leadsto \frac{\color{blue}{\frac{\sqrt{x + 1} \cdot \sqrt{x + 1} - \sqrt{x} \cdot \sqrt{x}}{\sqrt{x + 1} + \sqrt{x}}}}{\sqrt{x} \cdot \sqrt{x + 1}}\]
  7. Simplified18.9

    \[\leadsto \frac{\frac{\color{blue}{\left(x + 1\right) - x}}{\sqrt{x + 1} + \sqrt{x}}}{\sqrt{x} \cdot \sqrt{x + 1}}\]
  8. Taylor expanded around 0 0.4

    \[\leadsto \frac{\frac{\color{blue}{1}}{\sqrt{x + 1} + \sqrt{x}}}{\sqrt{x} \cdot \sqrt{x + 1}}\]
  9. Using strategy rm
  10. Applied div-inv0.4

    \[\leadsto \color{blue}{\frac{1}{\sqrt{x + 1} + \sqrt{x}} \cdot \frac{1}{\sqrt{x} \cdot \sqrt{x + 1}}}\]
  11. Final simplification0.4

    \[\leadsto \frac{1}{\sqrt{x + 1} + \sqrt{x}} \cdot \frac{1}{\sqrt{x + 1} \cdot \sqrt{x}}\]

Reproduce

herbie shell --seed 2019163 +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)))))