Average Error: 32.6 → 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 r3545801 = x;
        double r3545802 = r3545801 / r3545801;
        double r3545803 = 1.0;
        double r3545804 = r3545803 / r3545801;
        double r3545805 = r3545801 * r3545801;
        double r3545806 = sqrt(r3545805);
        double r3545807 = r3545804 * r3545806;
        double r3545808 = r3545802 - r3545807;
        return r3545808;
}

double f(double x) {
        double r3545809 = 1.0;
        double r3545810 = x;
        double r3545811 = fabs(r3545810);
        double r3545812 = r3545811 / r3545810;
        double r3545813 = r3545809 - r3545812;
        return r3545813;
}

Error

Bits error versus x

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

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

Derivation

  1. Initial program 32.6

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

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

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