Average Error: 0.3 → 0.2
Time: 16.4s
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 r39587581 = x;
        double r39587582 = y;
        double r39587583 = r39587582 - r39587581;
        double r39587584 = 6.0;
        double r39587585 = r39587583 * r39587584;
        double r39587586 = z;
        double r39587587 = r39587585 * r39587586;
        double r39587588 = r39587581 + r39587587;
        return r39587588;
}

double f(double x, double y, double z) {
        double r39587589 = z;
        double r39587590 = 6.0;
        double r39587591 = r39587589 * r39587590;
        double r39587592 = y;
        double r39587593 = x;
        double r39587594 = r39587592 - r39587593;
        double r39587595 = fma(r39587591, r39587594, r39587593);
        return r39587595;
}

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