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 r219149 = x;
        double r219150 = y;
        double r219151 = r219150 - r219149;
        double r219152 = 6.0;
        double r219153 = r219151 * r219152;
        double r219154 = 2.0;
        double r219155 = 3.0;
        double r219156 = r219154 / r219155;
        double r219157 = z;
        double r219158 = r219156 - r219157;
        double r219159 = r219153 * r219158;
        double r219160 = r219149 + r219159;
        return r219160;
}

double f(double x, double y, double z) {
        double r219161 = y;
        double r219162 = x;
        double r219163 = r219161 - r219162;
        double r219164 = 6.0;
        double r219165 = 2.0;
        double r219166 = 3.0;
        double r219167 = r219165 / r219166;
        double r219168 = r219164 * r219167;
        double r219169 = z;
        double r219170 = -r219169;
        double r219171 = r219164 * r219170;
        double r219172 = r219168 + r219171;
        double r219173 = fma(r219163, r219172, r219162);
        return r219173;
}

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 2020059 +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))))