Average Error: 32.5 → 0
Time: 4.6s
Precision: 64
\[\frac{x}{x} - \frac{1}{x} \cdot \sqrt{x \cdot x}\]
\[1 - \frac{\left|x\right|}{\frac{x}{1}}\]
\frac{x}{x} - \frac{1}{x} \cdot \sqrt{x \cdot x}
1 - \frac{\left|x\right|}{\frac{x}{1}}
double f(double x) {
        double r4217837 = x;
        double r4217838 = r4217837 / r4217837;
        double r4217839 = 1.0;
        double r4217840 = r4217839 / r4217837;
        double r4217841 = r4217837 * r4217837;
        double r4217842 = sqrt(r4217841);
        double r4217843 = r4217840 * r4217842;
        double r4217844 = r4217838 - r4217843;
        return r4217844;
}

double f(double x) {
        double r4217845 = 1.0;
        double r4217846 = x;
        double r4217847 = fabs(r4217846);
        double r4217848 = 1.0;
        double r4217849 = r4217846 / r4217848;
        double r4217850 = r4217847 / r4217849;
        double r4217851 = r4217845 - r4217850;
        return r4217851;
}

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.0:\\ \;\;\;\;2\\ \mathbf{else}:\\ \;\;\;\;0.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|}{\frac{x}{1}}}\]
  3. Final simplification0

    \[\leadsto 1 - \frac{\left|x\right|}{\frac{x}{1}}\]

Reproduce

herbie shell --seed 2019200 +o rules:numerics
(FPCore (x)
  :name "sqrt sqr"

  :herbie-target
  (if (< x 0.0) 2.0 0.0)

  (- (/ x x) (* (/ 1.0 x) (sqrt (* x x)))))