Average Error: 29.5 → 0.2
Time: 12.3s
Precision: 64
\[\sqrt{x + 1} - \sqrt{x}\]
\[\mathsf{log1p}\left(\mathsf{expm1}\left(\frac{1}{\sqrt{x} + \sqrt{x + 1}}\right)\right)\]
\sqrt{x + 1} - \sqrt{x}
\mathsf{log1p}\left(\mathsf{expm1}\left(\frac{1}{\sqrt{x} + \sqrt{x + 1}}\right)\right)
double f(double x) {
        double r1027982 = x;
        double r1027983 = 1.0;
        double r1027984 = r1027982 + r1027983;
        double r1027985 = sqrt(r1027984);
        double r1027986 = sqrt(r1027982);
        double r1027987 = r1027985 - r1027986;
        return r1027987;
}

double f(double x) {
        double r1027988 = 1.0;
        double r1027989 = x;
        double r1027990 = sqrt(r1027989);
        double r1027991 = r1027989 + r1027988;
        double r1027992 = sqrt(r1027991);
        double r1027993 = r1027990 + r1027992;
        double r1027994 = r1027988 / r1027993;
        double r1027995 = expm1(r1027994);
        double r1027996 = log1p(r1027995);
        return r1027996;
}

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.3

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

    \[\leadsto \frac{\color{blue}{\left(x + 1\right) - x}}{\sqrt{x + 1} + \sqrt{x}}\]
  5. Taylor expanded around 0 0.2

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

    \[\leadsto \frac{1}{\sqrt{\color{blue}{\sqrt{x + 1} \cdot \sqrt{x + 1}}} + \sqrt{x}}\]
  8. Applied sqrt-prod0.3

    \[\leadsto \frac{1}{\color{blue}{\sqrt{\sqrt{x + 1}} \cdot \sqrt{\sqrt{x + 1}}} + \sqrt{x}}\]
  9. Using strategy rm
  10. Applied log1p-expm1-u0.3

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

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

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

Reproduce

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

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

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