Average Error: 29.7 → 0.2
Time: 26.2s
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 r4325327 = x;
        double r4325328 = 1.0;
        double r4325329 = r4325327 + r4325328;
        double r4325330 = sqrt(r4325329);
        double r4325331 = sqrt(r4325327);
        double r4325332 = r4325330 - r4325331;
        return r4325332;
}

double f(double x) {
        double r4325333 = 1.0;
        double r4325334 = x;
        double r4325335 = r4325334 + r4325333;
        double r4325336 = sqrt(r4325335);
        double r4325337 = sqrt(r4325334);
        double r4325338 = r4325336 + r4325337;
        double r4325339 = r4325333 / r4325338;
        return r4325339;
}

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.5

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

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

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