Average Error: 20.0 → 0.4
Time: 21.0s
Precision: 64
\[\frac{1}{\sqrt{x}} - \frac{1}{\sqrt{x + 1}}\]
\[\frac{\frac{1}{x}}{\frac{1}{\sqrt{1 + x}} + \frac{1}{\sqrt{x}}} \cdot \frac{1 \cdot 1}{1 + x}\]
\frac{1}{\sqrt{x}} - \frac{1}{\sqrt{x + 1}}
\frac{\frac{1}{x}}{\frac{1}{\sqrt{1 + x}} + \frac{1}{\sqrt{x}}} \cdot \frac{1 \cdot 1}{1 + x}
double f(double x) {
        double r6251504 = 1.0;
        double r6251505 = x;
        double r6251506 = sqrt(r6251505);
        double r6251507 = r6251504 / r6251506;
        double r6251508 = r6251505 + r6251504;
        double r6251509 = sqrt(r6251508);
        double r6251510 = r6251504 / r6251509;
        double r6251511 = r6251507 - r6251510;
        return r6251511;
}

double f(double x) {
        double r6251512 = 1.0;
        double r6251513 = x;
        double r6251514 = r6251512 / r6251513;
        double r6251515 = r6251512 + r6251513;
        double r6251516 = sqrt(r6251515);
        double r6251517 = r6251512 / r6251516;
        double r6251518 = sqrt(r6251513);
        double r6251519 = r6251512 / r6251518;
        double r6251520 = r6251517 + r6251519;
        double r6251521 = r6251514 / r6251520;
        double r6251522 = r6251512 * r6251512;
        double r6251523 = r6251522 / r6251515;
        double r6251524 = r6251521 * r6251523;
        return r6251524;
}

Error

Bits error versus x

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

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

Derivation

  1. Initial program 20.0

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

    \[\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. Using strategy rm
  5. Applied frac-times25.2

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

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

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

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

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

    \[\leadsto \frac{\frac{\left(1 \cdot 1\right) \cdot \color{blue}{1}}{\left(x + 1\right) \cdot x}}{\frac{1}{\sqrt{x}} + \frac{1}{\sqrt{x + 1}}}\]
  11. Using strategy rm
  12. Applied *-un-lft-identity5.9

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

    \[\leadsto \frac{\color{blue}{\frac{1 \cdot 1}{x + 1} \cdot \frac{1}{x}}}{1 \cdot \left(\frac{1}{\sqrt{x}} + \frac{1}{\sqrt{x + 1}}\right)}\]
  14. Applied times-frac0.4

    \[\leadsto \color{blue}{\frac{\frac{1 \cdot 1}{x + 1}}{1} \cdot \frac{\frac{1}{x}}{\frac{1}{\sqrt{x}} + \frac{1}{\sqrt{x + 1}}}}\]
  15. Simplified0.4

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

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

Reproduce

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

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

  (- (/ 1.0 (sqrt x)) (/ 1.0 (sqrt (+ x 1.0)))))