Average Error: 31.6 → 0
Time: 3.9s
Precision: 64
\[\frac{x}{x} - \frac{1}{x} \cdot \sqrt{x \cdot x}\]
\[1 - \frac{\left|x\right|}{x}\]
\frac{x}{x} - \frac{1}{x} \cdot \sqrt{x \cdot x}
1 - \frac{\left|x\right|}{x}
double f(double x) {
        double r23334425 = x;
        double r23334426 = r23334425 / r23334425;
        double r23334427 = 1.0;
        double r23334428 = r23334427 / r23334425;
        double r23334429 = r23334425 * r23334425;
        double r23334430 = sqrt(r23334429);
        double r23334431 = r23334428 * r23334430;
        double r23334432 = r23334426 - r23334431;
        return r23334432;
}

double f(double x) {
        double r23334433 = 1.0;
        double r23334434 = x;
        double r23334435 = fabs(r23334434);
        double r23334436 = r23334435 / r23334434;
        double r23334437 = r23334433 - r23334436;
        return r23334437;
}

Error

Bits error versus x

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original31.6
Target0
Herbie0
\[\begin{array}{l} \mathbf{if}\;x \lt 0:\\ \;\;\;\;2\\ \mathbf{else}:\\ \;\;\;\;0\\ \end{array}\]

Derivation

  1. Initial program 31.6

    \[\frac{x}{x} - \frac{1}{x} \cdot \sqrt{x \cdot x}\]
  2. Simplified0

    \[\leadsto \color{blue}{1 - \frac{\left|x\right|}{x}}\]
  3. Final simplification0

    \[\leadsto 1 - \frac{\left|x\right|}{x}\]

Reproduce

herbie shell --seed 2019120 
(FPCore (x)
  :name "sqrt sqr"

  :herbie-target
  (if (< x 0) 2 0)

  (- (/ x x) (* (/ 1 x) (sqrt (* x x)))))