Average Error: 19.3 → 0.8
Time: 12.4s
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 r134164 = 1.0;
        double r134165 = x;
        double r134166 = sqrt(r134165);
        double r134167 = r134164 / r134166;
        double r134168 = r134165 + r134164;
        double r134169 = sqrt(r134168);
        double r134170 = r134164 / r134169;
        double r134171 = r134167 - r134170;
        return r134171;
}

double f(double x) {
        double r134172 = 1.0;
        double r134173 = r134172 * r134172;
        double r134174 = x;
        double r134175 = sqrt(r134174);
        double r134176 = r134172 / r134175;
        double r134177 = r134174 + r134172;
        double r134178 = sqrt(r134177);
        double r134179 = r134172 / r134178;
        double r134180 = r134176 + r134179;
        double r134181 = r134180 * r134174;
        double r134182 = r134181 * r134177;
        double r134183 = r134173 / r134182;
        return r134183;
}

Error

Bits error versus x

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

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

Derivation

  1. Initial program 19.3

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

    \[\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.4

    \[\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-sub18.8

    \[\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/18.8

    \[\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/18.8

    \[\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.4

    \[\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 2019350 
(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)))))