Average Error: 29.8 → 0.2
Time: 1.5m
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 r3248074 = x;
        double r3248075 = 1.0;
        double r3248076 = r3248074 + r3248075;
        double r3248077 = sqrt(r3248076);
        double r3248078 = sqrt(r3248074);
        double r3248079 = r3248077 - r3248078;
        return r3248079;
}

double f(double x) {
        double r3248080 = 1.0;
        double r3248081 = x;
        double r3248082 = r3248081 + r3248080;
        double r3248083 = sqrt(r3248082);
        double r3248084 = sqrt(r3248081);
        double r3248085 = r3248083 + r3248084;
        double r3248086 = r3248080 / r3248085;
        return r3248086;
}

Error

Bits error versus x

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

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

Derivation

  1. Initial program 29.8

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

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

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