Average Error: 59.7 → 0.3
Time: 10.1s
Precision: 64
\[\sqrt{x - 1} - \sqrt{x}\]
\[\frac{-1}{\sqrt{x - 1} + \sqrt{x}}\]
\sqrt{x - 1} - \sqrt{x}
\frac{-1}{\sqrt{x - 1} + \sqrt{x}}
double f(double x) {
        double r14356 = x;
        double r14357 = 1.0;
        double r14358 = r14356 - r14357;
        double r14359 = sqrt(r14358);
        double r14360 = sqrt(r14356);
        double r14361 = r14359 - r14360;
        return r14361;
}

double f(double x) {
        double r14362 = 1.0;
        double r14363 = -r14362;
        double r14364 = x;
        double r14365 = r14364 - r14362;
        double r14366 = sqrt(r14365);
        double r14367 = sqrt(r14364);
        double r14368 = r14366 + r14367;
        double r14369 = r14363 / r14368;
        return r14369;
}

Error

Bits error versus x

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Derivation

  1. Initial program 59.7

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

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

    \[\leadsto \frac{\color{blue}{\left(-1\right) + 0}}{\sqrt{x - 1} + \sqrt{x}}\]
  5. Final simplification0.3

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

Reproduce

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