Average Error: 19.6 → 0.8
Time: 18.1s
Precision: 64
\[\frac{1}{\sqrt{x}} - \frac{1}{\sqrt{x + 1}}\]
\[\frac{1 \cdot 1}{\left(\left(\frac{1}{\sqrt{x}} + \frac{1}{\sqrt{x + 1}}\right) \cdot x\right) \cdot \left(x + 1\right)}\]
\frac{1}{\sqrt{x}} - \frac{1}{\sqrt{x + 1}}
\frac{1 \cdot 1}{\left(\left(\frac{1}{\sqrt{x}} + \frac{1}{\sqrt{x + 1}}\right) \cdot x\right) \cdot \left(x + 1\right)}
double f(double x) {
        double r94864 = 1.0;
        double r94865 = x;
        double r94866 = sqrt(r94865);
        double r94867 = r94864 / r94866;
        double r94868 = r94865 + r94864;
        double r94869 = sqrt(r94868);
        double r94870 = r94864 / r94869;
        double r94871 = r94867 - r94870;
        return r94871;
}

double f(double x) {
        double r94872 = 1.0;
        double r94873 = r94872 * r94872;
        double r94874 = x;
        double r94875 = sqrt(r94874);
        double r94876 = r94872 / r94875;
        double r94877 = r94874 + r94872;
        double r94878 = sqrt(r94877);
        double r94879 = r94872 / r94878;
        double r94880 = r94876 + r94879;
        double r94881 = r94880 * r94874;
        double r94882 = r94881 * r94877;
        double r94883 = r94873 / r94882;
        return r94883;
}

Error

Bits error versus x

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original19.6
Target0.7
Herbie0.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 flip--19.7

    \[\leadsto \color{blue}{\frac{\frac{1}{\sqrt{x}} \cdot \frac{1}{\sqrt{x}} - \frac{1}{\sqrt{x + 1}} \cdot \frac{1}{\sqrt{x + 1}}}{\frac{1}{\sqrt{x}} + \frac{1}{\sqrt{x + 1}}}}\]
  4. Simplified19.7

    \[\leadsto \frac{\color{blue}{1 \cdot \left(\frac{1}{x} - \frac{1}{x + 1}\right)}}{\frac{1}{\sqrt{x}} + \frac{1}{\sqrt{x + 1}}}\]
  5. Using strategy rm
  6. Applied frac-sub19.0

    \[\leadsto \frac{1 \cdot \color{blue}{\frac{1 \cdot \left(x + 1\right) - x \cdot 1}{x \cdot \left(x + 1\right)}}}{\frac{1}{\sqrt{x}} + \frac{1}{\sqrt{x + 1}}}\]
  7. Applied associate-*r/19.0

    \[\leadsto \frac{\color{blue}{\frac{1 \cdot \left(1 \cdot \left(x + 1\right) - x \cdot 1\right)}{x \cdot \left(x + 1\right)}}}{\frac{1}{\sqrt{x}} + \frac{1}{\sqrt{x + 1}}}\]
  8. Applied associate-/l/19.0

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

    \[\leadsto \frac{1 \cdot \color{blue}{1}}{\left(\frac{1}{\sqrt{x}} + \frac{1}{\sqrt{x + 1}}\right) \cdot \left(x \cdot \left(x + 1\right)\right)}\]
  10. Using strategy rm
  11. Applied associate-*r*0.8

    \[\leadsto \frac{1 \cdot 1}{\color{blue}{\left(\left(\frac{1}{\sqrt{x}} + \frac{1}{\sqrt{x + 1}}\right) \cdot x\right) \cdot \left(x + 1\right)}}\]
  12. Final simplification0.8

    \[\leadsto \frac{1 \cdot 1}{\left(\left(\frac{1}{\sqrt{x}} + \frac{1}{\sqrt{x + 1}}\right) \cdot x\right) \cdot \left(x + 1\right)}\]

Reproduce

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