Average Error: 32.3 → 0
Time: 942.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 r119977 = x;
        double r119978 = r119977 / r119977;
        double r119979 = 1.0;
        double r119980 = r119979 / r119977;
        double r119981 = r119977 * r119977;
        double r119982 = sqrt(r119981);
        double r119983 = r119980 * r119982;
        double r119984 = r119978 - r119983;
        return r119984;
}

double f(double x) {
        double r119985 = 1.0;
        double r119986 = 1.0;
        double r119987 = x;
        double r119988 = fabs(r119987);
        double r119989 = r119986 * r119988;
        double r119990 = r119989 / r119987;
        double r119991 = -r119990;
        double r119992 = r119985 + r119991;
        return r119992;
}

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.0:\\ \;\;\;\;2\\ \mathbf{else}:\\ \;\;\;\;0.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 + \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 2020003 
(FPCore (x)
  :name "sqrt sqr"
  :precision binary64

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

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