Average Error: 32.5 → 0
Time: 867.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 r119232 = x;
        double r119233 = r119232 / r119232;
        double r119234 = 1.0;
        double r119235 = r119234 / r119232;
        double r119236 = r119232 * r119232;
        double r119237 = sqrt(r119236);
        double r119238 = r119235 * r119237;
        double r119239 = r119233 - r119238;
        return r119239;
}

double f(double x) {
        double r119240 = 1.0;
        double r119241 = 1.0;
        double r119242 = x;
        double r119243 = fabs(r119242);
        double r119244 = r119241 * r119243;
        double r119245 = r119244 / r119242;
        double r119246 = -r119245;
        double r119247 = r119240 + r119246;
        return r119247;
}

Error

Bits error versus x

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

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

Derivation

  1. Initial program 32.5

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

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

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