Average Error: 0.3 → 0.2
Time: 12.3s
Precision: 64
\[x + \left(\left(y - x\right) \cdot 6\right) \cdot z\]
\[\mathsf{fma}\left(\left(y - x\right) \cdot 6, z, x\right)\]
x + \left(\left(y - x\right) \cdot 6\right) \cdot z
\mathsf{fma}\left(\left(y - x\right) \cdot 6, z, x\right)
double f(double x, double y, double z) {
        double r541456 = x;
        double r541457 = y;
        double r541458 = r541457 - r541456;
        double r541459 = 6.0;
        double r541460 = r541458 * r541459;
        double r541461 = z;
        double r541462 = r541460 * r541461;
        double r541463 = r541456 + r541462;
        return r541463;
}

double f(double x, double y, double z) {
        double r541464 = y;
        double r541465 = x;
        double r541466 = r541464 - r541465;
        double r541467 = 6.0;
        double r541468 = r541466 * r541467;
        double r541469 = z;
        double r541470 = fma(r541468, r541469, r541465);
        return r541470;
}

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(y - x, 6 \cdot z, x\right)}\]
  3. Taylor expanded around 0 0.2

    \[\leadsto \color{blue}{\left(6 \cdot \left(z \cdot y\right) + x\right) - 6 \cdot \left(x \cdot z\right)}\]
  4. Simplified0.2

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

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

Reproduce

herbie shell --seed 2019209 +o rules:numerics
(FPCore (x y z)
  :name "Data.Colour.RGBSpace.HSL:hsl from colour-2.3.3, E"
  :precision binary64

  :herbie-target
  (- x (* (* 6 z) (- x y)))

  (+ x (* (* (- y x) 6) z)))