Average Error: 32.0 → 0
Time: 6.7s
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 r4090090 = x;
        double r4090091 = r4090090 / r4090090;
        double r4090092 = 1.0;
        double r4090093 = r4090092 / r4090090;
        double r4090094 = r4090090 * r4090090;
        double r4090095 = sqrt(r4090094);
        double r4090096 = r4090093 * r4090095;
        double r4090097 = r4090091 - r4090096;
        return r4090097;
}

double f(double x) {
        double r4090098 = 1.0;
        double r4090099 = x;
        double r4090100 = fabs(r4090099);
        double r4090101 = r4090100 / r4090099;
        double r4090102 = r4090098 - r4090101;
        return r4090102;
}

Error

Bits error versus x

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

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

Derivation

  1. Initial program 32.0

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

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

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