Average Error: 0.4 → 0.3
Time: 26.7s
Precision: 64
\[x + \left(\left(y - x\right) \cdot 6.0\right) \cdot \left(\frac{2.0}{3.0} - z\right)\]
\[\mathsf{fma}\left(-z, 1, z\right) \cdot \left(\left(y - x\right) \cdot 6.0\right) + \mathsf{fma}\left(y - x, \left(\frac{\frac{2.0}{\sqrt{3.0}}}{\sqrt{3.0}} - z\right) \cdot 6.0, x\right)\]
x + \left(\left(y - x\right) \cdot 6.0\right) \cdot \left(\frac{2.0}{3.0} - z\right)
\mathsf{fma}\left(-z, 1, z\right) \cdot \left(\left(y - x\right) \cdot 6.0\right) + \mathsf{fma}\left(y - x, \left(\frac{\frac{2.0}{\sqrt{3.0}}}{\sqrt{3.0}} - z\right) \cdot 6.0, x\right)
double f(double x, double y, double z) {
        double r11400153 = x;
        double r11400154 = y;
        double r11400155 = r11400154 - r11400153;
        double r11400156 = 6.0;
        double r11400157 = r11400155 * r11400156;
        double r11400158 = 2.0;
        double r11400159 = 3.0;
        double r11400160 = r11400158 / r11400159;
        double r11400161 = z;
        double r11400162 = r11400160 - r11400161;
        double r11400163 = r11400157 * r11400162;
        double r11400164 = r11400153 + r11400163;
        return r11400164;
}

double f(double x, double y, double z) {
        double r11400165 = z;
        double r11400166 = -r11400165;
        double r11400167 = 1.0;
        double r11400168 = fma(r11400166, r11400167, r11400165);
        double r11400169 = y;
        double r11400170 = x;
        double r11400171 = r11400169 - r11400170;
        double r11400172 = 6.0;
        double r11400173 = r11400171 * r11400172;
        double r11400174 = r11400168 * r11400173;
        double r11400175 = 2.0;
        double r11400176 = 3.0;
        double r11400177 = sqrt(r11400176);
        double r11400178 = r11400175 / r11400177;
        double r11400179 = r11400178 / r11400177;
        double r11400180 = r11400179 - r11400165;
        double r11400181 = r11400180 * r11400172;
        double r11400182 = fma(r11400171, r11400181, r11400170);
        double r11400183 = r11400174 + r11400182;
        return r11400183;
}

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.0\right) \cdot \left(\frac{2.0}{3.0} - z\right)\]
  2. Using strategy rm
  3. Applied *-un-lft-identity0.4

    \[\leadsto x + \left(\left(y - x\right) \cdot 6.0\right) \cdot \left(\frac{2.0}{3.0} - \color{blue}{1 \cdot z}\right)\]
  4. Applied add-sqr-sqrt0.7

    \[\leadsto x + \left(\left(y - x\right) \cdot 6.0\right) \cdot \left(\frac{2.0}{\color{blue}{\sqrt{3.0} \cdot \sqrt{3.0}}} - 1 \cdot z\right)\]
  5. Applied *-un-lft-identity0.7

    \[\leadsto x + \left(\left(y - x\right) \cdot 6.0\right) \cdot \left(\frac{\color{blue}{1 \cdot 2.0}}{\sqrt{3.0} \cdot \sqrt{3.0}} - 1 \cdot z\right)\]
  6. Applied times-frac1.1

    \[\leadsto x + \left(\left(y - x\right) \cdot 6.0\right) \cdot \left(\color{blue}{\frac{1}{\sqrt{3.0}} \cdot \frac{2.0}{\sqrt{3.0}}} - 1 \cdot z\right)\]
  7. Applied prod-diff1.1

    \[\leadsto x + \left(\left(y - x\right) \cdot 6.0\right) \cdot \color{blue}{\left(\mathsf{fma}\left(\frac{1}{\sqrt{3.0}}, \frac{2.0}{\sqrt{3.0}}, -z \cdot 1\right) + \mathsf{fma}\left(-z, 1, z \cdot 1\right)\right)}\]
  8. Applied distribute-rgt-in1.1

    \[\leadsto x + \color{blue}{\left(\mathsf{fma}\left(\frac{1}{\sqrt{3.0}}, \frac{2.0}{\sqrt{3.0}}, -z \cdot 1\right) \cdot \left(\left(y - x\right) \cdot 6.0\right) + \mathsf{fma}\left(-z, 1, z \cdot 1\right) \cdot \left(\left(y - x\right) \cdot 6.0\right)\right)}\]
  9. Applied associate-+r+1.1

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

    \[\leadsto \color{blue}{\mathsf{fma}\left(y - x, 6.0 \cdot \left(\frac{\frac{2.0}{\sqrt{3.0}}}{\sqrt{3.0}} - z\right), x\right)} + \mathsf{fma}\left(-z, 1, z \cdot 1\right) \cdot \left(\left(y - x\right) \cdot 6.0\right)\]
  11. Final simplification0.3

    \[\leadsto \mathsf{fma}\left(-z, 1, z\right) \cdot \left(\left(y - x\right) \cdot 6.0\right) + \mathsf{fma}\left(y - x, \left(\frac{\frac{2.0}{\sqrt{3.0}}}{\sqrt{3.0}} - z\right) \cdot 6.0, x\right)\]

Reproduce

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