Average Error: 31.8 → 0
Time: 5.6s
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 r1721744 = x;
        double r1721745 = r1721744 / r1721744;
        double r1721746 = 1.0;
        double r1721747 = r1721746 / r1721744;
        double r1721748 = r1721744 * r1721744;
        double r1721749 = sqrt(r1721748);
        double r1721750 = r1721747 * r1721749;
        double r1721751 = r1721745 - r1721750;
        return r1721751;
}

double f(double x) {
        double r1721752 = 1.0;
        double r1721753 = x;
        double r1721754 = fabs(r1721753);
        double r1721755 = r1721754 / r1721753;
        double r1721756 = r1721752 - r1721755;
        return r1721756;
}

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)))))