Average Error: 31.6 → 0
Time: 5.4s
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 r5039683 = x;
        double r5039684 = r5039683 / r5039683;
        double r5039685 = 1.0;
        double r5039686 = r5039685 / r5039683;
        double r5039687 = r5039683 * r5039683;
        double r5039688 = sqrt(r5039687);
        double r5039689 = r5039686 * r5039688;
        double r5039690 = r5039684 - r5039689;
        return r5039690;
}

double f(double x) {
        double r5039691 = 1.0;
        double r5039692 = x;
        double r5039693 = fabs(r5039692);
        double r5039694 = r5039693 / r5039692;
        double r5039695 = r5039691 - r5039694;
        return r5039695;
}

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

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

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