Average Error: 32.5 → 0
Time: 4.1s
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 r2744246 = x;
        double r2744247 = r2744246 / r2744246;
        double r2744248 = 1.0;
        double r2744249 = r2744248 / r2744246;
        double r2744250 = r2744246 * r2744246;
        double r2744251 = sqrt(r2744250);
        double r2744252 = r2744249 * r2744251;
        double r2744253 = r2744247 - r2744252;
        return r2744253;
}

double f(double x) {
        double r2744254 = 1.0;
        double r2744255 = x;
        double r2744256 = fabs(r2744255);
        double r2744257 = r2744256 / r2744255;
        double r2744258 = r2744254 - r2744257;
        return r2744258;
}

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

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

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