Average Error: 32.1 → 0
Time: 4.2s
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 r5725102 = x;
        double r5725103 = r5725102 / r5725102;
        double r5725104 = 1.0;
        double r5725105 = r5725104 / r5725102;
        double r5725106 = r5725102 * r5725102;
        double r5725107 = sqrt(r5725106);
        double r5725108 = r5725105 * r5725107;
        double r5725109 = r5725103 - r5725108;
        return r5725109;
}

double f(double x) {
        double r5725110 = 1.0;
        double r5725111 = x;
        double r5725112 = fabs(r5725111);
        double r5725113 = r5725112 / r5725111;
        double r5725114 = r5725110 - r5725113;
        return r5725114;
}

Error

Bits error versus x

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

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

Derivation

  1. Initial program 32.1

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

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

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