Average Error: 0.2 → 0.2
Time: 12.3s
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 r37056453 = x;
        double r37056454 = y;
        double r37056455 = r37056454 - r37056453;
        double r37056456 = 6.0;
        double r37056457 = r37056455 * r37056456;
        double r37056458 = z;
        double r37056459 = r37056457 * r37056458;
        double r37056460 = r37056453 + r37056459;
        return r37056460;
}

double f(double x, double y, double z) {
        double r37056461 = z;
        double r37056462 = 6.0;
        double r37056463 = r37056461 * r37056462;
        double r37056464 = y;
        double r37056465 = x;
        double r37056466 = r37056465 * r37056463;
        double r37056467 = r37056465 - r37056466;
        double r37056468 = fma(r37056463, r37056464, r37056467);
        return r37056468;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Target

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

Derivation

  1. Initial program 0.2

    \[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. 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 2019179 +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)))