Average Error: 30.0 → 0.2
Time: 33.5s
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 r25098775 = x;
        double r25098776 = 1.0;
        double r25098777 = r25098775 + r25098776;
        double r25098778 = sqrt(r25098777);
        double r25098779 = sqrt(r25098775);
        double r25098780 = r25098778 - r25098779;
        return r25098780;
}

double f(double x) {
        double r25098781 = 1.0;
        double r25098782 = x;
        double r25098783 = r25098782 + r25098781;
        double r25098784 = sqrt(r25098783);
        double r25098785 = sqrt(r25098782);
        double r25098786 = r25098784 + r25098785;
        double r25098787 = r25098781 / r25098786;
        double r25098788 = log1p(r25098787);
        double r25098789 = expm1(r25098788);
        return r25098789;
}

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}{\sqrt{x + 1} + \sqrt{x}}\]

Derivation

  1. Initial program 30.0

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

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

    \[\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 expm1-log1p-u0.2

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

    \[\leadsto \mathsf{expm1}\left(\mathsf{log1p}\left(\frac{1}{\sqrt{x + 1} + \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)))