Average Error: 32.3 → 0
Time: 6.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 r4543574 = x;
        double r4543575 = r4543574 / r4543574;
        double r4543576 = 1.0;
        double r4543577 = r4543576 / r4543574;
        double r4543578 = r4543574 * r4543574;
        double r4543579 = sqrt(r4543578);
        double r4543580 = r4543577 * r4543579;
        double r4543581 = r4543575 - r4543580;
        return r4543581;
}

double f(double x) {
        double r4543582 = 1.0;
        double r4543583 = x;
        double r4543584 = fabs(r4543583);
        double r4543585 = r4543584 / r4543583;
        double r4543586 = r4543582 - r4543585;
        return r4543586;
}

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

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

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