Average Error: 0.4 → 0.2
Time: 5.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 r261462 = x;
        double r261463 = y;
        double r261464 = r261463 - r261462;
        double r261465 = 6.0;
        double r261466 = r261464 * r261465;
        double r261467 = 2.0;
        double r261468 = 3.0;
        double r261469 = r261467 / r261468;
        double r261470 = z;
        double r261471 = r261469 - r261470;
        double r261472 = r261466 * r261471;
        double r261473 = r261462 + r261472;
        return r261473;
}

double f(double x, double y, double z) {
        double r261474 = y;
        double r261475 = x;
        double r261476 = r261474 - r261475;
        double r261477 = 6.0;
        double r261478 = 2.0;
        double r261479 = 3.0;
        double r261480 = r261478 / r261479;
        double r261481 = r261477 * r261480;
        double r261482 = z;
        double r261483 = -r261482;
        double r261484 = r261477 * r261483;
        double r261485 = r261481 + r261484;
        double r261486 = fma(r261476, r261485, r261475);
        return r261486;
}

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