Average Error: 0.0 → 0.0
Time: 10.2s
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 r100774 = x;
        double r100775 = y;
        double r100776 = r100774 * r100775;
        double r100777 = 1.0;
        double r100778 = r100774 - r100777;
        double r100779 = z;
        double r100780 = r100778 * r100779;
        double r100781 = r100776 + r100780;
        return r100781;
}

double f(double x, double y, double z) {
        double r100782 = z;
        double r100783 = x;
        double r100784 = 1.0;
        double r100785 = r100783 - r100784;
        double r100786 = y;
        double r100787 = r100783 * r100786;
        double r100788 = fma(r100782, r100785, r100787);
        return r100788;
}

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