Average Error: 32.6 → 0
Time: 5.2s
Precision: 64
\[\frac{x}{x} - \frac{1}{x} \cdot \sqrt{x \cdot x}\]
\[1 - \frac{\left|x\right| \cdot 1}{x}\]
\frac{x}{x} - \frac{1}{x} \cdot \sqrt{x \cdot x}
1 - \frac{\left|x\right| \cdot 1}{x}
double f(double x) {
        double r4738045 = x;
        double r4738046 = r4738045 / r4738045;
        double r4738047 = 1.0;
        double r4738048 = r4738047 / r4738045;
        double r4738049 = r4738045 * r4738045;
        double r4738050 = sqrt(r4738049);
        double r4738051 = r4738048 * r4738050;
        double r4738052 = r4738046 - r4738051;
        return r4738052;
}

double f(double x) {
        double r4738053 = 1.0;
        double r4738054 = x;
        double r4738055 = fabs(r4738054);
        double r4738056 = 1.0;
        double r4738057 = r4738055 * r4738056;
        double r4738058 = r4738057 / r4738054;
        double r4738059 = r4738053 - r4738058;
        return r4738059;
}

Error

Bits error versus x

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

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

Derivation

  1. Initial program 32.6

    \[\frac{x}{x} - \frac{1}{x} \cdot \sqrt{x \cdot x}\]
  2. Simplified4.6

    \[\leadsto \color{blue}{1 - \frac{1}{x} \cdot \left|x\right|}\]
  3. Using strategy rm
  4. Applied associate-*l/0

    \[\leadsto 1 - \color{blue}{\frac{1 \cdot \left|x\right|}{x}}\]
  5. Final simplification0

    \[\leadsto 1 - \frac{\left|x\right| \cdot 1}{x}\]

Reproduce

herbie shell --seed 2019171 
(FPCore (x)
  :name "sqrt sqr"

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

  (- (/ x x) (* (/ 1.0 x) (sqrt (* x x)))))