Average Error: 0.0 → 0
Time: 2.8s
Precision: 64
\[x \cdot \left(x - 1\right)\]
\[\mathsf{fma}\left(x, x, 1 \cdot \left(-x\right)\right)\]
x \cdot \left(x - 1\right)
\mathsf{fma}\left(x, x, 1 \cdot \left(-x\right)\right)
double f(double x) {
        double r232914 = x;
        double r232915 = 1.0;
        double r232916 = r232914 - r232915;
        double r232917 = r232914 * r232916;
        return r232917;
}

double f(double x) {
        double r232918 = x;
        double r232919 = 1.0;
        double r232920 = -r232918;
        double r232921 = r232919 * r232920;
        double r232922 = fma(r232918, r232918, r232921);
        return r232922;
}

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-lft-in0.0

    \[\leadsto \color{blue}{x \cdot x + x \cdot \left(-1\right)}\]
  5. Simplified0.0

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

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

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

Reproduce

herbie shell --seed 2019194 +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)))