Average Error: 32.0 → 0
Time: 6.4s
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 r94326 = x;
        double r94327 = r94326 / r94326;
        double r94328 = 1.0;
        double r94329 = r94328 / r94326;
        double r94330 = r94326 * r94326;
        double r94331 = sqrt(r94330);
        double r94332 = r94329 * r94331;
        double r94333 = r94327 - r94332;
        return r94333;
}

double f(double x) {
        double r94334 = 1.0;
        double r94335 = x;
        double r94336 = fabs(r94335);
        double r94337 = 1.0;
        double r94338 = r94336 * r94337;
        double r94339 = r94338 / r94335;
        double r94340 = r94334 - r94339;
        return r94340;
}

Error

Bits error versus x

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

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

Derivation

  1. Initial program 32.0

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

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

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

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