Average Error: 32.7 → 0
Time: 878.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 r146913 = x;
        double r146914 = r146913 / r146913;
        double r146915 = 1.0;
        double r146916 = r146915 / r146913;
        double r146917 = r146913 * r146913;
        double r146918 = sqrt(r146917);
        double r146919 = r146916 * r146918;
        double r146920 = r146914 - r146919;
        return r146920;
}

double f(double x) {
        double r146921 = 1.0;
        double r146922 = 1.0;
        double r146923 = x;
        double r146924 = fabs(r146923);
        double r146925 = r146922 * r146924;
        double r146926 = r146925 / r146923;
        double r146927 = -r146926;
        double r146928 = r146921 + r146927;
        return r146928;
}

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

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

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