Average Error: 32.2 → 0
Time: 3.9s
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 r25217871 = x;
        double r25217872 = r25217871 / r25217871;
        double r25217873 = 1.0;
        double r25217874 = r25217873 / r25217871;
        double r25217875 = r25217871 * r25217871;
        double r25217876 = sqrt(r25217875);
        double r25217877 = r25217874 * r25217876;
        double r25217878 = r25217872 - r25217877;
        return r25217878;
}

double f(double x) {
        double r25217879 = 1.0;
        double r25217880 = x;
        double r25217881 = fabs(r25217880);
        double r25217882 = r25217881 / r25217880;
        double r25217883 = r25217879 - r25217882;
        return r25217883;
}

Error

Bits error versus x

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

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

Derivation

  1. Initial program 32.2

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

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

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