Average Error: 32.6 → 0
Time: 3.9s
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 r2997719 = x;
        double r2997720 = r2997719 / r2997719;
        double r2997721 = 1.0;
        double r2997722 = r2997721 / r2997719;
        double r2997723 = r2997719 * r2997719;
        double r2997724 = sqrt(r2997723);
        double r2997725 = r2997722 * r2997724;
        double r2997726 = r2997720 - r2997725;
        return r2997726;
}

double f(double x) {
        double r2997727 = 1.0;
        double r2997728 = x;
        double r2997729 = fabs(r2997728);
        double r2997730 = r2997729 / r2997728;
        double r2997731 = r2997727 - r2997730;
        return r2997731;
}

Error

Bits error versus x

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

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

Derivation

  1. Initial program 32.6

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

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

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