Average Error: 32.6 → 0
Time: 2.6s
Precision: binary64
\[\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) ((x / x) - ((double) ((1.0 / x) * ((double) sqrt(((double) (x * x))))))));
}
double code(double x) {
	return ((double) (1.0 - (((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.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. Simplified4.6

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

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

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

Reproduce

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

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

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