Average Error: 0.0 → 0.0
Time: 3.8s
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 r1044 = x;
        double r1045 = y;
        double r1046 = r1045 - r1044;
        double r1047 = z;
        double r1048 = r1046 * r1047;
        double r1049 = r1044 + r1048;
        return r1049;
}

double f(double x, double y, double z) {
        double r1050 = z;
        double r1051 = y;
        double r1052 = x;
        double r1053 = r1051 - r1052;
        double r1054 = fma(r1050, r1053, r1052);
        return r1054;
}

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