Average Error: 31.8 → 0
Time: 4.5s
Precision: 64
\[\frac{x}{x} - \frac{1}{x} \cdot \sqrt{x \cdot x}\]
\[1 - \log \left({\left(e^{1}\right)}^{\left(\frac{\left|x\right|}{x}\right)}\right)\]
\frac{x}{x} - \frac{1}{x} \cdot \sqrt{x \cdot x}
1 - \log \left({\left(e^{1}\right)}^{\left(\frac{\left|x\right|}{x}\right)}\right)
double f(double x) {
        double r87819 = x;
        double r87820 = r87819 / r87819;
        double r87821 = 1.0;
        double r87822 = r87821 / r87819;
        double r87823 = r87819 * r87819;
        double r87824 = sqrt(r87823);
        double r87825 = r87822 * r87824;
        double r87826 = r87820 - r87825;
        return r87826;
}

double f(double x) {
        double r87827 = 1.0;
        double r87828 = 1.0;
        double r87829 = exp(r87828);
        double r87830 = x;
        double r87831 = fabs(r87830);
        double r87832 = r87831 / r87830;
        double r87833 = pow(r87829, r87832);
        double r87834 = log(r87833);
        double r87835 = r87827 - r87834;
        return r87835;
}

Error

Bits error versus x

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

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

Derivation

  1. Initial program 31.8

    \[\frac{x}{x} - \frac{1}{x} \cdot \sqrt{x \cdot x}\]
  2. Simplified4.7

    \[\leadsto \color{blue}{1 - \frac{1}{x} \cdot \left|x\right|}\]
  3. Using strategy rm
  4. Applied add-log-exp0.1

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

    \[\leadsto 1 - \log \color{blue}{\left({\left(e^{1}\right)}^{\left(\frac{\left|x\right|}{x}\right)}\right)}\]
  6. Final simplification0

    \[\leadsto 1 - \log \left({\left(e^{1}\right)}^{\left(\frac{\left|x\right|}{x}\right)}\right)\]

Reproduce

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

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

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