Average Error: 0.2 → 0.2
Time: 19.2s
Precision: binary64
Cost: 6976
\[x + \left(\left(y - x\right) \cdot 6\right) \cdot z \]
\[x + \mathsf{fma}\left(x, -6, y \cdot 6\right) \cdot z \]
(FPCore (x y z) :precision binary64 (+ x (* (* (- y x) 6.0) z)))
(FPCore (x y z) :precision binary64 (+ x (* (fma x -6.0 (* y 6.0)) z)))
double code(double x, double y, double z) {
	return x + (((y - x) * 6.0) * z);
}
double code(double x, double y, double z) {
	return x + (fma(x, -6.0, (y * 6.0)) * z);
}
function code(x, y, z)
	return Float64(x + Float64(Float64(Float64(y - x) * 6.0) * z))
end
function code(x, y, z)
	return Float64(x + Float64(fma(x, -6.0, Float64(y * 6.0)) * z))
end
code[x_, y_, z_] := N[(x + N[(N[(N[(y - x), $MachinePrecision] * 6.0), $MachinePrecision] * z), $MachinePrecision]), $MachinePrecision]
code[x_, y_, z_] := N[(x + N[(N[(x * -6.0 + N[(y * 6.0), $MachinePrecision]), $MachinePrecision] * z), $MachinePrecision]), $MachinePrecision]
x + \left(\left(y - x\right) \cdot 6\right) \cdot z
x + \mathsf{fma}\left(x, -6, y \cdot 6\right) \cdot z

Error

Target

Original0.2
Target0.2
Herbie0.2
\[x - \left(6 \cdot z\right) \cdot \left(x - y\right) \]

Derivation

  1. Initial program 0.2

    \[x + \left(\left(y - x\right) \cdot 6\right) \cdot z \]
  2. Applied egg-rr0.2

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

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

Alternatives

Alternative 1
Error18.6
Cost976
\[\begin{array}{l} t_0 := x + -6 \cdot \left(z \cdot x\right)\\ \mathbf{if}\;y \leq -1.15 \cdot 10^{+42}:\\ \;\;\;\;\left(6 \cdot z\right) \cdot y\\ \mathbf{elif}\;y \leq 14000:\\ \;\;\;\;t_0\\ \mathbf{elif}\;y \leq 5 \cdot 10^{+79}:\\ \;\;\;\;6 \cdot \left(y \cdot z\right)\\ \mathbf{elif}\;y \leq 5.1 \cdot 10^{+123}:\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;\left(6 \cdot y\right) \cdot z\\ \end{array} \]
Alternative 2
Error8.7
Cost712
\[\begin{array}{l} t_0 := x + 6 \cdot \left(y \cdot z\right)\\ \mathbf{if}\;y \leq -1.25 \cdot 10^{+28}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;y \leq 2.3 \cdot 10^{-167}:\\ \;\;\;\;x + -6 \cdot \left(z \cdot x\right)\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 3
Error8.6
Cost712
\[\begin{array}{l} \mathbf{if}\;y \leq -1.3 \cdot 10^{+23}:\\ \;\;\;\;x + 6 \cdot \left(y \cdot z\right)\\ \mathbf{elif}\;y \leq 2.2 \cdot 10^{-165}:\\ \;\;\;\;x + -6 \cdot \left(z \cdot x\right)\\ \mathbf{else}:\\ \;\;\;\;x + \left(6 \cdot y\right) \cdot z\\ \end{array} \]
Alternative 4
Error8.6
Cost712
\[\begin{array}{l} \mathbf{if}\;y \leq -1.3 \cdot 10^{+23}:\\ \;\;\;\;x + \left(6 \cdot z\right) \cdot y\\ \mathbf{elif}\;y \leq 9 \cdot 10^{-167}:\\ \;\;\;\;x + -6 \cdot \left(z \cdot x\right)\\ \mathbf{else}:\\ \;\;\;\;x + \left(6 \cdot y\right) \cdot z\\ \end{array} \]
Alternative 5
Error8.6
Cost712
\[\begin{array}{l} \mathbf{if}\;y \leq -1.3 \cdot 10^{+23}:\\ \;\;\;\;x + \left(6 \cdot z\right) \cdot y\\ \mathbf{elif}\;y \leq 4.5 \cdot 10^{-164}:\\ \;\;\;\;x + \left(z \cdot -6\right) \cdot x\\ \mathbf{else}:\\ \;\;\;\;x + \left(6 \cdot y\right) \cdot z\\ \end{array} \]
Alternative 6
Error23.8
Cost584
\[\begin{array}{l} t_0 := 6 \cdot \left(y \cdot z\right)\\ \mathbf{if}\;z \leq -9.5 \cdot 10^{-39}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;z \leq 3.9 \cdot 10^{-16}:\\ \;\;\;\;x\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 7
Error23.8
Cost584
\[\begin{array}{l} t_0 := \left(6 \cdot y\right) \cdot z\\ \mathbf{if}\;z \leq -4.2 \cdot 10^{-39}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;z \leq 3.9 \cdot 10^{-16}:\\ \;\;\;\;x\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 8
Error0.2
Cost576
\[x + \left(\left(y - x\right) \cdot 6\right) \cdot z \]
Alternative 9
Error35.4
Cost64
\[x \]

Error

Reproduce

herbie shell --seed 2023010 
(FPCore (x y z)
  :name "Data.Colour.RGBSpace.HSL:hsl from colour-2.3.3, E"
  :precision binary64

  :herbie-target
  (- x (* (* 6.0 z) (- x y)))

  (+ x (* (* (- y x) 6.0) z)))