Average Error: 3.5 → 2.0
Time: 23.2s
Precision: binary64
Cost: 13960
\[\left(x \cdot 2 - \left(\left(y \cdot 9\right) \cdot z\right) \cdot t\right) + \left(a \cdot 27\right) \cdot b \]
\[\begin{array}{l} t_1 := x \cdot 2 - \left(\left(y \cdot 9\right) \cdot z\right) \cdot t\\ \mathbf{if}\;t \leq -1 \cdot 10^{+217}:\\ \;\;\;\;t_1 + \left(a \cdot 27\right) \cdot b\\ \mathbf{elif}\;t \leq 4.8 \cdot 10^{+124}:\\ \;\;\;\;\mathsf{fma}\left(27, b \cdot a, \mathsf{fma}\left(x, 2, -9 \cdot \left(y \cdot \left(z \cdot t\right)\right)\right)\right)\\ \mathbf{else}:\\ \;\;\;\;t_1 + \left(27 \cdot b\right) \cdot a\\ \end{array} \]
(FPCore (x y z t a b)
 :precision binary64
 (+ (- (* x 2.0) (* (* (* y 9.0) z) t)) (* (* a 27.0) b)))
(FPCore (x y z t a b)
 :precision binary64
 (let* ((t_1 (- (* x 2.0) (* (* (* y 9.0) z) t))))
   (if (<= t -1e+217)
     (+ t_1 (* (* a 27.0) b))
     (if (<= t 4.8e+124)
       (fma 27.0 (* b a) (fma x 2.0 (- (* 9.0 (* y (* z t))))))
       (+ t_1 (* (* 27.0 b) a))))))
double code(double x, double y, double z, double t, double a, double b) {
	return ((x * 2.0) - (((y * 9.0) * z) * t)) + ((a * 27.0) * b);
}
double code(double x, double y, double z, double t, double a, double b) {
	double t_1 = (x * 2.0) - (((y * 9.0) * z) * t);
	double tmp;
	if (t <= -1e+217) {
		tmp = t_1 + ((a * 27.0) * b);
	} else if (t <= 4.8e+124) {
		tmp = fma(27.0, (b * a), fma(x, 2.0, -(9.0 * (y * (z * t)))));
	} else {
		tmp = t_1 + ((27.0 * b) * a);
	}
	return tmp;
}
function code(x, y, z, t, a, b)
	return Float64(Float64(Float64(x * 2.0) - Float64(Float64(Float64(y * 9.0) * z) * t)) + Float64(Float64(a * 27.0) * b))
end
function code(x, y, z, t, a, b)
	t_1 = Float64(Float64(x * 2.0) - Float64(Float64(Float64(y * 9.0) * z) * t))
	tmp = 0.0
	if (t <= -1e+217)
		tmp = Float64(t_1 + Float64(Float64(a * 27.0) * b));
	elseif (t <= 4.8e+124)
		tmp = fma(27.0, Float64(b * a), fma(x, 2.0, Float64(-Float64(9.0 * Float64(y * Float64(z * t))))));
	else
		tmp = Float64(t_1 + Float64(Float64(27.0 * b) * a));
	end
	return tmp
end
code[x_, y_, z_, t_, a_, b_] := N[(N[(N[(x * 2.0), $MachinePrecision] - N[(N[(N[(y * 9.0), $MachinePrecision] * z), $MachinePrecision] * t), $MachinePrecision]), $MachinePrecision] + N[(N[(a * 27.0), $MachinePrecision] * b), $MachinePrecision]), $MachinePrecision]
code[x_, y_, z_, t_, a_, b_] := Block[{t$95$1 = N[(N[(x * 2.0), $MachinePrecision] - N[(N[(N[(y * 9.0), $MachinePrecision] * z), $MachinePrecision] * t), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t, -1e+217], N[(t$95$1 + N[(N[(a * 27.0), $MachinePrecision] * b), $MachinePrecision]), $MachinePrecision], If[LessEqual[t, 4.8e+124], N[(27.0 * N[(b * a), $MachinePrecision] + N[(x * 2.0 + (-N[(9.0 * N[(y * N[(z * t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision])), $MachinePrecision]), $MachinePrecision], N[(t$95$1 + N[(N[(27.0 * b), $MachinePrecision] * a), $MachinePrecision]), $MachinePrecision]]]]
\left(x \cdot 2 - \left(\left(y \cdot 9\right) \cdot z\right) \cdot t\right) + \left(a \cdot 27\right) \cdot b
\begin{array}{l}
t_1 := x \cdot 2 - \left(\left(y \cdot 9\right) \cdot z\right) \cdot t\\
\mathbf{if}\;t \leq -1 \cdot 10^{+217}:\\
\;\;\;\;t_1 + \left(a \cdot 27\right) \cdot b\\

\mathbf{elif}\;t \leq 4.8 \cdot 10^{+124}:\\
\;\;\;\;\mathsf{fma}\left(27, b \cdot a, \mathsf{fma}\left(x, 2, -9 \cdot \left(y \cdot \left(z \cdot t\right)\right)\right)\right)\\

\mathbf{else}:\\
\;\;\;\;t_1 + \left(27 \cdot b\right) \cdot a\\


\end{array}

Error

Target

Original3.5
Target2.8
Herbie2.0
\[\begin{array}{l} \mathbf{if}\;y < 7.590524218811189 \cdot 10^{-161}:\\ \;\;\;\;\left(x \cdot 2 - \left(\left(y \cdot 9\right) \cdot z\right) \cdot t\right) + a \cdot \left(27 \cdot b\right)\\ \mathbf{else}:\\ \;\;\;\;\left(x \cdot 2 - 9 \cdot \left(y \cdot \left(t \cdot z\right)\right)\right) + \left(a \cdot 27\right) \cdot b\\ \end{array} \]

Derivation

  1. Split input into 3 regimes
  2. if t < -9.9999999999999996e216

    1. Initial program 1.4

      \[\left(x \cdot 2 - \left(\left(y \cdot 9\right) \cdot z\right) \cdot t\right) + \left(a \cdot 27\right) \cdot b \]

    if -9.9999999999999996e216 < t < 4.80000000000000013e124

    1. Initial program 3.9

      \[\left(x \cdot 2 - \left(\left(y \cdot 9\right) \cdot z\right) \cdot t\right) + \left(a \cdot 27\right) \cdot b \]
    2. Simplified2.2

      \[\leadsto \color{blue}{\mathsf{fma}\left(27, b \cdot a, \mathsf{fma}\left(x, 2, -9 \cdot \left(y \cdot \left(z \cdot t\right)\right)\right)\right)} \]
      Proof

    if 4.80000000000000013e124 < t

    1. Initial program 1.0

      \[\left(x \cdot 2 - \left(\left(y \cdot 9\right) \cdot z\right) \cdot t\right) + \left(a \cdot 27\right) \cdot b \]
    2. Applied egg-rr1.0

      \[\leadsto \left(x \cdot 2 - \left(\left(y \cdot 9\right) \cdot z\right) \cdot t\right) + \color{blue}{\left(27 \cdot b\right) \cdot a} \]
  3. Recombined 3 regimes into one program.

Alternatives

Alternative 1
Error0.9
Cost1608
\[\begin{array}{l} t_1 := \left(a \cdot 27\right) \cdot b\\ t_2 := \left(x \cdot 2 - \left(z \cdot t\right) \cdot \left(y \cdot 9\right)\right) + t_1\\ \mathbf{if}\;y \cdot 9 \leq -5 \cdot 10^{-92}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;y \cdot 9 \leq 5 \cdot 10^{-40}:\\ \;\;\;\;\left(x \cdot 2 - \left(9 \cdot \left(t \cdot y\right)\right) \cdot z\right) + t_1\\ \mathbf{else}:\\ \;\;\;\;t_2\\ \end{array} \]
Alternative 2
Error10.8
Cost1480
\[\begin{array}{l} t_1 := \left(a \cdot 27\right) \cdot b\\ t_2 := 2 \cdot x + 27 \cdot \left(a \cdot b\right)\\ \mathbf{if}\;t_1 \leq -2 \cdot 10^{-27}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;t_1 \leq 5 \cdot 10^{+16}:\\ \;\;\;\;2 \cdot x - 9 \cdot \left(y \cdot \left(t \cdot z\right)\right)\\ \mathbf{else}:\\ \;\;\;\;t_2\\ \end{array} \]
Alternative 3
Error10.6
Cost1480
\[\begin{array}{l} t_1 := \left(a \cdot 27\right) \cdot b\\ t_2 := 2 \cdot x + 27 \cdot \left(a \cdot b\right)\\ \mathbf{if}\;t_1 \leq -1 \cdot 10^{-13}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;t_1 \leq 100000000000:\\ \;\;\;\;2 \cdot x - \left(z \cdot 9\right) \cdot \left(y \cdot t\right)\\ \mathbf{else}:\\ \;\;\;\;t_2\\ \end{array} \]
Alternative 4
Error1.9
Cost1352
\[\begin{array}{l} t_1 := \left(x \cdot 2 - \left(\left(y \cdot 9\right) \cdot z\right) \cdot t\right) + \left(27 \cdot b\right) \cdot a\\ \mathbf{if}\;t \leq -1.15 \cdot 10^{+206}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;t \leq 2 \cdot 10^{-113}:\\ \;\;\;\;\left(x \cdot 2 - \left(z \cdot t\right) \cdot \left(y \cdot 9\right)\right) + \left(a \cdot 27\right) \cdot b\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 5
Error1.9
Cost1352
\[\begin{array}{l} t_1 := \left(a \cdot 27\right) \cdot b\\ t_2 := x \cdot 2 - \left(\left(y \cdot 9\right) \cdot z\right) \cdot t\\ \mathbf{if}\;t \leq -2.1 \cdot 10^{+216}:\\ \;\;\;\;t_2 + t_1\\ \mathbf{elif}\;t \leq 2 \cdot 10^{-112}:\\ \;\;\;\;\left(x \cdot 2 - \left(z \cdot t\right) \cdot \left(y \cdot 9\right)\right) + t_1\\ \mathbf{else}:\\ \;\;\;\;t_2 + \left(27 \cdot b\right) \cdot a\\ \end{array} \]
Alternative 6
Error28.8
Cost1112
\[\begin{array}{l} t_1 := -9 \cdot \left(y \cdot \left(t \cdot z\right)\right)\\ t_2 := 27 \cdot \left(a \cdot b\right)\\ \mathbf{if}\;x \leq -550000000000:\\ \;\;\;\;2 \cdot x\\ \mathbf{elif}\;x \leq -6.2 \cdot 10^{-114}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;x \leq -1.3 \cdot 10^{-162}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq 3.8 \cdot 10^{-220}:\\ \;\;\;\;\left(27 \cdot b\right) \cdot a\\ \mathbf{elif}\;x \leq 6.5 \cdot 10^{-168}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq 6.5 \cdot 10^{+32}:\\ \;\;\;\;t_2\\ \mathbf{else}:\\ \;\;\;\;2 \cdot x\\ \end{array} \]
Alternative 7
Error28.7
Cost1112
\[\begin{array}{l} t_1 := 27 \cdot \left(a \cdot b\right)\\ \mathbf{if}\;x \leq -210000000000:\\ \;\;\;\;2 \cdot x\\ \mathbf{elif}\;x \leq -3.1 \cdot 10^{-109}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq -1.48 \cdot 10^{-164}:\\ \;\;\;\;-9 \cdot \left(\left(y \cdot z\right) \cdot t\right)\\ \mathbf{elif}\;x \leq 2.3 \cdot 10^{-221}:\\ \;\;\;\;\left(27 \cdot b\right) \cdot a\\ \mathbf{elif}\;x \leq 5.5 \cdot 10^{-168}:\\ \;\;\;\;-9 \cdot \left(y \cdot \left(t \cdot z\right)\right)\\ \mathbf{elif}\;x \leq 3.4 \cdot 10^{+16}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;2 \cdot x\\ \end{array} \]
Alternative 8
Error28.7
Cost1112
\[\begin{array}{l} t_1 := 27 \cdot \left(a \cdot b\right)\\ \mathbf{if}\;x \leq -950000000000:\\ \;\;\;\;2 \cdot x\\ \mathbf{elif}\;x \leq -3.7 \cdot 10^{-109}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq -5.5 \cdot 10^{-162}:\\ \;\;\;\;-9 \cdot \left(\left(y \cdot z\right) \cdot t\right)\\ \mathbf{elif}\;x \leq 3.8 \cdot 10^{-220}:\\ \;\;\;\;\left(27 \cdot b\right) \cdot a\\ \mathbf{elif}\;x \leq 5.5 \cdot 10^{-168}:\\ \;\;\;\;\left(t \cdot z\right) \cdot \left(-9 \cdot y\right)\\ \mathbf{elif}\;x \leq 1.11 \cdot 10^{+21}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;2 \cdot x\\ \end{array} \]
Alternative 9
Error29.0
Cost1112
\[\begin{array}{l} t_1 := 27 \cdot \left(a \cdot b\right)\\ \mathbf{if}\;x \leq -850000000000:\\ \;\;\;\;2 \cdot x\\ \mathbf{elif}\;x \leq -2.05 \cdot 10^{-109}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq -1.4 \cdot 10^{-164}:\\ \;\;\;\;-9 \cdot \left(\left(y \cdot z\right) \cdot t\right)\\ \mathbf{elif}\;x \leq 1.55 \cdot 10^{-266}:\\ \;\;\;\;\left(27 \cdot b\right) \cdot a\\ \mathbf{elif}\;x \leq 5.5 \cdot 10^{-168}:\\ \;\;\;\;\left(z \cdot -9\right) \cdot \left(y \cdot t\right)\\ \mathbf{elif}\;x \leq 4.2 \cdot 10^{+17}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;2 \cdot x\\ \end{array} \]
Alternative 10
Error19.1
Cost1104
\[\begin{array}{l} t_1 := 2 \cdot x + 27 \cdot \left(a \cdot b\right)\\ \mathbf{if}\;x \leq -1.82 \cdot 10^{-109}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq -4.3 \cdot 10^{-162}:\\ \;\;\;\;-9 \cdot \left(\left(y \cdot z\right) \cdot t\right)\\ \mathbf{elif}\;x \leq 4.4 \cdot 10^{-186}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq 10^{-167}:\\ \;\;\;\;\left(t \cdot z\right) \cdot \left(-9 \cdot y\right)\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 11
Error19.2
Cost1104
\[\begin{array}{l} t_1 := 2 \cdot x + 27 \cdot \left(a \cdot b\right)\\ \mathbf{if}\;x \leq -1.82 \cdot 10^{-109}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq -1 \cdot 10^{-161}:\\ \;\;\;\;-9 \cdot \left(\left(y \cdot z\right) \cdot t\right)\\ \mathbf{elif}\;x \leq 2.5 \cdot 10^{-187}:\\ \;\;\;\;2 \cdot x + \left(27 \cdot b\right) \cdot a\\ \mathbf{elif}\;x \leq 10^{-167}:\\ \;\;\;\;\left(t \cdot z\right) \cdot \left(-9 \cdot y\right)\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 12
Error3.3
Cost1088
\[\left(x \cdot 2 - \left(9 \cdot \left(t \cdot y\right)\right) \cdot z\right) + \left(a \cdot 27\right) \cdot b \]
Alternative 13
Error28.1
Cost584
\[\begin{array}{l} \mathbf{if}\;x \leq -1.7 \cdot 10^{+14}:\\ \;\;\;\;2 \cdot x\\ \mathbf{elif}\;x \leq 1.16 \cdot 10^{+15}:\\ \;\;\;\;27 \cdot \left(a \cdot b\right)\\ \mathbf{else}:\\ \;\;\;\;2 \cdot x\\ \end{array} \]
Alternative 14
Error37.4
Cost192
\[2 \cdot x \]

Error

Reproduce

herbie shell --seed 2023010 
(FPCore (x y z t a b)
  :name "Diagrams.Solve.Polynomial:cubForm  from diagrams-solve-0.1, A"
  :precision binary64

  :herbie-target
  (if (< y 7.590524218811189e-161) (+ (- (* x 2.0) (* (* (* y 9.0) z) t)) (* a (* 27.0 b))) (+ (- (* x 2.0) (* 9.0 (* y (* t z)))) (* (* a 27.0) b)))

  (+ (- (* x 2.0) (* (* (* y 9.0) z) t)) (* (* a 27.0) b)))