Average Error: 32.4 → 0
Time: 4.4s
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 r2464014 = x;
        double r2464015 = r2464014 / r2464014;
        double r2464016 = 1.0;
        double r2464017 = r2464016 / r2464014;
        double r2464018 = r2464014 * r2464014;
        double r2464019 = sqrt(r2464018);
        double r2464020 = r2464017 * r2464019;
        double r2464021 = r2464015 - r2464020;
        return r2464021;
}

double f(double x) {
        double r2464022 = 1.0;
        double r2464023 = x;
        double r2464024 = fabs(r2464023);
        double r2464025 = r2464024 / r2464023;
        double r2464026 = r2464022 - r2464025;
        return r2464026;
}

Error

Bits error versus x

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

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

Derivation

  1. Initial program 32.4

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

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

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