Average Error: 0.0 → 0.0
Time: 701.0ms
Precision: 64
\[x + \left(y - x\right) \cdot z\]
\[\mathsf{fma}\left(z, y - x, x\right)\]
x + \left(y - x\right) \cdot z
\mathsf{fma}\left(z, y - x, x\right)
double f(double x, double y, double z) {
        double r197996 = x;
        double r197997 = y;
        double r197998 = r197997 - r197996;
        double r197999 = z;
        double r198000 = r197998 * r197999;
        double r198001 = r197996 + r198000;
        return r198001;
}

double f(double x, double y, double z) {
        double r198002 = z;
        double r198003 = y;
        double r198004 = x;
        double r198005 = r198003 - r198004;
        double r198006 = fma(r198002, r198005, r198004);
        return r198006;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Derivation

  1. Initial program 0.0

    \[x + \left(y - x\right) \cdot z\]
  2. Simplified0.0

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

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

Reproduce

herbie shell --seed 2020018 +o rules:numerics
(FPCore (x y z)
  :name "Diagrams.ThreeD.Shapes:frustum from diagrams-lib-1.3.0.3, B"
  :precision binary64
  (+ x (* (- y x) z)))