Average Error: 0.4 → 0.4
Time: 1.3m
Precision: 64
\[x + \left(\left(y - x\right) \cdot 6\right) \cdot \left(\frac{2}{3} - z\right)\]
\[\mathsf{fma}\left(-z, 1, z\right) \cdot \left(6 \cdot \left(y - x\right)\right) + \mathsf{fma}\left(\left(\frac{2}{3} - z\right) \cdot \left(y - x\right), 6, x\right)\]
x + \left(\left(y - x\right) \cdot 6\right) \cdot \left(\frac{2}{3} - z\right)
\mathsf{fma}\left(-z, 1, z\right) \cdot \left(6 \cdot \left(y - x\right)\right) + \mathsf{fma}\left(\left(\frac{2}{3} - z\right) \cdot \left(y - x\right), 6, x\right)
double f(double x, double y, double z) {
        double r6868096 = x;
        double r6868097 = y;
        double r6868098 = r6868097 - r6868096;
        double r6868099 = 6.0;
        double r6868100 = r6868098 * r6868099;
        double r6868101 = 2.0;
        double r6868102 = 3.0;
        double r6868103 = r6868101 / r6868102;
        double r6868104 = z;
        double r6868105 = r6868103 - r6868104;
        double r6868106 = r6868100 * r6868105;
        double r6868107 = r6868096 + r6868106;
        return r6868107;
}

double f(double x, double y, double z) {
        double r6868108 = z;
        double r6868109 = -r6868108;
        double r6868110 = 1.0;
        double r6868111 = fma(r6868109, r6868110, r6868108);
        double r6868112 = 6.0;
        double r6868113 = y;
        double r6868114 = x;
        double r6868115 = r6868113 - r6868114;
        double r6868116 = r6868112 * r6868115;
        double r6868117 = r6868111 * r6868116;
        double r6868118 = 2.0;
        double r6868119 = 3.0;
        double r6868120 = r6868118 / r6868119;
        double r6868121 = r6868120 - r6868108;
        double r6868122 = r6868121 * r6868115;
        double r6868123 = fma(r6868122, r6868112, r6868114);
        double r6868124 = r6868117 + r6868123;
        return r6868124;
}

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 *-un-lft-identity0.4

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

    \[\leadsto x + \left(\left(y - x\right) \cdot 6\right) \cdot \left(\frac{2}{\color{blue}{\left(\sqrt[3]{3} \cdot \sqrt[3]{3}\right) \cdot \sqrt[3]{3}}} - 1 \cdot z\right)\]
  5. Applied *-un-lft-identity0.4

    \[\leadsto x + \left(\left(y - x\right) \cdot 6\right) \cdot \left(\frac{\color{blue}{1 \cdot 2}}{\left(\sqrt[3]{3} \cdot \sqrt[3]{3}\right) \cdot \sqrt[3]{3}} - 1 \cdot z\right)\]
  6. Applied times-frac0.7

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

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

    \[\leadsto x + \color{blue}{\left(\left(\left(y - x\right) \cdot 6\right) \cdot \mathsf{fma}\left(\frac{1}{\sqrt[3]{3} \cdot \sqrt[3]{3}}, \frac{2}{\sqrt[3]{3}}, -z \cdot 1\right) + \left(\left(y - x\right) \cdot 6\right) \cdot \mathsf{fma}\left(-z, 1, z \cdot 1\right)\right)}\]
  9. Applied associate-+r+0.7

    \[\leadsto \color{blue}{\left(x + \left(\left(y - x\right) \cdot 6\right) \cdot \mathsf{fma}\left(\frac{1}{\sqrt[3]{3} \cdot \sqrt[3]{3}}, \frac{2}{\sqrt[3]{3}}, -z \cdot 1\right)\right) + \left(\left(y - x\right) \cdot 6\right) \cdot \mathsf{fma}\left(-z, 1, z \cdot 1\right)}\]
  10. Simplified0.7

    \[\leadsto \color{blue}{\mathsf{fma}\left(\frac{\frac{2}{\sqrt[3]{3}}}{\sqrt[3]{3} \cdot \sqrt[3]{3}} - z, \left(y - x\right) \cdot 6, x\right)} + \left(\left(y - x\right) \cdot 6\right) \cdot \mathsf{fma}\left(-z, 1, z \cdot 1\right)\]
  11. Using strategy rm
  12. Applied fma-udef0.7

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

    \[\leadsto \left(\color{blue}{\left(\left(y - x\right) \cdot \left(\frac{2}{3} - z\right)\right) \cdot 6} + x\right) + \left(\left(y - x\right) \cdot 6\right) \cdot \mathsf{fma}\left(-z, 1, z \cdot 1\right)\]
  14. Using strategy rm
  15. Applied fma-def0.4

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

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

Reproduce

herbie shell --seed 2019200 +o rules:numerics
(FPCore (x y z)
  :name "Data.Colour.RGBSpace.HSL:hsl from colour-2.3.3, D"
  (+ x (* (* (- y x) 6.0) (- (/ 2.0 3.0) z))))