Average Error: 0.4 → 0.2
Time: 4.9s
Precision: 64
\[x + \left(\left(y - x\right) \cdot 6\right) \cdot \left(\frac{2}{3} - z\right)\]
\[x + \left(\left(y - x\right) \cdot \left(4 - 6 \cdot z\right) + \left(y - x\right) \cdot \mathsf{fma}\left(-z, 6, z \cdot 6\right)\right)\]
x + \left(\left(y - x\right) \cdot 6\right) \cdot \left(\frac{2}{3} - z\right)
x + \left(\left(y - x\right) \cdot \left(4 - 6 \cdot z\right) + \left(y - x\right) \cdot \mathsf{fma}\left(-z, 6, z \cdot 6\right)\right)
double f(double x, double y, double z) {
        double r252806 = x;
        double r252807 = y;
        double r252808 = r252807 - r252806;
        double r252809 = 6.0;
        double r252810 = r252808 * r252809;
        double r252811 = 2.0;
        double r252812 = 3.0;
        double r252813 = r252811 / r252812;
        double r252814 = z;
        double r252815 = r252813 - r252814;
        double r252816 = r252810 * r252815;
        double r252817 = r252806 + r252816;
        return r252817;
}

double f(double x, double y, double z) {
        double r252818 = x;
        double r252819 = y;
        double r252820 = r252819 - r252818;
        double r252821 = 4.0;
        double r252822 = 6.0;
        double r252823 = z;
        double r252824 = r252822 * r252823;
        double r252825 = r252821 - r252824;
        double r252826 = r252820 * r252825;
        double r252827 = -r252823;
        double r252828 = r252823 * r252822;
        double r252829 = fma(r252827, r252822, r252828);
        double r252830 = r252820 * r252829;
        double r252831 = r252826 + r252830;
        double r252832 = r252818 + r252831;
        return r252832;
}

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 associate-*l*0.2

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

    \[\leadsto x + \left(y - x\right) \cdot \color{blue}{\left(4 - 6 \cdot z\right)}\]
  5. Using strategy rm
  6. Applied add-sqr-sqrt0.2

    \[\leadsto x + \left(y - x\right) \cdot \left(\color{blue}{\sqrt{4} \cdot \sqrt{4}} - 6 \cdot z\right)\]
  7. Applied prod-diff0.2

    \[\leadsto x + \left(y - x\right) \cdot \color{blue}{\left(\mathsf{fma}\left(\sqrt{4}, \sqrt{4}, -z \cdot 6\right) + \mathsf{fma}\left(-z, 6, z \cdot 6\right)\right)}\]
  8. Applied distribute-lft-in0.2

    \[\leadsto x + \color{blue}{\left(\left(y - x\right) \cdot \mathsf{fma}\left(\sqrt{4}, \sqrt{4}, -z \cdot 6\right) + \left(y - x\right) \cdot \mathsf{fma}\left(-z, 6, z \cdot 6\right)\right)}\]
  9. Simplified0.2

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

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

Reproduce

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