Average Error: 30.4 → 0.2
Time: 15.6s
Precision: 64
\[\sqrt{x + 1} - \sqrt{x}\]
\[\mathsf{expm1}\left(\left(\mathsf{expm1}\left(\left(\mathsf{log1p}\left(\left(\mathsf{log1p}\left(\left(\frac{1}{\sqrt{x + 1} + \sqrt{x}}\right)\right)\right)\right)\right)\right)\right)\right)\]
\sqrt{x + 1} - \sqrt{x}
\mathsf{expm1}\left(\left(\mathsf{expm1}\left(\left(\mathsf{log1p}\left(\left(\mathsf{log1p}\left(\left(\frac{1}{\sqrt{x + 1} + \sqrt{x}}\right)\right)\right)\right)\right)\right)\right)\right)
double f(double x) {
        double r3255363 = x;
        double r3255364 = 1.0;
        double r3255365 = r3255363 + r3255364;
        double r3255366 = sqrt(r3255365);
        double r3255367 = sqrt(r3255363);
        double r3255368 = r3255366 - r3255367;
        return r3255368;
}

double f(double x) {
        double r3255369 = 1.0;
        double r3255370 = x;
        double r3255371 = r3255370 + r3255369;
        double r3255372 = sqrt(r3255371);
        double r3255373 = sqrt(r3255370);
        double r3255374 = r3255372 + r3255373;
        double r3255375 = r3255369 / r3255374;
        double r3255376 = log1p(r3255375);
        double r3255377 = log1p(r3255376);
        double r3255378 = expm1(r3255377);
        double r3255379 = expm1(r3255378);
        return r3255379;
}

Error

Bits error versus x

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

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

Derivation

  1. Initial program 30.4

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

    \[\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. Using strategy rm
  8. Applied expm1-log1p-u0.2

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

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

Reproduce

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

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

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