Average Error: 20.0 → 0.4
Time: 15.1s
Precision: 64
\[\frac{1}{\sqrt{x}} - \frac{1}{\sqrt{x + 1}}\]
\[\frac{\sqrt{\frac{1}{\sqrt{x} \cdot 1 + \sqrt{x + 1} \cdot 1}}}{\sqrt{x}} \cdot \frac{\sqrt{\frac{1}{\sqrt{x} \cdot 1 + \sqrt{x + 1} \cdot 1}}}{\sqrt{x + 1}}\]
\frac{1}{\sqrt{x}} - \frac{1}{\sqrt{x + 1}}
\frac{\sqrt{\frac{1}{\sqrt{x} \cdot 1 + \sqrt{x + 1} \cdot 1}}}{\sqrt{x}} \cdot \frac{\sqrt{\frac{1}{\sqrt{x} \cdot 1 + \sqrt{x + 1} \cdot 1}}}{\sqrt{x + 1}}
double f(double x) {
        double r6332459 = 1.0;
        double r6332460 = x;
        double r6332461 = sqrt(r6332460);
        double r6332462 = r6332459 / r6332461;
        double r6332463 = r6332460 + r6332459;
        double r6332464 = sqrt(r6332463);
        double r6332465 = r6332459 / r6332464;
        double r6332466 = r6332462 - r6332465;
        return r6332466;
}

double f(double x) {
        double r6332467 = 1.0;
        double r6332468 = x;
        double r6332469 = sqrt(r6332468);
        double r6332470 = r6332469 * r6332467;
        double r6332471 = r6332468 + r6332467;
        double r6332472 = sqrt(r6332471);
        double r6332473 = r6332472 * r6332467;
        double r6332474 = r6332470 + r6332473;
        double r6332475 = r6332467 / r6332474;
        double r6332476 = sqrt(r6332475);
        double r6332477 = r6332476 / r6332469;
        double r6332478 = r6332476 / r6332472;
        double r6332479 = r6332477 * r6332478;
        return r6332479;
}

Error

Bits error versus x

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original20.0
Target0.7
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 add-sqr-sqrt0.4

    \[\leadsto \frac{\color{blue}{\sqrt{\frac{1}{1 \cdot \sqrt{x + 1} + \sqrt{x} \cdot 1}} \cdot \sqrt{\frac{1}{1 \cdot \sqrt{x + 1} + \sqrt{x} \cdot 1}}}}{\sqrt{x} \cdot \sqrt{x + 1}}\]
  9. Applied times-frac0.4

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

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

Reproduce

herbie shell --seed 2019171 
(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)))))