Average Error: 31.7 → 0
Time: 4.2s
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 r26301272 = x;
        double r26301273 = r26301272 / r26301272;
        double r26301274 = 1.0;
        double r26301275 = r26301274 / r26301272;
        double r26301276 = r26301272 * r26301272;
        double r26301277 = sqrt(r26301276);
        double r26301278 = r26301275 * r26301277;
        double r26301279 = r26301273 - r26301278;
        return r26301279;
}

double f(double x) {
        double r26301280 = 1.0;
        double r26301281 = x;
        double r26301282 = fabs(r26301281);
        double r26301283 = r26301282 / r26301281;
        double r26301284 = r26301280 - r26301283;
        return r26301284;
}

Error

Bits error versus x

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

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

Derivation

  1. Initial program 31.7

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

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

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