Average Error: 20.1 → 0.8
Time: 16.3s
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 r137638 = 1.0;
        double r137639 = x;
        double r137640 = sqrt(r137639);
        double r137641 = r137638 / r137640;
        double r137642 = r137639 + r137638;
        double r137643 = sqrt(r137642);
        double r137644 = r137638 / r137643;
        double r137645 = r137641 - r137644;
        return r137645;
}

double f(double x) {
        double r137646 = 1.0;
        double r137647 = r137646 * r137646;
        double r137648 = x;
        double r137649 = sqrt(r137648);
        double r137650 = r137646 / r137649;
        double r137651 = r137648 + r137646;
        double r137652 = sqrt(r137651);
        double r137653 = r137646 / r137652;
        double r137654 = r137650 + r137653;
        double r137655 = r137654 * r137648;
        double r137656 = r137655 * r137651;
        double r137657 = r137647 / r137656;
        return r137657;
}

Error

Bits error versus x

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original20.1
Target0.6
Herbie0.8
\[\frac{1}{\left(x + 1\right) \cdot \sqrt{x} + x \cdot \sqrt{x + 1}}\]

Derivation

  1. Initial program 20.1

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

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

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

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

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

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

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