Average Error: 29.5 → 0.2
Time: 20.6s
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 r203558 = x;
        double r203559 = 1.0;
        double r203560 = r203558 + r203559;
        double r203561 = sqrt(r203560);
        double r203562 = sqrt(r203558);
        double r203563 = r203561 - r203562;
        return r203563;
}

double f(double x) {
        double r203564 = 1.0;
        double r203565 = x;
        double r203566 = sqrt(r203565);
        double r203567 = r203565 + r203564;
        double r203568 = sqrt(r203567);
        double r203569 = r203566 + r203568;
        double r203570 = r203564 / r203569;
        double r203571 = log1p(r203570);
        double r203572 = expm1(r203571);
        double r203573 = expm1(r203572);
        double r203574 = log1p(r203573);
        return r203574;
}

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 "2sqrt (example 3.1)"

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

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