Average Error: 32.4 → 0
Time: 876.0ms
Precision: 64
\[\frac{x}{x} - \frac{1}{x} \cdot \sqrt{x \cdot x}\]
\[1 + \left(-\frac{1 \cdot \left|x\right|}{x}\right)\]
\frac{x}{x} - \frac{1}{x} \cdot \sqrt{x \cdot x}
1 + \left(-\frac{1 \cdot \left|x\right|}{x}\right)
double f(double x) {
        double r152250 = x;
        double r152251 = r152250 / r152250;
        double r152252 = 1.0;
        double r152253 = r152252 / r152250;
        double r152254 = r152250 * r152250;
        double r152255 = sqrt(r152254);
        double r152256 = r152253 * r152255;
        double r152257 = r152251 - r152256;
        return r152257;
}

double f(double x) {
        double r152258 = 1.0;
        double r152259 = 1.0;
        double r152260 = x;
        double r152261 = fabs(r152260);
        double r152262 = r152259 * r152261;
        double r152263 = r152262 / r152260;
        double r152264 = -r152263;
        double r152265 = r152258 + r152264;
        return r152265;
}

Error

Bits error versus x

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

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

Derivation

  1. Initial program 32.4

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

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

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

Reproduce

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

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

  (- (/ x x) (* (/ 1 x) (sqrt (* x x)))))