Average Error: 32.0 → 0
Time: 7.5s
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 r5566789 = x;
        double r5566790 = r5566789 / r5566789;
        double r5566791 = 1.0;
        double r5566792 = r5566791 / r5566789;
        double r5566793 = r5566789 * r5566789;
        double r5566794 = sqrt(r5566793);
        double r5566795 = r5566792 * r5566794;
        double r5566796 = r5566790 - r5566795;
        return r5566796;
}

double f(double x) {
        double r5566797 = 1.0;
        double r5566798 = x;
        double r5566799 = fabs(r5566798);
        double r5566800 = r5566799 / r5566798;
        double r5566801 = r5566797 - r5566800;
        return r5566801;
}

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)))))