Average Error: 32.3 → 0
Time: 5.4s
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 r1598850 = x;
        double r1598851 = r1598850 / r1598850;
        double r1598852 = 1.0;
        double r1598853 = r1598852 / r1598850;
        double r1598854 = r1598850 * r1598850;
        double r1598855 = sqrt(r1598854);
        double r1598856 = r1598853 * r1598855;
        double r1598857 = r1598851 - r1598856;
        return r1598857;
}

double f(double x) {
        double r1598858 = 1.0;
        double r1598859 = x;
        double r1598860 = fabs(r1598859);
        double r1598861 = r1598860 / r1598859;
        double r1598862 = r1598858 - r1598861;
        return r1598862;
}

Error

Bits error versus x

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

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

Derivation

  1. Initial program 32.3

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

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

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