Average Error: 31.6 → 0
Time: 4.2s
Precision: 64
\[\frac{x}{x} - \frac{1}{x} \cdot \sqrt{x \cdot x}\]
\[1 - \frac{\left|x\right|}{\frac{x}{1}}\]
\frac{x}{x} - \frac{1}{x} \cdot \sqrt{x \cdot x}
1 - \frac{\left|x\right|}{\frac{x}{1}}
double f(double x) {
        double r83946 = x;
        double r83947 = r83946 / r83946;
        double r83948 = 1.0;
        double r83949 = r83948 / r83946;
        double r83950 = r83946 * r83946;
        double r83951 = sqrt(r83950);
        double r83952 = r83949 * r83951;
        double r83953 = r83947 - r83952;
        return r83953;
}

double f(double x) {
        double r83954 = 1.0;
        double r83955 = x;
        double r83956 = fabs(r83955);
        double r83957 = 1.0;
        double r83958 = r83955 / r83957;
        double r83959 = r83956 / r83958;
        double r83960 = r83954 - r83959;
        return r83960;
}

Error

Bits error versus x

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

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

Derivation

  1. Initial program 31.6

    \[\frac{x}{x} - \frac{1}{x} \cdot \sqrt{x \cdot x}\]
  2. Simplified5.0

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

    \[\leadsto 1 - \color{blue}{\left(1 \cdot \frac{1}{x}\right)} \cdot \left|x\right|\]
  5. Applied associate-*l*5.0

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

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

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

Reproduce

herbie shell --seed 2019194 
(FPCore (x)
  :name "sqrt sqr"

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

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