Average Error: 19.6 → 19.8
Time: 29.8s
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 r157980 = 1.0;
        double r157981 = x;
        double r157982 = sqrt(r157981);
        double r157983 = r157980 / r157982;
        double r157984 = r157981 + r157980;
        double r157985 = sqrt(r157984);
        double r157986 = r157980 / r157985;
        double r157987 = r157983 - r157986;
        return r157987;
}

double f(double x) {
        double r157988 = 1.0;
        double r157989 = x;
        double r157990 = sqrt(r157989);
        double r157991 = r157988 / r157990;
        double r157992 = r157989 + r157988;
        double r157993 = sqrt(r157992);
        double r157994 = r157988 / r157993;
        double r157995 = r157991 - r157994;
        double r157996 = sqrt(r157995);
        double r157997 = r157996 * r157996;
        return r157997;
}

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)))))