Average Error: 19.6 → 19.8
Time: 27.4s
Precision: 64
\[\frac{1}{\sqrt{x}} - \frac{1}{\sqrt{x + 1}}\]
\[\sqrt{\frac{1}{\sqrt{x}} - \frac{1}{\sqrt{x + 1}}} \cdot \sqrt{\frac{1}{\sqrt{x}} - \frac{1}{\sqrt{x + 1}}}\]
\frac{1}{\sqrt{x}} - \frac{1}{\sqrt{x + 1}}
\sqrt{\frac{1}{\sqrt{x}} - \frac{1}{\sqrt{x + 1}}} \cdot \sqrt{\frac{1}{\sqrt{x}} - \frac{1}{\sqrt{x + 1}}}
double f(double x) {
        double r140092 = 1.0;
        double r140093 = x;
        double r140094 = sqrt(r140093);
        double r140095 = r140092 / r140094;
        double r140096 = r140093 + r140092;
        double r140097 = sqrt(r140096);
        double r140098 = r140092 / r140097;
        double r140099 = r140095 - r140098;
        return r140099;
}

double f(double x) {
        double r140100 = 1.0;
        double r140101 = x;
        double r140102 = sqrt(r140101);
        double r140103 = r140100 / r140102;
        double r140104 = r140101 + r140100;
        double r140105 = sqrt(r140104);
        double r140106 = r140100 / r140105;
        double r140107 = r140103 - r140106;
        double r140108 = sqrt(r140107);
        double r140109 = r140108 * r140108;
        return r140109;
}

Error

Bits error versus x

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original19.6
Target0.7
Herbie19.8
\[\frac{1}{\left(x + 1\right) \cdot \sqrt{x} + x \cdot \sqrt{x + 1}}\]

Derivation

  1. Initial program 19.6

    \[\frac{1}{\sqrt{x}} - \frac{1}{\sqrt{x + 1}}\]
  2. Using strategy rm
  3. Applied add-sqr-sqrt19.8

    \[\leadsto \color{blue}{\sqrt{\frac{1}{\sqrt{x}} - \frac{1}{\sqrt{x + 1}}} \cdot \sqrt{\frac{1}{\sqrt{x}} - \frac{1}{\sqrt{x + 1}}}}\]
  4. Final simplification19.8

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

Reproduce

herbie shell --seed 2019325 +o rules:numerics
(FPCore (x)
  :name "2isqrt (example 3.6)"
  :precision binary64

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

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