Average Error: 0.0 → 0.0
Time: 6.4s
Precision: 64
\[\left(1 - x\right) \cdot y + x \cdot z\]
\[\mathsf{fma}\left(z, x, 1 \cdot y + y \cdot \left(-x\right)\right)\]
\left(1 - x\right) \cdot y + x \cdot z
\mathsf{fma}\left(z, x, 1 \cdot y + y \cdot \left(-x\right)\right)
double f(double x, double y, double z) {
        double r666923 = 1.0;
        double r666924 = x;
        double r666925 = r666923 - r666924;
        double r666926 = y;
        double r666927 = r666925 * r666926;
        double r666928 = z;
        double r666929 = r666924 * r666928;
        double r666930 = r666927 + r666929;
        return r666930;
}

double f(double x, double y, double z) {
        double r666931 = z;
        double r666932 = x;
        double r666933 = 1.0;
        double r666934 = y;
        double r666935 = r666933 * r666934;
        double r666936 = -r666932;
        double r666937 = r666934 * r666936;
        double r666938 = r666935 + r666937;
        double r666939 = fma(r666931, r666932, r666938);
        return r666939;
}

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(1 - x, y, x \cdot z\right)}\]
  3. Taylor expanded around 0 0.0

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

    \[\leadsto \color{blue}{\mathsf{fma}\left(z, x, \left(1 - x\right) \cdot y\right)}\]
  5. Using strategy rm
  6. Applied *-commutative0.0

    \[\leadsto \mathsf{fma}\left(z, x, \color{blue}{y \cdot \left(1 - x\right)}\right)\]
  7. Using strategy rm
  8. Applied sub-neg0.0

    \[\leadsto \mathsf{fma}\left(z, x, y \cdot \color{blue}{\left(1 + \left(-x\right)\right)}\right)\]
  9. Applied distribute-lft-in0.0

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

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

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

Reproduce

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

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

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