Average Error: 32.4 → 0
Time: 7.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 r63874 = x;
        double r63875 = r63874 / r63874;
        double r63876 = 1.0;
        double r63877 = r63876 / r63874;
        double r63878 = r63874 * r63874;
        double r63879 = sqrt(r63878);
        double r63880 = r63877 * r63879;
        double r63881 = r63875 - r63880;
        return r63881;
}

double f(double x) {
        double r63882 = 1.0;
        double r63883 = x;
        double r63884 = fabs(r63883);
        double r63885 = 1.0;
        double r63886 = r63884 * r63885;
        double r63887 = r63886 / r63883;
        double r63888 = r63882 - r63887;
        return r63888;
}

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. 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 2019323 
(FPCore (x)
  :name "sqrt sqr"
  :precision binary64

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

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