Average Error: 32.7 → 0
Time: 861.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 r154621 = x;
        double r154622 = r154621 / r154621;
        double r154623 = 1.0;
        double r154624 = r154623 / r154621;
        double r154625 = r154621 * r154621;
        double r154626 = sqrt(r154625);
        double r154627 = r154624 * r154626;
        double r154628 = r154622 - r154627;
        return r154628;
}

double f(double x) {
        double r154629 = 1.0;
        double r154630 = 1.0;
        double r154631 = x;
        double r154632 = fabs(r154631);
        double r154633 = r154630 * r154632;
        double r154634 = r154633 / r154631;
        double r154635 = -r154634;
        double r154636 = r154629 + r154635;
        return r154636;
}

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

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

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