Average Error: 32.3 → 0
Time: 3.7s
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 r12321319 = x;
        double r12321320 = r12321319 / r12321319;
        double r12321321 = 1.0;
        double r12321322 = r12321321 / r12321319;
        double r12321323 = r12321319 * r12321319;
        double r12321324 = sqrt(r12321323);
        double r12321325 = r12321322 * r12321324;
        double r12321326 = r12321320 - r12321325;
        return r12321326;
}

double f(double x) {
        double r12321327 = 1.0;
        double r12321328 = x;
        double r12321329 = fabs(r12321328);
        double r12321330 = r12321329 / r12321328;
        double r12321331 = r12321327 - r12321330;
        return r12321331;
}

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

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

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