Average Error: 32.4 → 0
Time: 889.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 r242507 = x;
        double r242508 = r242507 / r242507;
        double r242509 = 1.0;
        double r242510 = r242509 / r242507;
        double r242511 = r242507 * r242507;
        double r242512 = sqrt(r242511);
        double r242513 = r242510 * r242512;
        double r242514 = r242508 - r242513;
        return r242514;
}

double f(double x) {
        double r242515 = 1.0;
        double r242516 = 1.0;
        double r242517 = x;
        double r242518 = fabs(r242517);
        double r242519 = r242516 * r242518;
        double r242520 = r242519 / r242517;
        double r242521 = -r242520;
        double r242522 = r242515 + r242521;
        return r242522;
}

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

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

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