Average Error: 29.5 → 0.2
Time: 21.3s
Precision: 64
\[\sqrt{x + 1} - \sqrt{x}\]
\[\mathsf{log1p}\left(\mathsf{expm1}\left(\mathsf{expm1}\left(\mathsf{log1p}\left(\frac{1}{\sqrt{x} + \sqrt{x + 1}}\right)\right)\right)\right)\]
\sqrt{x + 1} - \sqrt{x}
\mathsf{log1p}\left(\mathsf{expm1}\left(\mathsf{expm1}\left(\mathsf{log1p}\left(\frac{1}{\sqrt{x} + \sqrt{x + 1}}\right)\right)\right)\right)
double f(double x) {
        double r342294 = x;
        double r342295 = 1.0;
        double r342296 = r342294 + r342295;
        double r342297 = sqrt(r342296);
        double r342298 = sqrt(r342294);
        double r342299 = r342297 - r342298;
        return r342299;
}

double f(double x) {
        double r342300 = 1.0;
        double r342301 = x;
        double r342302 = sqrt(r342301);
        double r342303 = r342301 + r342300;
        double r342304 = sqrt(r342303);
        double r342305 = r342302 + r342304;
        double r342306 = r342300 / r342305;
        double r342307 = log1p(r342306);
        double r342308 = expm1(r342307);
        double r342309 = expm1(r342308);
        double r342310 = log1p(r342309);
        return r342310;
}

Error

Bits error versus x

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

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

Derivation

  1. Initial program 29.5

    \[\sqrt{x + 1} - \sqrt{x}\]
  2. Using strategy rm
  3. Applied flip--29.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 + 0}}{\sqrt{x + 1} + \sqrt{x}}\]
  5. Simplified0.2

    \[\leadsto \frac{1 + 0}{\color{blue}{\sqrt{x} + \sqrt{x + 1}}}\]
  6. Using strategy rm
  7. Applied log1p-expm1-u0.2

    \[\leadsto \color{blue}{\mathsf{log1p}\left(\mathsf{expm1}\left(\frac{1 + 0}{\sqrt{x} + \sqrt{x + 1}}\right)\right)}\]
  8. Simplified0.2

    \[\leadsto \mathsf{log1p}\left(\color{blue}{\mathsf{expm1}\left(\frac{1}{\sqrt{x} + \sqrt{x + 1}}\right)}\right)\]
  9. Using strategy rm
  10. Applied expm1-log1p-u0.2

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

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

Reproduce

herbie shell --seed 2019198 +o rules:numerics
(FPCore (x)
  :name "Main:bigenough3 from C"

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

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