Average Error: 0.4 → 0.2
Time: 3.8s
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 r179094 = x;
        double r179095 = y;
        double r179096 = r179095 - r179094;
        double r179097 = 6.0;
        double r179098 = r179096 * r179097;
        double r179099 = 2.0;
        double r179100 = 3.0;
        double r179101 = r179099 / r179100;
        double r179102 = z;
        double r179103 = r179101 - r179102;
        double r179104 = r179098 * r179103;
        double r179105 = r179094 + r179104;
        return r179105;
}

double f(double x, double y, double z) {
        double r179106 = y;
        double r179107 = x;
        double r179108 = r179106 - r179107;
        double r179109 = 6.0;
        double r179110 = 2.0;
        double r179111 = 3.0;
        double r179112 = r179110 / r179111;
        double r179113 = r179109 * r179112;
        double r179114 = z;
        double r179115 = -r179114;
        double r179116 = r179109 * r179115;
        double r179117 = r179113 + r179116;
        double r179118 = fma(r179108, r179117, r179107);
        return r179118;
}

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