Average Error: 31.8 → 0
Time: 4.1s
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 r4478798 = x;
        double r4478799 = r4478798 / r4478798;
        double r4478800 = 1.0;
        double r4478801 = r4478800 / r4478798;
        double r4478802 = r4478798 * r4478798;
        double r4478803 = sqrt(r4478802);
        double r4478804 = r4478801 * r4478803;
        double r4478805 = r4478799 - r4478804;
        return r4478805;
}

double f(double x) {
        double r4478806 = 1.0;
        double r4478807 = x;
        double r4478808 = fabs(r4478807);
        double r4478809 = r4478808 / r4478807;
        double r4478810 = r4478806 - r4478809;
        return r4478810;
}

Error

Bits error versus x

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

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

Derivation

  1. Initial program 31.8

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

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

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