Average Error: 32.7 → 0
Time: 904.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 r173526 = x;
        double r173527 = r173526 / r173526;
        double r173528 = 1.0;
        double r173529 = r173528 / r173526;
        double r173530 = r173526 * r173526;
        double r173531 = sqrt(r173530);
        double r173532 = r173529 * r173531;
        double r173533 = r173527 - r173532;
        return r173533;
}

double f(double x) {
        double r173534 = 1.0;
        double r173535 = 1.0;
        double r173536 = x;
        double r173537 = fabs(r173536);
        double r173538 = r173535 * r173537;
        double r173539 = r173538 / r173536;
        double r173540 = -r173539;
        double r173541 = r173534 + r173540;
        return r173541;
}

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

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

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