Average Error: 32.3 → 0
Time: 6.6s
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 r83597 = x;
        double r83598 = r83597 / r83597;
        double r83599 = 1.0;
        double r83600 = r83599 / r83597;
        double r83601 = r83597 * r83597;
        double r83602 = sqrt(r83601);
        double r83603 = r83600 * r83602;
        double r83604 = r83598 - r83603;
        return r83604;
}

double f(double x) {
        double r83605 = 1.0;
        double r83606 = x;
        double r83607 = fabs(r83606);
        double r83608 = 1.0;
        double r83609 = r83607 * r83608;
        double r83610 = r83609 / r83606;
        double r83611 = r83605 - r83610;
        return r83611;
}

Error

Bits error versus x

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

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

Derivation

  1. Initial program 32.3

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

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

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