Average Error: 0.4 → 0.2
Time: 3.6s
Precision: 64
\[x + \left(\left(y - x\right) \cdot 6\right) \cdot \left(\frac{2}{3} - z\right)\]
\[\mathsf{fma}\left(y - x, 6 \cdot \frac{2}{3} + 6 \cdot \left(-z\right), x\right)\]
x + \left(\left(y - x\right) \cdot 6\right) \cdot \left(\frac{2}{3} - z\right)
\mathsf{fma}\left(y - x, 6 \cdot \frac{2}{3} + 6 \cdot \left(-z\right), x\right)
double f(double x, double y, double z) {
        double r227168 = x;
        double r227169 = y;
        double r227170 = r227169 - r227168;
        double r227171 = 6.0;
        double r227172 = r227170 * r227171;
        double r227173 = 2.0;
        double r227174 = 3.0;
        double r227175 = r227173 / r227174;
        double r227176 = z;
        double r227177 = r227175 - r227176;
        double r227178 = r227172 * r227177;
        double r227179 = r227168 + r227178;
        return r227179;
}

double f(double x, double y, double z) {
        double r227180 = y;
        double r227181 = x;
        double r227182 = r227180 - r227181;
        double r227183 = 6.0;
        double r227184 = 2.0;
        double r227185 = 3.0;
        double r227186 = r227184 / r227185;
        double r227187 = r227183 * r227186;
        double r227188 = z;
        double r227189 = -r227188;
        double r227190 = r227183 * r227189;
        double r227191 = r227187 + r227190;
        double r227192 = fma(r227182, r227191, r227181);
        return r227192;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Derivation

  1. Initial program 0.4

    \[x + \left(\left(y - x\right) \cdot 6\right) \cdot \left(\frac{2}{3} - z\right)\]
  2. Simplified0.2

    \[\leadsto \color{blue}{\mathsf{fma}\left(y - x, 6 \cdot \left(\frac{2}{3} - z\right), x\right)}\]
  3. Using strategy rm
  4. Applied sub-neg0.2

    \[\leadsto \mathsf{fma}\left(y - x, 6 \cdot \color{blue}{\left(\frac{2}{3} + \left(-z\right)\right)}, x\right)\]
  5. Applied distribute-lft-in0.2

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

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

Reproduce

herbie shell --seed 2020001 +o rules:numerics
(FPCore (x y z)
  :name "Data.Colour.RGBSpace.HSL:hsl from colour-2.3.3, D"
  :precision binary64
  (+ x (* (* (- y x) 6) (- (/ 2 3) z))))