Average Error: 32.4 → 0
Time: 881.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 r221288 = x;
        double r221289 = r221288 / r221288;
        double r221290 = 1.0;
        double r221291 = r221290 / r221288;
        double r221292 = r221288 * r221288;
        double r221293 = sqrt(r221292);
        double r221294 = r221291 * r221293;
        double r221295 = r221289 - r221294;
        return r221295;
}

double f(double x) {
        double r221296 = 1.0;
        double r221297 = 1.0;
        double r221298 = x;
        double r221299 = fabs(r221298);
        double r221300 = r221297 * r221299;
        double r221301 = r221300 / r221298;
        double r221302 = -r221301;
        double r221303 = r221296 + r221302;
        return r221303;
}

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

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

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