Average Error: 30.3 → 0.2
Time: 5.0s
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 r482139 = x;
        double r482140 = 1.0;
        double r482141 = r482139 + r482140;
        double r482142 = sqrt(r482141);
        double r482143 = sqrt(r482139);
        double r482144 = r482142 - r482143;
        return r482144;
}

double f(double x) {
        double r482145 = 1.0;
        double r482146 = 0.0;
        double r482147 = r482145 + r482146;
        double r482148 = x;
        double r482149 = r482148 + r482145;
        double r482150 = sqrt(r482149);
        double r482151 = sqrt(r482148);
        double r482152 = r482150 + r482151;
        double r482153 = r482147 / r482152;
        double r482154 = log1p(r482153);
        double r482155 = expm1(r482154);
        return r482155;
}

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. Using strategy rm
  3. Applied flip--30.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 expm1-log1p-u0.2

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

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

Reproduce

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