Average Error: 31.9 → 0
Time: 855.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 r175605 = x;
        double r175606 = r175605 / r175605;
        double r175607 = 1.0;
        double r175608 = r175607 / r175605;
        double r175609 = r175605 * r175605;
        double r175610 = sqrt(r175609);
        double r175611 = r175608 * r175610;
        double r175612 = r175606 - r175611;
        return r175612;
}

double f(double x) {
        double r175613 = 1.0;
        double r175614 = 1.0;
        double r175615 = x;
        double r175616 = fabs(r175615);
        double r175617 = r175614 * r175616;
        double r175618 = r175617 / r175615;
        double r175619 = -r175618;
        double r175620 = r175613 + r175619;
        return r175620;
}

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

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

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