Average Error: 0.3 → 0.2
Time: 12.7s
Precision: 64
\[x + \left(\left(y - x\right) \cdot 6\right) \cdot z\]
\[\mathsf{fma}\left(z \cdot 6, y, x - x \cdot \left(z \cdot 6\right)\right)\]
x + \left(\left(y - x\right) \cdot 6\right) \cdot z
\mathsf{fma}\left(z \cdot 6, y, x - x \cdot \left(z \cdot 6\right)\right)
double f(double x, double y, double z) {
        double r33401513 = x;
        double r33401514 = y;
        double r33401515 = r33401514 - r33401513;
        double r33401516 = 6.0;
        double r33401517 = r33401515 * r33401516;
        double r33401518 = z;
        double r33401519 = r33401517 * r33401518;
        double r33401520 = r33401513 + r33401519;
        return r33401520;
}

double f(double x, double y, double z) {
        double r33401521 = z;
        double r33401522 = 6.0;
        double r33401523 = r33401521 * r33401522;
        double r33401524 = y;
        double r33401525 = x;
        double r33401526 = r33401525 * r33401523;
        double r33401527 = r33401525 - r33401526;
        double r33401528 = fma(r33401523, r33401524, r33401527);
        return r33401528;
}

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.3

    \[\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. 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)}\]
  6. Simplified0.2

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

    \[\leadsto \mathsf{fma}\left(z \cdot 6, y, x - x \cdot \left(z \cdot 6\right)\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)))