Average Error: 30.8 → 0.2
Time: 5.5s
Precision: 64
\[\sqrt{x + 1} - \sqrt{x}\]
\[\mathsf{expm1}\left(\mathsf{log1p}\left(\frac{1 + 0}{\sqrt{x + 1} + \sqrt{x}}\right)\right)\]
\sqrt{x + 1} - \sqrt{x}
\mathsf{expm1}\left(\mathsf{log1p}\left(\frac{1 + 0}{\sqrt{x + 1} + \sqrt{x}}\right)\right)
double f(double x) {
        double r495505 = x;
        double r495506 = 1.0;
        double r495507 = r495505 + r495506;
        double r495508 = sqrt(r495507);
        double r495509 = sqrt(r495505);
        double r495510 = r495508 - r495509;
        return r495510;
}

double f(double x) {
        double r495511 = 1.0;
        double r495512 = 0.0;
        double r495513 = r495511 + r495512;
        double r495514 = x;
        double r495515 = r495514 + r495511;
        double r495516 = sqrt(r495515);
        double r495517 = sqrt(r495514);
        double r495518 = r495516 + r495517;
        double r495519 = r495513 / r495518;
        double r495520 = log1p(r495519);
        double r495521 = expm1(r495520);
        return r495521;
}

Error

Bits error versus x

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

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

Derivation

  1. Initial program 30.8

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

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

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

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

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

Reproduce

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