Average Error: 29.3 → 0.2
Time: 25.6s
Precision: 64
\[\sqrt{x + 1} - \sqrt{x}\]
\[{\left(\left(\sqrt{x} + \mathsf{hypot}\left(\sqrt{x}, 1\right)\right) \cdot \left(\sqrt{x} + \mathsf{hypot}\left(\sqrt{x}, 1\right)\right)\right)}^{\frac{-1}{2}}\]
\sqrt{x + 1} - \sqrt{x}
{\left(\left(\sqrt{x} + \mathsf{hypot}\left(\sqrt{x}, 1\right)\right) \cdot \left(\sqrt{x} + \mathsf{hypot}\left(\sqrt{x}, 1\right)\right)\right)}^{\frac{-1}{2}}
double f(double x) {
        double r3604236 = x;
        double r3604237 = 1.0;
        double r3604238 = r3604236 + r3604237;
        double r3604239 = sqrt(r3604238);
        double r3604240 = sqrt(r3604236);
        double r3604241 = r3604239 - r3604240;
        return r3604241;
}

double f(double x) {
        double r3604242 = x;
        double r3604243 = sqrt(r3604242);
        double r3604244 = 1.0;
        double r3604245 = hypot(r3604243, r3604244);
        double r3604246 = r3604243 + r3604245;
        double r3604247 = r3604246 * r3604246;
        double r3604248 = -0.5;
        double r3604249 = pow(r3604247, r3604248);
        return r3604249;
}

Error

Bits error versus x

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original29.3
Target0.2
Herbie0.2
\[\frac{1}{\sqrt{x + 1} + \sqrt{x}}\]

Derivation

  1. Initial program 29.3

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

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

    \[\leadsto \frac{\color{blue}{1}}{\sqrt{x + 1} + \sqrt{x}}\]
  5. Using strategy rm
  6. Applied *-un-lft-identity0.2

    \[\leadsto \frac{1}{\sqrt{x + \color{blue}{1 \cdot 1}} + \sqrt{x}}\]
  7. Applied add-sqr-sqrt0.2

    \[\leadsto \frac{1}{\sqrt{\color{blue}{\sqrt{x} \cdot \sqrt{x}} + 1 \cdot 1} + \sqrt{x}}\]
  8. Applied hypot-def0.2

    \[\leadsto \frac{1}{\color{blue}{\mathsf{hypot}\left(\sqrt{x}, 1\right)} + \sqrt{x}}\]
  9. Using strategy rm
  10. Applied add-sqr-sqrt0.3

    \[\leadsto \color{blue}{\sqrt{\frac{1}{\mathsf{hypot}\left(\sqrt{x}, 1\right) + \sqrt{x}}} \cdot \sqrt{\frac{1}{\mathsf{hypot}\left(\sqrt{x}, 1\right) + \sqrt{x}}}}\]
  11. Using strategy rm
  12. Applied inv-pow0.3

    \[\leadsto \sqrt{\frac{1}{\mathsf{hypot}\left(\sqrt{x}, 1\right) + \sqrt{x}}} \cdot \sqrt{\color{blue}{{\left(\mathsf{hypot}\left(\sqrt{x}, 1\right) + \sqrt{x}\right)}^{-1}}}\]
  13. Applied sqrt-pow10.3

    \[\leadsto \sqrt{\frac{1}{\mathsf{hypot}\left(\sqrt{x}, 1\right) + \sqrt{x}}} \cdot \color{blue}{{\left(\mathsf{hypot}\left(\sqrt{x}, 1\right) + \sqrt{x}\right)}^{\left(\frac{-1}{2}\right)}}\]
  14. Applied inv-pow0.3

    \[\leadsto \sqrt{\color{blue}{{\left(\mathsf{hypot}\left(\sqrt{x}, 1\right) + \sqrt{x}\right)}^{-1}}} \cdot {\left(\mathsf{hypot}\left(\sqrt{x}, 1\right) + \sqrt{x}\right)}^{\left(\frac{-1}{2}\right)}\]
  15. Applied sqrt-pow10.3

    \[\leadsto \color{blue}{{\left(\mathsf{hypot}\left(\sqrt{x}, 1\right) + \sqrt{x}\right)}^{\left(\frac{-1}{2}\right)}} \cdot {\left(\mathsf{hypot}\left(\sqrt{x}, 1\right) + \sqrt{x}\right)}^{\left(\frac{-1}{2}\right)}\]
  16. Applied pow-prod-down0.2

    \[\leadsto \color{blue}{{\left(\left(\mathsf{hypot}\left(\sqrt{x}, 1\right) + \sqrt{x}\right) \cdot \left(\mathsf{hypot}\left(\sqrt{x}, 1\right) + \sqrt{x}\right)\right)}^{\left(\frac{-1}{2}\right)}}\]
  17. Final simplification0.2

    \[\leadsto {\left(\left(\sqrt{x} + \mathsf{hypot}\left(\sqrt{x}, 1\right)\right) \cdot \left(\sqrt{x} + \mathsf{hypot}\left(\sqrt{x}, 1\right)\right)\right)}^{\frac{-1}{2}}\]

Reproduce

herbie shell --seed 2019138 +o rules:numerics
(FPCore (x)
  :name "2sqrt (example 3.1)"

  :herbie-target
  (/ 1 (+ (sqrt (+ x 1)) (sqrt x)))

  (- (sqrt (+ x 1)) (sqrt x)))