Average Error: 32.5 → 0
Time: 5.0s
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 r5872491 = x;
        double r5872492 = r5872491 / r5872491;
        double r5872493 = 1.0;
        double r5872494 = r5872493 / r5872491;
        double r5872495 = r5872491 * r5872491;
        double r5872496 = sqrt(r5872495);
        double r5872497 = r5872494 * r5872496;
        double r5872498 = r5872492 - r5872497;
        return r5872498;
}

double f(double x) {
        double r5872499 = 1.0;
        double r5872500 = x;
        double r5872501 = fabs(r5872500);
        double r5872502 = 1.0;
        double r5872503 = r5872501 * r5872502;
        double r5872504 = r5872503 / r5872500;
        double r5872505 = r5872499 - r5872504;
        return r5872505;
}

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. 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. Final simplification0

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

Reproduce

herbie shell --seed 2019169 
(FPCore (x)
  :name "sqrt sqr"

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

  (- (/ x x) (* (/ 1.0 x) (sqrt (* x x)))))