Average Error: 19.6 → 0.7
Time: 8.2s
Precision: 64
\[\frac{1}{\sqrt{x}} - \frac{1}{\sqrt{x + 1}}\]
\[\frac{1 \cdot 1}{\sqrt{x} \cdot \left(x + 1\right) + \sqrt{\sqrt{x + 1}} \cdot \left(\sqrt{\sqrt{x + 1}} \cdot x\right)}\]
\frac{1}{\sqrt{x}} - \frac{1}{\sqrt{x + 1}}
\frac{1 \cdot 1}{\sqrt{x} \cdot \left(x + 1\right) + \sqrt{\sqrt{x + 1}} \cdot \left(\sqrt{\sqrt{x + 1}} \cdot x\right)}
double f(double x) {
        double r96001 = 1.0;
        double r96002 = x;
        double r96003 = sqrt(r96002);
        double r96004 = r96001 / r96003;
        double r96005 = r96002 + r96001;
        double r96006 = sqrt(r96005);
        double r96007 = r96001 / r96006;
        double r96008 = r96004 - r96007;
        return r96008;
}

double f(double x) {
        double r96009 = 1.0;
        double r96010 = r96009 * r96009;
        double r96011 = x;
        double r96012 = sqrt(r96011);
        double r96013 = r96011 + r96009;
        double r96014 = r96012 * r96013;
        double r96015 = sqrt(r96013);
        double r96016 = sqrt(r96015);
        double r96017 = r96016 * r96011;
        double r96018 = r96016 * r96017;
        double r96019 = r96014 + r96018;
        double r96020 = r96010 / r96019;
        return r96020;
}

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.7
\[\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 frac-sub19.6

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

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

    \[\leadsto \frac{1 \cdot \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. Applied associate-*r/19.4

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

    \[\leadsto \color{blue}{\frac{1 \cdot \left(\sqrt{x + 1} \cdot \sqrt{x + 1} - \sqrt{x} \cdot \sqrt{x}\right)}{\left(\sqrt{x} \cdot \sqrt{x + 1}\right) \cdot \left(\sqrt{x + 1} + \sqrt{x}\right)}}\]
  9. Simplified19.4

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

    \[\leadsto \frac{1 \cdot \color{blue}{1}}{\sqrt{x} \cdot \left(x + 1\right) + \sqrt{x + 1} \cdot x}\]
  11. Using strategy rm
  12. Applied add-sqr-sqrt0.7

    \[\leadsto \frac{1 \cdot 1}{\sqrt{x} \cdot \left(x + 1\right) + \sqrt{\color{blue}{\sqrt{x + 1} \cdot \sqrt{x + 1}}} \cdot x}\]
  13. Applied sqrt-prod0.7

    \[\leadsto \frac{1 \cdot 1}{\sqrt{x} \cdot \left(x + 1\right) + \color{blue}{\left(\sqrt{\sqrt{x + 1}} \cdot \sqrt{\sqrt{x + 1}}\right)} \cdot x}\]
  14. Applied associate-*l*0.7

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

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

Reproduce

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