Average Error: 0.4 → 0.2
Time: 3.5s
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 r249627 = x;
        double r249628 = y;
        double r249629 = r249628 - r249627;
        double r249630 = 6.0;
        double r249631 = r249629 * r249630;
        double r249632 = 2.0;
        double r249633 = 3.0;
        double r249634 = r249632 / r249633;
        double r249635 = z;
        double r249636 = r249634 - r249635;
        double r249637 = r249631 * r249636;
        double r249638 = r249627 + r249637;
        return r249638;
}

double f(double x, double y, double z) {
        double r249639 = y;
        double r249640 = x;
        double r249641 = r249639 - r249640;
        double r249642 = 6.0;
        double r249643 = 2.0;
        double r249644 = 3.0;
        double r249645 = r249643 / r249644;
        double r249646 = r249642 * r249645;
        double r249647 = z;
        double r249648 = -r249647;
        double r249649 = r249642 * r249648;
        double r249650 = r249646 + r249649;
        double r249651 = fma(r249641, r249650, r249640);
        return r249651;
}

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