Average Error: 29.7 → 0.2
Time: 11.4s
Precision: 64
\[\sqrt{x + 1} - \sqrt{x}\]
\[\frac{1}{\sqrt{x + 1} + \sqrt{x}}\]
\sqrt{x + 1} - \sqrt{x}
\frac{1}{\sqrt{x + 1} + \sqrt{x}}
double f(double x) {
        double r1989467 = x;
        double r1989468 = 1.0;
        double r1989469 = r1989467 + r1989468;
        double r1989470 = sqrt(r1989469);
        double r1989471 = sqrt(r1989467);
        double r1989472 = r1989470 - r1989471;
        return r1989472;
}

double f(double x) {
        double r1989473 = 1.0;
        double r1989474 = x;
        double r1989475 = r1989474 + r1989473;
        double r1989476 = sqrt(r1989475);
        double r1989477 = sqrt(r1989474);
        double r1989478 = r1989476 + r1989477;
        double r1989479 = r1989473 / r1989478;
        return r1989479;
}

Error

Bits error versus x

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original29.7
Target0.2
Herbie0.2
\[\frac{1}{\sqrt{x + 1} + \sqrt{x}}\]

Derivation

  1. Initial program 29.7

    \[\sqrt{x + 1} - \sqrt{x}\]
  2. Using strategy rm
  3. Applied flip--29.4

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

    \[\leadsto \frac{\color{blue}{1}}{\sqrt{x + 1} + \sqrt{x}}\]
  5. Final simplification0.2

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

Reproduce

herbie shell --seed 2019128 +o rules:numerics
(FPCore (x)
  :name "2sqrt (example 3.1)"

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

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