Average Error: 30.2 → 0.2
Time: 20.8s
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 r2595270 = x;
        double r2595271 = 1.0;
        double r2595272 = r2595270 + r2595271;
        double r2595273 = sqrt(r2595272);
        double r2595274 = sqrt(r2595270);
        double r2595275 = r2595273 - r2595274;
        return r2595275;
}

double f(double x) {
        double r2595276 = 1.0;
        double r2595277 = x;
        double r2595278 = r2595277 + r2595276;
        double r2595279 = sqrt(r2595278);
        double r2595280 = sqrt(r2595277);
        double r2595281 = r2595279 + r2595280;
        double r2595282 = r2595276 / r2595281;
        return r2595282;
}

Error

Bits error versus x

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

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

Derivation

  1. Initial program 30.2

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

    \[\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 2019135 +o rules:numerics
(FPCore (x)
  :name "2sqrt (example 3.1)"

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

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