Average Error: 0.3 → 0.2
Time: 12.4s
Precision: 64
\[x + \left(\left(y - x\right) \cdot 6\right) \cdot z\]
\[\mathsf{fma}\left(6, z \cdot \left(y - x\right), x\right)\]
x + \left(\left(y - x\right) \cdot 6\right) \cdot z
\mathsf{fma}\left(6, z \cdot \left(y - x\right), x\right)
double f(double x, double y, double z) {
        double r775722 = x;
        double r775723 = y;
        double r775724 = r775723 - r775722;
        double r775725 = 6.0;
        double r775726 = r775724 * r775725;
        double r775727 = z;
        double r775728 = r775726 * r775727;
        double r775729 = r775722 + r775728;
        return r775729;
}

double f(double x, double y, double z) {
        double r775730 = 6.0;
        double r775731 = z;
        double r775732 = y;
        double r775733 = x;
        double r775734 = r775732 - r775733;
        double r775735 = r775731 * r775734;
        double r775736 = fma(r775730, r775735, r775733);
        return r775736;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Target

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

Derivation

  1. Initial program 0.3

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

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

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

    \[\leadsto \color{blue}{\mathsf{fma}\left(6, z \cdot \left(y - x\right), x\right)}\]
  5. Final simplification0.2

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

Reproduce

herbie shell --seed 2019196 +o rules:numerics
(FPCore (x y z)
  :name "Data.Colour.RGBSpace.HSL:hsl from colour-2.3.3, E"

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

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