Average Error: 19.7 → 0.4
Time: 15.3s
Precision: 64
\[\frac{1}{\sqrt{x}} - \frac{1}{\sqrt{x + 1}}\]
\[\frac{1}{\sqrt{x + 1} + \sqrt{x}} \cdot \frac{1}{\sqrt{x + 1} \cdot \sqrt{x}}\]
\frac{1}{\sqrt{x}} - \frac{1}{\sqrt{x + 1}}
\frac{1}{\sqrt{x + 1} + \sqrt{x}} \cdot \frac{1}{\sqrt{x + 1} \cdot \sqrt{x}}
double f(double x) {
        double r5675177 = 1.0;
        double r5675178 = x;
        double r5675179 = sqrt(r5675178);
        double r5675180 = r5675177 / r5675179;
        double r5675181 = r5675178 + r5675177;
        double r5675182 = sqrt(r5675181);
        double r5675183 = r5675177 / r5675182;
        double r5675184 = r5675180 - r5675183;
        return r5675184;
}

double f(double x) {
        double r5675185 = 1.0;
        double r5675186 = x;
        double r5675187 = r5675186 + r5675185;
        double r5675188 = sqrt(r5675187);
        double r5675189 = sqrt(r5675186);
        double r5675190 = r5675188 + r5675189;
        double r5675191 = r5675185 / r5675190;
        double r5675192 = r5675188 * r5675189;
        double r5675193 = r5675185 / r5675192;
        double r5675194 = r5675191 * r5675193;
        return r5675194;
}

Error

Bits error versus x

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

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

Derivation

  1. Initial program 19.7

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

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

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

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

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

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

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

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

Reproduce

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

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

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