Average Error: 0.0 → 0.0
Time: 5.0s
Precision: 64
\[x \cdot y + \left(x - 1\right) \cdot z\]
\[\mathsf{fma}\left(z, x - 1, x \cdot y\right)\]
x \cdot y + \left(x - 1\right) \cdot z
\mathsf{fma}\left(z, x - 1, x \cdot y\right)
double f(double x, double y, double z) {
        double r111616 = x;
        double r111617 = y;
        double r111618 = r111616 * r111617;
        double r111619 = 1.0;
        double r111620 = r111616 - r111619;
        double r111621 = z;
        double r111622 = r111620 * r111621;
        double r111623 = r111618 + r111622;
        return r111623;
}

double f(double x, double y, double z) {
        double r111624 = z;
        double r111625 = x;
        double r111626 = 1.0;
        double r111627 = r111625 - r111626;
        double r111628 = y;
        double r111629 = r111625 * r111628;
        double r111630 = fma(r111624, r111627, r111629);
        return r111630;
}

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. Taylor expanded around 0 0.0

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

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

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

Reproduce

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