Average Error: 32.1 → 0
Time: 923.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 r145204 = x;
        double r145205 = r145204 / r145204;
        double r145206 = 1.0;
        double r145207 = r145206 / r145204;
        double r145208 = r145204 * r145204;
        double r145209 = sqrt(r145208);
        double r145210 = r145207 * r145209;
        double r145211 = r145205 - r145210;
        return r145211;
}

double f(double x) {
        double r145212 = 1.0;
        double r145213 = 1.0;
        double r145214 = x;
        double r145215 = fabs(r145214);
        double r145216 = r145213 * r145215;
        double r145217 = r145216 / r145214;
        double r145218 = -r145217;
        double r145219 = r145212 + r145218;
        return r145219;
}

Error

Bits error versus x

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

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

Derivation

  1. Initial program 32.1

    \[\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 2020018 
(FPCore (x)
  :name "sqrt sqr"
  :precision binary64

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

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