Average Error: 0.0 → 0
Time: 3.1s
Precision: 64
\[x \cdot \left(x - 1\right)\]
\[\mathsf{fma}\left(x, x, x \cdot \left(-1\right)\right)\]
x \cdot \left(x - 1\right)
\mathsf{fma}\left(x, x, x \cdot \left(-1\right)\right)
double f(double x) {
        double r12590901 = x;
        double r12590902 = 1.0;
        double r12590903 = r12590901 - r12590902;
        double r12590904 = r12590901 * r12590903;
        return r12590904;
}

double f(double x) {
        double r12590905 = x;
        double r12590906 = 1.0;
        double r12590907 = -r12590906;
        double r12590908 = r12590905 * r12590907;
        double r12590909 = fma(r12590905, r12590905, r12590908);
        return r12590909;
}

Error

Bits error versus x

Target

Original0.0
Target0.0
Herbie0
\[x \cdot x - x\]

Derivation

  1. Initial program 0.0

    \[x \cdot \left(x - 1\right)\]
  2. Using strategy rm
  3. Applied sub-neg0.0

    \[\leadsto x \cdot \color{blue}{\left(x + \left(-1\right)\right)}\]
  4. Applied distribute-rgt-in0.0

    \[\leadsto \color{blue}{x \cdot x + \left(-1\right) \cdot x}\]
  5. Using strategy rm
  6. Applied fma-def0

    \[\leadsto \color{blue}{\mathsf{fma}\left(x, x, \left(-1\right) \cdot x\right)}\]
  7. Final simplification0

    \[\leadsto \mathsf{fma}\left(x, x, x \cdot \left(-1\right)\right)\]

Reproduce

herbie shell --seed 2019171 +o rules:numerics
(FPCore (x)
  :name "Statistics.Correlation.Kendall:numOfTiesBy from math-functions-0.1.5.2"

  :herbie-target
  (- (* x x) x)

  (* x (- x 1.0)))