Average Error: 32.3 → 0
Time: 912.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 r120583 = x;
        double r120584 = r120583 / r120583;
        double r120585 = 1.0;
        double r120586 = r120585 / r120583;
        double r120587 = r120583 * r120583;
        double r120588 = sqrt(r120587);
        double r120589 = r120586 * r120588;
        double r120590 = r120584 - r120589;
        return r120590;
}

double f(double x) {
        double r120591 = 1.0;
        double r120592 = 1.0;
        double r120593 = x;
        double r120594 = fabs(r120593);
        double r120595 = r120592 * r120594;
        double r120596 = r120595 / r120593;
        double r120597 = -r120596;
        double r120598 = r120591 + r120597;
        return r120598;
}

Error

Bits error versus x

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

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

Derivation

  1. Initial program 32.3

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

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

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