Average Error: 32.7 → 0
Time: 899.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 r121921 = x;
        double r121922 = r121921 / r121921;
        double r121923 = 1.0;
        double r121924 = r121923 / r121921;
        double r121925 = r121921 * r121921;
        double r121926 = sqrt(r121925);
        double r121927 = r121924 * r121926;
        double r121928 = r121922 - r121927;
        return r121928;
}

double f(double x) {
        double r121929 = 1.0;
        double r121930 = 1.0;
        double r121931 = x;
        double r121932 = fabs(r121931);
        double r121933 = r121930 * r121932;
        double r121934 = r121933 / r121931;
        double r121935 = -r121934;
        double r121936 = r121929 + r121935;
        return r121936;
}

Error

Bits error versus x

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

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

Derivation

  1. Initial program 32.7

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

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

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