Average Error: 0.4 → 2.1
Time: 9.6s
Precision: binary64
Cost: 6984
\[x + \left(\left(y - x\right) \cdot 6\right) \cdot \left(\frac{2}{3} - z\right) \]
\[\begin{array}{l} t_0 := \left(y - x\right) \cdot \left(z \cdot -6\right)\\ \mathbf{if}\;z \leq -4266169.684303526:\\ \;\;\;\;t_0\\ \mathbf{elif}\;z \leq 2.445416525238844 \cdot 10^{-6}:\\ \;\;\;\;\mathsf{fma}\left(x, -3, y \cdot 4\right)\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
(FPCore (x y z)
 :precision binary64
 (+ x (* (* (- y x) 6.0) (- (/ 2.0 3.0) z))))
(FPCore (x y z)
 :precision binary64
 (let* ((t_0 (* (- y x) (* z -6.0))))
   (if (<= z -4266169.684303526)
     t_0
     (if (<= z 2.445416525238844e-6) (fma x -3.0 (* y 4.0)) t_0))))
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) {
	double t_0 = (y - x) * (z * -6.0);
	double tmp;
	if (z <= -4266169.684303526) {
		tmp = t_0;
	} else if (z <= 2.445416525238844e-6) {
		tmp = fma(x, -3.0, (y * 4.0));
	} else {
		tmp = t_0;
	}
	return tmp;
}
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)
	t_0 = Float64(Float64(y - x) * Float64(z * -6.0))
	tmp = 0.0
	if (z <= -4266169.684303526)
		tmp = t_0;
	elseif (z <= 2.445416525238844e-6)
		tmp = fma(x, -3.0, Float64(y * 4.0));
	else
		tmp = t_0;
	end
	return tmp
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_] := Block[{t$95$0 = N[(N[(y - x), $MachinePrecision] * N[(z * -6.0), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[z, -4266169.684303526], t$95$0, If[LessEqual[z, 2.445416525238844e-6], N[(x * -3.0 + N[(y * 4.0), $MachinePrecision]), $MachinePrecision], t$95$0]]]
x + \left(\left(y - x\right) \cdot 6\right) \cdot \left(\frac{2}{3} - z\right)
\begin{array}{l}
t_0 := \left(y - x\right) \cdot \left(z \cdot -6\right)\\
\mathbf{if}\;z \leq -4266169.684303526:\\
\;\;\;\;t_0\\

\mathbf{elif}\;z \leq 2.445416525238844 \cdot 10^{-6}:\\
\;\;\;\;\mathsf{fma}\left(x, -3, y \cdot 4\right)\\

\mathbf{else}:\\
\;\;\;\;t_0\\


\end{array}

Error

Derivation

  1. Split input into 2 regimes
  2. if z < -4266169.6843035258 or 2.4454165252388438e-6 < z

    1. Initial program 0.3

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

      \[\leadsto \color{blue}{\mathsf{fma}\left(y - x, \mathsf{fma}\left(z, -6, 4\right), x\right)} \]
    3. Taylor expanded in z around inf 2.8

      \[\leadsto \color{blue}{-6 \cdot \left(z \cdot \left(y - x\right)\right)} \]
    4. Taylor expanded in y around 0 2.8

      \[\leadsto \color{blue}{6 \cdot \left(z \cdot x\right) + -6 \cdot \left(y \cdot z\right)} \]
    5. Simplified2.8

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

    if -4266169.6843035258 < z < 2.4454165252388438e-6

    1. Initial program 0.4

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

      \[\leadsto \color{blue}{\mathsf{fma}\left(y - x, \mathsf{fma}\left(z, -6, 4\right), x\right)} \]
    3. Taylor expanded in x around -inf 0.1

      \[\leadsto \color{blue}{-1 \cdot \left(\left(3 + -6 \cdot z\right) \cdot x\right) + \left(4 + -6 \cdot z\right) \cdot y} \]
    4. Applied egg-rr0.0

      \[\leadsto -1 \cdot \color{blue}{\mathsf{fma}\left(3, x, \left(-6 \cdot z\right) \cdot x\right)} + \left(4 + -6 \cdot z\right) \cdot y \]
    5. Taylor expanded in z around 0 1.7

      \[\leadsto \color{blue}{-3 \cdot x + 4 \cdot y} \]
    6. Simplified1.6

      \[\leadsto \color{blue}{\mathsf{fma}\left(x, -3, 4 \cdot y\right)} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification2.1

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \leq -4266169.684303526:\\ \;\;\;\;\left(y - x\right) \cdot \left(z \cdot -6\right)\\ \mathbf{elif}\;z \leq 2.445416525238844 \cdot 10^{-6}:\\ \;\;\;\;\mathsf{fma}\left(x, -3, y \cdot 4\right)\\ \mathbf{else}:\\ \;\;\;\;\left(y - x\right) \cdot \left(z \cdot -6\right)\\ \end{array} \]

Alternatives

Alternative 1
Error33.0
Cost1244
\[\begin{array}{l} t_0 := z \cdot \left(x \cdot 6\right)\\ \mathbf{if}\;z \leq -6.8 \cdot 10^{+193}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;z \leq -4 \cdot 10^{+124}:\\ \;\;\;\;y \cdot \left(z \cdot -6\right)\\ \mathbf{elif}\;z \leq -1.112120447770264 \cdot 10^{-24}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;z \leq -8.752896088424601 \cdot 10^{-117}:\\ \;\;\;\;y \cdot 4\\ \mathbf{elif}\;z \leq -1.6807249871587955 \cdot 10^{-213}:\\ \;\;\;\;x \cdot -3\\ \mathbf{elif}\;z \leq 5.268262622518538 \cdot 10^{-46}:\\ \;\;\;\;y \cdot 4\\ \mathbf{elif}\;z \leq 2.445416525238844 \cdot 10^{-6}:\\ \;\;\;\;x \cdot -3\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 2
Error33.0
Cost1244
\[\begin{array}{l} t_0 := 6 \cdot \left(z \cdot x\right)\\ \mathbf{if}\;z \leq -6.8 \cdot 10^{+193}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;z \leq -4 \cdot 10^{+124}:\\ \;\;\;\;y \cdot \left(z \cdot -6\right)\\ \mathbf{elif}\;z \leq -1.112120447770264 \cdot 10^{-24}:\\ \;\;\;\;z \cdot \left(x \cdot 6\right)\\ \mathbf{elif}\;z \leq -8.752896088424601 \cdot 10^{-117}:\\ \;\;\;\;y \cdot 4\\ \mathbf{elif}\;z \leq -1.6807249871587955 \cdot 10^{-213}:\\ \;\;\;\;x \cdot -3\\ \mathbf{elif}\;z \leq 5.268262622518538 \cdot 10^{-46}:\\ \;\;\;\;y \cdot 4\\ \mathbf{elif}\;z \leq 2.445416525238844 \cdot 10^{-6}:\\ \;\;\;\;x \cdot -3\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 3
Error33.0
Cost1244
\[\begin{array}{l} t_0 := x \cdot \left(z \cdot 6\right)\\ \mathbf{if}\;z \leq -6.8 \cdot 10^{+193}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;z \leq -4 \cdot 10^{+124}:\\ \;\;\;\;y \cdot \left(z \cdot -6\right)\\ \mathbf{elif}\;z \leq -1.112120447770264 \cdot 10^{-24}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;z \leq -8.752896088424601 \cdot 10^{-117}:\\ \;\;\;\;y \cdot 4\\ \mathbf{elif}\;z \leq -1.6807249871587955 \cdot 10^{-213}:\\ \;\;\;\;x \cdot -3\\ \mathbf{elif}\;z \leq 5.268262622518538 \cdot 10^{-46}:\\ \;\;\;\;y \cdot 4\\ \mathbf{elif}\;z \leq 2.445416525238844 \cdot 10^{-6}:\\ \;\;\;\;x \cdot -3\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 4
Error33.0
Cost1244
\[\begin{array}{l} t_0 := x \cdot \left(z \cdot 6\right)\\ \mathbf{if}\;z \leq -6.8 \cdot 10^{+193}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;z \leq -4 \cdot 10^{+124}:\\ \;\;\;\;z \cdot \left(y \cdot -6\right)\\ \mathbf{elif}\;z \leq -1.112120447770264 \cdot 10^{-24}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;z \leq -8.752896088424601 \cdot 10^{-117}:\\ \;\;\;\;y \cdot 4\\ \mathbf{elif}\;z \leq -1.6807249871587955 \cdot 10^{-213}:\\ \;\;\;\;x \cdot -3\\ \mathbf{elif}\;z \leq 5.268262622518538 \cdot 10^{-46}:\\ \;\;\;\;y \cdot 4\\ \mathbf{elif}\;z \leq 2.445416525238844 \cdot 10^{-6}:\\ \;\;\;\;x \cdot -3\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 5
Error33.2
Cost980
\[\begin{array}{l} t_0 := z \cdot \left(x \cdot 6\right)\\ \mathbf{if}\;z \leq -1.112120447770264 \cdot 10^{-24}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;z \leq -8.752896088424601 \cdot 10^{-117}:\\ \;\;\;\;y \cdot 4\\ \mathbf{elif}\;z \leq -1.6807249871587955 \cdot 10^{-213}:\\ \;\;\;\;x \cdot -3\\ \mathbf{elif}\;z \leq 5.268262622518538 \cdot 10^{-46}:\\ \;\;\;\;y \cdot 4\\ \mathbf{elif}\;z \leq 2.445416525238844 \cdot 10^{-6}:\\ \;\;\;\;x \cdot -3\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 6
Error13.4
Cost976
\[\begin{array}{l} t_0 := x \cdot \left(z \cdot 6\right)\\ \mathbf{if}\;z \leq -6.8 \cdot 10^{+193}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;z \leq -4 \cdot 10^{+124}:\\ \;\;\;\;z \cdot \left(y \cdot -6\right)\\ \mathbf{elif}\;z \leq -4266169.684303526:\\ \;\;\;\;t_0\\ \mathbf{elif}\;z \leq 2.445416525238844 \cdot 10^{-6}:\\ \;\;\;\;y \cdot 4 + x \cdot -3\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 7
Error12.8
Cost976
\[\begin{array}{l} t_0 := x \cdot \left(-3 + z \cdot 6\right)\\ \mathbf{if}\;z \leq -6.8 \cdot 10^{+193}:\\ \;\;\;\;x \cdot \left(z \cdot 6\right)\\ \mathbf{elif}\;z \leq -4 \cdot 10^{+124}:\\ \;\;\;\;z \cdot \left(y \cdot -6\right)\\ \mathbf{elif}\;z \leq -4.783005926315238 \cdot 10^{-12}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;z \leq 1.873640288215899 \cdot 10^{-12}:\\ \;\;\;\;y \cdot 4 + x \cdot -3\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 8
Error2.1
Cost712
\[\begin{array}{l} t_0 := \left(y - x\right) \cdot \left(z \cdot -6\right)\\ \mathbf{if}\;z \leq -4266169.684303526:\\ \;\;\;\;t_0\\ \mathbf{elif}\;z \leq 2.445416525238844 \cdot 10^{-6}:\\ \;\;\;\;y \cdot 4 + x \cdot -3\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 9
Error34.3
Cost456
\[\begin{array}{l} \mathbf{if}\;y \leq -0.0008286039625974825:\\ \;\;\;\;y \cdot 4\\ \mathbf{elif}\;y \leq 1.7316867519206246 \cdot 10^{-60}:\\ \;\;\;\;x \cdot -3\\ \mathbf{else}:\\ \;\;\;\;y \cdot 4\\ \end{array} \]
Alternative 10
Error43.6
Cost192
\[x \cdot -3 \]

Error

Reproduce

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