Average Error: 32.5 → 0
Time: 4.2s
Precision: 64
\[\frac{x}{x} - \frac{1}{x} \cdot \sqrt{x \cdot x}\]
\[1 - \frac{\left|x\right|}{\frac{x}{1}}\]
\frac{x}{x} - \frac{1}{x} \cdot \sqrt{x \cdot x}
1 - \frac{\left|x\right|}{\frac{x}{1}}
double f(double x) {
        double r144022 = x;
        double r144023 = r144022 / r144022;
        double r144024 = 1.0;
        double r144025 = r144024 / r144022;
        double r144026 = r144022 * r144022;
        double r144027 = sqrt(r144026);
        double r144028 = r144025 * r144027;
        double r144029 = r144023 - r144028;
        return r144029;
}

double f(double x) {
        double r144030 = 1.0;
        double r144031 = x;
        double r144032 = fabs(r144031);
        double r144033 = 1.0;
        double r144034 = r144031 / r144033;
        double r144035 = r144032 / r144034;
        double r144036 = r144030 - r144035;
        return r144036;
}

Error

Bits error versus x

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

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

Derivation

  1. Initial program 32.5

    \[\frac{x}{x} - \frac{1}{x} \cdot \sqrt{x \cdot x}\]
  2. Simplified4.7

    \[\leadsto \color{blue}{1 - \frac{1}{x} \cdot \left|x\right|}\]
  3. Using strategy rm
  4. Applied *-un-lft-identity4.7

    \[\leadsto 1 - \color{blue}{\left(1 \cdot \frac{1}{x}\right)} \cdot \left|x\right|\]
  5. Applied associate-*l*4.7

    \[\leadsto 1 - \color{blue}{1 \cdot \left(\frac{1}{x} \cdot \left|x\right|\right)}\]
  6. Simplified0

    \[\leadsto 1 - 1 \cdot \color{blue}{\frac{\left|x\right|}{\frac{x}{1}}}\]
  7. Final simplification0

    \[\leadsto 1 - \frac{\left|x\right|}{\frac{x}{1}}\]

Reproduce

herbie shell --seed 2019196 
(FPCore (x)
  :name "sqrt sqr"

  :herbie-target
  (if (< x 0.0) 2.0 0.0)

  (- (/ x x) (* (/ 1.0 x) (sqrt (* x x)))))