Average Error: 31.9 → 0
Time: 871.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 r122709 = x;
        double r122710 = r122709 / r122709;
        double r122711 = 1.0;
        double r122712 = r122711 / r122709;
        double r122713 = r122709 * r122709;
        double r122714 = sqrt(r122713);
        double r122715 = r122712 * r122714;
        double r122716 = r122710 - r122715;
        return r122716;
}

double f(double x) {
        double r122717 = 1.0;
        double r122718 = 1.0;
        double r122719 = x;
        double r122720 = fabs(r122719);
        double r122721 = r122718 * r122720;
        double r122722 = r122721 / r122719;
        double r122723 = -r122722;
        double r122724 = r122717 + r122723;
        return r122724;
}

Error

Bits error versus x

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

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

Derivation

  1. Initial program 31.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 2020049 
(FPCore (x)
  :name "sqrt sqr"
  :precision binary64

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

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