Average Error: 32.2 → 0
Time: 4.9s
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 r5399186 = x;
        double r5399187 = r5399186 / r5399186;
        double r5399188 = 1.0;
        double r5399189 = r5399188 / r5399186;
        double r5399190 = r5399186 * r5399186;
        double r5399191 = sqrt(r5399190);
        double r5399192 = r5399189 * r5399191;
        double r5399193 = r5399187 - r5399192;
        return r5399193;
}

double f(double x) {
        double r5399194 = 1.0;
        double r5399195 = x;
        double r5399196 = fabs(r5399195);
        double r5399197 = 1.0;
        double r5399198 = r5399196 * r5399197;
        double r5399199 = r5399198 / r5399195;
        double r5399200 = r5399194 - r5399199;
        return r5399200;
}

Error

Bits error versus x

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

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

Derivation

  1. Initial program 32.2

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

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

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

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