Average Error: 0.0 → 0.0
Time: 10.8s
Precision: 64
\[\left(1 - x\right) \cdot y + x \cdot z\]
\[\mathsf{fma}\left(y, 1 - x, z \cdot x\right)\]
\left(1 - x\right) \cdot y + x \cdot z
\mathsf{fma}\left(y, 1 - x, z \cdot x\right)
double f(double x, double y, double z) {
        double r577913 = 1.0;
        double r577914 = x;
        double r577915 = r577913 - r577914;
        double r577916 = y;
        double r577917 = r577915 * r577916;
        double r577918 = z;
        double r577919 = r577914 * r577918;
        double r577920 = r577917 + r577919;
        return r577920;
}

double f(double x, double y, double z) {
        double r577921 = y;
        double r577922 = 1.0;
        double r577923 = x;
        double r577924 = r577922 - r577923;
        double r577925 = z;
        double r577926 = r577925 * r577923;
        double r577927 = fma(r577921, r577924, r577926);
        return r577927;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Target

Original0.0
Target0.0
Herbie0.0
\[y - x \cdot \left(y - z\right)\]

Derivation

  1. Initial program 0.0

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

    \[\leadsto \color{blue}{\mathsf{fma}\left(x, z - y, y \cdot 1\right)}\]
  3. Using strategy rm
  4. Applied add-cbrt-cube40.2

    \[\leadsto \color{blue}{\sqrt[3]{\left(\mathsf{fma}\left(x, z - y, y \cdot 1\right) \cdot \mathsf{fma}\left(x, z - y, y \cdot 1\right)\right) \cdot \mathsf{fma}\left(x, z - y, y \cdot 1\right)}}\]
  5. Simplified40.2

    \[\leadsto \sqrt[3]{\color{blue}{{\left(\mathsf{fma}\left(x, z - y, 1 \cdot y\right)\right)}^{3}}}\]
  6. Taylor expanded around 0 0.0

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

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

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

Reproduce

herbie shell --seed 2019194 +o rules:numerics
(FPCore (x y z)
  :name "Diagrams.Color.HSV:lerp  from diagrams-contrib-1.3.0.5"

  :herbie-target
  (- y (* x (- y z)))

  (+ (* (- 1.0 x) y) (* x z)))