Average Error: 30.4 → 0.2
Time: 11.8s
Precision: 64
\[\sqrt{x + 1} - \sqrt{x}\]
\[\frac{1}{\sqrt{1 + x} + \sqrt{x}}\]
\sqrt{x + 1} - \sqrt{x}
\frac{1}{\sqrt{1 + x} + \sqrt{x}}
double f(double x) {
        double r8318677 = x;
        double r8318678 = 1.0;
        double r8318679 = r8318677 + r8318678;
        double r8318680 = sqrt(r8318679);
        double r8318681 = sqrt(r8318677);
        double r8318682 = r8318680 - r8318681;
        return r8318682;
}

double f(double x) {
        double r8318683 = 1.0;
        double r8318684 = x;
        double r8318685 = r8318683 + r8318684;
        double r8318686 = sqrt(r8318685);
        double r8318687 = sqrt(r8318684);
        double r8318688 = r8318686 + r8318687;
        double r8318689 = r8318683 / r8318688;
        return r8318689;
}

Error

Bits error versus x

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Derivation

  1. Initial program 30.4

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

    \[\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}}{\sqrt{x + 1} + \sqrt{x}}\]
  5. Final simplification0.2

    \[\leadsto \frac{1}{\sqrt{1 + x} + \sqrt{x}}\]

Reproduce

herbie shell --seed 1 
(FPCore (x)
  :name "sqrt(x+1)-sqrt(x)"
  (- (sqrt (+ x 1)) (sqrt x)))