Average Error: 32.4 → 0
Time: 5.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 r4112509 = x;
        double r4112510 = r4112509 / r4112509;
        double r4112511 = 1.0;
        double r4112512 = r4112511 / r4112509;
        double r4112513 = r4112509 * r4112509;
        double r4112514 = sqrt(r4112513);
        double r4112515 = r4112512 * r4112514;
        double r4112516 = r4112510 - r4112515;
        return r4112516;
}

double f(double x) {
        double r4112517 = 1.0;
        double r4112518 = x;
        double r4112519 = fabs(r4112518);
        double r4112520 = 1.0;
        double r4112521 = r4112519 * r4112520;
        double r4112522 = r4112521 / r4112518;
        double r4112523 = r4112517 - r4112522;
        return r4112523;
}

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

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

Reproduce

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

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

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