Average Error: 30.3 → 0.2
Time: 16.6s
Precision: 64
\[\sqrt{x + 1} - \sqrt{x}\]
\[\mathsf{expm1}\left(\mathsf{log1p}\left(\frac{1}{\sqrt{x + 1} + \sqrt{x}}\right)\right)\]
\sqrt{x + 1} - \sqrt{x}
\mathsf{expm1}\left(\mathsf{log1p}\left(\frac{1}{\sqrt{x + 1} + \sqrt{x}}\right)\right)
double f(double x) {
        double r462556 = x;
        double r462557 = 1.0;
        double r462558 = r462556 + r462557;
        double r462559 = sqrt(r462558);
        double r462560 = sqrt(r462556);
        double r462561 = r462559 - r462560;
        return r462561;
}

double f(double x) {
        double r462562 = 1.0;
        double r462563 = x;
        double r462564 = r462563 + r462562;
        double r462565 = sqrt(r462564);
        double r462566 = sqrt(r462563);
        double r462567 = r462565 + r462566;
        double r462568 = r462562 / r462567;
        double r462569 = log1p(r462568);
        double r462570 = expm1(r462569);
        return r462570;
}

Error

Bits error versus x

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

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

Derivation

  1. Initial program 30.3

    \[\sqrt{x + 1} - \sqrt{x}\]
  2. Simplified30.3

    \[\leadsto \color{blue}{\sqrt{1 + x} - \sqrt{x}}\]
  3. Using strategy rm
  4. Applied flip--30.1

    \[\leadsto \color{blue}{\frac{\sqrt{1 + x} \cdot \sqrt{1 + x} - \sqrt{x} \cdot \sqrt{x}}{\sqrt{1 + x} + \sqrt{x}}}\]
  5. Simplified0.2

    \[\leadsto \frac{\color{blue}{1 + 0}}{\sqrt{1 + x} + \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{1 + x} + \sqrt{x}}\right)\right)}\]
  8. Simplified0.2

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

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

Reproduce

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