Average Error: 32.9 → 0
Time: 1.9s
Precision: 64
\[\frac{x}{x} - \frac{1}{x} \cdot \sqrt{x \cdot x}\]
\[\frac{x}{x} - \frac{\sqrt[3]{1} \cdot \sqrt[3]{1}}{1} \cdot \frac{\sqrt[3]{1} \cdot \left|x\right|}{x}\]
\frac{x}{x} - \frac{1}{x} \cdot \sqrt{x \cdot x}
\frac{x}{x} - \frac{\sqrt[3]{1} \cdot \sqrt[3]{1}}{1} \cdot \frac{\sqrt[3]{1} \cdot \left|x\right|}{x}
double f(double x) {
        double r137796 = x;
        double r137797 = r137796 / r137796;
        double r137798 = 1.0;
        double r137799 = r137798 / r137796;
        double r137800 = r137796 * r137796;
        double r137801 = sqrt(r137800);
        double r137802 = r137799 * r137801;
        double r137803 = r137797 - r137802;
        return r137803;
}

double f(double x) {
        double r137804 = x;
        double r137805 = r137804 / r137804;
        double r137806 = 1.0;
        double r137807 = cbrt(r137806);
        double r137808 = r137807 * r137807;
        double r137809 = 1.0;
        double r137810 = r137808 / r137809;
        double r137811 = fabs(r137804);
        double r137812 = r137807 * r137811;
        double r137813 = r137812 / r137804;
        double r137814 = r137810 * r137813;
        double r137815 = r137805 - r137814;
        return r137815;
}

Error

Bits error versus x

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

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

Derivation

  1. Initial program 32.9

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

    \[\leadsto \frac{x}{x} - \frac{1}{\color{blue}{1 \cdot x}} \cdot \sqrt{x \cdot x}\]
  4. Applied add-cube-cbrt32.9

    \[\leadsto \frac{x}{x} - \frac{\color{blue}{\left(\sqrt[3]{1} \cdot \sqrt[3]{1}\right) \cdot \sqrt[3]{1}}}{1 \cdot x} \cdot \sqrt{x \cdot x}\]
  5. Applied times-frac32.9

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

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

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

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

Reproduce

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