Average Error: 32.3 → 0
Time: 2.1s
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 code(double x) {
	return ((double) (((double) (x / x)) - ((double) (((double) (1.0 / x)) * ((double) sqrt(((double) (x * x))))))));
}
double code(double x) {
	return ((double) (1.0 - ((double) (((double) (((double) fabs(x)) * 1.0)) / x))));
}

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. Using strategy rm
  3. Applied *-un-lft-identity32.3

    \[\leadsto \frac{x}{x} - \color{blue}{1 \cdot \left(\frac{1}{x} \cdot \sqrt{x \cdot x}\right)}\]
  4. Applied *-un-lft-identity32.3

    \[\leadsto \color{blue}{1 \cdot \frac{x}{x}} - 1 \cdot \left(\frac{1}{x} \cdot \sqrt{x \cdot x}\right)\]
  5. Applied distribute-lft-out--32.3

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

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

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

Reproduce

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

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

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