Average Error: 30.1 → 0.2
Time: 17.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 r3829699 = x;
        double r3829700 = 1.0;
        double r3829701 = r3829699 + r3829700;
        double r3829702 = sqrt(r3829701);
        double r3829703 = sqrt(r3829699);
        double r3829704 = r3829702 - r3829703;
        return r3829704;
}

double f(double x) {
        double r3829705 = 1.0;
        double r3829706 = x;
        double r3829707 = r3829706 + r3829705;
        double r3829708 = sqrt(r3829707);
        double r3829709 = sqrt(r3829706);
        double r3829710 = r3829708 + r3829709;
        double r3829711 = r3829705 / r3829710;
        return r3829711;
}

Error

Bits error versus x

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

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

Derivation

  1. Initial program 30.1

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

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

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

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