Average Error: 0.0 → 0.0
Time: 1.3s
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 r124017 = x;
        double r124018 = y;
        double r124019 = r124017 * r124018;
        double r124020 = 1.0;
        double r124021 = r124017 - r124020;
        double r124022 = z;
        double r124023 = r124021 * r124022;
        double r124024 = r124019 + r124023;
        return r124024;
}

double f(double x, double y, double z) {
        double r124025 = x;
        double r124026 = y;
        double r124027 = 1.0;
        double r124028 = r124025 - r124027;
        double r124029 = z;
        double r124030 = r124028 * r124029;
        double r124031 = fma(r124025, r124026, r124030);
        return r124031;
}

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 2020001 +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)))