Average Error: 0.4 → 0.2
Time: 3.2s
Precision: 64
\[x + \left(\left(y - x\right) \cdot 6\right) \cdot \left(\frac{2}{3} - z\right)\]
\[\mathsf{fma}\left(y - x, 6 \cdot \frac{2}{3} + 6 \cdot \left(-z\right), x\right)\]
x + \left(\left(y - x\right) \cdot 6\right) \cdot \left(\frac{2}{3} - z\right)
\mathsf{fma}\left(y - x, 6 \cdot \frac{2}{3} + 6 \cdot \left(-z\right), x\right)
double f(double x, double y, double z) {
        double r263022 = x;
        double r263023 = y;
        double r263024 = r263023 - r263022;
        double r263025 = 6.0;
        double r263026 = r263024 * r263025;
        double r263027 = 2.0;
        double r263028 = 3.0;
        double r263029 = r263027 / r263028;
        double r263030 = z;
        double r263031 = r263029 - r263030;
        double r263032 = r263026 * r263031;
        double r263033 = r263022 + r263032;
        return r263033;
}

double f(double x, double y, double z) {
        double r263034 = y;
        double r263035 = x;
        double r263036 = r263034 - r263035;
        double r263037 = 6.0;
        double r263038 = 2.0;
        double r263039 = 3.0;
        double r263040 = r263038 / r263039;
        double r263041 = r263037 * r263040;
        double r263042 = z;
        double r263043 = -r263042;
        double r263044 = r263037 * r263043;
        double r263045 = r263041 + r263044;
        double r263046 = fma(r263036, r263045, r263035);
        return r263046;
}

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. Simplified0.2

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

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

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

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

Reproduce

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