Average Error: 31.9 → 0
Time: 3.8s
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 r7364623 = x;
        double r7364624 = r7364623 / r7364623;
        double r7364625 = 1.0;
        double r7364626 = r7364625 / r7364623;
        double r7364627 = r7364623 * r7364623;
        double r7364628 = sqrt(r7364627);
        double r7364629 = r7364626 * r7364628;
        double r7364630 = r7364624 - r7364629;
        return r7364630;
}

double f(double x) {
        double r7364631 = 1.0;
        double r7364632 = x;
        double r7364633 = fabs(r7364632);
        double r7364634 = r7364633 / r7364632;
        double r7364635 = r7364631 - r7364634;
        return r7364635;
}

Error

Bits error versus x

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

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

Derivation

  1. Initial program 31.9

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

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

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