Average Error: 32.5 → 0
Time: 880.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 r132499 = x;
        double r132500 = r132499 / r132499;
        double r132501 = 1.0;
        double r132502 = r132501 / r132499;
        double r132503 = r132499 * r132499;
        double r132504 = sqrt(r132503);
        double r132505 = r132502 * r132504;
        double r132506 = r132500 - r132505;
        return r132506;
}

double f(double x) {
        double r132507 = 1.0;
        double r132508 = 1.0;
        double r132509 = x;
        double r132510 = fabs(r132509);
        double r132511 = r132508 * r132510;
        double r132512 = r132511 / r132509;
        double r132513 = -r132512;
        double r132514 = r132507 + r132513;
        return r132514;
}

Error

Bits error versus x

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

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

Derivation

  1. Initial program 32.5

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

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

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