Average Error: 32.6 → 0
Time: 4.6s
Precision: 64
\[\frac{x}{x} - \frac{1}{x} \cdot \sqrt{x \cdot x}\]
\[\frac{x}{x} - \frac{1 \cdot \left|x\right|}{x}\]
\frac{x}{x} - \frac{1}{x} \cdot \sqrt{x \cdot x}
\frac{x}{x} - \frac{1 \cdot \left|x\right|}{x}
double f(double x) {
        double r90676 = x;
        double r90677 = r90676 / r90676;
        double r90678 = 1.0;
        double r90679 = r90678 / r90676;
        double r90680 = r90676 * r90676;
        double r90681 = sqrt(r90680);
        double r90682 = r90679 * r90681;
        double r90683 = r90677 - r90682;
        return r90683;
}

double f(double x) {
        double r90684 = x;
        double r90685 = r90684 / r90684;
        double r90686 = 1.0;
        double r90687 = fabs(r90684);
        double r90688 = r90686 * r90687;
        double r90689 = r90688 / r90684;
        double r90690 = r90685 - r90689;
        return r90690;
}

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.0:\\ \;\;\;\;2\\ \mathbf{else}:\\ \;\;\;\;0.0\\ \end{array}\]

Derivation

  1. Initial program 32.6

    \[\frac{x}{x} - \frac{1}{x} \cdot \sqrt{x \cdot x}\]
  2. Using strategy rm
  3. Applied *-un-lft-identity32.6

    \[\leadsto \frac{x}{x} - \color{blue}{\left(1 \cdot \frac{1}{x}\right)} \cdot \sqrt{x \cdot x}\]
  4. Applied associate-*l*32.6

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

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

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

Reproduce

herbie shell --seed 2019174 +o rules:numerics
(FPCore (x)
  :name "sqrt sqr"

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

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