Average Error: 32.5 → 0
Time: 5.2s
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 r1618479 = x;
        double r1618480 = r1618479 / r1618479;
        double r1618481 = 1.0;
        double r1618482 = r1618481 / r1618479;
        double r1618483 = r1618479 * r1618479;
        double r1618484 = sqrt(r1618483);
        double r1618485 = r1618482 * r1618484;
        double r1618486 = r1618480 - r1618485;
        return r1618486;
}

double f(double x) {
        double r1618487 = 1.0;
        double r1618488 = x;
        double r1618489 = fabs(r1618488);
        double r1618490 = r1618489 / r1618488;
        double r1618491 = r1618487 - r1618490;
        return r1618491;
}

Error

Bits error versus x

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

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

Derivation

  1. Initial program 32.5

    \[\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 2019153 
(FPCore (x)
  :name "sqrt sqr"

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

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