Average Error: 0.3 → 0.2
Time: 14.3s
Precision: 64
\[x + \left(\left(y - x\right) \cdot 6\right) \cdot z\]
\[\mathsf{fma}\left(z \cdot 6, y - x, x\right)\]
x + \left(\left(y - x\right) \cdot 6\right) \cdot z
\mathsf{fma}\left(z \cdot 6, y - x, x\right)
double f(double x, double y, double z) {
        double r41350972 = x;
        double r41350973 = y;
        double r41350974 = r41350973 - r41350972;
        double r41350975 = 6.0;
        double r41350976 = r41350974 * r41350975;
        double r41350977 = z;
        double r41350978 = r41350976 * r41350977;
        double r41350979 = r41350972 + r41350978;
        return r41350979;
}

double f(double x, double y, double z) {
        double r41350980 = z;
        double r41350981 = 6.0;
        double r41350982 = r41350980 * r41350981;
        double r41350983 = y;
        double r41350984 = x;
        double r41350985 = r41350983 - r41350984;
        double r41350986 = fma(r41350982, r41350985, r41350984);
        return r41350986;
}

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 \cdot 6, y - x, x\right)}\]
  3. Final simplification0.2

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

Reproduce

herbie shell --seed 2019170 +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)))