Average Error: 29.9 → 0.2
Time: 8.3s
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 r130362 = x;
        double r130363 = 1.0;
        double r130364 = r130362 + r130363;
        double r130365 = sqrt(r130364);
        double r130366 = sqrt(r130362);
        double r130367 = r130365 - r130366;
        return r130367;
}

double f(double x) {
        double r130368 = 1.0;
        double r130369 = x;
        double r130370 = r130369 + r130368;
        double r130371 = sqrt(r130370);
        double r130372 = sqrt(r130369);
        double r130373 = r130371 + r130372;
        double r130374 = r130368 / r130373;
        return r130374;
}

Error

Bits error versus x

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

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

Derivation

  1. Initial program 29.9

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

    \[\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}{0 + 1}}{\sqrt{x + 1} + \sqrt{x}}\]
  5. Final simplification0.2

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

Reproduce

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

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

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