Average Error: 32.3 → 0
Time: 5.2s
Precision: 64
\[\frac{x}{x} - \frac{1}{x} \cdot \sqrt{x \cdot x}\]
\[1 - \frac{\left|x\right| \cdot 1}{x}\]
\frac{x}{x} - \frac{1}{x} \cdot \sqrt{x \cdot x}
1 - \frac{\left|x\right| \cdot 1}{x}
double f(double x) {
        double r16542 = x;
        double r16543 = r16542 / r16542;
        double r16544 = 1.0;
        double r16545 = r16544 / r16542;
        double r16546 = r16542 * r16542;
        double r16547 = sqrt(r16546);
        double r16548 = r16545 * r16547;
        double r16549 = r16543 - r16548;
        return r16549;
}

double f(double x) {
        double r16550 = 1.0;
        double r16551 = x;
        double r16552 = fabs(r16551);
        double r16553 = 1.0;
        double r16554 = r16552 * r16553;
        double r16555 = r16554 / r16551;
        double r16556 = r16550 - r16555;
        return r16556;
}

Error

Bits error versus x

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

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

Derivation

  1. Initial program 32.3

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

    \[\leadsto \color{blue}{1 - \frac{1}{x} \cdot \left|x\right|}\]
  3. Using strategy rm
  4. Applied associate-*l/0

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

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

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

Reproduce

herbie shell --seed 2019315 
(FPCore (x)
  :name "sqrt sqr"
  :precision binary64

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

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