Average Error: 32.7 → 0
Time: 1.2s
Precision: 64
\[\frac{x}{x} - \frac{1}{x} \cdot \sqrt{x \cdot x}\]
\[\frac{x}{x} - 1 \cdot \frac{\left|x\right| \cdot 1}{x}\]
\frac{x}{x} - \frac{1}{x} \cdot \sqrt{x \cdot x}
\frac{x}{x} - 1 \cdot \frac{\left|x\right| \cdot 1}{x}
double f(double x) {
        double r126796 = x;
        double r126797 = r126796 / r126796;
        double r126798 = 1.0;
        double r126799 = r126798 / r126796;
        double r126800 = r126796 * r126796;
        double r126801 = sqrt(r126800);
        double r126802 = r126799 * r126801;
        double r126803 = r126797 - r126802;
        return r126803;
}

double f(double x) {
        double r126804 = x;
        double r126805 = r126804 / r126804;
        double r126806 = 1.0;
        double r126807 = fabs(r126804);
        double r126808 = 1.0;
        double r126809 = r126807 * r126808;
        double r126810 = r126809 / r126804;
        double r126811 = r126806 * r126810;
        double r126812 = r126805 - r126811;
        return r126812;
}

Error

Bits error versus x

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

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

Derivation

  1. Initial program 32.7

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

    \[\leadsto \frac{x}{x} - \frac{1}{\color{blue}{1 \cdot x}} \cdot \sqrt{x \cdot x}\]
  4. Applied *-un-lft-identity32.7

    \[\leadsto \frac{x}{x} - \frac{\color{blue}{1 \cdot 1}}{1 \cdot x} \cdot \sqrt{x \cdot x}\]
  5. Applied times-frac32.7

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

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

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

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

Reproduce

herbie shell --seed 2020062 +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)))))