Average Error: 0.0 → 0.0
Time: 2.0s
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 r159407 = x;
        double r159408 = y;
        double r159409 = r159407 * r159408;
        double r159410 = 1.0;
        double r159411 = r159407 - r159410;
        double r159412 = z;
        double r159413 = r159411 * r159412;
        double r159414 = r159409 + r159413;
        return r159414;
}

double f(double x, double y, double z) {
        double r159415 = x;
        double r159416 = y;
        double r159417 = 1.0;
        double r159418 = r159415 - r159417;
        double r159419 = z;
        double r159420 = r159418 * r159419;
        double r159421 = fma(r159415, r159416, r159420);
        return r159421;
}

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