Average Error: 32.5 → 0
Time: 892.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 r99400 = x;
        double r99401 = r99400 / r99400;
        double r99402 = 1.0;
        double r99403 = r99402 / r99400;
        double r99404 = r99400 * r99400;
        double r99405 = sqrt(r99404);
        double r99406 = r99403 * r99405;
        double r99407 = r99401 - r99406;
        return r99407;
}

double f(double x) {
        double r99408 = 1.0;
        double r99409 = 1.0;
        double r99410 = x;
        double r99411 = fabs(r99410);
        double r99412 = r99409 * r99411;
        double r99413 = r99412 / r99410;
        double r99414 = -r99413;
        double r99415 = r99408 + r99414;
        return r99415;
}

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

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

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