Average Error: 32.8 → 0
Time: 888.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 r121081 = x;
        double r121082 = r121081 / r121081;
        double r121083 = 1.0;
        double r121084 = r121083 / r121081;
        double r121085 = r121081 * r121081;
        double r121086 = sqrt(r121085);
        double r121087 = r121084 * r121086;
        double r121088 = r121082 - r121087;
        return r121088;
}

double f(double x) {
        double r121089 = 1.0;
        double r121090 = 1.0;
        double r121091 = x;
        double r121092 = fabs(r121091);
        double r121093 = r121090 * r121092;
        double r121094 = r121093 / r121091;
        double r121095 = -r121094;
        double r121096 = r121089 + r121095;
        return r121096;
}

Error

Bits error versus x

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

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

Derivation

  1. Initial program 32.8

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

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

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