Average Error: 32.6 → 0
Time: 873.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 r113685 = x;
        double r113686 = r113685 / r113685;
        double r113687 = 1.0;
        double r113688 = r113687 / r113685;
        double r113689 = r113685 * r113685;
        double r113690 = sqrt(r113689);
        double r113691 = r113688 * r113690;
        double r113692 = r113686 - r113691;
        return r113692;
}

double f(double x) {
        double r113693 = 1.0;
        double r113694 = 1.0;
        double r113695 = x;
        double r113696 = fabs(r113695);
        double r113697 = r113694 * r113696;
        double r113698 = r113697 / r113695;
        double r113699 = -r113698;
        double r113700 = r113693 + r113699;
        return r113700;
}

Error

Bits error versus x

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

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

Derivation

  1. Initial program 32.6

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

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

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