Average Error: 30.0 → 0.2
Time: 19.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 r3104081 = x;
        double r3104082 = 1.0;
        double r3104083 = r3104081 + r3104082;
        double r3104084 = sqrt(r3104083);
        double r3104085 = sqrt(r3104081);
        double r3104086 = r3104084 - r3104085;
        return r3104086;
}

double f(double x) {
        double r3104087 = 1.0;
        double r3104088 = x;
        double r3104089 = r3104088 + r3104087;
        double r3104090 = sqrt(r3104089);
        double r3104091 = sqrt(r3104088);
        double r3104092 = r3104090 + r3104091;
        double r3104093 = r3104087 / r3104092;
        return r3104093;
}

Error

Bits error versus x

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

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

Derivation

  1. Initial program 30.0

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

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

Reproduce

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

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

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