Average Error: 0.4 → 0.2
Time: 4.8s
Precision: binary64
\[x + \left(\left(y - x\right) \cdot 6\right) \cdot \left(\frac{2}{3} - z\right) \]
\[\mathsf{fma}\left(4, y - x, x\right) - \left(\left(y - x\right) \cdot 6\right) \cdot z \]
x + \left(\left(y - x\right) \cdot 6\right) \cdot \left(\frac{2}{3} - z\right)
\mathsf{fma}\left(4, y - x, x\right) - \left(\left(y - x\right) \cdot 6\right) \cdot z
(FPCore (x y z)
 :precision binary64
 (+ x (* (* (- y x) 6.0) (- (/ 2.0 3.0) z))))
(FPCore (x y z)
 :precision binary64
 (- (fma 4.0 (- y x) x) (* (* (- y x) 6.0) z)))
double code(double x, double y, double z) {
	return x + (((y - x) * 6.0) * ((2.0 / 3.0) - z));
}
double code(double x, double y, double z) {
	return fma(4.0, (y - x), x) - (((y - x) * 6.0) * z);
}

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

    \[\leadsto x + \left(\left(y - x\right) \cdot 6\right) \cdot \left(\frac{2}{3} - \color{blue}{1 \cdot z}\right) \]
  3. Applied cancel-sign-sub-inv_binary640.4

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

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

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

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

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

Reproduce

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