Average Error: 19.4 → 0.7
Time: 17.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 r111054 = 1.0;
        double r111055 = x;
        double r111056 = sqrt(r111055);
        double r111057 = r111054 / r111056;
        double r111058 = r111055 + r111054;
        double r111059 = sqrt(r111058);
        double r111060 = r111054 / r111059;
        double r111061 = r111057 - r111060;
        return r111061;
}

double f(double x) {
        double r111062 = 1.0;
        double r111063 = r111062 * r111062;
        double r111064 = x;
        double r111065 = sqrt(r111064);
        double r111066 = r111062 / r111065;
        double r111067 = r111064 + r111062;
        double r111068 = sqrt(r111067);
        double r111069 = r111062 / r111068;
        double r111070 = r111066 + r111069;
        double r111071 = r111070 * r111064;
        double r111072 = r111071 * r111067;
        double r111073 = r111063 / r111072;
        return r111073;
}

Error

Bits error versus x

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

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

Derivation

  1. Initial program 19.4

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

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

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

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

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

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

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

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

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