Average Error: 30.0 → 0.2
Time: 18.5s
Precision: 64
\[\sqrt{x + 1.0} - \sqrt{x}\]
\[\mathsf{expm1}\left(\mathsf{log1p}\left(\frac{1.0}{\sqrt{x + 1.0} + \sqrt{x}}\right)\right)\]
\sqrt{x + 1.0} - \sqrt{x}
\mathsf{expm1}\left(\mathsf{log1p}\left(\frac{1.0}{\sqrt{x + 1.0} + \sqrt{x}}\right)\right)
double f(double x) {
        double r20252890 = x;
        double r20252891 = 1.0;
        double r20252892 = r20252890 + r20252891;
        double r20252893 = sqrt(r20252892);
        double r20252894 = sqrt(r20252890);
        double r20252895 = r20252893 - r20252894;
        return r20252895;
}

double f(double x) {
        double r20252896 = 1.0;
        double r20252897 = x;
        double r20252898 = r20252897 + r20252896;
        double r20252899 = sqrt(r20252898);
        double r20252900 = sqrt(r20252897);
        double r20252901 = r20252899 + r20252900;
        double r20252902 = r20252896 / r20252901;
        double r20252903 = log1p(r20252902);
        double r20252904 = expm1(r20252903);
        return r20252904;
}

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.0}{\sqrt{x + 1.0} + \sqrt{x}}\]

Derivation

  1. Initial program 30.0

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

    \[\leadsto \color{blue}{\frac{\sqrt{x + 1.0} \cdot \sqrt{x + 1.0} - \sqrt{x} \cdot \sqrt{x}}{\sqrt{x + 1.0} + \sqrt{x}}}\]
  4. Simplified29.4

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

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

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

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

Reproduce

herbie shell --seed 2019168 +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)))