Average Error: 33.1 → 0
Time: 890.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 r100284 = x;
        double r100285 = r100284 / r100284;
        double r100286 = 1.0;
        double r100287 = r100286 / r100284;
        double r100288 = r100284 * r100284;
        double r100289 = sqrt(r100288);
        double r100290 = r100287 * r100289;
        double r100291 = r100285 - r100290;
        return r100291;
}

double f(double x) {
        double r100292 = 1.0;
        double r100293 = 1.0;
        double r100294 = x;
        double r100295 = fabs(r100294);
        double r100296 = r100293 * r100295;
        double r100297 = r100296 / r100294;
        double r100298 = -r100297;
        double r100299 = r100292 + r100298;
        return r100299;
}

Error

Bits error versus x

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

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

Derivation

  1. Initial program 33.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 2020046 
(FPCore (x)
  :name "sqrt sqr"
  :precision binary64

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

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