Average Error: 30.0 → 0.2
Time: 15.4s
Precision: 64
\[\sqrt{x + 1} - \sqrt{x}\]
\[\mathsf{expm1}\left(\left(\mathsf{log1p}\left(\left(\frac{1}{\sqrt{x + 1} + \sqrt{x}}\right)\right)\right)\right)\]
\sqrt{x + 1} - \sqrt{x}
\mathsf{expm1}\left(\left(\mathsf{log1p}\left(\left(\frac{1}{\sqrt{x + 1} + \sqrt{x}}\right)\right)\right)\right)
double f(double x) {
        double r3555390 = x;
        double r3555391 = 1.0;
        double r3555392 = r3555390 + r3555391;
        double r3555393 = sqrt(r3555392);
        double r3555394 = sqrt(r3555390);
        double r3555395 = r3555393 - r3555394;
        return r3555395;
}

double f(double x) {
        double r3555396 = 1.0;
        double r3555397 = x;
        double r3555398 = r3555397 + r3555396;
        double r3555399 = sqrt(r3555398);
        double r3555400 = sqrt(r3555397);
        double r3555401 = r3555399 + r3555400;
        double r3555402 = r3555396 / r3555401;
        double r3555403 = log1p(r3555402);
        double r3555404 = expm1(r3555403);
        return r3555404;
}

Error

Bits error versus x

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original30.0
Target0.2
Herbie0.2
\[\frac{1}{\sqrt{x + 1} + \sqrt{x}}\]

Derivation

  1. Initial program 30.0

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

    \[\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 expm1-log1p-u0.2

    \[\leadsto \color{blue}{\mathsf{expm1}\left(\left(\mathsf{log1p}\left(\left(\frac{1}{\sqrt{x + 1} + \sqrt{x}}\right)\right)\right)\right)}\]
  7. Final simplification0.2

    \[\leadsto \mathsf{expm1}\left(\left(\mathsf{log1p}\left(\left(\frac{1}{\sqrt{x + 1} + \sqrt{x}}\right)\right)\right)\right)\]

Reproduce

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

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

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