Average Error: 0.0 → 0.0
Time: 10.2s
Precision: 64
\[x \cdot y + \left(x - 1\right) \cdot z\]
\[\mathsf{fma}\left(x, y, \left(x - 1\right) \cdot z\right)\]
x \cdot y + \left(x - 1\right) \cdot z
\mathsf{fma}\left(x, y, \left(x - 1\right) \cdot z\right)
double f(double x, double y, double z) {
        double r123259 = x;
        double r123260 = y;
        double r123261 = r123259 * r123260;
        double r123262 = 1.0;
        double r123263 = r123259 - r123262;
        double r123264 = z;
        double r123265 = r123263 * r123264;
        double r123266 = r123261 + r123265;
        return r123266;
}

double f(double x, double y, double z) {
        double r123267 = x;
        double r123268 = y;
        double r123269 = 1.0;
        double r123270 = r123267 - r123269;
        double r123271 = z;
        double r123272 = r123270 * r123271;
        double r123273 = fma(r123267, r123268, r123272);
        return r123273;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Derivation

  1. Initial program 0.0

    \[x \cdot y + \left(x - 1\right) \cdot z\]
  2. Simplified0.0

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

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

Reproduce

herbie shell --seed 2019323 +o rules:numerics
(FPCore (x y z)
  :name "Graphics.Rendering.Chart.Drawing:drawTextsR from Chart-1.5.3"
  :precision binary64
  (+ (* x y) (* (- x 1) z)))