Average Error: 32.3 → 0
Time: 3.9s
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 r4766723 = x;
        double r4766724 = r4766723 / r4766723;
        double r4766725 = 1.0;
        double r4766726 = r4766725 / r4766723;
        double r4766727 = r4766723 * r4766723;
        double r4766728 = sqrt(r4766727);
        double r4766729 = r4766726 * r4766728;
        double r4766730 = r4766724 - r4766729;
        return r4766730;
}

double f(double x) {
        double r4766731 = 1.0;
        double r4766732 = x;
        double r4766733 = fabs(r4766732);
        double r4766734 = r4766733 / r4766732;
        double r4766735 = r4766731 - r4766734;
        return r4766735;
}

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:\\ \;\;\;\;2\\ \mathbf{else}:\\ \;\;\;\;0\\ \end{array}\]

Derivation

  1. Initial program 32.3

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

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

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