?

Average Accuracy: 99.4% → 99.7%
Time: 15.0s
Precision: binary64
Cost: 13248

?

\[x + \left(\left(y - x\right) \cdot 6\right) \cdot \left(\frac{2}{3} - z\right) \]
\[\mathsf{fma}\left(y - x, \mathsf{fma}\left(z, -6, 4\right), x\right) \]
(FPCore (x y z)
 :precision binary64
 (+ x (* (* (- y x) 6.0) (- (/ 2.0 3.0) z))))
(FPCore (x y z) :precision binary64 (fma (- y x) (fma z -6.0 4.0) x))
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((y - x), fma(z, -6.0, 4.0), x);
}
function code(x, y, z)
	return Float64(x + Float64(Float64(Float64(y - x) * 6.0) * Float64(Float64(2.0 / 3.0) - z)))
end
function code(x, y, z)
	return fma(Float64(y - x), fma(z, -6.0, 4.0), x)
end
code[x_, y_, z_] := N[(x + N[(N[(N[(y - x), $MachinePrecision] * 6.0), $MachinePrecision] * N[(N[(2.0 / 3.0), $MachinePrecision] - z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
code[x_, y_, z_] := N[(N[(y - x), $MachinePrecision] * N[(z * -6.0 + 4.0), $MachinePrecision] + x), $MachinePrecision]
x + \left(\left(y - x\right) \cdot 6\right) \cdot \left(\frac{2}{3} - z\right)
\mathsf{fma}\left(y - x, \mathsf{fma}\left(z, -6, 4\right), x\right)

Error?

Derivation?

  1. Initial program 99.4%

    \[x + \left(\left(y - x\right) \cdot 6\right) \cdot \left(\frac{2}{3} - z\right) \]
  2. Simplified99.7%

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

    [Start]99.4

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

    +-commutative [=>]99.4

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

    associate-*l* [=>]99.7

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

    fma-def [=>]99.7

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

    sub-neg [=>]99.7

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

    distribute-lft-in [=>]99.7

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

    +-commutative [=>]99.7

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

    neg-mul-1 [=>]99.7

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

    associate-*r* [=>]99.7

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

    *-commutative [=>]99.7

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

    fma-def [=>]99.7

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

    metadata-eval [=>]99.7

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

    metadata-eval [=>]99.7

    \[ \mathsf{fma}\left(y - x, \mathsf{fma}\left(z, -6, 6 \cdot \color{blue}{0.6666666666666666}\right), x\right) \]

    metadata-eval [=>]99.7

    \[ \mathsf{fma}\left(y - x, \mathsf{fma}\left(z, -6, \color{blue}{4}\right), x\right) \]
  3. Final simplification99.7%

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

Alternatives

Alternative 1
Accuracy99.6%
Cost7360
\[\mathsf{fma}\left(-3, x, 6 \cdot \left(x \cdot z\right)\right) + 6 \cdot \left(y \cdot \left(0.6666666666666666 - z\right)\right) \]
Alternative 2
Accuracy49.2%
Cost1904
\[\begin{array}{l} t_0 := -6 \cdot \left(y \cdot z\right)\\ t_1 := 6 \cdot \left(x \cdot z\right)\\ \mathbf{if}\;z \leq -8.5 \cdot 10^{+125}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;z \leq -6.2 \cdot 10^{+49}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq -8.5 \cdot 10^{-8}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;z \leq -9 \cdot 10^{-177}:\\ \;\;\;\;x \cdot -3\\ \mathbf{elif}\;z \leq -2.4 \cdot 10^{-284}:\\ \;\;\;\;y \cdot 4\\ \mathbf{elif}\;z \leq -9.5 \cdot 10^{-309}:\\ \;\;\;\;x \cdot -3\\ \mathbf{elif}\;z \leq 3.25 \cdot 10^{-246}:\\ \;\;\;\;y \cdot 4\\ \mathbf{elif}\;z \leq 1.75 \cdot 10^{-221}:\\ \;\;\;\;x \cdot -3\\ \mathbf{elif}\;z \leq 3.3 \cdot 10^{-137}:\\ \;\;\;\;y \cdot 4\\ \mathbf{elif}\;z \leq 7.8 \cdot 10^{-122}:\\ \;\;\;\;x \cdot -3\\ \mathbf{elif}\;z \leq 2.55 \cdot 10^{-82}:\\ \;\;\;\;y \cdot 4\\ \mathbf{elif}\;z \leq 5 \cdot 10^{-5}:\\ \;\;\;\;x \cdot -3\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 3
Accuracy49.1%
Cost1904
\[\begin{array}{l} t_0 := -6 \cdot \left(y \cdot z\right)\\ t_1 := x \cdot \left(z \cdot 6\right)\\ \mathbf{if}\;z \leq -3.6 \cdot 10^{+123}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;z \leq -1.4 \cdot 10^{+53}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \leq -8.5 \cdot 10^{-8}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;z \leq -3.2 \cdot 10^{-176}:\\ \;\;\;\;x \cdot -3\\ \mathbf{elif}\;z \leq -2.45 \cdot 10^{-284}:\\ \;\;\;\;y \cdot 4\\ \mathbf{elif}\;z \leq -7 \cdot 10^{-305}:\\ \;\;\;\;x \cdot -3\\ \mathbf{elif}\;z \leq 4.1 \cdot 10^{-246}:\\ \;\;\;\;y \cdot 4\\ \mathbf{elif}\;z \leq 1.7 \cdot 10^{-221}:\\ \;\;\;\;x \cdot -3\\ \mathbf{elif}\;z \leq 3.3 \cdot 10^{-137}:\\ \;\;\;\;y \cdot 4\\ \mathbf{elif}\;z \leq 6.2 \cdot 10^{-121}:\\ \;\;\;\;x \cdot -3\\ \mathbf{elif}\;z \leq 2.55 \cdot 10^{-81}:\\ \;\;\;\;y \cdot 4\\ \mathbf{elif}\;z \leq 5 \cdot 10^{-5}:\\ \;\;\;\;x \cdot -3\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 4
Accuracy66.9%
Cost1900
\[\begin{array}{l} t_0 := -6 \cdot \left(\left(y - x\right) \cdot z\right)\\ \mathbf{if}\;z \leq -255000:\\ \;\;\;\;t_0\\ \mathbf{elif}\;z \leq -5.1 \cdot 10^{-51}:\\ \;\;\;\;6 \cdot \left(y \cdot \left(0.6666666666666666 - z\right)\right)\\ \mathbf{elif}\;z \leq -4 \cdot 10^{-177}:\\ \;\;\;\;x \cdot -3\\ \mathbf{elif}\;z \leq -2.45 \cdot 10^{-284}:\\ \;\;\;\;y \cdot 4\\ \mathbf{elif}\;z \leq 9.8 \cdot 10^{-306}:\\ \;\;\;\;x \cdot -3\\ \mathbf{elif}\;z \leq 4.4 \cdot 10^{-246}:\\ \;\;\;\;y \cdot 4\\ \mathbf{elif}\;z \leq 1.7 \cdot 10^{-221}:\\ \;\;\;\;x \cdot -3\\ \mathbf{elif}\;z \leq 3.6 \cdot 10^{-137}:\\ \;\;\;\;y \cdot 4\\ \mathbf{elif}\;z \leq 9.6 \cdot 10^{-121}:\\ \;\;\;\;x \cdot -3\\ \mathbf{elif}\;z \leq 3.1 \cdot 10^{-81}:\\ \;\;\;\;y \cdot 4\\ \mathbf{elif}\;z \leq 0.5:\\ \;\;\;\;x \cdot -3\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 5
Accuracy66.3%
Cost1768
\[\begin{array}{l} t_0 := -6 \cdot \left(\left(y - x\right) \cdot z\right)\\ \mathbf{if}\;z \leq -8.5 \cdot 10^{-8}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;z \leq -2.3 \cdot 10^{-176}:\\ \;\;\;\;x \cdot -3\\ \mathbf{elif}\;z \leq -2.45 \cdot 10^{-284}:\\ \;\;\;\;y \cdot 4\\ \mathbf{elif}\;z \leq 5.7 \cdot 10^{-307}:\\ \;\;\;\;x \cdot -3\\ \mathbf{elif}\;z \leq 1.85 \cdot 10^{-246}:\\ \;\;\;\;y \cdot 4\\ \mathbf{elif}\;z \leq 1.18 \cdot 10^{-219}:\\ \;\;\;\;x \cdot -3\\ \mathbf{elif}\;z \leq 3.4 \cdot 10^{-137}:\\ \;\;\;\;y \cdot 4\\ \mathbf{elif}\;z \leq 2.6 \cdot 10^{-122}:\\ \;\;\;\;x \cdot -3\\ \mathbf{elif}\;z \leq 3.6 \cdot 10^{-83}:\\ \;\;\;\;y \cdot 4\\ \mathbf{elif}\;z \leq 0.5:\\ \;\;\;\;x \cdot -3\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 6
Accuracy48.4%
Cost1640
\[\begin{array}{l} t_0 := -6 \cdot \left(y \cdot z\right)\\ \mathbf{if}\;z \leq -8.5 \cdot 10^{-8}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;z \leq -3 \cdot 10^{-177}:\\ \;\;\;\;x \cdot -3\\ \mathbf{elif}\;z \leq -2.4 \cdot 10^{-284}:\\ \;\;\;\;y \cdot 4\\ \mathbf{elif}\;z \leq 5.3 \cdot 10^{-307}:\\ \;\;\;\;x \cdot -3\\ \mathbf{elif}\;z \leq 7.6 \cdot 10^{-246}:\\ \;\;\;\;y \cdot 4\\ \mathbf{elif}\;z \leq 4 \cdot 10^{-221}:\\ \;\;\;\;x \cdot -3\\ \mathbf{elif}\;z \leq 2.9 \cdot 10^{-137}:\\ \;\;\;\;y \cdot 4\\ \mathbf{elif}\;z \leq 7 \cdot 10^{-121}:\\ \;\;\;\;x \cdot -3\\ \mathbf{elif}\;z \leq 4.85 \cdot 10^{-82}:\\ \;\;\;\;y \cdot 4\\ \mathbf{elif}\;z \leq 0.62:\\ \;\;\;\;x \cdot -3\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 7
Accuracy70.6%
Cost1504
\[\begin{array}{l} t_0 := 6 \cdot \left(y \cdot \left(0.6666666666666666 - z\right)\right)\\ t_1 := x \cdot \left(-3 + z \cdot 6\right)\\ \mathbf{if}\;x \leq -1.48 \cdot 10^{+60}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq -3.6 \cdot 10^{+33}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;x \leq -3.5 \cdot 10^{-47}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq -1.08 \cdot 10^{-181}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;x \leq -6.4 \cdot 10^{-201}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq 9.5 \cdot 10^{-72}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;x \leq 6 \cdot 10^{-57}:\\ \;\;\;\;x \cdot \left(z \cdot 6\right)\\ \mathbf{elif}\;x \leq 1.55 \cdot 10^{+60}:\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 8
Accuracy70.8%
Cost1504
\[\begin{array}{l} t_0 := y \cdot \left(4 + z \cdot -6\right)\\ t_1 := x \cdot \left(-3 + z \cdot 6\right)\\ \mathbf{if}\;x \leq -2.75 \cdot 10^{+60}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq -1.9 \cdot 10^{+34}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;x \leq -9.2 \cdot 10^{-45}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq -1.08 \cdot 10^{-181}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;x \leq -6.4 \cdot 10^{-201}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq 1.5 \cdot 10^{-69}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;x \leq 6 \cdot 10^{-57}:\\ \;\;\;\;x \cdot \left(z \cdot 6\right)\\ \mathbf{elif}\;x \leq 1.9 \cdot 10^{+60}:\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 9
Accuracy99.5%
Cost1088
\[x \cdot \left(1 + -6 \cdot \left(0.6666666666666666 - z\right)\right) + 6 \cdot \left(y \cdot \left(0.6666666666666666 - z\right)\right) \]
Alternative 10
Accuracy97.1%
Cost840
\[\begin{array}{l} \mathbf{if}\;z \leq -0.6:\\ \;\;\;\;-6 \cdot \left(\left(y - x\right) \cdot z\right)\\ \mathbf{elif}\;z \leq 0.65:\\ \;\;\;\;y \cdot 4 + x \cdot -3\\ \mathbf{else}:\\ \;\;\;\;-6 \cdot \left(y \cdot z - x \cdot z\right)\\ \end{array} \]
Alternative 11
Accuracy99.5%
Cost832
\[x + \frac{\left(y - x\right) \cdot 6}{\frac{1}{0.6666666666666666 - z}} \]
Alternative 12
Accuracy97.1%
Cost713
\[\begin{array}{l} \mathbf{if}\;z \leq -0.58 \lor \neg \left(z \leq 0.5\right):\\ \;\;\;\;-6 \cdot \left(\left(y - x\right) \cdot z\right)\\ \mathbf{else}:\\ \;\;\;\;y \cdot 4 + x \cdot -3\\ \end{array} \]
Alternative 13
Accuracy99.4%
Cost704
\[x + \left(0.6666666666666666 - z\right) \cdot \left(\left(y - x\right) \cdot 6\right) \]
Alternative 14
Accuracy48.6%
Cost456
\[\begin{array}{l} \mathbf{if}\;y \leq -1.85 \cdot 10^{+26}:\\ \;\;\;\;y \cdot 4\\ \mathbf{elif}\;y \leq 4.6 \cdot 10^{+32}:\\ \;\;\;\;x \cdot -3\\ \mathbf{else}:\\ \;\;\;\;y \cdot 4\\ \end{array} \]
Alternative 15
Accuracy33.0%
Cost192
\[y \cdot 4 \]

Error

Reproduce?

herbie shell --seed 2023135 
(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))))