Average Error: 32.4 → 0
Time: 6.2s
Precision: 64
\[\frac{x}{x} - \frac{1}{x} \cdot \sqrt{x \cdot x}\]
\[1 - \frac{\left|x\right| \cdot 1}{x}\]
\frac{x}{x} - \frac{1}{x} \cdot \sqrt{x \cdot x}
1 - \frac{\left|x\right| \cdot 1}{x}
double f(double x) {
        double r70464 = x;
        double r70465 = r70464 / r70464;
        double r70466 = 1.0;
        double r70467 = r70466 / r70464;
        double r70468 = r70464 * r70464;
        double r70469 = sqrt(r70468);
        double r70470 = r70467 * r70469;
        double r70471 = r70465 - r70470;
        return r70471;
}

double f(double x) {
        double r70472 = 1.0;
        double r70473 = x;
        double r70474 = fabs(r70473);
        double r70475 = 1.0;
        double r70476 = r70474 * r70475;
        double r70477 = r70476 / r70473;
        double r70478 = r70472 - r70477;
        return r70478;
}

Error

Bits error versus x

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

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

Derivation

  1. Initial program 32.4

    \[\frac{x}{x} - \frac{1}{x} \cdot \sqrt{x \cdot x}\]
  2. Simplified4.7

    \[\leadsto \color{blue}{1 - \frac{1}{x} \cdot \left|x\right|}\]
  3. Using strategy rm
  4. Applied associate-*l/0

    \[\leadsto 1 - \color{blue}{\frac{1 \cdot \left|x\right|}{x}}\]
  5. Simplified0

    \[\leadsto 1 - \frac{\color{blue}{\left|x\right| \cdot 1}}{x}\]
  6. Final simplification0

    \[\leadsto 1 - \frac{\left|x\right| \cdot 1}{x}\]

Reproduce

herbie shell --seed 2019323 
(FPCore (x)
  :name "sqrt sqr"
  :precision binary64

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

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