Average Error: 0.0 → 0.0
Time: 1.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 r181901 = x;
        double r181902 = y;
        double r181903 = r181901 * r181902;
        double r181904 = 1.0;
        double r181905 = r181901 - r181904;
        double r181906 = z;
        double r181907 = r181905 * r181906;
        double r181908 = r181903 + r181907;
        return r181908;
}

double f(double x, double y, double z) {
        double r181909 = x;
        double r181910 = y;
        double r181911 = 1.0;
        double r181912 = r181909 - r181911;
        double r181913 = z;
        double r181914 = r181912 * r181913;
        double r181915 = fma(r181909, r181910, r181914);
        return r181915;
}

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