Average Error: 32.4 → 0
Time: 900.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 r120418 = x;
        double r120419 = r120418 / r120418;
        double r120420 = 1.0;
        double r120421 = r120420 / r120418;
        double r120422 = r120418 * r120418;
        double r120423 = sqrt(r120422);
        double r120424 = r120421 * r120423;
        double r120425 = r120419 - r120424;
        return r120425;
}

double f(double x) {
        double r120426 = 1.0;
        double r120427 = 1.0;
        double r120428 = x;
        double r120429 = fabs(r120428);
        double r120430 = r120427 * r120429;
        double r120431 = r120430 / r120428;
        double r120432 = -r120431;
        double r120433 = r120426 + r120432;
        return r120433;
}

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

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

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