Average Error: 0.4 → 0.1
Time: 4.3s
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(z \cdot \left(y - x\right)\right) \cdot 6\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(z \cdot \left(y - x\right)\right) \cdot 6\right)
double f(double x, double y, double z) {
        double r305691 = x;
        double r305692 = y;
        double r305693 = r305692 - r305691;
        double r305694 = 6.0;
        double r305695 = r305693 * r305694;
        double r305696 = 2.0;
        double r305697 = 3.0;
        double r305698 = r305696 / r305697;
        double r305699 = z;
        double r305700 = r305698 - r305699;
        double r305701 = r305695 * r305700;
        double r305702 = r305691 + r305701;
        return r305702;
}

double f(double x, double y, double z) {
        double r305703 = 4.0;
        double r305704 = y;
        double r305705 = r305703 * r305704;
        double r305706 = x;
        double r305707 = 3.0;
        double r305708 = z;
        double r305709 = r305704 - r305706;
        double r305710 = r305708 * r305709;
        double r305711 = 6.0;
        double r305712 = r305710 * r305711;
        double r305713 = fma(r305706, r305707, r305712);
        double r305714 = r305705 - r305713;
        return r305714;
}

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-rgt-in0.4

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

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

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

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

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

    \[\leadsto 4 \cdot y - \color{blue}{\mathsf{fma}\left(x, 3, z \cdot \left(\left(y - x\right) \cdot 6\right)\right)}\]
  11. Using strategy rm
  12. Applied associate-*r*0.1

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

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

Reproduce

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