Average Error: 32.1 → 0
Time: 895.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 r198689 = x;
        double r198690 = r198689 / r198689;
        double r198691 = 1.0;
        double r198692 = r198691 / r198689;
        double r198693 = r198689 * r198689;
        double r198694 = sqrt(r198693);
        double r198695 = r198692 * r198694;
        double r198696 = r198690 - r198695;
        return r198696;
}

double f(double x) {
        double r198697 = 1.0;
        double r198698 = 1.0;
        double r198699 = x;
        double r198700 = fabs(r198699);
        double r198701 = r198698 * r198700;
        double r198702 = r198701 / r198699;
        double r198703 = -r198702;
        double r198704 = r198697 + r198703;
        return r198704;
}

Error

Bits error versus x

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

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

Derivation

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

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

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