Average Error: 0.4 → 0.1
Time: 4.2s
Precision: 64
\[x + \left(\left(y - x\right) \cdot 6\right) \cdot \left(\frac{2}{3} - z\right)\]
\[4 \cdot y - \mathsf{fma}\left(x, 3, \left(\left(y - x\right) \cdot 6\right) \cdot z\right)\]
x + \left(\left(y - x\right) \cdot 6\right) \cdot \left(\frac{2}{3} - z\right)
4 \cdot y - \mathsf{fma}\left(x, 3, \left(\left(y - x\right) \cdot 6\right) \cdot z\right)
double f(double x, double y, double z) {
        double r221493 = x;
        double r221494 = y;
        double r221495 = r221494 - r221493;
        double r221496 = 6.0;
        double r221497 = r221495 * r221496;
        double r221498 = 2.0;
        double r221499 = 3.0;
        double r221500 = r221498 / r221499;
        double r221501 = z;
        double r221502 = r221500 - r221501;
        double r221503 = r221497 * r221502;
        double r221504 = r221493 + r221503;
        return r221504;
}

double f(double x, double y, double z) {
        double r221505 = 4.0;
        double r221506 = y;
        double r221507 = r221505 * r221506;
        double r221508 = x;
        double r221509 = 3.0;
        double r221510 = r221506 - r221508;
        double r221511 = 6.0;
        double r221512 = r221510 * r221511;
        double r221513 = z;
        double r221514 = r221512 * r221513;
        double r221515 = fma(r221508, r221509, r221514);
        double r221516 = r221507 - r221515;
        return r221516;
}

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. Using strategy rm
  3. Applied sub-neg0.4

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

    \[\leadsto x + \color{blue}{\left(\left(\left(y - x\right) \cdot 6\right) \cdot \frac{2}{3} + \left(\left(y - x\right) \cdot 6\right) \cdot \left(-z\right)\right)}\]
  5. Applied associate-+r+0.4

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

    \[\leadsto \color{blue}{\mathsf{fma}\left(\frac{2}{3} \cdot \left(y - x\right), 6, x\right)} + \left(\left(y - x\right) \cdot 6\right) \cdot \left(-z\right)\]
  7. Taylor expanded around 0 0.2

    \[\leadsto \color{blue}{\left(4 \cdot y - 3 \cdot x\right)} + \left(\left(y - x\right) \cdot 6\right) \cdot \left(-z\right)\]
  8. Using strategy rm
  9. Applied associate-+l-0.2

    \[\leadsto \color{blue}{4 \cdot y - \left(3 \cdot x - \left(\left(y - x\right) \cdot 6\right) \cdot \left(-z\right)\right)}\]
  10. Simplified0.1

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

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

Reproduce

herbie shell --seed 2020033 +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))))