Average Error: 32.9 → 0
Time: 890.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 r141000 = x;
        double r141001 = r141000 / r141000;
        double r141002 = 1.0;
        double r141003 = r141002 / r141000;
        double r141004 = r141000 * r141000;
        double r141005 = sqrt(r141004);
        double r141006 = r141003 * r141005;
        double r141007 = r141001 - r141006;
        return r141007;
}

double f(double x) {
        double r141008 = 1.0;
        double r141009 = 1.0;
        double r141010 = x;
        double r141011 = fabs(r141010);
        double r141012 = r141009 * r141011;
        double r141013 = r141012 / r141010;
        double r141014 = -r141013;
        double r141015 = r141008 + r141014;
        return r141015;
}

Error

Bits error versus x

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

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

Derivation

  1. Initial program 32.9

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

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

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