Average Error: 20.0 → 0.4
Time: 16.6s
Precision: 64
\[\frac{1}{\sqrt{x}} - \frac{1}{\sqrt{x + 1}}\]
\[\frac{1}{\sqrt{x + 1} \cdot \sqrt{x}} \cdot \frac{1}{\sqrt{x} \cdot 1 + \sqrt{x + 1} \cdot 1}\]
\frac{1}{\sqrt{x}} - \frac{1}{\sqrt{x + 1}}
\frac{1}{\sqrt{x + 1} \cdot \sqrt{x}} \cdot \frac{1}{\sqrt{x} \cdot 1 + \sqrt{x + 1} \cdot 1}
double f(double x) {
        double r5882438 = 1.0;
        double r5882439 = x;
        double r5882440 = sqrt(r5882439);
        double r5882441 = r5882438 / r5882440;
        double r5882442 = r5882439 + r5882438;
        double r5882443 = sqrt(r5882442);
        double r5882444 = r5882438 / r5882443;
        double r5882445 = r5882441 - r5882444;
        return r5882445;
}

double f(double x) {
        double r5882446 = 1.0;
        double r5882447 = x;
        double r5882448 = 1.0;
        double r5882449 = r5882447 + r5882448;
        double r5882450 = sqrt(r5882449);
        double r5882451 = sqrt(r5882447);
        double r5882452 = r5882450 * r5882451;
        double r5882453 = r5882446 / r5882452;
        double r5882454 = r5882451 * r5882448;
        double r5882455 = r5882450 * r5882448;
        double r5882456 = r5882454 + r5882455;
        double r5882457 = r5882448 / r5882456;
        double r5882458 = r5882453 * r5882457;
        return r5882458;
}

Error

Bits error versus x

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original20.0
Target0.8
Herbie0.4
\[\frac{1}{\left(x + 1\right) \cdot \sqrt{x} + x \cdot \sqrt{x + 1}}\]

Derivation

  1. Initial program 20.0

    \[\frac{1}{\sqrt{x}} - \frac{1}{\sqrt{x + 1}}\]
  2. Using strategy rm
  3. Applied frac-sub20.0

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

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

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

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

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

Reproduce

herbie shell --seed 2019172 
(FPCore (x)
  :name "2isqrt (example 3.6)"

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

  (- (/ 1.0 (sqrt x)) (/ 1.0 (sqrt (+ x 1.0)))))