Average Error: 0.3 → 0.2
Time: 14.9s
Precision: 64
\[x + \left(\left(y - x\right) \cdot 6.0\right) \cdot z\]
\[\mathsf{fma}\left(z \cdot 6.0, y - x, x\right)\]
x + \left(\left(y - x\right) \cdot 6.0\right) \cdot z
\mathsf{fma}\left(z \cdot 6.0, y - x, x\right)
double f(double x, double y, double z) {
        double r35559684 = x;
        double r35559685 = y;
        double r35559686 = r35559685 - r35559684;
        double r35559687 = 6.0;
        double r35559688 = r35559686 * r35559687;
        double r35559689 = z;
        double r35559690 = r35559688 * r35559689;
        double r35559691 = r35559684 + r35559690;
        return r35559691;
}

double f(double x, double y, double z) {
        double r35559692 = z;
        double r35559693 = 6.0;
        double r35559694 = r35559692 * r35559693;
        double r35559695 = y;
        double r35559696 = x;
        double r35559697 = r35559695 - r35559696;
        double r35559698 = fma(r35559694, r35559697, r35559696);
        return r35559698;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Target

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

Derivation

  1. Initial program 0.3

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

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

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

Reproduce

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