Average Error: 32.7 → 0
Time: 853.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 r137195 = x;
        double r137196 = r137195 / r137195;
        double r137197 = 1.0;
        double r137198 = r137197 / r137195;
        double r137199 = r137195 * r137195;
        double r137200 = sqrt(r137199);
        double r137201 = r137198 * r137200;
        double r137202 = r137196 - r137201;
        return r137202;
}

double f(double x) {
        double r137203 = 1.0;
        double r137204 = 1.0;
        double r137205 = x;
        double r137206 = fabs(r137205);
        double r137207 = r137204 * r137206;
        double r137208 = r137207 / r137205;
        double r137209 = -r137208;
        double r137210 = r137203 + r137209;
        return r137210;
}

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

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

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