Average Error: 32.4 → 0
Time: 4.0s
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 r4081386 = x;
        double r4081387 = r4081386 / r4081386;
        double r4081388 = 1.0;
        double r4081389 = r4081388 / r4081386;
        double r4081390 = r4081386 * r4081386;
        double r4081391 = sqrt(r4081390);
        double r4081392 = r4081389 * r4081391;
        double r4081393 = r4081387 - r4081392;
        return r4081393;
}

double f(double x) {
        double r4081394 = 1.0;
        double r4081395 = x;
        double r4081396 = fabs(r4081395);
        double r4081397 = r4081396 / r4081395;
        double r4081398 = r4081394 - r4081397;
        return r4081398;
}

Error

Bits error versus x

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

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

Derivation

  1. Initial program 32.4

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

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

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