Average Error: 32.4 → 0
Time: 943.0ms
Precision: 64
\[\frac{x}{x} - \frac{1}{x} \cdot \sqrt{x \cdot x}\]
\[1 + \left(-\frac{1 \cdot \left|x\right|}{x}\right)\]
\frac{x}{x} - \frac{1}{x} \cdot \sqrt{x \cdot x}
1 + \left(-\frac{1 \cdot \left|x\right|}{x}\right)
double f(double x) {
        double r189465 = x;
        double r189466 = r189465 / r189465;
        double r189467 = 1.0;
        double r189468 = r189467 / r189465;
        double r189469 = r189465 * r189465;
        double r189470 = sqrt(r189469);
        double r189471 = r189468 * r189470;
        double r189472 = r189466 - r189471;
        return r189472;
}

double f(double x) {
        double r189473 = 1.0;
        double r189474 = 1.0;
        double r189475 = x;
        double r189476 = fabs(r189475);
        double r189477 = r189474 * r189476;
        double r189478 = r189477 / r189475;
        double r189479 = -r189478;
        double r189480 = r189473 + r189479;
        return r189480;
}

Error

Bits error versus x

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

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

Derivation

  1. Initial program 32.4

    \[\frac{x}{x} - \frac{1}{x} \cdot \sqrt{x \cdot x}\]
  2. Simplified0

    \[\leadsto \color{blue}{1 + \left(-\frac{1 \cdot \left|x\right|}{x}\right)}\]
  3. Final simplification0

    \[\leadsto 1 + \left(-\frac{1 \cdot \left|x\right|}{x}\right)\]

Reproduce

herbie shell --seed 2019353 
(FPCore (x)
  :name "sqrt sqr"
  :precision binary64

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

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