Average Error: 32.5 → 0
Time: 6.1s
Precision: 64
\[\frac{x}{x} - \frac{1}{x} \cdot \sqrt{x \cdot x}\]
\[1 - \frac{\left|x\right|}{x}\]
\frac{x}{x} - \frac{1}{x} \cdot \sqrt{x \cdot x}
1 - \frac{\left|x\right|}{x}
double f(double x) {
        double r1947823 = x;
        double r1947824 = r1947823 / r1947823;
        double r1947825 = 1.0;
        double r1947826 = r1947825 / r1947823;
        double r1947827 = r1947823 * r1947823;
        double r1947828 = sqrt(r1947827);
        double r1947829 = r1947826 * r1947828;
        double r1947830 = r1947824 - r1947829;
        return r1947830;
}

double f(double x) {
        double r1947831 = 1.0;
        double r1947832 = x;
        double r1947833 = fabs(r1947832);
        double r1947834 = r1947833 / r1947832;
        double r1947835 = r1947831 - r1947834;
        return r1947835;
}

Error

Bits error versus x

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

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

Derivation

  1. Initial program 32.5

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

    \[\leadsto \color{blue}{1 - \frac{\left|x\right|}{x}}\]
  3. Final simplification0

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

Reproduce

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

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

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