Average Error: 32.7 → 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 r4475449 = x;
        double r4475450 = r4475449 / r4475449;
        double r4475451 = 1.0;
        double r4475452 = r4475451 / r4475449;
        double r4475453 = r4475449 * r4475449;
        double r4475454 = sqrt(r4475453);
        double r4475455 = r4475452 * r4475454;
        double r4475456 = r4475450 - r4475455;
        return r4475456;
}

double f(double x) {
        double r4475457 = 1.0;
        double r4475458 = x;
        double r4475459 = fabs(r4475458);
        double r4475460 = r4475459 / r4475458;
        double r4475461 = r4475457 - r4475460;
        return r4475461;
}

Error

Bits error versus x

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

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

Derivation

  1. Initial program 32.7

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

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

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