Average Error: 29.4 → 0.2
Time: 5.0s
Precision: 64
\[\sqrt{x + 1} - \sqrt{x}\]
\[\mathsf{log1p}\left(\mathsf{expm1}\left(\frac{1 + 0}{\sqrt{x + 1} + \sqrt{x}}\right)\right)\]
\sqrt{x + 1} - \sqrt{x}
\mathsf{log1p}\left(\mathsf{expm1}\left(\frac{1 + 0}{\sqrt{x + 1} + \sqrt{x}}\right)\right)
double f(double x) {
        double r499509 = x;
        double r499510 = 1.0;
        double r499511 = r499509 + r499510;
        double r499512 = sqrt(r499511);
        double r499513 = sqrt(r499509);
        double r499514 = r499512 - r499513;
        return r499514;
}

double f(double x) {
        double r499515 = 1.0;
        double r499516 = 0.0;
        double r499517 = r499515 + r499516;
        double r499518 = x;
        double r499519 = r499518 + r499515;
        double r499520 = sqrt(r499519);
        double r499521 = sqrt(r499518);
        double r499522 = r499520 + r499521;
        double r499523 = r499517 / r499522;
        double r499524 = expm1(r499523);
        double r499525 = log1p(r499524);
        return r499525;
}

Error

Bits error versus x

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

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

Derivation

  1. Initial program 29.4

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

    \[\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. Using strategy rm
  6. Applied log1p-expm1-u0.2

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

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

Reproduce

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

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

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