Average Error: 31.8 → 0
Time: 921.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 r160319 = x;
        double r160320 = r160319 / r160319;
        double r160321 = 1.0;
        double r160322 = r160321 / r160319;
        double r160323 = r160319 * r160319;
        double r160324 = sqrt(r160323);
        double r160325 = r160322 * r160324;
        double r160326 = r160320 - r160325;
        return r160326;
}

double f(double x) {
        double r160327 = 1.0;
        double r160328 = 1.0;
        double r160329 = x;
        double r160330 = fabs(r160329);
        double r160331 = r160328 * r160330;
        double r160332 = r160331 / r160329;
        double r160333 = -r160332;
        double r160334 = r160327 + r160333;
        return r160334;
}

Error

Bits error versus x

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

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

Derivation

  1. Initial program 31.8

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

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

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