Average Error: 32.7 → 0
Time: 4.0s
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 r3884805 = x;
        double r3884806 = r3884805 / r3884805;
        double r3884807 = 1.0;
        double r3884808 = r3884807 / r3884805;
        double r3884809 = r3884805 * r3884805;
        double r3884810 = sqrt(r3884809);
        double r3884811 = r3884808 * r3884810;
        double r3884812 = r3884806 - r3884811;
        return r3884812;
}

double f(double x) {
        double r3884813 = 1.0;
        double r3884814 = x;
        double r3884815 = fabs(r3884814);
        double r3884816 = r3884815 / r3884814;
        double r3884817 = r3884813 - r3884816;
        return r3884817;
}

Error

Bits error versus x

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

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

Derivation

  1. Initial program 32.7

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

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

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