Average Error: 32.1 → 0
Time: 4.0s
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 r18468361 = x;
        double r18468362 = r18468361 / r18468361;
        double r18468363 = 1.0;
        double r18468364 = r18468363 / r18468361;
        double r18468365 = r18468361 * r18468361;
        double r18468366 = sqrt(r18468365);
        double r18468367 = r18468364 * r18468366;
        double r18468368 = r18468362 - r18468367;
        return r18468368;
}

double f(double x) {
        double r18468369 = 1.0;
        double r18468370 = x;
        double r18468371 = fabs(r18468370);
        double r18468372 = r18468371 / r18468370;
        double r18468373 = r18468369 - r18468372;
        return r18468373;
}

Error

Bits error versus x

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

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

Derivation

  1. Initial program 32.1

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

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

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