Average Error: 20.0 → 0.4
Time: 16.0s
Precision: 64
\[\frac{1}{\sqrt{x}} - \frac{1}{\sqrt{x + 1}}\]
\[\frac{1}{\sqrt{x + 1} \cdot \sqrt{x}} \cdot \frac{1}{\sqrt{x} \cdot 1 + \sqrt{x + 1} \cdot 1}\]
\frac{1}{\sqrt{x}} - \frac{1}{\sqrt{x + 1}}
\frac{1}{\sqrt{x + 1} \cdot \sqrt{x}} \cdot \frac{1}{\sqrt{x} \cdot 1 + \sqrt{x + 1} \cdot 1}
double f(double x) {
        double r6212284 = 1.0;
        double r6212285 = x;
        double r6212286 = sqrt(r6212285);
        double r6212287 = r6212284 / r6212286;
        double r6212288 = r6212285 + r6212284;
        double r6212289 = sqrt(r6212288);
        double r6212290 = r6212284 / r6212289;
        double r6212291 = r6212287 - r6212290;
        return r6212291;
}

double f(double x) {
        double r6212292 = 1.0;
        double r6212293 = x;
        double r6212294 = 1.0;
        double r6212295 = r6212293 + r6212294;
        double r6212296 = sqrt(r6212295);
        double r6212297 = sqrt(r6212293);
        double r6212298 = r6212296 * r6212297;
        double r6212299 = r6212292 / r6212298;
        double r6212300 = r6212297 * r6212294;
        double r6212301 = r6212296 * r6212294;
        double r6212302 = r6212300 + r6212301;
        double r6212303 = r6212294 / r6212302;
        double r6212304 = r6212299 * r6212303;
        return r6212304;
}

Error

Bits error versus x

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original20.0
Target0.8
Herbie0.4
\[\frac{1}{\left(x + 1\right) \cdot \sqrt{x} + x \cdot \sqrt{x + 1}}\]

Derivation

  1. Initial program 20.0

    \[\frac{1}{\sqrt{x}} - \frac{1}{\sqrt{x + 1}}\]
  2. Using strategy rm
  3. Applied frac-sub20.0

    \[\leadsto \color{blue}{\frac{1 \cdot \sqrt{x + 1} - \sqrt{x} \cdot 1}{\sqrt{x} \cdot \sqrt{x + 1}}}\]
  4. Using strategy rm
  5. Applied flip--19.8

    \[\leadsto \frac{\color{blue}{\frac{\left(1 \cdot \sqrt{x + 1}\right) \cdot \left(1 \cdot \sqrt{x + 1}\right) - \left(\sqrt{x} \cdot 1\right) \cdot \left(\sqrt{x} \cdot 1\right)}{1 \cdot \sqrt{x + 1} + \sqrt{x} \cdot 1}}}{\sqrt{x} \cdot \sqrt{x + 1}}\]
  6. Taylor expanded around 0 0.4

    \[\leadsto \frac{\frac{\color{blue}{1}}{1 \cdot \sqrt{x + 1} + \sqrt{x} \cdot 1}}{\sqrt{x} \cdot \sqrt{x + 1}}\]
  7. Using strategy rm
  8. Applied div-inv0.4

    \[\leadsto \color{blue}{\frac{1}{1 \cdot \sqrt{x + 1} + \sqrt{x} \cdot 1} \cdot \frac{1}{\sqrt{x} \cdot \sqrt{x + 1}}}\]
  9. Final simplification0.4

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

Reproduce

herbie shell --seed 2019172 
(FPCore (x)
  :name "2isqrt (example 3.6)"

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

  (- (/ 1.0 (sqrt x)) (/ 1.0 (sqrt (+ x 1.0)))))