Average Error: 32.6 → 0
Time: 3.8s
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 r9932504 = x;
        double r9932505 = r9932504 / r9932504;
        double r9932506 = 1.0;
        double r9932507 = r9932506 / r9932504;
        double r9932508 = r9932504 * r9932504;
        double r9932509 = sqrt(r9932508);
        double r9932510 = r9932507 * r9932509;
        double r9932511 = r9932505 - r9932510;
        return r9932511;
}

double f(double x) {
        double r9932512 = 1.0;
        double r9932513 = x;
        double r9932514 = fabs(r9932513);
        double r9932515 = r9932514 / r9932513;
        double r9932516 = r9932512 - r9932515;
        return r9932516;
}

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

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

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