Diagrams.Solve.Polynomial:cubForm from diagrams-solve-0.1, A

Percentage Accurate: 95.5% → 97.9%
Time: 26.6s
Alternatives: 14
Speedup: 0.9×

Specification

?
\[\begin{array}{l} \\ \left(x \cdot 2 - \left(\left(y \cdot 9\right) \cdot z\right) \cdot t\right) + \left(a \cdot 27\right) \cdot b \end{array} \]
(FPCore (x y z t a b)
 :precision binary64
 (+ (- (* 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) {
	return ((x * 2.0) - (((y * 9.0) * z) * t)) + ((a * 27.0) * b);
}
real(8) function code(x, y, z, t, a, b)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8), intent (in) :: t
    real(8), intent (in) :: a
    real(8), intent (in) :: b
    code = ((x * 2.0d0) - (((y * 9.0d0) * z) * t)) + ((a * 27.0d0) * b)
end function
public static 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);
}
def code(x, y, z, t, a, b):
	return ((x * 2.0) - (((y * 9.0) * z) * t)) + ((a * 27.0) * b)
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 tmp = code(x, y, z, t, a, b)
	tmp = ((x * 2.0) - (((y * 9.0) * z) * t)) + ((a * 27.0) * b);
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]
\begin{array}{l}

\\
\left(x \cdot 2 - \left(\left(y \cdot 9\right) \cdot z\right) \cdot t\right) + \left(a \cdot 27\right) \cdot b
\end{array}

Sampling outcomes in binary64 precision:

Local Percentage Accuracy vs ?

The average percentage accuracy by input value. Horizontal axis shows value of an input variable; the variable is choosen in the title. Vertical axis is accuracy; higher is better. Red represent the original program, while blue represents Herbie's suggestion. These can be toggled with buttons below the plot. The line is an average while dots represent individual samples.

Accuracy vs Speed?

Herbie found 14 alternatives:

AlternativeAccuracySpeedup
The accuracy (vertical axis) and speed (horizontal axis) of each alternatives. Up and to the right is better. The red square shows the initial program, and each blue circle shows an alternative.The line shows the best available speed-accuracy tradeoffs.

Initial Program: 95.5% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \left(x \cdot 2 - \left(\left(y \cdot 9\right) \cdot z\right) \cdot t\right) + \left(a \cdot 27\right) \cdot b \end{array} \]
(FPCore (x y z t a b)
 :precision binary64
 (+ (- (* 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) {
	return ((x * 2.0) - (((y * 9.0) * z) * t)) + ((a * 27.0) * b);
}
real(8) function code(x, y, z, t, a, b)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8), intent (in) :: t
    real(8), intent (in) :: a
    real(8), intent (in) :: b
    code = ((x * 2.0d0) - (((y * 9.0d0) * z) * t)) + ((a * 27.0d0) * b)
end function
public static 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);
}
def code(x, y, z, t, a, b):
	return ((x * 2.0) - (((y * 9.0) * z) * t)) + ((a * 27.0) * b)
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 tmp = code(x, y, z, t, a, b)
	tmp = ((x * 2.0) - (((y * 9.0) * z) * t)) + ((a * 27.0) * b);
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]
\begin{array}{l}

\\
\left(x \cdot 2 - \left(\left(y \cdot 9\right) \cdot z\right) \cdot t\right) + \left(a \cdot 27\right) \cdot b
\end{array}

Alternative 1: 97.9% accurate, 0.7× speedup?

\[\begin{array}{l} [x, y, z, t, a, b] = \mathsf{sort}([x, y, z, t, a, b])\\\\ [x, y, z, t, a, b] = \mathsf{sort}([x, y, z, t, a, b])\\ \\ \begin{array}{l} t_1 := \left(y \cdot 9\right) \cdot z\\ \mathbf{if}\;t\_1 \leq 10^{+308}:\\ \;\;\;\;\left(x \cdot 2 - t\_1 \cdot t\right) + \left(a \cdot 27\right) \cdot b\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(27 \cdot b, a, z \cdot \left(t \cdot \left(y \cdot -9\right)\right)\right)\\ \end{array} \end{array} \]
NOTE: x, y, z, t, a, and b should be sorted in increasing order before calling this function.
NOTE: x, y, z, t, a, and b should be sorted in increasing order before calling this function.
(FPCore (x y z t a b)
 :precision binary64
 (let* ((t_1 (* (* y 9.0) z)))
   (if (<= t_1 1e+308)
     (+ (- (* x 2.0) (* t_1 t)) (* (* a 27.0) b))
     (fma (* 27.0 b) a (* z (* t (* y -9.0)))))))
assert(x < y && y < z && z < t && t < a && a < b);
assert(x < y && y < z && z < t && t < a && a < b);
double code(double x, double y, double z, double t, double a, double b) {
	double t_1 = (y * 9.0) * z;
	double tmp;
	if (t_1 <= 1e+308) {
		tmp = ((x * 2.0) - (t_1 * t)) + ((a * 27.0) * b);
	} else {
		tmp = fma((27.0 * b), a, (z * (t * (y * -9.0))));
	}
	return tmp;
}
x, y, z, t, a, b = sort([x, y, z, t, a, b])
x, y, z, t, a, b = sort([x, y, z, t, a, b])
function code(x, y, z, t, a, b)
	t_1 = Float64(Float64(y * 9.0) * z)
	tmp = 0.0
	if (t_1 <= 1e+308)
		tmp = Float64(Float64(Float64(x * 2.0) - Float64(t_1 * t)) + Float64(Float64(a * 27.0) * b));
	else
		tmp = fma(Float64(27.0 * b), a, Float64(z * Float64(t * Float64(y * -9.0))));
	end
	return tmp
end
NOTE: x, y, z, t, a, and b should be sorted in increasing order before calling this function.
NOTE: x, y, z, t, a, and b should be sorted in increasing order before calling this function.
code[x_, y_, z_, t_, a_, b_] := Block[{t$95$1 = N[(N[(y * 9.0), $MachinePrecision] * z), $MachinePrecision]}, If[LessEqual[t$95$1, 1e+308], N[(N[(N[(x * 2.0), $MachinePrecision] - N[(t$95$1 * t), $MachinePrecision]), $MachinePrecision] + N[(N[(a * 27.0), $MachinePrecision] * b), $MachinePrecision]), $MachinePrecision], N[(N[(27.0 * b), $MachinePrecision] * a + N[(z * N[(t * N[(y * -9.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
[x, y, z, t, a, b] = \mathsf{sort}([x, y, z, t, a, b])\\\\
[x, y, z, t, a, b] = \mathsf{sort}([x, y, z, t, a, b])\\
\\
\begin{array}{l}
t_1 := \left(y \cdot 9\right) \cdot z\\
\mathbf{if}\;t\_1 \leq 10^{+308}:\\
\;\;\;\;\left(x \cdot 2 - t\_1 \cdot t\right) + \left(a \cdot 27\right) \cdot b\\

\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(27 \cdot b, a, z \cdot \left(t \cdot \left(y \cdot -9\right)\right)\right)\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (*.f64 (*.f64 y #s(literal 9 binary64)) z) < 1e308

    1. Initial program 96.8%

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

    if 1e308 < (*.f64 (*.f64 y #s(literal 9 binary64)) z)

    1. Initial program 84.1%

      \[\left(x \cdot 2 - \left(\left(y \cdot 9\right) \cdot z\right) \cdot t\right) + \left(a \cdot 27\right) \cdot b \]
    2. Add Preprocessing
    3. Taylor expanded in x around 0

      \[\leadsto \color{blue}{27 \cdot \left(a \cdot b\right) - 9 \cdot \left(t \cdot \left(y \cdot z\right)\right)} \]
    4. Step-by-step derivation
      1. cancel-sign-sub-invN/A

        \[\leadsto 27 \cdot \left(a \cdot b\right) + \color{blue}{\left(\mathsf{neg}\left(9\right)\right) \cdot \left(t \cdot \left(y \cdot z\right)\right)} \]
      2. metadata-evalN/A

        \[\leadsto 27 \cdot \left(a \cdot b\right) + -9 \cdot \left(\color{blue}{t} \cdot \left(y \cdot z\right)\right) \]
      3. +-commutativeN/A

        \[\leadsto -9 \cdot \left(t \cdot \left(y \cdot z\right)\right) + \color{blue}{27 \cdot \left(a \cdot b\right)} \]
      4. *-commutativeN/A

        \[\leadsto \left(t \cdot \left(y \cdot z\right)\right) \cdot -9 + \color{blue}{27} \cdot \left(a \cdot b\right) \]
      5. associate-*l*N/A

        \[\leadsto t \cdot \left(\left(y \cdot z\right) \cdot -9\right) + \color{blue}{27} \cdot \left(a \cdot b\right) \]
      6. *-commutativeN/A

        \[\leadsto t \cdot \left(-9 \cdot \left(y \cdot z\right)\right) + 27 \cdot \left(a \cdot b\right) \]
      7. accelerator-lowering-fma.f64N/A

        \[\leadsto \mathsf{fma.f64}\left(t, \color{blue}{\left(-9 \cdot \left(y \cdot z\right)\right)}, \left(27 \cdot \left(a \cdot b\right)\right)\right) \]
      8. +-lft-identityN/A

        \[\leadsto \mathsf{fma.f64}\left(t, \left(0 + \color{blue}{-9 \cdot \left(y \cdot z\right)}\right), \left(27 \cdot \left(a \cdot b\right)\right)\right) \]
      9. +-commutativeN/A

        \[\leadsto \mathsf{fma.f64}\left(t, \left(-9 \cdot \left(y \cdot z\right) + \color{blue}{0}\right), \left(27 \cdot \left(a \cdot b\right)\right)\right) \]
      10. *-commutativeN/A

        \[\leadsto \mathsf{fma.f64}\left(t, \left(\left(y \cdot z\right) \cdot -9 + 0\right), \left(27 \cdot \left(a \cdot b\right)\right)\right) \]
      11. accelerator-lowering-fma.f64N/A

        \[\leadsto \mathsf{fma.f64}\left(t, \mathsf{fma.f64}\left(\left(y \cdot z\right), \color{blue}{-9}, 0\right), \left(27 \cdot \left(a \cdot b\right)\right)\right) \]
      12. *-lowering-*.f64N/A

        \[\leadsto \mathsf{fma.f64}\left(t, \mathsf{fma.f64}\left(\mathsf{*.f64}\left(y, z\right), -9, 0\right), \left(27 \cdot \left(a \cdot b\right)\right)\right) \]
      13. +-rgt-identityN/A

        \[\leadsto \mathsf{fma.f64}\left(t, \mathsf{fma.f64}\left(\mathsf{*.f64}\left(y, z\right), -9, \color{blue}{0}\right), \left(27 \cdot \left(a \cdot b\right) + 0\right)\right) \]
      14. accelerator-lowering-fma.f64N/A

        \[\leadsto \mathsf{fma.f64}\left(t, \mathsf{fma.f64}\left(\mathsf{*.f64}\left(y, z\right), -9, \color{blue}{0}\right), \mathsf{fma.f64}\left(27, \left(a \cdot b\right), 0\right)\right) \]
      15. *-lowering-*.f6484.1%

        \[\leadsto \mathsf{fma.f64}\left(t, \mathsf{fma.f64}\left(\mathsf{*.f64}\left(y, z\right), -9, 0\right), \mathsf{fma.f64}\left(27, \mathsf{*.f64}\left(a, b\right), 0\right)\right) \]
    5. Simplified84.1%

      \[\leadsto \color{blue}{\mathsf{fma}\left(t, \mathsf{fma}\left(y \cdot z, -9, 0\right), \mathsf{fma}\left(27, a \cdot b, 0\right)\right)} \]
    6. Step-by-step derivation
      1. +-rgt-identityN/A

        \[\leadsto t \cdot \left(\left(y \cdot z\right) \cdot -9\right) + \left(27 \cdot \color{blue}{\left(a \cdot b\right)} + 0\right) \]
      2. +-rgt-identityN/A

        \[\leadsto t \cdot \left(\left(y \cdot z\right) \cdot -9\right) + 27 \cdot \color{blue}{\left(a \cdot b\right)} \]
      3. *-commutativeN/A

        \[\leadsto \left(\left(y \cdot z\right) \cdot -9\right) \cdot t + \color{blue}{27} \cdot \left(a \cdot b\right) \]
      4. associate-*r*N/A

        \[\leadsto \left(y \cdot \left(z \cdot -9\right)\right) \cdot t + 27 \cdot \left(a \cdot b\right) \]
      5. +-commutativeN/A

        \[\leadsto 27 \cdot \left(a \cdot b\right) + \color{blue}{\left(y \cdot \left(z \cdot -9\right)\right) \cdot t} \]
      6. *-commutativeN/A

        \[\leadsto 27 \cdot \left(b \cdot a\right) + \left(y \cdot \color{blue}{\left(z \cdot -9\right)}\right) \cdot t \]
      7. associate-*r*N/A

        \[\leadsto \left(27 \cdot b\right) \cdot a + \color{blue}{\left(y \cdot \left(z \cdot -9\right)\right)} \cdot t \]
      8. accelerator-lowering-fma.f64N/A

        \[\leadsto \mathsf{fma.f64}\left(\left(27 \cdot b\right), \color{blue}{a}, \left(\left(y \cdot \left(z \cdot -9\right)\right) \cdot t\right)\right) \]
      9. *-lowering-*.f64N/A

        \[\leadsto \mathsf{fma.f64}\left(\mathsf{*.f64}\left(27, b\right), a, \left(\left(y \cdot \left(z \cdot -9\right)\right) \cdot t\right)\right) \]
      10. +-rgt-identityN/A

        \[\leadsto \mathsf{fma.f64}\left(\mathsf{*.f64}\left(27, b\right), a, \left(\left(y \cdot \left(z \cdot -9\right)\right) \cdot t + 0\right)\right) \]
      11. associate-*r*N/A

        \[\leadsto \mathsf{fma.f64}\left(\mathsf{*.f64}\left(27, b\right), a, \left(\left(\left(y \cdot z\right) \cdot -9\right) \cdot t + 0\right)\right) \]
      12. *-commutativeN/A

        \[\leadsto \mathsf{fma.f64}\left(\mathsf{*.f64}\left(27, b\right), a, \left(\left(-9 \cdot \left(y \cdot z\right)\right) \cdot t + 0\right)\right) \]
      13. associate-*l*N/A

        \[\leadsto \mathsf{fma.f64}\left(\mathsf{*.f64}\left(27, b\right), a, \left(-9 \cdot \left(\left(y \cdot z\right) \cdot t\right) + 0\right)\right) \]
      14. accelerator-lowering-fma.f64N/A

        \[\leadsto \mathsf{fma.f64}\left(\mathsf{*.f64}\left(27, b\right), a, \mathsf{fma.f64}\left(-9, \left(\left(y \cdot z\right) \cdot t\right), 0\right)\right) \]
      15. *-lowering-*.f64N/A

        \[\leadsto \mathsf{fma.f64}\left(\mathsf{*.f64}\left(27, b\right), a, \mathsf{fma.f64}\left(-9, \mathsf{*.f64}\left(\left(y \cdot z\right), t\right), 0\right)\right) \]
      16. *-lowering-*.f6484.1%

        \[\leadsto \mathsf{fma.f64}\left(\mathsf{*.f64}\left(27, b\right), a, \mathsf{fma.f64}\left(-9, \mathsf{*.f64}\left(\mathsf{*.f64}\left(y, z\right), t\right), 0\right)\right) \]
    7. Applied egg-rr84.1%

      \[\leadsto \color{blue}{\mathsf{fma}\left(27 \cdot b, a, \mathsf{fma}\left(-9, \left(y \cdot z\right) \cdot t, 0\right)\right)} \]
    8. Step-by-step derivation
      1. +-rgt-identityN/A

        \[\leadsto \mathsf{fma.f64}\left(\mathsf{*.f64}\left(27, b\right), a, \left(-9 \cdot \left(\left(y \cdot z\right) \cdot t\right)\right)\right) \]
      2. associate-*l*N/A

        \[\leadsto \mathsf{fma.f64}\left(\mathsf{*.f64}\left(27, b\right), a, \left(-9 \cdot \left(y \cdot \left(z \cdot t\right)\right)\right)\right) \]
      3. associate-*r*N/A

        \[\leadsto \mathsf{fma.f64}\left(\mathsf{*.f64}\left(27, b\right), a, \left(\left(-9 \cdot y\right) \cdot \left(z \cdot t\right)\right)\right) \]
      4. *-commutativeN/A

        \[\leadsto \mathsf{fma.f64}\left(\mathsf{*.f64}\left(27, b\right), a, \left(\left(y \cdot -9\right) \cdot \left(z \cdot t\right)\right)\right) \]
      5. *-commutativeN/A

        \[\leadsto \mathsf{fma.f64}\left(\mathsf{*.f64}\left(27, b\right), a, \left(\left(z \cdot t\right) \cdot \left(y \cdot -9\right)\right)\right) \]
      6. associate-*l*N/A

        \[\leadsto \mathsf{fma.f64}\left(\mathsf{*.f64}\left(27, b\right), a, \left(z \cdot \left(t \cdot \left(y \cdot -9\right)\right)\right)\right) \]
      7. *-commutativeN/A

        \[\leadsto \mathsf{fma.f64}\left(\mathsf{*.f64}\left(27, b\right), a, \left(\left(t \cdot \left(y \cdot -9\right)\right) \cdot z\right)\right) \]
      8. *-lowering-*.f64N/A

        \[\leadsto \mathsf{fma.f64}\left(\mathsf{*.f64}\left(27, b\right), a, \mathsf{*.f64}\left(\left(t \cdot \left(y \cdot -9\right)\right), z\right)\right) \]
      9. *-lowering-*.f64N/A

        \[\leadsto \mathsf{fma.f64}\left(\mathsf{*.f64}\left(27, b\right), a, \mathsf{*.f64}\left(\mathsf{*.f64}\left(t, \left(y \cdot -9\right)\right), z\right)\right) \]
      10. *-lowering-*.f6499.9%

        \[\leadsto \mathsf{fma.f64}\left(\mathsf{*.f64}\left(27, b\right), a, \mathsf{*.f64}\left(\mathsf{*.f64}\left(t, \mathsf{*.f64}\left(y, -9\right)\right), z\right)\right) \]
    9. Applied egg-rr99.9%

      \[\leadsto \mathsf{fma}\left(27 \cdot b, a, \color{blue}{\left(t \cdot \left(y \cdot -9\right)\right) \cdot z}\right) \]
  3. Recombined 2 regimes into one program.
  4. Final simplification96.9%

    \[\leadsto \begin{array}{l} \mathbf{if}\;\left(y \cdot 9\right) \cdot z \leq 10^{+308}:\\ \;\;\;\;\left(x \cdot 2 - \left(\left(y \cdot 9\right) \cdot z\right) \cdot t\right) + \left(a \cdot 27\right) \cdot b\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(27 \cdot b, a, z \cdot \left(t \cdot \left(y \cdot -9\right)\right)\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 2: 52.4% accurate, 0.6× speedup?

\[\begin{array}{l} [x, y, z, t, a, b] = \mathsf{sort}([x, y, z, t, a, b])\\\\ [x, y, z, t, a, b] = \mathsf{sort}([x, y, z, t, a, b])\\ \\ \begin{array}{l} t_1 := \left(a \cdot 27\right) \cdot b\\ \mathbf{if}\;t\_1 \leq -4 \cdot 10^{+100}:\\ \;\;\;\;27 \cdot \left(a \cdot b\right)\\ \mathbf{elif}\;t\_1 \leq 2 \cdot 10^{-222}:\\ \;\;\;\;t \cdot \left(z \cdot \left(y \cdot -9\right)\right)\\ \mathbf{elif}\;t\_1 \leq 2 \cdot 10^{+111}:\\ \;\;\;\;x \cdot 2\\ \mathbf{else}:\\ \;\;\;\;t\_1\\ \end{array} \end{array} \]
NOTE: x, y, z, t, a, and b should be sorted in increasing order before calling this function.
NOTE: x, y, z, t, a, and b should be sorted in increasing order before calling this function.
(FPCore (x y z t a b)
 :precision binary64
 (let* ((t_1 (* (* a 27.0) b)))
   (if (<= t_1 -4e+100)
     (* 27.0 (* a b))
     (if (<= t_1 2e-222)
       (* t (* z (* y -9.0)))
       (if (<= t_1 2e+111) (* x 2.0) t_1)))))
assert(x < y && y < z && z < t && t < a && a < b);
assert(x < y && y < z && z < t && t < a && a < b);
double code(double x, double y, double z, double t, double a, double b) {
	double t_1 = (a * 27.0) * b;
	double tmp;
	if (t_1 <= -4e+100) {
		tmp = 27.0 * (a * b);
	} else if (t_1 <= 2e-222) {
		tmp = t * (z * (y * -9.0));
	} else if (t_1 <= 2e+111) {
		tmp = x * 2.0;
	} else {
		tmp = t_1;
	}
	return tmp;
}
NOTE: x, y, z, t, a, and b should be sorted in increasing order before calling this function.
NOTE: x, y, z, t, a, and b should be sorted in increasing order before calling this function.
real(8) function code(x, y, z, t, a, b)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8), intent (in) :: t
    real(8), intent (in) :: a
    real(8), intent (in) :: b
    real(8) :: t_1
    real(8) :: tmp
    t_1 = (a * 27.0d0) * b
    if (t_1 <= (-4d+100)) then
        tmp = 27.0d0 * (a * b)
    else if (t_1 <= 2d-222) then
        tmp = t * (z * (y * (-9.0d0)))
    else if (t_1 <= 2d+111) then
        tmp = x * 2.0d0
    else
        tmp = t_1
    end if
    code = tmp
end function
assert x < y && y < z && z < t && t < a && a < b;
assert x < y && y < z && z < t && t < a && a < b;
public static double code(double x, double y, double z, double t, double a, double b) {
	double t_1 = (a * 27.0) * b;
	double tmp;
	if (t_1 <= -4e+100) {
		tmp = 27.0 * (a * b);
	} else if (t_1 <= 2e-222) {
		tmp = t * (z * (y * -9.0));
	} else if (t_1 <= 2e+111) {
		tmp = x * 2.0;
	} else {
		tmp = t_1;
	}
	return tmp;
}
[x, y, z, t, a, b] = sort([x, y, z, t, a, b])
[x, y, z, t, a, b] = sort([x, y, z, t, a, b])
def code(x, y, z, t, a, b):
	t_1 = (a * 27.0) * b
	tmp = 0
	if t_1 <= -4e+100:
		tmp = 27.0 * (a * b)
	elif t_1 <= 2e-222:
		tmp = t * (z * (y * -9.0))
	elif t_1 <= 2e+111:
		tmp = x * 2.0
	else:
		tmp = t_1
	return tmp
x, y, z, t, a, b = sort([x, y, z, t, a, b])
x, y, z, t, a, b = sort([x, y, z, t, a, b])
function code(x, y, z, t, a, b)
	t_1 = Float64(Float64(a * 27.0) * b)
	tmp = 0.0
	if (t_1 <= -4e+100)
		tmp = Float64(27.0 * Float64(a * b));
	elseif (t_1 <= 2e-222)
		tmp = Float64(t * Float64(z * Float64(y * -9.0)));
	elseif (t_1 <= 2e+111)
		tmp = Float64(x * 2.0);
	else
		tmp = t_1;
	end
	return tmp
end
x, y, z, t, a, b = num2cell(sort([x, y, z, t, a, b])){:}
x, y, z, t, a, b = num2cell(sort([x, y, z, t, a, b])){:}
function tmp_2 = code(x, y, z, t, a, b)
	t_1 = (a * 27.0) * b;
	tmp = 0.0;
	if (t_1 <= -4e+100)
		tmp = 27.0 * (a * b);
	elseif (t_1 <= 2e-222)
		tmp = t * (z * (y * -9.0));
	elseif (t_1 <= 2e+111)
		tmp = x * 2.0;
	else
		tmp = t_1;
	end
	tmp_2 = tmp;
end
NOTE: x, y, z, t, a, and b should be sorted in increasing order before calling this function.
NOTE: x, y, z, t, a, and b should be sorted in increasing order before calling this function.
code[x_, y_, z_, t_, a_, b_] := Block[{t$95$1 = N[(N[(a * 27.0), $MachinePrecision] * b), $MachinePrecision]}, If[LessEqual[t$95$1, -4e+100], N[(27.0 * N[(a * b), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$1, 2e-222], N[(t * N[(z * N[(y * -9.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$1, 2e+111], N[(x * 2.0), $MachinePrecision], t$95$1]]]]
\begin{array}{l}
[x, y, z, t, a, b] = \mathsf{sort}([x, y, z, t, a, b])\\\\
[x, y, z, t, a, b] = \mathsf{sort}([x, y, z, t, a, b])\\
\\
\begin{array}{l}
t_1 := \left(a \cdot 27\right) \cdot b\\
\mathbf{if}\;t\_1 \leq -4 \cdot 10^{+100}:\\
\;\;\;\;27 \cdot \left(a \cdot b\right)\\

\mathbf{elif}\;t\_1 \leq 2 \cdot 10^{-222}:\\
\;\;\;\;t \cdot \left(z \cdot \left(y \cdot -9\right)\right)\\

\mathbf{elif}\;t\_1 \leq 2 \cdot 10^{+111}:\\
\;\;\;\;x \cdot 2\\

\mathbf{else}:\\
\;\;\;\;t\_1\\


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if (*.f64 (*.f64 a #s(literal 27 binary64)) b) < -4.00000000000000006e100

    1. Initial program 97.4%

      \[\left(x \cdot 2 - \left(\left(y \cdot 9\right) \cdot z\right) \cdot t\right) + \left(a \cdot 27\right) \cdot b \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. sub-negN/A

        \[\leadsto \left(x \cdot 2 + \left(\mathsf{neg}\left(\left(\left(y \cdot 9\right) \cdot z\right) \cdot t\right)\right)\right) + \color{blue}{\left(a \cdot 27\right)} \cdot b \]
      2. +-commutativeN/A

        \[\leadsto \left(\left(\mathsf{neg}\left(\left(\left(y \cdot 9\right) \cdot z\right) \cdot t\right)\right) + x \cdot 2\right) + \color{blue}{\left(a \cdot 27\right)} \cdot b \]
      3. associate-+l+N/A

        \[\leadsto \left(\mathsf{neg}\left(\left(\left(y \cdot 9\right) \cdot z\right) \cdot t\right)\right) + \color{blue}{\left(x \cdot 2 + \left(a \cdot 27\right) \cdot b\right)} \]
      4. distribute-lft-neg-inN/A

        \[\leadsto \left(\mathsf{neg}\left(\left(y \cdot 9\right) \cdot z\right)\right) \cdot t + \left(\color{blue}{x \cdot 2} + \left(a \cdot 27\right) \cdot b\right) \]
      5. +-commutativeN/A

        \[\leadsto \left(\mathsf{neg}\left(\left(y \cdot 9\right) \cdot z\right)\right) \cdot t + \left(\left(a \cdot 27\right) \cdot b + \color{blue}{x \cdot 2}\right) \]
      6. accelerator-lowering-fma.f64N/A

        \[\leadsto \mathsf{fma.f64}\left(\left(\mathsf{neg}\left(\left(y \cdot 9\right) \cdot z\right)\right), \color{blue}{t}, \left(\left(a \cdot 27\right) \cdot b + x \cdot 2\right)\right) \]
      7. associate-*l*N/A

        \[\leadsto \mathsf{fma.f64}\left(\left(\mathsf{neg}\left(y \cdot \left(9 \cdot z\right)\right)\right), t, \left(\left(a \cdot 27\right) \cdot b + x \cdot 2\right)\right) \]
      8. distribute-rgt-neg-inN/A

        \[\leadsto \mathsf{fma.f64}\left(\left(y \cdot \left(\mathsf{neg}\left(9 \cdot z\right)\right)\right), t, \left(\left(a \cdot 27\right) \cdot b + x \cdot 2\right)\right) \]
      9. *-lowering-*.f64N/A

        \[\leadsto \mathsf{fma.f64}\left(\mathsf{*.f64}\left(y, \left(\mathsf{neg}\left(9 \cdot z\right)\right)\right), t, \left(\left(a \cdot 27\right) \cdot b + x \cdot 2\right)\right) \]
      10. *-commutativeN/A

        \[\leadsto \mathsf{fma.f64}\left(\mathsf{*.f64}\left(y, \left(\mathsf{neg}\left(z \cdot 9\right)\right)\right), t, \left(\left(a \cdot 27\right) \cdot b + x \cdot 2\right)\right) \]
      11. distribute-rgt-neg-inN/A

        \[\leadsto \mathsf{fma.f64}\left(\mathsf{*.f64}\left(y, \left(z \cdot \left(\mathsf{neg}\left(9\right)\right)\right)\right), t, \left(\left(a \cdot 27\right) \cdot b + x \cdot 2\right)\right) \]
      12. *-lowering-*.f64N/A

        \[\leadsto \mathsf{fma.f64}\left(\mathsf{*.f64}\left(y, \mathsf{*.f64}\left(z, \left(\mathsf{neg}\left(9\right)\right)\right)\right), t, \left(\left(a \cdot 27\right) \cdot b + x \cdot 2\right)\right) \]
      13. metadata-evalN/A

        \[\leadsto \mathsf{fma.f64}\left(\mathsf{*.f64}\left(y, \mathsf{*.f64}\left(z, -9\right)\right), t, \left(\left(a \cdot 27\right) \cdot b + x \cdot 2\right)\right) \]
      14. associate-*l*N/A

        \[\leadsto \mathsf{fma.f64}\left(\mathsf{*.f64}\left(y, \mathsf{*.f64}\left(z, -9\right)\right), t, \left(a \cdot \left(27 \cdot b\right) + x \cdot 2\right)\right) \]
      15. accelerator-lowering-fma.f64N/A

        \[\leadsto \mathsf{fma.f64}\left(\mathsf{*.f64}\left(y, \mathsf{*.f64}\left(z, -9\right)\right), t, \mathsf{fma.f64}\left(a, \left(27 \cdot b\right), \left(x \cdot 2\right)\right)\right) \]
      16. *-lowering-*.f64N/A

        \[\leadsto \mathsf{fma.f64}\left(\mathsf{*.f64}\left(y, \mathsf{*.f64}\left(z, -9\right)\right), t, \mathsf{fma.f64}\left(a, \mathsf{*.f64}\left(27, b\right), \left(x \cdot 2\right)\right)\right) \]
      17. *-lowering-*.f6497.4%

        \[\leadsto \mathsf{fma.f64}\left(\mathsf{*.f64}\left(y, \mathsf{*.f64}\left(z, -9\right)\right), t, \mathsf{fma.f64}\left(a, \mathsf{*.f64}\left(27, b\right), \mathsf{*.f64}\left(x, 2\right)\right)\right) \]
    4. Applied egg-rr97.4%

      \[\leadsto \color{blue}{\mathsf{fma}\left(y \cdot \left(z \cdot -9\right), t, \mathsf{fma}\left(a, 27 \cdot b, x \cdot 2\right)\right)} \]
    5. Taylor expanded in a around inf

      \[\leadsto \color{blue}{27 \cdot \left(a \cdot b\right)} \]
    6. Step-by-step derivation
      1. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(27, \color{blue}{\left(a \cdot b\right)}\right) \]
      2. *-lowering-*.f6485.4%

        \[\leadsto \mathsf{*.f64}\left(27, \mathsf{*.f64}\left(a, \color{blue}{b}\right)\right) \]
    7. Simplified85.4%

      \[\leadsto \color{blue}{27 \cdot \left(a \cdot b\right)} \]

    if -4.00000000000000006e100 < (*.f64 (*.f64 a #s(literal 27 binary64)) b) < 2.0000000000000001e-222

    1. Initial program 97.1%

      \[\left(x \cdot 2 - \left(\left(y \cdot 9\right) \cdot z\right) \cdot t\right) + \left(a \cdot 27\right) \cdot b \]
    2. Add Preprocessing
    3. Taylor expanded in y around inf

      \[\leadsto \color{blue}{-9 \cdot \left(t \cdot \left(y \cdot z\right)\right)} \]
    4. Step-by-step derivation
      1. +-lft-identityN/A

        \[\leadsto 0 + \color{blue}{-9 \cdot \left(t \cdot \left(y \cdot z\right)\right)} \]
      2. +-commutativeN/A

        \[\leadsto -9 \cdot \left(t \cdot \left(y \cdot z\right)\right) + \color{blue}{0} \]
      3. *-commutativeN/A

        \[\leadsto \left(t \cdot \left(y \cdot z\right)\right) \cdot -9 + 0 \]
      4. associate-*l*N/A

        \[\leadsto t \cdot \left(\left(y \cdot z\right) \cdot -9\right) + 0 \]
      5. *-commutativeN/A

        \[\leadsto t \cdot \left(-9 \cdot \left(y \cdot z\right)\right) + 0 \]
      6. accelerator-lowering-fma.f64N/A

        \[\leadsto \mathsf{fma.f64}\left(t, \color{blue}{\left(-9 \cdot \left(y \cdot z\right)\right)}, 0\right) \]
      7. +-lft-identityN/A

        \[\leadsto \mathsf{fma.f64}\left(t, \left(0 + \color{blue}{-9 \cdot \left(y \cdot z\right)}\right), 0\right) \]
      8. +-commutativeN/A

        \[\leadsto \mathsf{fma.f64}\left(t, \left(-9 \cdot \left(y \cdot z\right) + \color{blue}{0}\right), 0\right) \]
      9. *-commutativeN/A

        \[\leadsto \mathsf{fma.f64}\left(t, \left(\left(y \cdot z\right) \cdot -9 + 0\right), 0\right) \]
      10. accelerator-lowering-fma.f64N/A

        \[\leadsto \mathsf{fma.f64}\left(t, \mathsf{fma.f64}\left(\left(y \cdot z\right), \color{blue}{-9}, 0\right), 0\right) \]
      11. *-lowering-*.f6452.0%

        \[\leadsto \mathsf{fma.f64}\left(t, \mathsf{fma.f64}\left(\mathsf{*.f64}\left(y, z\right), -9, 0\right), 0\right) \]
    5. Simplified52.0%

      \[\leadsto \color{blue}{\mathsf{fma}\left(t, \mathsf{fma}\left(y \cdot z, -9, 0\right), 0\right)} \]
    6. Step-by-step derivation
      1. +-rgt-identityN/A

        \[\leadsto t \cdot \left(\left(y \cdot z\right) \cdot -9\right) + 0 \]
      2. *-commutativeN/A

        \[\leadsto \left(\left(y \cdot z\right) \cdot -9\right) \cdot t + 0 \]
      3. associate-*r*N/A

        \[\leadsto \left(y \cdot \left(z \cdot -9\right)\right) \cdot t + 0 \]
      4. +-rgt-identityN/A

        \[\leadsto \left(y \cdot \left(z \cdot -9\right)\right) \cdot \color{blue}{t} \]
      5. *-commutativeN/A

        \[\leadsto \left(\left(z \cdot -9\right) \cdot y\right) \cdot t \]
      6. associate-*l*N/A

        \[\leadsto \left(z \cdot -9\right) \cdot \color{blue}{\left(y \cdot t\right)} \]
      7. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\left(z \cdot -9\right), \color{blue}{\left(y \cdot t\right)}\right) \]
      8. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(z, -9\right), \left(\color{blue}{y} \cdot t\right)\right) \]
      9. *-lowering-*.f6448.8%

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(z, -9\right), \mathsf{*.f64}\left(y, \color{blue}{t}\right)\right) \]
    7. Applied egg-rr48.8%

      \[\leadsto \color{blue}{\left(z \cdot -9\right) \cdot \left(y \cdot t\right)} \]
    8. Step-by-step derivation
      1. associate-*r*N/A

        \[\leadsto \left(\left(z \cdot -9\right) \cdot y\right) \cdot \color{blue}{t} \]
      2. *-commutativeN/A

        \[\leadsto \left(\left(-9 \cdot z\right) \cdot y\right) \cdot t \]
      3. associate-*r*N/A

        \[\leadsto \left(-9 \cdot \left(z \cdot y\right)\right) \cdot t \]
      4. *-commutativeN/A

        \[\leadsto \left(-9 \cdot \left(y \cdot z\right)\right) \cdot t \]
      5. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\left(-9 \cdot \left(y \cdot z\right)\right), \color{blue}{t}\right) \]
      6. *-commutativeN/A

        \[\leadsto \mathsf{*.f64}\left(\left(-9 \cdot \left(z \cdot y\right)\right), t\right) \]
      7. associate-*r*N/A

        \[\leadsto \mathsf{*.f64}\left(\left(\left(-9 \cdot z\right) \cdot y\right), t\right) \]
      8. *-commutativeN/A

        \[\leadsto \mathsf{*.f64}\left(\left(\left(z \cdot -9\right) \cdot y\right), t\right) \]
      9. associate-*l*N/A

        \[\leadsto \mathsf{*.f64}\left(\left(z \cdot \left(-9 \cdot y\right)\right), t\right) \]
      10. *-commutativeN/A

        \[\leadsto \mathsf{*.f64}\left(\left(z \cdot \left(y \cdot -9\right)\right), t\right) \]
      11. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(z, \left(y \cdot -9\right)\right), t\right) \]
      12. *-lowering-*.f6452.1%

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(z, \mathsf{*.f64}\left(y, -9\right)\right), t\right) \]
    9. Applied egg-rr52.1%

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

    if 2.0000000000000001e-222 < (*.f64 (*.f64 a #s(literal 27 binary64)) b) < 1.99999999999999991e111

    1. Initial program 98.1%

      \[\left(x \cdot 2 - \left(\left(y \cdot 9\right) \cdot z\right) \cdot t\right) + \left(a \cdot 27\right) \cdot b \]
    2. Add Preprocessing
    3. Taylor expanded in x around inf

      \[\leadsto \color{blue}{2 \cdot x} \]
    4. Step-by-step derivation
      1. +-rgt-identityN/A

        \[\leadsto 2 \cdot x + \color{blue}{0} \]
      2. accelerator-lowering-fma.f6452.9%

        \[\leadsto \mathsf{fma.f64}\left(2, \color{blue}{x}, 0\right) \]
    5. Simplified52.9%

      \[\leadsto \color{blue}{\mathsf{fma}\left(2, x, 0\right)} \]
    6. Step-by-step derivation
      1. +-rgt-identityN/A

        \[\leadsto 2 \cdot \color{blue}{x} \]
      2. *-commutativeN/A

        \[\leadsto x \cdot \color{blue}{2} \]
      3. *-lowering-*.f6452.9%

        \[\leadsto \mathsf{*.f64}\left(x, \color{blue}{2}\right) \]
    7. Applied egg-rr52.9%

      \[\leadsto \color{blue}{x \cdot 2} \]

    if 1.99999999999999991e111 < (*.f64 (*.f64 a #s(literal 27 binary64)) b)

    1. Initial program 88.1%

      \[\left(x \cdot 2 - \left(\left(y \cdot 9\right) \cdot z\right) \cdot t\right) + \left(a \cdot 27\right) \cdot b \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. sub-negN/A

        \[\leadsto \left(x \cdot 2 + \left(\mathsf{neg}\left(\left(\left(y \cdot 9\right) \cdot z\right) \cdot t\right)\right)\right) + \color{blue}{\left(a \cdot 27\right)} \cdot b \]
      2. +-commutativeN/A

        \[\leadsto \left(\left(\mathsf{neg}\left(\left(\left(y \cdot 9\right) \cdot z\right) \cdot t\right)\right) + x \cdot 2\right) + \color{blue}{\left(a \cdot 27\right)} \cdot b \]
      3. associate-+l+N/A

        \[\leadsto \left(\mathsf{neg}\left(\left(\left(y \cdot 9\right) \cdot z\right) \cdot t\right)\right) + \color{blue}{\left(x \cdot 2 + \left(a \cdot 27\right) \cdot b\right)} \]
      4. distribute-lft-neg-inN/A

        \[\leadsto \left(\mathsf{neg}\left(\left(y \cdot 9\right) \cdot z\right)\right) \cdot t + \left(\color{blue}{x \cdot 2} + \left(a \cdot 27\right) \cdot b\right) \]
      5. +-commutativeN/A

        \[\leadsto \left(\mathsf{neg}\left(\left(y \cdot 9\right) \cdot z\right)\right) \cdot t + \left(\left(a \cdot 27\right) \cdot b + \color{blue}{x \cdot 2}\right) \]
      6. accelerator-lowering-fma.f64N/A

        \[\leadsto \mathsf{fma.f64}\left(\left(\mathsf{neg}\left(\left(y \cdot 9\right) \cdot z\right)\right), \color{blue}{t}, \left(\left(a \cdot 27\right) \cdot b + x \cdot 2\right)\right) \]
      7. associate-*l*N/A

        \[\leadsto \mathsf{fma.f64}\left(\left(\mathsf{neg}\left(y \cdot \left(9 \cdot z\right)\right)\right), t, \left(\left(a \cdot 27\right) \cdot b + x \cdot 2\right)\right) \]
      8. distribute-rgt-neg-inN/A

        \[\leadsto \mathsf{fma.f64}\left(\left(y \cdot \left(\mathsf{neg}\left(9 \cdot z\right)\right)\right), t, \left(\left(a \cdot 27\right) \cdot b + x \cdot 2\right)\right) \]
      9. *-lowering-*.f64N/A

        \[\leadsto \mathsf{fma.f64}\left(\mathsf{*.f64}\left(y, \left(\mathsf{neg}\left(9 \cdot z\right)\right)\right), t, \left(\left(a \cdot 27\right) \cdot b + x \cdot 2\right)\right) \]
      10. *-commutativeN/A

        \[\leadsto \mathsf{fma.f64}\left(\mathsf{*.f64}\left(y, \left(\mathsf{neg}\left(z \cdot 9\right)\right)\right), t, \left(\left(a \cdot 27\right) \cdot b + x \cdot 2\right)\right) \]
      11. distribute-rgt-neg-inN/A

        \[\leadsto \mathsf{fma.f64}\left(\mathsf{*.f64}\left(y, \left(z \cdot \left(\mathsf{neg}\left(9\right)\right)\right)\right), t, \left(\left(a \cdot 27\right) \cdot b + x \cdot 2\right)\right) \]
      12. *-lowering-*.f64N/A

        \[\leadsto \mathsf{fma.f64}\left(\mathsf{*.f64}\left(y, \mathsf{*.f64}\left(z, \left(\mathsf{neg}\left(9\right)\right)\right)\right), t, \left(\left(a \cdot 27\right) \cdot b + x \cdot 2\right)\right) \]
      13. metadata-evalN/A

        \[\leadsto \mathsf{fma.f64}\left(\mathsf{*.f64}\left(y, \mathsf{*.f64}\left(z, -9\right)\right), t, \left(\left(a \cdot 27\right) \cdot b + x \cdot 2\right)\right) \]
      14. associate-*l*N/A

        \[\leadsto \mathsf{fma.f64}\left(\mathsf{*.f64}\left(y, \mathsf{*.f64}\left(z, -9\right)\right), t, \left(a \cdot \left(27 \cdot b\right) + x \cdot 2\right)\right) \]
      15. accelerator-lowering-fma.f64N/A

        \[\leadsto \mathsf{fma.f64}\left(\mathsf{*.f64}\left(y, \mathsf{*.f64}\left(z, -9\right)\right), t, \mathsf{fma.f64}\left(a, \left(27 \cdot b\right), \left(x \cdot 2\right)\right)\right) \]
      16. *-lowering-*.f64N/A

        \[\leadsto \mathsf{fma.f64}\left(\mathsf{*.f64}\left(y, \mathsf{*.f64}\left(z, -9\right)\right), t, \mathsf{fma.f64}\left(a, \mathsf{*.f64}\left(27, b\right), \left(x \cdot 2\right)\right)\right) \]
      17. *-lowering-*.f6488.0%

        \[\leadsto \mathsf{fma.f64}\left(\mathsf{*.f64}\left(y, \mathsf{*.f64}\left(z, -9\right)\right), t, \mathsf{fma.f64}\left(a, \mathsf{*.f64}\left(27, b\right), \mathsf{*.f64}\left(x, 2\right)\right)\right) \]
    4. Applied egg-rr88.0%

      \[\leadsto \color{blue}{\mathsf{fma}\left(y \cdot \left(z \cdot -9\right), t, \mathsf{fma}\left(a, 27 \cdot b, x \cdot 2\right)\right)} \]
    5. Taylor expanded in a around inf

      \[\leadsto \color{blue}{27 \cdot \left(a \cdot b\right)} \]
    6. Step-by-step derivation
      1. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(27, \color{blue}{\left(a \cdot b\right)}\right) \]
      2. *-lowering-*.f6464.8%

        \[\leadsto \mathsf{*.f64}\left(27, \mathsf{*.f64}\left(a, \color{blue}{b}\right)\right) \]
    7. Simplified64.8%

      \[\leadsto \color{blue}{27 \cdot \left(a \cdot b\right)} \]
    8. Step-by-step derivation
      1. associate-*r*N/A

        \[\leadsto \left(27 \cdot a\right) \cdot \color{blue}{b} \]
      2. *-commutativeN/A

        \[\leadsto \left(a \cdot 27\right) \cdot b \]
      3. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\left(a \cdot 27\right), \color{blue}{b}\right) \]
      4. *-lowering-*.f6464.7%

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(a, 27\right), b\right) \]
    9. Applied egg-rr64.7%

      \[\leadsto \color{blue}{\left(a \cdot 27\right) \cdot b} \]
  3. Recombined 4 regimes into one program.
  4. Final simplification59.0%

    \[\leadsto \begin{array}{l} \mathbf{if}\;\left(a \cdot 27\right) \cdot b \leq -4 \cdot 10^{+100}:\\ \;\;\;\;27 \cdot \left(a \cdot b\right)\\ \mathbf{elif}\;\left(a \cdot 27\right) \cdot b \leq 2 \cdot 10^{-222}:\\ \;\;\;\;t \cdot \left(z \cdot \left(y \cdot -9\right)\right)\\ \mathbf{elif}\;\left(a \cdot 27\right) \cdot b \leq 2 \cdot 10^{+111}:\\ \;\;\;\;x \cdot 2\\ \mathbf{else}:\\ \;\;\;\;\left(a \cdot 27\right) \cdot b\\ \end{array} \]
  5. Add Preprocessing

Alternative 3: 52.4% accurate, 0.6× speedup?

\[\begin{array}{l} [x, y, z, t, a, b] = \mathsf{sort}([x, y, z, t, a, b])\\\\ [x, y, z, t, a, b] = \mathsf{sort}([x, y, z, t, a, b])\\ \\ \begin{array}{l} t_1 := \left(a \cdot 27\right) \cdot b\\ \mathbf{if}\;t\_1 \leq -4 \cdot 10^{+100}:\\ \;\;\;\;27 \cdot \left(a \cdot b\right)\\ \mathbf{elif}\;t\_1 \leq 2 \cdot 10^{-222}:\\ \;\;\;\;-9 \cdot \left(t \cdot \left(y \cdot z\right)\right)\\ \mathbf{elif}\;t\_1 \leq 2 \cdot 10^{+111}:\\ \;\;\;\;x \cdot 2\\ \mathbf{else}:\\ \;\;\;\;t\_1\\ \end{array} \end{array} \]
NOTE: x, y, z, t, a, and b should be sorted in increasing order before calling this function.
NOTE: x, y, z, t, a, and b should be sorted in increasing order before calling this function.
(FPCore (x y z t a b)
 :precision binary64
 (let* ((t_1 (* (* a 27.0) b)))
   (if (<= t_1 -4e+100)
     (* 27.0 (* a b))
     (if (<= t_1 2e-222)
       (* -9.0 (* t (* y z)))
       (if (<= t_1 2e+111) (* x 2.0) t_1)))))
assert(x < y && y < z && z < t && t < a && a < b);
assert(x < y && y < z && z < t && t < a && a < b);
double code(double x, double y, double z, double t, double a, double b) {
	double t_1 = (a * 27.0) * b;
	double tmp;
	if (t_1 <= -4e+100) {
		tmp = 27.0 * (a * b);
	} else if (t_1 <= 2e-222) {
		tmp = -9.0 * (t * (y * z));
	} else if (t_1 <= 2e+111) {
		tmp = x * 2.0;
	} else {
		tmp = t_1;
	}
	return tmp;
}
NOTE: x, y, z, t, a, and b should be sorted in increasing order before calling this function.
NOTE: x, y, z, t, a, and b should be sorted in increasing order before calling this function.
real(8) function code(x, y, z, t, a, b)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8), intent (in) :: t
    real(8), intent (in) :: a
    real(8), intent (in) :: b
    real(8) :: t_1
    real(8) :: tmp
    t_1 = (a * 27.0d0) * b
    if (t_1 <= (-4d+100)) then
        tmp = 27.0d0 * (a * b)
    else if (t_1 <= 2d-222) then
        tmp = (-9.0d0) * (t * (y * z))
    else if (t_1 <= 2d+111) then
        tmp = x * 2.0d0
    else
        tmp = t_1
    end if
    code = tmp
end function
assert x < y && y < z && z < t && t < a && a < b;
assert x < y && y < z && z < t && t < a && a < b;
public static double code(double x, double y, double z, double t, double a, double b) {
	double t_1 = (a * 27.0) * b;
	double tmp;
	if (t_1 <= -4e+100) {
		tmp = 27.0 * (a * b);
	} else if (t_1 <= 2e-222) {
		tmp = -9.0 * (t * (y * z));
	} else if (t_1 <= 2e+111) {
		tmp = x * 2.0;
	} else {
		tmp = t_1;
	}
	return tmp;
}
[x, y, z, t, a, b] = sort([x, y, z, t, a, b])
[x, y, z, t, a, b] = sort([x, y, z, t, a, b])
def code(x, y, z, t, a, b):
	t_1 = (a * 27.0) * b
	tmp = 0
	if t_1 <= -4e+100:
		tmp = 27.0 * (a * b)
	elif t_1 <= 2e-222:
		tmp = -9.0 * (t * (y * z))
	elif t_1 <= 2e+111:
		tmp = x * 2.0
	else:
		tmp = t_1
	return tmp
x, y, z, t, a, b = sort([x, y, z, t, a, b])
x, y, z, t, a, b = sort([x, y, z, t, a, b])
function code(x, y, z, t, a, b)
	t_1 = Float64(Float64(a * 27.0) * b)
	tmp = 0.0
	if (t_1 <= -4e+100)
		tmp = Float64(27.0 * Float64(a * b));
	elseif (t_1 <= 2e-222)
		tmp = Float64(-9.0 * Float64(t * Float64(y * z)));
	elseif (t_1 <= 2e+111)
		tmp = Float64(x * 2.0);
	else
		tmp = t_1;
	end
	return tmp
end
x, y, z, t, a, b = num2cell(sort([x, y, z, t, a, b])){:}
x, y, z, t, a, b = num2cell(sort([x, y, z, t, a, b])){:}
function tmp_2 = code(x, y, z, t, a, b)
	t_1 = (a * 27.0) * b;
	tmp = 0.0;
	if (t_1 <= -4e+100)
		tmp = 27.0 * (a * b);
	elseif (t_1 <= 2e-222)
		tmp = -9.0 * (t * (y * z));
	elseif (t_1 <= 2e+111)
		tmp = x * 2.0;
	else
		tmp = t_1;
	end
	tmp_2 = tmp;
end
NOTE: x, y, z, t, a, and b should be sorted in increasing order before calling this function.
NOTE: x, y, z, t, a, and b should be sorted in increasing order before calling this function.
code[x_, y_, z_, t_, a_, b_] := Block[{t$95$1 = N[(N[(a * 27.0), $MachinePrecision] * b), $MachinePrecision]}, If[LessEqual[t$95$1, -4e+100], N[(27.0 * N[(a * b), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$1, 2e-222], N[(-9.0 * N[(t * N[(y * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$1, 2e+111], N[(x * 2.0), $MachinePrecision], t$95$1]]]]
\begin{array}{l}
[x, y, z, t, a, b] = \mathsf{sort}([x, y, z, t, a, b])\\\\
[x, y, z, t, a, b] = \mathsf{sort}([x, y, z, t, a, b])\\
\\
\begin{array}{l}
t_1 := \left(a \cdot 27\right) \cdot b\\
\mathbf{if}\;t\_1 \leq -4 \cdot 10^{+100}:\\
\;\;\;\;27 \cdot \left(a \cdot b\right)\\

\mathbf{elif}\;t\_1 \leq 2 \cdot 10^{-222}:\\
\;\;\;\;-9 \cdot \left(t \cdot \left(y \cdot z\right)\right)\\

\mathbf{elif}\;t\_1 \leq 2 \cdot 10^{+111}:\\
\;\;\;\;x \cdot 2\\

\mathbf{else}:\\
\;\;\;\;t\_1\\


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if (*.f64 (*.f64 a #s(literal 27 binary64)) b) < -4.00000000000000006e100

    1. Initial program 97.4%

      \[\left(x \cdot 2 - \left(\left(y \cdot 9\right) \cdot z\right) \cdot t\right) + \left(a \cdot 27\right) \cdot b \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. sub-negN/A

        \[\leadsto \left(x \cdot 2 + \left(\mathsf{neg}\left(\left(\left(y \cdot 9\right) \cdot z\right) \cdot t\right)\right)\right) + \color{blue}{\left(a \cdot 27\right)} \cdot b \]
      2. +-commutativeN/A

        \[\leadsto \left(\left(\mathsf{neg}\left(\left(\left(y \cdot 9\right) \cdot z\right) \cdot t\right)\right) + x \cdot 2\right) + \color{blue}{\left(a \cdot 27\right)} \cdot b \]
      3. associate-+l+N/A

        \[\leadsto \left(\mathsf{neg}\left(\left(\left(y \cdot 9\right) \cdot z\right) \cdot t\right)\right) + \color{blue}{\left(x \cdot 2 + \left(a \cdot 27\right) \cdot b\right)} \]
      4. distribute-lft-neg-inN/A

        \[\leadsto \left(\mathsf{neg}\left(\left(y \cdot 9\right) \cdot z\right)\right) \cdot t + \left(\color{blue}{x \cdot 2} + \left(a \cdot 27\right) \cdot b\right) \]
      5. +-commutativeN/A

        \[\leadsto \left(\mathsf{neg}\left(\left(y \cdot 9\right) \cdot z\right)\right) \cdot t + \left(\left(a \cdot 27\right) \cdot b + \color{blue}{x \cdot 2}\right) \]
      6. accelerator-lowering-fma.f64N/A

        \[\leadsto \mathsf{fma.f64}\left(\left(\mathsf{neg}\left(\left(y \cdot 9\right) \cdot z\right)\right), \color{blue}{t}, \left(\left(a \cdot 27\right) \cdot b + x \cdot 2\right)\right) \]
      7. associate-*l*N/A

        \[\leadsto \mathsf{fma.f64}\left(\left(\mathsf{neg}\left(y \cdot \left(9 \cdot z\right)\right)\right), t, \left(\left(a \cdot 27\right) \cdot b + x \cdot 2\right)\right) \]
      8. distribute-rgt-neg-inN/A

        \[\leadsto \mathsf{fma.f64}\left(\left(y \cdot \left(\mathsf{neg}\left(9 \cdot z\right)\right)\right), t, \left(\left(a \cdot 27\right) \cdot b + x \cdot 2\right)\right) \]
      9. *-lowering-*.f64N/A

        \[\leadsto \mathsf{fma.f64}\left(\mathsf{*.f64}\left(y, \left(\mathsf{neg}\left(9 \cdot z\right)\right)\right), t, \left(\left(a \cdot 27\right) \cdot b + x \cdot 2\right)\right) \]
      10. *-commutativeN/A

        \[\leadsto \mathsf{fma.f64}\left(\mathsf{*.f64}\left(y, \left(\mathsf{neg}\left(z \cdot 9\right)\right)\right), t, \left(\left(a \cdot 27\right) \cdot b + x \cdot 2\right)\right) \]
      11. distribute-rgt-neg-inN/A

        \[\leadsto \mathsf{fma.f64}\left(\mathsf{*.f64}\left(y, \left(z \cdot \left(\mathsf{neg}\left(9\right)\right)\right)\right), t, \left(\left(a \cdot 27\right) \cdot b + x \cdot 2\right)\right) \]
      12. *-lowering-*.f64N/A

        \[\leadsto \mathsf{fma.f64}\left(\mathsf{*.f64}\left(y, \mathsf{*.f64}\left(z, \left(\mathsf{neg}\left(9\right)\right)\right)\right), t, \left(\left(a \cdot 27\right) \cdot b + x \cdot 2\right)\right) \]
      13. metadata-evalN/A

        \[\leadsto \mathsf{fma.f64}\left(\mathsf{*.f64}\left(y, \mathsf{*.f64}\left(z, -9\right)\right), t, \left(\left(a \cdot 27\right) \cdot b + x \cdot 2\right)\right) \]
      14. associate-*l*N/A

        \[\leadsto \mathsf{fma.f64}\left(\mathsf{*.f64}\left(y, \mathsf{*.f64}\left(z, -9\right)\right), t, \left(a \cdot \left(27 \cdot b\right) + x \cdot 2\right)\right) \]
      15. accelerator-lowering-fma.f64N/A

        \[\leadsto \mathsf{fma.f64}\left(\mathsf{*.f64}\left(y, \mathsf{*.f64}\left(z, -9\right)\right), t, \mathsf{fma.f64}\left(a, \left(27 \cdot b\right), \left(x \cdot 2\right)\right)\right) \]
      16. *-lowering-*.f64N/A

        \[\leadsto \mathsf{fma.f64}\left(\mathsf{*.f64}\left(y, \mathsf{*.f64}\left(z, -9\right)\right), t, \mathsf{fma.f64}\left(a, \mathsf{*.f64}\left(27, b\right), \left(x \cdot 2\right)\right)\right) \]
      17. *-lowering-*.f6497.4%

        \[\leadsto \mathsf{fma.f64}\left(\mathsf{*.f64}\left(y, \mathsf{*.f64}\left(z, -9\right)\right), t, \mathsf{fma.f64}\left(a, \mathsf{*.f64}\left(27, b\right), \mathsf{*.f64}\left(x, 2\right)\right)\right) \]
    4. Applied egg-rr97.4%

      \[\leadsto \color{blue}{\mathsf{fma}\left(y \cdot \left(z \cdot -9\right), t, \mathsf{fma}\left(a, 27 \cdot b, x \cdot 2\right)\right)} \]
    5. Taylor expanded in a around inf

      \[\leadsto \color{blue}{27 \cdot \left(a \cdot b\right)} \]
    6. Step-by-step derivation
      1. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(27, \color{blue}{\left(a \cdot b\right)}\right) \]
      2. *-lowering-*.f6485.4%

        \[\leadsto \mathsf{*.f64}\left(27, \mathsf{*.f64}\left(a, \color{blue}{b}\right)\right) \]
    7. Simplified85.4%

      \[\leadsto \color{blue}{27 \cdot \left(a \cdot b\right)} \]

    if -4.00000000000000006e100 < (*.f64 (*.f64 a #s(literal 27 binary64)) b) < 2.0000000000000001e-222

    1. Initial program 97.1%

      \[\left(x \cdot 2 - \left(\left(y \cdot 9\right) \cdot z\right) \cdot t\right) + \left(a \cdot 27\right) \cdot b \]
    2. Add Preprocessing
    3. Taylor expanded in y around inf

      \[\leadsto \color{blue}{-9 \cdot \left(t \cdot \left(y \cdot z\right)\right)} \]
    4. Step-by-step derivation
      1. +-lft-identityN/A

        \[\leadsto 0 + \color{blue}{-9 \cdot \left(t \cdot \left(y \cdot z\right)\right)} \]
      2. +-commutativeN/A

        \[\leadsto -9 \cdot \left(t \cdot \left(y \cdot z\right)\right) + \color{blue}{0} \]
      3. *-commutativeN/A

        \[\leadsto \left(t \cdot \left(y \cdot z\right)\right) \cdot -9 + 0 \]
      4. associate-*l*N/A

        \[\leadsto t \cdot \left(\left(y \cdot z\right) \cdot -9\right) + 0 \]
      5. *-commutativeN/A

        \[\leadsto t \cdot \left(-9 \cdot \left(y \cdot z\right)\right) + 0 \]
      6. accelerator-lowering-fma.f64N/A

        \[\leadsto \mathsf{fma.f64}\left(t, \color{blue}{\left(-9 \cdot \left(y \cdot z\right)\right)}, 0\right) \]
      7. +-lft-identityN/A

        \[\leadsto \mathsf{fma.f64}\left(t, \left(0 + \color{blue}{-9 \cdot \left(y \cdot z\right)}\right), 0\right) \]
      8. +-commutativeN/A

        \[\leadsto \mathsf{fma.f64}\left(t, \left(-9 \cdot \left(y \cdot z\right) + \color{blue}{0}\right), 0\right) \]
      9. *-commutativeN/A

        \[\leadsto \mathsf{fma.f64}\left(t, \left(\left(y \cdot z\right) \cdot -9 + 0\right), 0\right) \]
      10. accelerator-lowering-fma.f64N/A

        \[\leadsto \mathsf{fma.f64}\left(t, \mathsf{fma.f64}\left(\left(y \cdot z\right), \color{blue}{-9}, 0\right), 0\right) \]
      11. *-lowering-*.f6452.0%

        \[\leadsto \mathsf{fma.f64}\left(t, \mathsf{fma.f64}\left(\mathsf{*.f64}\left(y, z\right), -9, 0\right), 0\right) \]
    5. Simplified52.0%

      \[\leadsto \color{blue}{\mathsf{fma}\left(t, \mathsf{fma}\left(y \cdot z, -9, 0\right), 0\right)} \]
    6. Step-by-step derivation
      1. +-rgt-identityN/A

        \[\leadsto t \cdot \left(\left(y \cdot z\right) \cdot -9\right) + 0 \]
      2. mul0-rgtN/A

        \[\leadsto t \cdot \left(\left(y \cdot z\right) \cdot -9\right) + t \cdot \color{blue}{0} \]
      3. distribute-lft-inN/A

        \[\leadsto t \cdot \color{blue}{\left(\left(y \cdot z\right) \cdot -9 + 0\right)} \]
      4. +-rgt-identityN/A

        \[\leadsto t \cdot \left(\left(y \cdot z\right) \cdot \color{blue}{-9}\right) \]
      5. associate-*r*N/A

        \[\leadsto \left(t \cdot \left(y \cdot z\right)\right) \cdot \color{blue}{-9} \]
      6. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\left(t \cdot \left(y \cdot z\right)\right), \color{blue}{-9}\right) \]
      7. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(t, \left(y \cdot z\right)\right), -9\right) \]
      8. *-lowering-*.f6452.0%

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(t, \mathsf{*.f64}\left(y, z\right)\right), -9\right) \]
    7. Applied egg-rr52.0%

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

    if 2.0000000000000001e-222 < (*.f64 (*.f64 a #s(literal 27 binary64)) b) < 1.99999999999999991e111

    1. Initial program 98.1%

      \[\left(x \cdot 2 - \left(\left(y \cdot 9\right) \cdot z\right) \cdot t\right) + \left(a \cdot 27\right) \cdot b \]
    2. Add Preprocessing
    3. Taylor expanded in x around inf

      \[\leadsto \color{blue}{2 \cdot x} \]
    4. Step-by-step derivation
      1. +-rgt-identityN/A

        \[\leadsto 2 \cdot x + \color{blue}{0} \]
      2. accelerator-lowering-fma.f6452.9%

        \[\leadsto \mathsf{fma.f64}\left(2, \color{blue}{x}, 0\right) \]
    5. Simplified52.9%

      \[\leadsto \color{blue}{\mathsf{fma}\left(2, x, 0\right)} \]
    6. Step-by-step derivation
      1. +-rgt-identityN/A

        \[\leadsto 2 \cdot \color{blue}{x} \]
      2. *-commutativeN/A

        \[\leadsto x \cdot \color{blue}{2} \]
      3. *-lowering-*.f6452.9%

        \[\leadsto \mathsf{*.f64}\left(x, \color{blue}{2}\right) \]
    7. Applied egg-rr52.9%

      \[\leadsto \color{blue}{x \cdot 2} \]

    if 1.99999999999999991e111 < (*.f64 (*.f64 a #s(literal 27 binary64)) b)

    1. Initial program 88.1%

      \[\left(x \cdot 2 - \left(\left(y \cdot 9\right) \cdot z\right) \cdot t\right) + \left(a \cdot 27\right) \cdot b \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. sub-negN/A

        \[\leadsto \left(x \cdot 2 + \left(\mathsf{neg}\left(\left(\left(y \cdot 9\right) \cdot z\right) \cdot t\right)\right)\right) + \color{blue}{\left(a \cdot 27\right)} \cdot b \]
      2. +-commutativeN/A

        \[\leadsto \left(\left(\mathsf{neg}\left(\left(\left(y \cdot 9\right) \cdot z\right) \cdot t\right)\right) + x \cdot 2\right) + \color{blue}{\left(a \cdot 27\right)} \cdot b \]
      3. associate-+l+N/A

        \[\leadsto \left(\mathsf{neg}\left(\left(\left(y \cdot 9\right) \cdot z\right) \cdot t\right)\right) + \color{blue}{\left(x \cdot 2 + \left(a \cdot 27\right) \cdot b\right)} \]
      4. distribute-lft-neg-inN/A

        \[\leadsto \left(\mathsf{neg}\left(\left(y \cdot 9\right) \cdot z\right)\right) \cdot t + \left(\color{blue}{x \cdot 2} + \left(a \cdot 27\right) \cdot b\right) \]
      5. +-commutativeN/A

        \[\leadsto \left(\mathsf{neg}\left(\left(y \cdot 9\right) \cdot z\right)\right) \cdot t + \left(\left(a \cdot 27\right) \cdot b + \color{blue}{x \cdot 2}\right) \]
      6. accelerator-lowering-fma.f64N/A

        \[\leadsto \mathsf{fma.f64}\left(\left(\mathsf{neg}\left(\left(y \cdot 9\right) \cdot z\right)\right), \color{blue}{t}, \left(\left(a \cdot 27\right) \cdot b + x \cdot 2\right)\right) \]
      7. associate-*l*N/A

        \[\leadsto \mathsf{fma.f64}\left(\left(\mathsf{neg}\left(y \cdot \left(9 \cdot z\right)\right)\right), t, \left(\left(a \cdot 27\right) \cdot b + x \cdot 2\right)\right) \]
      8. distribute-rgt-neg-inN/A

        \[\leadsto \mathsf{fma.f64}\left(\left(y \cdot \left(\mathsf{neg}\left(9 \cdot z\right)\right)\right), t, \left(\left(a \cdot 27\right) \cdot b + x \cdot 2\right)\right) \]
      9. *-lowering-*.f64N/A

        \[\leadsto \mathsf{fma.f64}\left(\mathsf{*.f64}\left(y, \left(\mathsf{neg}\left(9 \cdot z\right)\right)\right), t, \left(\left(a \cdot 27\right) \cdot b + x \cdot 2\right)\right) \]
      10. *-commutativeN/A

        \[\leadsto \mathsf{fma.f64}\left(\mathsf{*.f64}\left(y, \left(\mathsf{neg}\left(z \cdot 9\right)\right)\right), t, \left(\left(a \cdot 27\right) \cdot b + x \cdot 2\right)\right) \]
      11. distribute-rgt-neg-inN/A

        \[\leadsto \mathsf{fma.f64}\left(\mathsf{*.f64}\left(y, \left(z \cdot \left(\mathsf{neg}\left(9\right)\right)\right)\right), t, \left(\left(a \cdot 27\right) \cdot b + x \cdot 2\right)\right) \]
      12. *-lowering-*.f64N/A

        \[\leadsto \mathsf{fma.f64}\left(\mathsf{*.f64}\left(y, \mathsf{*.f64}\left(z, \left(\mathsf{neg}\left(9\right)\right)\right)\right), t, \left(\left(a \cdot 27\right) \cdot b + x \cdot 2\right)\right) \]
      13. metadata-evalN/A

        \[\leadsto \mathsf{fma.f64}\left(\mathsf{*.f64}\left(y, \mathsf{*.f64}\left(z, -9\right)\right), t, \left(\left(a \cdot 27\right) \cdot b + x \cdot 2\right)\right) \]
      14. associate-*l*N/A

        \[\leadsto \mathsf{fma.f64}\left(\mathsf{*.f64}\left(y, \mathsf{*.f64}\left(z, -9\right)\right), t, \left(a \cdot \left(27 \cdot b\right) + x \cdot 2\right)\right) \]
      15. accelerator-lowering-fma.f64N/A

        \[\leadsto \mathsf{fma.f64}\left(\mathsf{*.f64}\left(y, \mathsf{*.f64}\left(z, -9\right)\right), t, \mathsf{fma.f64}\left(a, \left(27 \cdot b\right), \left(x \cdot 2\right)\right)\right) \]
      16. *-lowering-*.f64N/A

        \[\leadsto \mathsf{fma.f64}\left(\mathsf{*.f64}\left(y, \mathsf{*.f64}\left(z, -9\right)\right), t, \mathsf{fma.f64}\left(a, \mathsf{*.f64}\left(27, b\right), \left(x \cdot 2\right)\right)\right) \]
      17. *-lowering-*.f6488.0%

        \[\leadsto \mathsf{fma.f64}\left(\mathsf{*.f64}\left(y, \mathsf{*.f64}\left(z, -9\right)\right), t, \mathsf{fma.f64}\left(a, \mathsf{*.f64}\left(27, b\right), \mathsf{*.f64}\left(x, 2\right)\right)\right) \]
    4. Applied egg-rr88.0%

      \[\leadsto \color{blue}{\mathsf{fma}\left(y \cdot \left(z \cdot -9\right), t, \mathsf{fma}\left(a, 27 \cdot b, x \cdot 2\right)\right)} \]
    5. Taylor expanded in a around inf

      \[\leadsto \color{blue}{27 \cdot \left(a \cdot b\right)} \]
    6. Step-by-step derivation
      1. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(27, \color{blue}{\left(a \cdot b\right)}\right) \]
      2. *-lowering-*.f6464.8%

        \[\leadsto \mathsf{*.f64}\left(27, \mathsf{*.f64}\left(a, \color{blue}{b}\right)\right) \]
    7. Simplified64.8%

      \[\leadsto \color{blue}{27 \cdot \left(a \cdot b\right)} \]
    8. Step-by-step derivation
      1. associate-*r*N/A

        \[\leadsto \left(27 \cdot a\right) \cdot \color{blue}{b} \]
      2. *-commutativeN/A

        \[\leadsto \left(a \cdot 27\right) \cdot b \]
      3. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\left(a \cdot 27\right), \color{blue}{b}\right) \]
      4. *-lowering-*.f6464.7%

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(a, 27\right), b\right) \]
    9. Applied egg-rr64.7%

      \[\leadsto \color{blue}{\left(a \cdot 27\right) \cdot b} \]
  3. Recombined 4 regimes into one program.
  4. Final simplification58.9%

    \[\leadsto \begin{array}{l} \mathbf{if}\;\left(a \cdot 27\right) \cdot b \leq -4 \cdot 10^{+100}:\\ \;\;\;\;27 \cdot \left(a \cdot b\right)\\ \mathbf{elif}\;\left(a \cdot 27\right) \cdot b \leq 2 \cdot 10^{-222}:\\ \;\;\;\;-9 \cdot \left(t \cdot \left(y \cdot z\right)\right)\\ \mathbf{elif}\;\left(a \cdot 27\right) \cdot b \leq 2 \cdot 10^{+111}:\\ \;\;\;\;x \cdot 2\\ \mathbf{else}:\\ \;\;\;\;\left(a \cdot 27\right) \cdot b\\ \end{array} \]
  5. Add Preprocessing

Alternative 4: 84.2% accurate, 0.6× speedup?

\[\begin{array}{l} [x, y, z, t, a, b] = \mathsf{sort}([x, y, z, t, a, b])\\\\ [x, y, z, t, a, b] = \mathsf{sort}([x, y, z, t, a, b])\\ \\ \begin{array}{l} t_1 := \left(a \cdot 27\right) \cdot b\\ \mathbf{if}\;t\_1 \leq -1 \cdot 10^{+41}:\\ \;\;\;\;\mathsf{fma}\left(z \cdot \left(t \cdot -9\right), y, \mathsf{fma}\left(27, a \cdot b, 0\right)\right)\\ \mathbf{elif}\;t\_1 \leq 2 \cdot 10^{+89}:\\ \;\;\;\;\mathsf{fma}\left(y \cdot \left(z \cdot -9\right), t, x \cdot 2\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(27 \cdot b, a, z \cdot \left(t \cdot \left(y \cdot -9\right)\right)\right)\\ \end{array} \end{array} \]
NOTE: x, y, z, t, a, and b should be sorted in increasing order before calling this function.
NOTE: x, y, z, t, a, and b should be sorted in increasing order before calling this function.
(FPCore (x y z t a b)
 :precision binary64
 (let* ((t_1 (* (* a 27.0) b)))
   (if (<= t_1 -1e+41)
     (fma (* z (* t -9.0)) y (fma 27.0 (* a b) 0.0))
     (if (<= t_1 2e+89)
       (fma (* y (* z -9.0)) t (* x 2.0))
       (fma (* 27.0 b) a (* z (* t (* y -9.0))))))))
assert(x < y && y < z && z < t && t < a && a < b);
assert(x < y && y < z && z < t && t < a && a < b);
double code(double x, double y, double z, double t, double a, double b) {
	double t_1 = (a * 27.0) * b;
	double tmp;
	if (t_1 <= -1e+41) {
		tmp = fma((z * (t * -9.0)), y, fma(27.0, (a * b), 0.0));
	} else if (t_1 <= 2e+89) {
		tmp = fma((y * (z * -9.0)), t, (x * 2.0));
	} else {
		tmp = fma((27.0 * b), a, (z * (t * (y * -9.0))));
	}
	return tmp;
}
x, y, z, t, a, b = sort([x, y, z, t, a, b])
x, y, z, t, a, b = sort([x, y, z, t, a, b])
function code(x, y, z, t, a, b)
	t_1 = Float64(Float64(a * 27.0) * b)
	tmp = 0.0
	if (t_1 <= -1e+41)
		tmp = fma(Float64(z * Float64(t * -9.0)), y, fma(27.0, Float64(a * b), 0.0));
	elseif (t_1 <= 2e+89)
		tmp = fma(Float64(y * Float64(z * -9.0)), t, Float64(x * 2.0));
	else
		tmp = fma(Float64(27.0 * b), a, Float64(z * Float64(t * Float64(y * -9.0))));
	end
	return tmp
end
NOTE: x, y, z, t, a, and b should be sorted in increasing order before calling this function.
NOTE: x, y, z, t, a, and b should be sorted in increasing order before calling this function.
code[x_, y_, z_, t_, a_, b_] := Block[{t$95$1 = N[(N[(a * 27.0), $MachinePrecision] * b), $MachinePrecision]}, If[LessEqual[t$95$1, -1e+41], N[(N[(z * N[(t * -9.0), $MachinePrecision]), $MachinePrecision] * y + N[(27.0 * N[(a * b), $MachinePrecision] + 0.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$1, 2e+89], N[(N[(y * N[(z * -9.0), $MachinePrecision]), $MachinePrecision] * t + N[(x * 2.0), $MachinePrecision]), $MachinePrecision], N[(N[(27.0 * b), $MachinePrecision] * a + N[(z * N[(t * N[(y * -9.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
[x, y, z, t, a, b] = \mathsf{sort}([x, y, z, t, a, b])\\\\
[x, y, z, t, a, b] = \mathsf{sort}([x, y, z, t, a, b])\\
\\
\begin{array}{l}
t_1 := \left(a \cdot 27\right) \cdot b\\
\mathbf{if}\;t\_1 \leq -1 \cdot 10^{+41}:\\
\;\;\;\;\mathsf{fma}\left(z \cdot \left(t \cdot -9\right), y, \mathsf{fma}\left(27, a \cdot b, 0\right)\right)\\

\mathbf{elif}\;t\_1 \leq 2 \cdot 10^{+89}:\\
\;\;\;\;\mathsf{fma}\left(y \cdot \left(z \cdot -9\right), t, x \cdot 2\right)\\

\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(27 \cdot b, a, z \cdot \left(t \cdot \left(y \cdot -9\right)\right)\right)\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if (*.f64 (*.f64 a #s(literal 27 binary64)) b) < -1.00000000000000001e41

    1. Initial program 96.3%

      \[\left(x \cdot 2 - \left(\left(y \cdot 9\right) \cdot z\right) \cdot t\right) + \left(a \cdot 27\right) \cdot b \]
    2. Add Preprocessing
    3. Taylor expanded in x around 0

      \[\leadsto \color{blue}{27 \cdot \left(a \cdot b\right) - 9 \cdot \left(t \cdot \left(y \cdot z\right)\right)} \]
    4. Step-by-step derivation
      1. cancel-sign-sub-invN/A

        \[\leadsto 27 \cdot \left(a \cdot b\right) + \color{blue}{\left(\mathsf{neg}\left(9\right)\right) \cdot \left(t \cdot \left(y \cdot z\right)\right)} \]
      2. metadata-evalN/A

        \[\leadsto 27 \cdot \left(a \cdot b\right) + -9 \cdot \left(\color{blue}{t} \cdot \left(y \cdot z\right)\right) \]
      3. +-commutativeN/A

        \[\leadsto -9 \cdot \left(t \cdot \left(y \cdot z\right)\right) + \color{blue}{27 \cdot \left(a \cdot b\right)} \]
      4. *-commutativeN/A

        \[\leadsto \left(t \cdot \left(y \cdot z\right)\right) \cdot -9 + \color{blue}{27} \cdot \left(a \cdot b\right) \]
      5. associate-*l*N/A

        \[\leadsto t \cdot \left(\left(y \cdot z\right) \cdot -9\right) + \color{blue}{27} \cdot \left(a \cdot b\right) \]
      6. *-commutativeN/A

        \[\leadsto t \cdot \left(-9 \cdot \left(y \cdot z\right)\right) + 27 \cdot \left(a \cdot b\right) \]
      7. accelerator-lowering-fma.f64N/A

        \[\leadsto \mathsf{fma.f64}\left(t, \color{blue}{\left(-9 \cdot \left(y \cdot z\right)\right)}, \left(27 \cdot \left(a \cdot b\right)\right)\right) \]
      8. +-lft-identityN/A

        \[\leadsto \mathsf{fma.f64}\left(t, \left(0 + \color{blue}{-9 \cdot \left(y \cdot z\right)}\right), \left(27 \cdot \left(a \cdot b\right)\right)\right) \]
      9. +-commutativeN/A

        \[\leadsto \mathsf{fma.f64}\left(t, \left(-9 \cdot \left(y \cdot z\right) + \color{blue}{0}\right), \left(27 \cdot \left(a \cdot b\right)\right)\right) \]
      10. *-commutativeN/A

        \[\leadsto \mathsf{fma.f64}\left(t, \left(\left(y \cdot z\right) \cdot -9 + 0\right), \left(27 \cdot \left(a \cdot b\right)\right)\right) \]
      11. accelerator-lowering-fma.f64N/A

        \[\leadsto \mathsf{fma.f64}\left(t, \mathsf{fma.f64}\left(\left(y \cdot z\right), \color{blue}{-9}, 0\right), \left(27 \cdot \left(a \cdot b\right)\right)\right) \]
      12. *-lowering-*.f64N/A

        \[\leadsto \mathsf{fma.f64}\left(t, \mathsf{fma.f64}\left(\mathsf{*.f64}\left(y, z\right), -9, 0\right), \left(27 \cdot \left(a \cdot b\right)\right)\right) \]
      13. +-rgt-identityN/A

        \[\leadsto \mathsf{fma.f64}\left(t, \mathsf{fma.f64}\left(\mathsf{*.f64}\left(y, z\right), -9, \color{blue}{0}\right), \left(27 \cdot \left(a \cdot b\right) + 0\right)\right) \]
      14. accelerator-lowering-fma.f64N/A

        \[\leadsto \mathsf{fma.f64}\left(t, \mathsf{fma.f64}\left(\mathsf{*.f64}\left(y, z\right), -9, \color{blue}{0}\right), \mathsf{fma.f64}\left(27, \left(a \cdot b\right), 0\right)\right) \]
      15. *-lowering-*.f6484.5%

        \[\leadsto \mathsf{fma.f64}\left(t, \mathsf{fma.f64}\left(\mathsf{*.f64}\left(y, z\right), -9, 0\right), \mathsf{fma.f64}\left(27, \mathsf{*.f64}\left(a, b\right), 0\right)\right) \]
    5. Simplified84.5%

      \[\leadsto \color{blue}{\mathsf{fma}\left(t, \mathsf{fma}\left(y \cdot z, -9, 0\right), \mathsf{fma}\left(27, a \cdot b, 0\right)\right)} \]
    6. Step-by-step derivation
      1. +-rgt-identityN/A

        \[\leadsto t \cdot \left(\left(y \cdot z\right) \cdot -9\right) + \left(27 \cdot \color{blue}{\left(a \cdot b\right)} + 0\right) \]
      2. *-commutativeN/A

        \[\leadsto \left(\left(y \cdot z\right) \cdot -9\right) \cdot t + \left(\color{blue}{27 \cdot \left(a \cdot b\right)} + 0\right) \]
      3. +-rgt-identityN/A

        \[\leadsto \left(\left(y \cdot z\right) \cdot -9\right) \cdot t + 27 \cdot \color{blue}{\left(a \cdot b\right)} \]
      4. associate-*r*N/A

        \[\leadsto \left(y \cdot \left(z \cdot -9\right)\right) \cdot t + 27 \cdot \left(a \cdot b\right) \]
      5. associate-*l*N/A

        \[\leadsto y \cdot \left(\left(z \cdot -9\right) \cdot t\right) + \color{blue}{27} \cdot \left(a \cdot b\right) \]
      6. *-commutativeN/A

        \[\leadsto \left(\left(z \cdot -9\right) \cdot t\right) \cdot y + \color{blue}{27} \cdot \left(a \cdot b\right) \]
      7. accelerator-lowering-fma.f64N/A

        \[\leadsto \mathsf{fma.f64}\left(\left(\left(z \cdot -9\right) \cdot t\right), \color{blue}{y}, \left(27 \cdot \left(a \cdot b\right)\right)\right) \]
      8. associate-*l*N/A

        \[\leadsto \mathsf{fma.f64}\left(\left(z \cdot \left(-9 \cdot t\right)\right), y, \left(27 \cdot \left(a \cdot b\right)\right)\right) \]
      9. *-lowering-*.f64N/A

        \[\leadsto \mathsf{fma.f64}\left(\mathsf{*.f64}\left(z, \left(-9 \cdot t\right)\right), y, \left(27 \cdot \left(a \cdot b\right)\right)\right) \]
      10. *-lowering-*.f64N/A

        \[\leadsto \mathsf{fma.f64}\left(\mathsf{*.f64}\left(z, \mathsf{*.f64}\left(-9, t\right)\right), y, \left(27 \cdot \left(a \cdot b\right)\right)\right) \]
      11. +-rgt-identityN/A

        \[\leadsto \mathsf{fma.f64}\left(\mathsf{*.f64}\left(z, \mathsf{*.f64}\left(-9, t\right)\right), y, \left(27 \cdot \left(a \cdot b\right) + 0\right)\right) \]
      12. accelerator-lowering-fma.f64N/A

        \[\leadsto \mathsf{fma.f64}\left(\mathsf{*.f64}\left(z, \mathsf{*.f64}\left(-9, t\right)\right), y, \mathsf{fma.f64}\left(27, \left(a \cdot b\right), 0\right)\right) \]
      13. *-lowering-*.f6487.9%

        \[\leadsto \mathsf{fma.f64}\left(\mathsf{*.f64}\left(z, \mathsf{*.f64}\left(-9, t\right)\right), y, \mathsf{fma.f64}\left(27, \mathsf{*.f64}\left(a, b\right), 0\right)\right) \]
    7. Applied egg-rr87.9%

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

    if -1.00000000000000001e41 < (*.f64 (*.f64 a #s(literal 27 binary64)) b) < 1.99999999999999999e89

    1. Initial program 97.7%

      \[\left(x \cdot 2 - \left(\left(y \cdot 9\right) \cdot z\right) \cdot t\right) + \left(a \cdot 27\right) \cdot b \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. sub-negN/A

        \[\leadsto \left(x \cdot 2 + \left(\mathsf{neg}\left(\left(\left(y \cdot 9\right) \cdot z\right) \cdot t\right)\right)\right) + \color{blue}{\left(a \cdot 27\right)} \cdot b \]
      2. +-commutativeN/A

        \[\leadsto \left(\left(\mathsf{neg}\left(\left(\left(y \cdot 9\right) \cdot z\right) \cdot t\right)\right) + x \cdot 2\right) + \color{blue}{\left(a \cdot 27\right)} \cdot b \]
      3. associate-+l+N/A

        \[\leadsto \left(\mathsf{neg}\left(\left(\left(y \cdot 9\right) \cdot z\right) \cdot t\right)\right) + \color{blue}{\left(x \cdot 2 + \left(a \cdot 27\right) \cdot b\right)} \]
      4. distribute-lft-neg-inN/A

        \[\leadsto \left(\mathsf{neg}\left(\left(y \cdot 9\right) \cdot z\right)\right) \cdot t + \left(\color{blue}{x \cdot 2} + \left(a \cdot 27\right) \cdot b\right) \]
      5. +-commutativeN/A

        \[\leadsto \left(\mathsf{neg}\left(\left(y \cdot 9\right) \cdot z\right)\right) \cdot t + \left(\left(a \cdot 27\right) \cdot b + \color{blue}{x \cdot 2}\right) \]
      6. accelerator-lowering-fma.f64N/A

        \[\leadsto \mathsf{fma.f64}\left(\left(\mathsf{neg}\left(\left(y \cdot 9\right) \cdot z\right)\right), \color{blue}{t}, \left(\left(a \cdot 27\right) \cdot b + x \cdot 2\right)\right) \]
      7. associate-*l*N/A

        \[\leadsto \mathsf{fma.f64}\left(\left(\mathsf{neg}\left(y \cdot \left(9 \cdot z\right)\right)\right), t, \left(\left(a \cdot 27\right) \cdot b + x \cdot 2\right)\right) \]
      8. distribute-rgt-neg-inN/A

        \[\leadsto \mathsf{fma.f64}\left(\left(y \cdot \left(\mathsf{neg}\left(9 \cdot z\right)\right)\right), t, \left(\left(a \cdot 27\right) \cdot b + x \cdot 2\right)\right) \]
      9. *-lowering-*.f64N/A

        \[\leadsto \mathsf{fma.f64}\left(\mathsf{*.f64}\left(y, \left(\mathsf{neg}\left(9 \cdot z\right)\right)\right), t, \left(\left(a \cdot 27\right) \cdot b + x \cdot 2\right)\right) \]
      10. *-commutativeN/A

        \[\leadsto \mathsf{fma.f64}\left(\mathsf{*.f64}\left(y, \left(\mathsf{neg}\left(z \cdot 9\right)\right)\right), t, \left(\left(a \cdot 27\right) \cdot b + x \cdot 2\right)\right) \]
      11. distribute-rgt-neg-inN/A

        \[\leadsto \mathsf{fma.f64}\left(\mathsf{*.f64}\left(y, \left(z \cdot \left(\mathsf{neg}\left(9\right)\right)\right)\right), t, \left(\left(a \cdot 27\right) \cdot b + x \cdot 2\right)\right) \]
      12. *-lowering-*.f64N/A

        \[\leadsto \mathsf{fma.f64}\left(\mathsf{*.f64}\left(y, \mathsf{*.f64}\left(z, \left(\mathsf{neg}\left(9\right)\right)\right)\right), t, \left(\left(a \cdot 27\right) \cdot b + x \cdot 2\right)\right) \]
      13. metadata-evalN/A

        \[\leadsto \mathsf{fma.f64}\left(\mathsf{*.f64}\left(y, \mathsf{*.f64}\left(z, -9\right)\right), t, \left(\left(a \cdot 27\right) \cdot b + x \cdot 2\right)\right) \]
      14. associate-*l*N/A

        \[\leadsto \mathsf{fma.f64}\left(\mathsf{*.f64}\left(y, \mathsf{*.f64}\left(z, -9\right)\right), t, \left(a \cdot \left(27 \cdot b\right) + x \cdot 2\right)\right) \]
      15. accelerator-lowering-fma.f64N/A

        \[\leadsto \mathsf{fma.f64}\left(\mathsf{*.f64}\left(y, \mathsf{*.f64}\left(z, -9\right)\right), t, \mathsf{fma.f64}\left(a, \left(27 \cdot b\right), \left(x \cdot 2\right)\right)\right) \]
      16. *-lowering-*.f64N/A

        \[\leadsto \mathsf{fma.f64}\left(\mathsf{*.f64}\left(y, \mathsf{*.f64}\left(z, -9\right)\right), t, \mathsf{fma.f64}\left(a, \mathsf{*.f64}\left(27, b\right), \left(x \cdot 2\right)\right)\right) \]
      17. *-lowering-*.f6497.7%

        \[\leadsto \mathsf{fma.f64}\left(\mathsf{*.f64}\left(y, \mathsf{*.f64}\left(z, -9\right)\right), t, \mathsf{fma.f64}\left(a, \mathsf{*.f64}\left(27, b\right), \mathsf{*.f64}\left(x, 2\right)\right)\right) \]
    4. Applied egg-rr97.7%

      \[\leadsto \color{blue}{\mathsf{fma}\left(y \cdot \left(z \cdot -9\right), t, \mathsf{fma}\left(a, 27 \cdot b, x \cdot 2\right)\right)} \]
    5. Taylor expanded in a around 0

      \[\leadsto \mathsf{fma.f64}\left(\mathsf{*.f64}\left(y, \mathsf{*.f64}\left(z, -9\right)\right), t, \color{blue}{\left(2 \cdot x\right)}\right) \]
    6. Step-by-step derivation
      1. *-lowering-*.f6490.7%

        \[\leadsto \mathsf{fma.f64}\left(\mathsf{*.f64}\left(y, \mathsf{*.f64}\left(z, -9\right)\right), t, \mathsf{*.f64}\left(2, x\right)\right) \]
    7. Simplified90.7%

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

    if 1.99999999999999999e89 < (*.f64 (*.f64 a #s(literal 27 binary64)) b)

    1. Initial program 89.3%

      \[\left(x \cdot 2 - \left(\left(y \cdot 9\right) \cdot z\right) \cdot t\right) + \left(a \cdot 27\right) \cdot b \]
    2. Add Preprocessing
    3. Taylor expanded in x around 0

      \[\leadsto \color{blue}{27 \cdot \left(a \cdot b\right) - 9 \cdot \left(t \cdot \left(y \cdot z\right)\right)} \]
    4. Step-by-step derivation
      1. cancel-sign-sub-invN/A

        \[\leadsto 27 \cdot \left(a \cdot b\right) + \color{blue}{\left(\mathsf{neg}\left(9\right)\right) \cdot \left(t \cdot \left(y \cdot z\right)\right)} \]
      2. metadata-evalN/A

        \[\leadsto 27 \cdot \left(a \cdot b\right) + -9 \cdot \left(\color{blue}{t} \cdot \left(y \cdot z\right)\right) \]
      3. +-commutativeN/A

        \[\leadsto -9 \cdot \left(t \cdot \left(y \cdot z\right)\right) + \color{blue}{27 \cdot \left(a \cdot b\right)} \]
      4. *-commutativeN/A

        \[\leadsto \left(t \cdot \left(y \cdot z\right)\right) \cdot -9 + \color{blue}{27} \cdot \left(a \cdot b\right) \]
      5. associate-*l*N/A

        \[\leadsto t \cdot \left(\left(y \cdot z\right) \cdot -9\right) + \color{blue}{27} \cdot \left(a \cdot b\right) \]
      6. *-commutativeN/A

        \[\leadsto t \cdot \left(-9 \cdot \left(y \cdot z\right)\right) + 27 \cdot \left(a \cdot b\right) \]
      7. accelerator-lowering-fma.f64N/A

        \[\leadsto \mathsf{fma.f64}\left(t, \color{blue}{\left(-9 \cdot \left(y \cdot z\right)\right)}, \left(27 \cdot \left(a \cdot b\right)\right)\right) \]
      8. +-lft-identityN/A

        \[\leadsto \mathsf{fma.f64}\left(t, \left(0 + \color{blue}{-9 \cdot \left(y \cdot z\right)}\right), \left(27 \cdot \left(a \cdot b\right)\right)\right) \]
      9. +-commutativeN/A

        \[\leadsto \mathsf{fma.f64}\left(t, \left(-9 \cdot \left(y \cdot z\right) + \color{blue}{0}\right), \left(27 \cdot \left(a \cdot b\right)\right)\right) \]
      10. *-commutativeN/A

        \[\leadsto \mathsf{fma.f64}\left(t, \left(\left(y \cdot z\right) \cdot -9 + 0\right), \left(27 \cdot \left(a \cdot b\right)\right)\right) \]
      11. accelerator-lowering-fma.f64N/A

        \[\leadsto \mathsf{fma.f64}\left(t, \mathsf{fma.f64}\left(\left(y \cdot z\right), \color{blue}{-9}, 0\right), \left(27 \cdot \left(a \cdot b\right)\right)\right) \]
      12. *-lowering-*.f64N/A

        \[\leadsto \mathsf{fma.f64}\left(t, \mathsf{fma.f64}\left(\mathsf{*.f64}\left(y, z\right), -9, 0\right), \left(27 \cdot \left(a \cdot b\right)\right)\right) \]
      13. +-rgt-identityN/A

        \[\leadsto \mathsf{fma.f64}\left(t, \mathsf{fma.f64}\left(\mathsf{*.f64}\left(y, z\right), -9, \color{blue}{0}\right), \left(27 \cdot \left(a \cdot b\right) + 0\right)\right) \]
      14. accelerator-lowering-fma.f64N/A

        \[\leadsto \mathsf{fma.f64}\left(t, \mathsf{fma.f64}\left(\mathsf{*.f64}\left(y, z\right), -9, \color{blue}{0}\right), \mathsf{fma.f64}\left(27, \left(a \cdot b\right), 0\right)\right) \]
      15. *-lowering-*.f6480.6%

        \[\leadsto \mathsf{fma.f64}\left(t, \mathsf{fma.f64}\left(\mathsf{*.f64}\left(y, z\right), -9, 0\right), \mathsf{fma.f64}\left(27, \mathsf{*.f64}\left(a, b\right), 0\right)\right) \]
    5. Simplified80.6%

      \[\leadsto \color{blue}{\mathsf{fma}\left(t, \mathsf{fma}\left(y \cdot z, -9, 0\right), \mathsf{fma}\left(27, a \cdot b, 0\right)\right)} \]
    6. Step-by-step derivation
      1. +-rgt-identityN/A

        \[\leadsto t \cdot \left(\left(y \cdot z\right) \cdot -9\right) + \left(27 \cdot \color{blue}{\left(a \cdot b\right)} + 0\right) \]
      2. +-rgt-identityN/A

        \[\leadsto t \cdot \left(\left(y \cdot z\right) \cdot -9\right) + 27 \cdot \color{blue}{\left(a \cdot b\right)} \]
      3. *-commutativeN/A

        \[\leadsto \left(\left(y \cdot z\right) \cdot -9\right) \cdot t + \color{blue}{27} \cdot \left(a \cdot b\right) \]
      4. associate-*r*N/A

        \[\leadsto \left(y \cdot \left(z \cdot -9\right)\right) \cdot t + 27 \cdot \left(a \cdot b\right) \]
      5. +-commutativeN/A

        \[\leadsto 27 \cdot \left(a \cdot b\right) + \color{blue}{\left(y \cdot \left(z \cdot -9\right)\right) \cdot t} \]
      6. *-commutativeN/A

        \[\leadsto 27 \cdot \left(b \cdot a\right) + \left(y \cdot \color{blue}{\left(z \cdot -9\right)}\right) \cdot t \]
      7. associate-*r*N/A

        \[\leadsto \left(27 \cdot b\right) \cdot a + \color{blue}{\left(y \cdot \left(z \cdot -9\right)\right)} \cdot t \]
      8. accelerator-lowering-fma.f64N/A

        \[\leadsto \mathsf{fma.f64}\left(\left(27 \cdot b\right), \color{blue}{a}, \left(\left(y \cdot \left(z \cdot -9\right)\right) \cdot t\right)\right) \]
      9. *-lowering-*.f64N/A

        \[\leadsto \mathsf{fma.f64}\left(\mathsf{*.f64}\left(27, b\right), a, \left(\left(y \cdot \left(z \cdot -9\right)\right) \cdot t\right)\right) \]
      10. +-rgt-identityN/A

        \[\leadsto \mathsf{fma.f64}\left(\mathsf{*.f64}\left(27, b\right), a, \left(\left(y \cdot \left(z \cdot -9\right)\right) \cdot t + 0\right)\right) \]
      11. associate-*r*N/A

        \[\leadsto \mathsf{fma.f64}\left(\mathsf{*.f64}\left(27, b\right), a, \left(\left(\left(y \cdot z\right) \cdot -9\right) \cdot t + 0\right)\right) \]
      12. *-commutativeN/A

        \[\leadsto \mathsf{fma.f64}\left(\mathsf{*.f64}\left(27, b\right), a, \left(\left(-9 \cdot \left(y \cdot z\right)\right) \cdot t + 0\right)\right) \]
      13. associate-*l*N/A

        \[\leadsto \mathsf{fma.f64}\left(\mathsf{*.f64}\left(27, b\right), a, \left(-9 \cdot \left(\left(y \cdot z\right) \cdot t\right) + 0\right)\right) \]
      14. accelerator-lowering-fma.f64N/A

        \[\leadsto \mathsf{fma.f64}\left(\mathsf{*.f64}\left(27, b\right), a, \mathsf{fma.f64}\left(-9, \left(\left(y \cdot z\right) \cdot t\right), 0\right)\right) \]
      15. *-lowering-*.f64N/A

        \[\leadsto \mathsf{fma.f64}\left(\mathsf{*.f64}\left(27, b\right), a, \mathsf{fma.f64}\left(-9, \mathsf{*.f64}\left(\left(y \cdot z\right), t\right), 0\right)\right) \]
      16. *-lowering-*.f6486.0%

        \[\leadsto \mathsf{fma.f64}\left(\mathsf{*.f64}\left(27, b\right), a, \mathsf{fma.f64}\left(-9, \mathsf{*.f64}\left(\mathsf{*.f64}\left(y, z\right), t\right), 0\right)\right) \]
    7. Applied egg-rr86.0%

      \[\leadsto \color{blue}{\mathsf{fma}\left(27 \cdot b, a, \mathsf{fma}\left(-9, \left(y \cdot z\right) \cdot t, 0\right)\right)} \]
    8. Step-by-step derivation
      1. +-rgt-identityN/A

        \[\leadsto \mathsf{fma.f64}\left(\mathsf{*.f64}\left(27, b\right), a, \left(-9 \cdot \left(\left(y \cdot z\right) \cdot t\right)\right)\right) \]
      2. associate-*l*N/A

        \[\leadsto \mathsf{fma.f64}\left(\mathsf{*.f64}\left(27, b\right), a, \left(-9 \cdot \left(y \cdot \left(z \cdot t\right)\right)\right)\right) \]
      3. associate-*r*N/A

        \[\leadsto \mathsf{fma.f64}\left(\mathsf{*.f64}\left(27, b\right), a, \left(\left(-9 \cdot y\right) \cdot \left(z \cdot t\right)\right)\right) \]
      4. *-commutativeN/A

        \[\leadsto \mathsf{fma.f64}\left(\mathsf{*.f64}\left(27, b\right), a, \left(\left(y \cdot -9\right) \cdot \left(z \cdot t\right)\right)\right) \]
      5. *-commutativeN/A

        \[\leadsto \mathsf{fma.f64}\left(\mathsf{*.f64}\left(27, b\right), a, \left(\left(z \cdot t\right) \cdot \left(y \cdot -9\right)\right)\right) \]
      6. associate-*l*N/A

        \[\leadsto \mathsf{fma.f64}\left(\mathsf{*.f64}\left(27, b\right), a, \left(z \cdot \left(t \cdot \left(y \cdot -9\right)\right)\right)\right) \]
      7. *-commutativeN/A

        \[\leadsto \mathsf{fma.f64}\left(\mathsf{*.f64}\left(27, b\right), a, \left(\left(t \cdot \left(y \cdot -9\right)\right) \cdot z\right)\right) \]
      8. *-lowering-*.f64N/A

        \[\leadsto \mathsf{fma.f64}\left(\mathsf{*.f64}\left(27, b\right), a, \mathsf{*.f64}\left(\left(t \cdot \left(y \cdot -9\right)\right), z\right)\right) \]
      9. *-lowering-*.f64N/A

        \[\leadsto \mathsf{fma.f64}\left(\mathsf{*.f64}\left(27, b\right), a, \mathsf{*.f64}\left(\mathsf{*.f64}\left(t, \left(y \cdot -9\right)\right), z\right)\right) \]
      10. *-lowering-*.f6483.5%

        \[\leadsto \mathsf{fma.f64}\left(\mathsf{*.f64}\left(27, b\right), a, \mathsf{*.f64}\left(\mathsf{*.f64}\left(t, \mathsf{*.f64}\left(y, -9\right)\right), z\right)\right) \]
    9. Applied egg-rr83.5%

      \[\leadsto \mathsf{fma}\left(27 \cdot b, a, \color{blue}{\left(t \cdot \left(y \cdot -9\right)\right) \cdot z}\right) \]
  3. Recombined 3 regimes into one program.
  4. Final simplification89.0%

    \[\leadsto \begin{array}{l} \mathbf{if}\;\left(a \cdot 27\right) \cdot b \leq -1 \cdot 10^{+41}:\\ \;\;\;\;\mathsf{fma}\left(z \cdot \left(t \cdot -9\right), y, \mathsf{fma}\left(27, a \cdot b, 0\right)\right)\\ \mathbf{elif}\;\left(a \cdot 27\right) \cdot b \leq 2 \cdot 10^{+89}:\\ \;\;\;\;\mathsf{fma}\left(y \cdot \left(z \cdot -9\right), t, x \cdot 2\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(27 \cdot b, a, z \cdot \left(t \cdot \left(y \cdot -9\right)\right)\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 5: 84.2% accurate, 0.6× speedup?

\[\begin{array}{l} [x, y, z, t, a, b] = \mathsf{sort}([x, y, z, t, a, b])\\\\ [x, y, z, t, a, b] = \mathsf{sort}([x, y, z, t, a, b])\\ \\ \begin{array}{l} t_1 := \left(a \cdot 27\right) \cdot b\\ \mathbf{if}\;t\_1 \leq -1 \cdot 10^{+41}:\\ \;\;\;\;\mathsf{fma}\left(z \cdot t, y \cdot -9, 27 \cdot \left(a \cdot b\right)\right)\\ \mathbf{elif}\;t\_1 \leq 2 \cdot 10^{+89}:\\ \;\;\;\;\mathsf{fma}\left(y \cdot \left(z \cdot -9\right), t, x \cdot 2\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(27 \cdot b, a, z \cdot \left(t \cdot \left(y \cdot -9\right)\right)\right)\\ \end{array} \end{array} \]
NOTE: x, y, z, t, a, and b should be sorted in increasing order before calling this function.
NOTE: x, y, z, t, a, and b should be sorted in increasing order before calling this function.
(FPCore (x y z t a b)
 :precision binary64
 (let* ((t_1 (* (* a 27.0) b)))
   (if (<= t_1 -1e+41)
     (fma (* z t) (* y -9.0) (* 27.0 (* a b)))
     (if (<= t_1 2e+89)
       (fma (* y (* z -9.0)) t (* x 2.0))
       (fma (* 27.0 b) a (* z (* t (* y -9.0))))))))
assert(x < y && y < z && z < t && t < a && a < b);
assert(x < y && y < z && z < t && t < a && a < b);
double code(double x, double y, double z, double t, double a, double b) {
	double t_1 = (a * 27.0) * b;
	double tmp;
	if (t_1 <= -1e+41) {
		tmp = fma((z * t), (y * -9.0), (27.0 * (a * b)));
	} else if (t_1 <= 2e+89) {
		tmp = fma((y * (z * -9.0)), t, (x * 2.0));
	} else {
		tmp = fma((27.0 * b), a, (z * (t * (y * -9.0))));
	}
	return tmp;
}
x, y, z, t, a, b = sort([x, y, z, t, a, b])
x, y, z, t, a, b = sort([x, y, z, t, a, b])
function code(x, y, z, t, a, b)
	t_1 = Float64(Float64(a * 27.0) * b)
	tmp = 0.0
	if (t_1 <= -1e+41)
		tmp = fma(Float64(z * t), Float64(y * -9.0), Float64(27.0 * Float64(a * b)));
	elseif (t_1 <= 2e+89)
		tmp = fma(Float64(y * Float64(z * -9.0)), t, Float64(x * 2.0));
	else
		tmp = fma(Float64(27.0 * b), a, Float64(z * Float64(t * Float64(y * -9.0))));
	end
	return tmp
end
NOTE: x, y, z, t, a, and b should be sorted in increasing order before calling this function.
NOTE: x, y, z, t, a, and b should be sorted in increasing order before calling this function.
code[x_, y_, z_, t_, a_, b_] := Block[{t$95$1 = N[(N[(a * 27.0), $MachinePrecision] * b), $MachinePrecision]}, If[LessEqual[t$95$1, -1e+41], N[(N[(z * t), $MachinePrecision] * N[(y * -9.0), $MachinePrecision] + N[(27.0 * N[(a * b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$1, 2e+89], N[(N[(y * N[(z * -9.0), $MachinePrecision]), $MachinePrecision] * t + N[(x * 2.0), $MachinePrecision]), $MachinePrecision], N[(N[(27.0 * b), $MachinePrecision] * a + N[(z * N[(t * N[(y * -9.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
[x, y, z, t, a, b] = \mathsf{sort}([x, y, z, t, a, b])\\\\
[x, y, z, t, a, b] = \mathsf{sort}([x, y, z, t, a, b])\\
\\
\begin{array}{l}
t_1 := \left(a \cdot 27\right) \cdot b\\
\mathbf{if}\;t\_1 \leq -1 \cdot 10^{+41}:\\
\;\;\;\;\mathsf{fma}\left(z \cdot t, y \cdot -9, 27 \cdot \left(a \cdot b\right)\right)\\

\mathbf{elif}\;t\_1 \leq 2 \cdot 10^{+89}:\\
\;\;\;\;\mathsf{fma}\left(y \cdot \left(z \cdot -9\right), t, x \cdot 2\right)\\

\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(27 \cdot b, a, z \cdot \left(t \cdot \left(y \cdot -9\right)\right)\right)\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if (*.f64 (*.f64 a #s(literal 27 binary64)) b) < -1.00000000000000001e41

    1. Initial program 96.3%

      \[\left(x \cdot 2 - \left(\left(y \cdot 9\right) \cdot z\right) \cdot t\right) + \left(a \cdot 27\right) \cdot b \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. sub-negN/A

        \[\leadsto \left(x \cdot 2 + \left(\mathsf{neg}\left(\left(\left(y \cdot 9\right) \cdot z\right) \cdot t\right)\right)\right) + \color{blue}{\left(a \cdot 27\right)} \cdot b \]
      2. +-commutativeN/A

        \[\leadsto \left(\left(\mathsf{neg}\left(\left(\left(y \cdot 9\right) \cdot z\right) \cdot t\right)\right) + x \cdot 2\right) + \color{blue}{\left(a \cdot 27\right)} \cdot b \]
      3. associate-+l+N/A

        \[\leadsto \left(\mathsf{neg}\left(\left(\left(y \cdot 9\right) \cdot z\right) \cdot t\right)\right) + \color{blue}{\left(x \cdot 2 + \left(a \cdot 27\right) \cdot b\right)} \]
      4. associate-*l*N/A

        \[\leadsto \left(\mathsf{neg}\left(\left(y \cdot 9\right) \cdot \left(z \cdot t\right)\right)\right) + \left(\color{blue}{x} \cdot 2 + \left(a \cdot 27\right) \cdot b\right) \]
      5. *-commutativeN/A

        \[\leadsto \left(\mathsf{neg}\left(\left(z \cdot t\right) \cdot \left(y \cdot 9\right)\right)\right) + \left(\color{blue}{x} \cdot 2 + \left(a \cdot 27\right) \cdot b\right) \]
      6. distribute-rgt-neg-inN/A

        \[\leadsto \left(z \cdot t\right) \cdot \left(\mathsf{neg}\left(y \cdot 9\right)\right) + \left(\color{blue}{x \cdot 2} + \left(a \cdot 27\right) \cdot b\right) \]
      7. +-commutativeN/A

        \[\leadsto \left(z \cdot t\right) \cdot \left(\mathsf{neg}\left(y \cdot 9\right)\right) + \left(\left(a \cdot 27\right) \cdot b + \color{blue}{x \cdot 2}\right) \]
      8. accelerator-lowering-fma.f64N/A

        \[\leadsto \mathsf{fma.f64}\left(\left(z \cdot t\right), \color{blue}{\left(\mathsf{neg}\left(y \cdot 9\right)\right)}, \left(\left(a \cdot 27\right) \cdot b + x \cdot 2\right)\right) \]
      9. *-lowering-*.f64N/A

        \[\leadsto \mathsf{fma.f64}\left(\mathsf{*.f64}\left(z, t\right), \left(\mathsf{neg}\left(\color{blue}{y \cdot 9}\right)\right), \left(\left(a \cdot 27\right) \cdot b + x \cdot 2\right)\right) \]
      10. distribute-rgt-neg-inN/A

        \[\leadsto \mathsf{fma.f64}\left(\mathsf{*.f64}\left(z, t\right), \left(y \cdot \color{blue}{\left(\mathsf{neg}\left(9\right)\right)}\right), \left(\left(a \cdot 27\right) \cdot b + x \cdot 2\right)\right) \]
      11. *-lowering-*.f64N/A

        \[\leadsto \mathsf{fma.f64}\left(\mathsf{*.f64}\left(z, t\right), \mathsf{*.f64}\left(y, \color{blue}{\left(\mathsf{neg}\left(9\right)\right)}\right), \left(\left(a \cdot 27\right) \cdot b + x \cdot 2\right)\right) \]
      12. metadata-evalN/A

        \[\leadsto \mathsf{fma.f64}\left(\mathsf{*.f64}\left(z, t\right), \mathsf{*.f64}\left(y, -9\right), \left(\left(a \cdot 27\right) \cdot b + x \cdot 2\right)\right) \]
      13. associate-*l*N/A

        \[\leadsto \mathsf{fma.f64}\left(\mathsf{*.f64}\left(z, t\right), \mathsf{*.f64}\left(y, -9\right), \left(a \cdot \left(27 \cdot b\right) + x \cdot 2\right)\right) \]
      14. accelerator-lowering-fma.f64N/A

        \[\leadsto \mathsf{fma.f64}\left(\mathsf{*.f64}\left(z, t\right), \mathsf{*.f64}\left(y, -9\right), \mathsf{fma.f64}\left(a, \left(27 \cdot b\right), \left(x \cdot 2\right)\right)\right) \]
      15. *-lowering-*.f64N/A

        \[\leadsto \mathsf{fma.f64}\left(\mathsf{*.f64}\left(z, t\right), \mathsf{*.f64}\left(y, -9\right), \mathsf{fma.f64}\left(a, \mathsf{*.f64}\left(27, b\right), \left(x \cdot 2\right)\right)\right) \]
      16. *-lowering-*.f6499.8%

        \[\leadsto \mathsf{fma.f64}\left(\mathsf{*.f64}\left(z, t\right), \mathsf{*.f64}\left(y, -9\right), \mathsf{fma.f64}\left(a, \mathsf{*.f64}\left(27, b\right), \mathsf{*.f64}\left(x, 2\right)\right)\right) \]
    4. Applied egg-rr99.8%

      \[\leadsto \color{blue}{\mathsf{fma}\left(z \cdot t, y \cdot -9, \mathsf{fma}\left(a, 27 \cdot b, x \cdot 2\right)\right)} \]
    5. Taylor expanded in a around inf

      \[\leadsto \mathsf{fma.f64}\left(\mathsf{*.f64}\left(z, t\right), \mathsf{*.f64}\left(y, -9\right), \color{blue}{\left(27 \cdot \left(a \cdot b\right)\right)}\right) \]
    6. Step-by-step derivation
      1. *-lowering-*.f64N/A

        \[\leadsto \mathsf{fma.f64}\left(\mathsf{*.f64}\left(z, t\right), \mathsf{*.f64}\left(y, -9\right), \mathsf{*.f64}\left(27, \left(a \cdot b\right)\right)\right) \]
      2. *-lowering-*.f6487.8%

        \[\leadsto \mathsf{fma.f64}\left(\mathsf{*.f64}\left(z, t\right), \mathsf{*.f64}\left(y, -9\right), \mathsf{*.f64}\left(27, \mathsf{*.f64}\left(a, b\right)\right)\right) \]
    7. Simplified87.8%

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

    if -1.00000000000000001e41 < (*.f64 (*.f64 a #s(literal 27 binary64)) b) < 1.99999999999999999e89

    1. Initial program 97.7%

      \[\left(x \cdot 2 - \left(\left(y \cdot 9\right) \cdot z\right) \cdot t\right) + \left(a \cdot 27\right) \cdot b \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. sub-negN/A

        \[\leadsto \left(x \cdot 2 + \left(\mathsf{neg}\left(\left(\left(y \cdot 9\right) \cdot z\right) \cdot t\right)\right)\right) + \color{blue}{\left(a \cdot 27\right)} \cdot b \]
      2. +-commutativeN/A

        \[\leadsto \left(\left(\mathsf{neg}\left(\left(\left(y \cdot 9\right) \cdot z\right) \cdot t\right)\right) + x \cdot 2\right) + \color{blue}{\left(a \cdot 27\right)} \cdot b \]
      3. associate-+l+N/A

        \[\leadsto \left(\mathsf{neg}\left(\left(\left(y \cdot 9\right) \cdot z\right) \cdot t\right)\right) + \color{blue}{\left(x \cdot 2 + \left(a \cdot 27\right) \cdot b\right)} \]
      4. distribute-lft-neg-inN/A

        \[\leadsto \left(\mathsf{neg}\left(\left(y \cdot 9\right) \cdot z\right)\right) \cdot t + \left(\color{blue}{x \cdot 2} + \left(a \cdot 27\right) \cdot b\right) \]
      5. +-commutativeN/A

        \[\leadsto \left(\mathsf{neg}\left(\left(y \cdot 9\right) \cdot z\right)\right) \cdot t + \left(\left(a \cdot 27\right) \cdot b + \color{blue}{x \cdot 2}\right) \]
      6. accelerator-lowering-fma.f64N/A

        \[\leadsto \mathsf{fma.f64}\left(\left(\mathsf{neg}\left(\left(y \cdot 9\right) \cdot z\right)\right), \color{blue}{t}, \left(\left(a \cdot 27\right) \cdot b + x \cdot 2\right)\right) \]
      7. associate-*l*N/A

        \[\leadsto \mathsf{fma.f64}\left(\left(\mathsf{neg}\left(y \cdot \left(9 \cdot z\right)\right)\right), t, \left(\left(a \cdot 27\right) \cdot b + x \cdot 2\right)\right) \]
      8. distribute-rgt-neg-inN/A

        \[\leadsto \mathsf{fma.f64}\left(\left(y \cdot \left(\mathsf{neg}\left(9 \cdot z\right)\right)\right), t, \left(\left(a \cdot 27\right) \cdot b + x \cdot 2\right)\right) \]
      9. *-lowering-*.f64N/A

        \[\leadsto \mathsf{fma.f64}\left(\mathsf{*.f64}\left(y, \left(\mathsf{neg}\left(9 \cdot z\right)\right)\right), t, \left(\left(a \cdot 27\right) \cdot b + x \cdot 2\right)\right) \]
      10. *-commutativeN/A

        \[\leadsto \mathsf{fma.f64}\left(\mathsf{*.f64}\left(y, \left(\mathsf{neg}\left(z \cdot 9\right)\right)\right), t, \left(\left(a \cdot 27\right) \cdot b + x \cdot 2\right)\right) \]
      11. distribute-rgt-neg-inN/A

        \[\leadsto \mathsf{fma.f64}\left(\mathsf{*.f64}\left(y, \left(z \cdot \left(\mathsf{neg}\left(9\right)\right)\right)\right), t, \left(\left(a \cdot 27\right) \cdot b + x \cdot 2\right)\right) \]
      12. *-lowering-*.f64N/A

        \[\leadsto \mathsf{fma.f64}\left(\mathsf{*.f64}\left(y, \mathsf{*.f64}\left(z, \left(\mathsf{neg}\left(9\right)\right)\right)\right), t, \left(\left(a \cdot 27\right) \cdot b + x \cdot 2\right)\right) \]
      13. metadata-evalN/A

        \[\leadsto \mathsf{fma.f64}\left(\mathsf{*.f64}\left(y, \mathsf{*.f64}\left(z, -9\right)\right), t, \left(\left(a \cdot 27\right) \cdot b + x \cdot 2\right)\right) \]
      14. associate-*l*N/A

        \[\leadsto \mathsf{fma.f64}\left(\mathsf{*.f64}\left(y, \mathsf{*.f64}\left(z, -9\right)\right), t, \left(a \cdot \left(27 \cdot b\right) + x \cdot 2\right)\right) \]
      15. accelerator-lowering-fma.f64N/A

        \[\leadsto \mathsf{fma.f64}\left(\mathsf{*.f64}\left(y, \mathsf{*.f64}\left(z, -9\right)\right), t, \mathsf{fma.f64}\left(a, \left(27 \cdot b\right), \left(x \cdot 2\right)\right)\right) \]
      16. *-lowering-*.f64N/A

        \[\leadsto \mathsf{fma.f64}\left(\mathsf{*.f64}\left(y, \mathsf{*.f64}\left(z, -9\right)\right), t, \mathsf{fma.f64}\left(a, \mathsf{*.f64}\left(27, b\right), \left(x \cdot 2\right)\right)\right) \]
      17. *-lowering-*.f6497.7%

        \[\leadsto \mathsf{fma.f64}\left(\mathsf{*.f64}\left(y, \mathsf{*.f64}\left(z, -9\right)\right), t, \mathsf{fma.f64}\left(a, \mathsf{*.f64}\left(27, b\right), \mathsf{*.f64}\left(x, 2\right)\right)\right) \]
    4. Applied egg-rr97.7%

      \[\leadsto \color{blue}{\mathsf{fma}\left(y \cdot \left(z \cdot -9\right), t, \mathsf{fma}\left(a, 27 \cdot b, x \cdot 2\right)\right)} \]
    5. Taylor expanded in a around 0

      \[\leadsto \mathsf{fma.f64}\left(\mathsf{*.f64}\left(y, \mathsf{*.f64}\left(z, -9\right)\right), t, \color{blue}{\left(2 \cdot x\right)}\right) \]
    6. Step-by-step derivation
      1. *-lowering-*.f6490.7%

        \[\leadsto \mathsf{fma.f64}\left(\mathsf{*.f64}\left(y, \mathsf{*.f64}\left(z, -9\right)\right), t, \mathsf{*.f64}\left(2, x\right)\right) \]
    7. Simplified90.7%

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

    if 1.99999999999999999e89 < (*.f64 (*.f64 a #s(literal 27 binary64)) b)

    1. Initial program 89.3%

      \[\left(x \cdot 2 - \left(\left(y \cdot 9\right) \cdot z\right) \cdot t\right) + \left(a \cdot 27\right) \cdot b \]
    2. Add Preprocessing
    3. Taylor expanded in x around 0

      \[\leadsto \color{blue}{27 \cdot \left(a \cdot b\right) - 9 \cdot \left(t \cdot \left(y \cdot z\right)\right)} \]
    4. Step-by-step derivation
      1. cancel-sign-sub-invN/A

        \[\leadsto 27 \cdot \left(a \cdot b\right) + \color{blue}{\left(\mathsf{neg}\left(9\right)\right) \cdot \left(t \cdot \left(y \cdot z\right)\right)} \]
      2. metadata-evalN/A

        \[\leadsto 27 \cdot \left(a \cdot b\right) + -9 \cdot \left(\color{blue}{t} \cdot \left(y \cdot z\right)\right) \]
      3. +-commutativeN/A

        \[\leadsto -9 \cdot \left(t \cdot \left(y \cdot z\right)\right) + \color{blue}{27 \cdot \left(a \cdot b\right)} \]
      4. *-commutativeN/A

        \[\leadsto \left(t \cdot \left(y \cdot z\right)\right) \cdot -9 + \color{blue}{27} \cdot \left(a \cdot b\right) \]
      5. associate-*l*N/A

        \[\leadsto t \cdot \left(\left(y \cdot z\right) \cdot -9\right) + \color{blue}{27} \cdot \left(a \cdot b\right) \]
      6. *-commutativeN/A

        \[\leadsto t \cdot \left(-9 \cdot \left(y \cdot z\right)\right) + 27 \cdot \left(a \cdot b\right) \]
      7. accelerator-lowering-fma.f64N/A

        \[\leadsto \mathsf{fma.f64}\left(t, \color{blue}{\left(-9 \cdot \left(y \cdot z\right)\right)}, \left(27 \cdot \left(a \cdot b\right)\right)\right) \]
      8. +-lft-identityN/A

        \[\leadsto \mathsf{fma.f64}\left(t, \left(0 + \color{blue}{-9 \cdot \left(y \cdot z\right)}\right), \left(27 \cdot \left(a \cdot b\right)\right)\right) \]
      9. +-commutativeN/A

        \[\leadsto \mathsf{fma.f64}\left(t, \left(-9 \cdot \left(y \cdot z\right) + \color{blue}{0}\right), \left(27 \cdot \left(a \cdot b\right)\right)\right) \]
      10. *-commutativeN/A

        \[\leadsto \mathsf{fma.f64}\left(t, \left(\left(y \cdot z\right) \cdot -9 + 0\right), \left(27 \cdot \left(a \cdot b\right)\right)\right) \]
      11. accelerator-lowering-fma.f64N/A

        \[\leadsto \mathsf{fma.f64}\left(t, \mathsf{fma.f64}\left(\left(y \cdot z\right), \color{blue}{-9}, 0\right), \left(27 \cdot \left(a \cdot b\right)\right)\right) \]
      12. *-lowering-*.f64N/A

        \[\leadsto \mathsf{fma.f64}\left(t, \mathsf{fma.f64}\left(\mathsf{*.f64}\left(y, z\right), -9, 0\right), \left(27 \cdot \left(a \cdot b\right)\right)\right) \]
      13. +-rgt-identityN/A

        \[\leadsto \mathsf{fma.f64}\left(t, \mathsf{fma.f64}\left(\mathsf{*.f64}\left(y, z\right), -9, \color{blue}{0}\right), \left(27 \cdot \left(a \cdot b\right) + 0\right)\right) \]
      14. accelerator-lowering-fma.f64N/A

        \[\leadsto \mathsf{fma.f64}\left(t, \mathsf{fma.f64}\left(\mathsf{*.f64}\left(y, z\right), -9, \color{blue}{0}\right), \mathsf{fma.f64}\left(27, \left(a \cdot b\right), 0\right)\right) \]
      15. *-lowering-*.f6480.6%

        \[\leadsto \mathsf{fma.f64}\left(t, \mathsf{fma.f64}\left(\mathsf{*.f64}\left(y, z\right), -9, 0\right), \mathsf{fma.f64}\left(27, \mathsf{*.f64}\left(a, b\right), 0\right)\right) \]
    5. Simplified80.6%

      \[\leadsto \color{blue}{\mathsf{fma}\left(t, \mathsf{fma}\left(y \cdot z, -9, 0\right), \mathsf{fma}\left(27, a \cdot b, 0\right)\right)} \]
    6. Step-by-step derivation
      1. +-rgt-identityN/A

        \[\leadsto t \cdot \left(\left(y \cdot z\right) \cdot -9\right) + \left(27 \cdot \color{blue}{\left(a \cdot b\right)} + 0\right) \]
      2. +-rgt-identityN/A

        \[\leadsto t \cdot \left(\left(y \cdot z\right) \cdot -9\right) + 27 \cdot \color{blue}{\left(a \cdot b\right)} \]
      3. *-commutativeN/A

        \[\leadsto \left(\left(y \cdot z\right) \cdot -9\right) \cdot t + \color{blue}{27} \cdot \left(a \cdot b\right) \]
      4. associate-*r*N/A

        \[\leadsto \left(y \cdot \left(z \cdot -9\right)\right) \cdot t + 27 \cdot \left(a \cdot b\right) \]
      5. +-commutativeN/A

        \[\leadsto 27 \cdot \left(a \cdot b\right) + \color{blue}{\left(y \cdot \left(z \cdot -9\right)\right) \cdot t} \]
      6. *-commutativeN/A

        \[\leadsto 27 \cdot \left(b \cdot a\right) + \left(y \cdot \color{blue}{\left(z \cdot -9\right)}\right) \cdot t \]
      7. associate-*r*N/A

        \[\leadsto \left(27 \cdot b\right) \cdot a + \color{blue}{\left(y \cdot \left(z \cdot -9\right)\right)} \cdot t \]
      8. accelerator-lowering-fma.f64N/A

        \[\leadsto \mathsf{fma.f64}\left(\left(27 \cdot b\right), \color{blue}{a}, \left(\left(y \cdot \left(z \cdot -9\right)\right) \cdot t\right)\right) \]
      9. *-lowering-*.f64N/A

        \[\leadsto \mathsf{fma.f64}\left(\mathsf{*.f64}\left(27, b\right), a, \left(\left(y \cdot \left(z \cdot -9\right)\right) \cdot t\right)\right) \]
      10. +-rgt-identityN/A

        \[\leadsto \mathsf{fma.f64}\left(\mathsf{*.f64}\left(27, b\right), a, \left(\left(y \cdot \left(z \cdot -9\right)\right) \cdot t + 0\right)\right) \]
      11. associate-*r*N/A

        \[\leadsto \mathsf{fma.f64}\left(\mathsf{*.f64}\left(27, b\right), a, \left(\left(\left(y \cdot z\right) \cdot -9\right) \cdot t + 0\right)\right) \]
      12. *-commutativeN/A

        \[\leadsto \mathsf{fma.f64}\left(\mathsf{*.f64}\left(27, b\right), a, \left(\left(-9 \cdot \left(y \cdot z\right)\right) \cdot t + 0\right)\right) \]
      13. associate-*l*N/A

        \[\leadsto \mathsf{fma.f64}\left(\mathsf{*.f64}\left(27, b\right), a, \left(-9 \cdot \left(\left(y \cdot z\right) \cdot t\right) + 0\right)\right) \]
      14. accelerator-lowering-fma.f64N/A

        \[\leadsto \mathsf{fma.f64}\left(\mathsf{*.f64}\left(27, b\right), a, \mathsf{fma.f64}\left(-9, \left(\left(y \cdot z\right) \cdot t\right), 0\right)\right) \]
      15. *-lowering-*.f64N/A

        \[\leadsto \mathsf{fma.f64}\left(\mathsf{*.f64}\left(27, b\right), a, \mathsf{fma.f64}\left(-9, \mathsf{*.f64}\left(\left(y \cdot z\right), t\right), 0\right)\right) \]
      16. *-lowering-*.f6486.0%

        \[\leadsto \mathsf{fma.f64}\left(\mathsf{*.f64}\left(27, b\right), a, \mathsf{fma.f64}\left(-9, \mathsf{*.f64}\left(\mathsf{*.f64}\left(y, z\right), t\right), 0\right)\right) \]
    7. Applied egg-rr86.0%

      \[\leadsto \color{blue}{\mathsf{fma}\left(27 \cdot b, a, \mathsf{fma}\left(-9, \left(y \cdot z\right) \cdot t, 0\right)\right)} \]
    8. Step-by-step derivation
      1. +-rgt-identityN/A

        \[\leadsto \mathsf{fma.f64}\left(\mathsf{*.f64}\left(27, b\right), a, \left(-9 \cdot \left(\left(y \cdot z\right) \cdot t\right)\right)\right) \]
      2. associate-*l*N/A

        \[\leadsto \mathsf{fma.f64}\left(\mathsf{*.f64}\left(27, b\right), a, \left(-9 \cdot \left(y \cdot \left(z \cdot t\right)\right)\right)\right) \]
      3. associate-*r*N/A

        \[\leadsto \mathsf{fma.f64}\left(\mathsf{*.f64}\left(27, b\right), a, \left(\left(-9 \cdot y\right) \cdot \left(z \cdot t\right)\right)\right) \]
      4. *-commutativeN/A

        \[\leadsto \mathsf{fma.f64}\left(\mathsf{*.f64}\left(27, b\right), a, \left(\left(y \cdot -9\right) \cdot \left(z \cdot t\right)\right)\right) \]
      5. *-commutativeN/A

        \[\leadsto \mathsf{fma.f64}\left(\mathsf{*.f64}\left(27, b\right), a, \left(\left(z \cdot t\right) \cdot \left(y \cdot -9\right)\right)\right) \]
      6. associate-*l*N/A

        \[\leadsto \mathsf{fma.f64}\left(\mathsf{*.f64}\left(27, b\right), a, \left(z \cdot \left(t \cdot \left(y \cdot -9\right)\right)\right)\right) \]
      7. *-commutativeN/A

        \[\leadsto \mathsf{fma.f64}\left(\mathsf{*.f64}\left(27, b\right), a, \left(\left(t \cdot \left(y \cdot -9\right)\right) \cdot z\right)\right) \]
      8. *-lowering-*.f64N/A

        \[\leadsto \mathsf{fma.f64}\left(\mathsf{*.f64}\left(27, b\right), a, \mathsf{*.f64}\left(\left(t \cdot \left(y \cdot -9\right)\right), z\right)\right) \]
      9. *-lowering-*.f64N/A

        \[\leadsto \mathsf{fma.f64}\left(\mathsf{*.f64}\left(27, b\right), a, \mathsf{*.f64}\left(\mathsf{*.f64}\left(t, \left(y \cdot -9\right)\right), z\right)\right) \]
      10. *-lowering-*.f6483.5%

        \[\leadsto \mathsf{fma.f64}\left(\mathsf{*.f64}\left(27, b\right), a, \mathsf{*.f64}\left(\mathsf{*.f64}\left(t, \mathsf{*.f64}\left(y, -9\right)\right), z\right)\right) \]
    9. Applied egg-rr83.5%

      \[\leadsto \mathsf{fma}\left(27 \cdot b, a, \color{blue}{\left(t \cdot \left(y \cdot -9\right)\right) \cdot z}\right) \]
  3. Recombined 3 regimes into one program.
  4. Final simplification89.0%

    \[\leadsto \begin{array}{l} \mathbf{if}\;\left(a \cdot 27\right) \cdot b \leq -1 \cdot 10^{+41}:\\ \;\;\;\;\mathsf{fma}\left(z \cdot t, y \cdot -9, 27 \cdot \left(a \cdot b\right)\right)\\ \mathbf{elif}\;\left(a \cdot 27\right) \cdot b \leq 2 \cdot 10^{+89}:\\ \;\;\;\;\mathsf{fma}\left(y \cdot \left(z \cdot -9\right), t, x \cdot 2\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(27 \cdot b, a, z \cdot \left(t \cdot \left(y \cdot -9\right)\right)\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 6: 82.7% accurate, 0.6× speedup?

\[\begin{array}{l} [x, y, z, t, a, b] = \mathsf{sort}([x, y, z, t, a, b])\\\\ [x, y, z, t, a, b] = \mathsf{sort}([x, y, z, t, a, b])\\ \\ \begin{array}{l} t_1 := \left(a \cdot 27\right) \cdot b\\ \mathbf{if}\;t\_1 \leq -4 \cdot 10^{+100}:\\ \;\;\;\;\mathsf{fma}\left(27, a \cdot b, x \cdot 2\right)\\ \mathbf{elif}\;t\_1 \leq 2 \cdot 10^{+89}:\\ \;\;\;\;\mathsf{fma}\left(y \cdot \left(z \cdot -9\right), t, x \cdot 2\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(27 \cdot b, a, z \cdot \left(t \cdot \left(y \cdot -9\right)\right)\right)\\ \end{array} \end{array} \]
NOTE: x, y, z, t, a, and b should be sorted in increasing order before calling this function.
NOTE: x, y, z, t, a, and b should be sorted in increasing order before calling this function.
(FPCore (x y z t a b)
 :precision binary64
 (let* ((t_1 (* (* a 27.0) b)))
   (if (<= t_1 -4e+100)
     (fma 27.0 (* a b) (* x 2.0))
     (if (<= t_1 2e+89)
       (fma (* y (* z -9.0)) t (* x 2.0))
       (fma (* 27.0 b) a (* z (* t (* y -9.0))))))))
assert(x < y && y < z && z < t && t < a && a < b);
assert(x < y && y < z && z < t && t < a && a < b);
double code(double x, double y, double z, double t, double a, double b) {
	double t_1 = (a * 27.0) * b;
	double tmp;
	if (t_1 <= -4e+100) {
		tmp = fma(27.0, (a * b), (x * 2.0));
	} else if (t_1 <= 2e+89) {
		tmp = fma((y * (z * -9.0)), t, (x * 2.0));
	} else {
		tmp = fma((27.0 * b), a, (z * (t * (y * -9.0))));
	}
	return tmp;
}
x, y, z, t, a, b = sort([x, y, z, t, a, b])
x, y, z, t, a, b = sort([x, y, z, t, a, b])
function code(x, y, z, t, a, b)
	t_1 = Float64(Float64(a * 27.0) * b)
	tmp = 0.0
	if (t_1 <= -4e+100)
		tmp = fma(27.0, Float64(a * b), Float64(x * 2.0));
	elseif (t_1 <= 2e+89)
		tmp = fma(Float64(y * Float64(z * -9.0)), t, Float64(x * 2.0));
	else
		tmp = fma(Float64(27.0 * b), a, Float64(z * Float64(t * Float64(y * -9.0))));
	end
	return tmp
end
NOTE: x, y, z, t, a, and b should be sorted in increasing order before calling this function.
NOTE: x, y, z, t, a, and b should be sorted in increasing order before calling this function.
code[x_, y_, z_, t_, a_, b_] := Block[{t$95$1 = N[(N[(a * 27.0), $MachinePrecision] * b), $MachinePrecision]}, If[LessEqual[t$95$1, -4e+100], N[(27.0 * N[(a * b), $MachinePrecision] + N[(x * 2.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$1, 2e+89], N[(N[(y * N[(z * -9.0), $MachinePrecision]), $MachinePrecision] * t + N[(x * 2.0), $MachinePrecision]), $MachinePrecision], N[(N[(27.0 * b), $MachinePrecision] * a + N[(z * N[(t * N[(y * -9.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
[x, y, z, t, a, b] = \mathsf{sort}([x, y, z, t, a, b])\\\\
[x, y, z, t, a, b] = \mathsf{sort}([x, y, z, t, a, b])\\
\\
\begin{array}{l}
t_1 := \left(a \cdot 27\right) \cdot b\\
\mathbf{if}\;t\_1 \leq -4 \cdot 10^{+100}:\\
\;\;\;\;\mathsf{fma}\left(27, a \cdot b, x \cdot 2\right)\\

\mathbf{elif}\;t\_1 \leq 2 \cdot 10^{+89}:\\
\;\;\;\;\mathsf{fma}\left(y \cdot \left(z \cdot -9\right), t, x \cdot 2\right)\\

\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(27 \cdot b, a, z \cdot \left(t \cdot \left(y \cdot -9\right)\right)\right)\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if (*.f64 (*.f64 a #s(literal 27 binary64)) b) < -4.00000000000000006e100

    1. Initial program 97.4%

      \[\left(x \cdot 2 - \left(\left(y \cdot 9\right) \cdot z\right) \cdot t\right) + \left(a \cdot 27\right) \cdot b \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. sub-negN/A

        \[\leadsto \left(x \cdot 2 + \left(\mathsf{neg}\left(\left(\left(y \cdot 9\right) \cdot z\right) \cdot t\right)\right)\right) + \color{blue}{\left(a \cdot 27\right)} \cdot b \]
      2. +-commutativeN/A

        \[\leadsto \left(\left(\mathsf{neg}\left(\left(\left(y \cdot 9\right) \cdot z\right) \cdot t\right)\right) + x \cdot 2\right) + \color{blue}{\left(a \cdot 27\right)} \cdot b \]
      3. associate-+l+N/A

        \[\leadsto \left(\mathsf{neg}\left(\left(\left(y \cdot 9\right) \cdot z\right) \cdot t\right)\right) + \color{blue}{\left(x \cdot 2 + \left(a \cdot 27\right) \cdot b\right)} \]
      4. distribute-lft-neg-inN/A

        \[\leadsto \left(\mathsf{neg}\left(\left(y \cdot 9\right) \cdot z\right)\right) \cdot t + \left(\color{blue}{x \cdot 2} + \left(a \cdot 27\right) \cdot b\right) \]
      5. +-commutativeN/A

        \[\leadsto \left(\mathsf{neg}\left(\left(y \cdot 9\right) \cdot z\right)\right) \cdot t + \left(\left(a \cdot 27\right) \cdot b + \color{blue}{x \cdot 2}\right) \]
      6. accelerator-lowering-fma.f64N/A

        \[\leadsto \mathsf{fma.f64}\left(\left(\mathsf{neg}\left(\left(y \cdot 9\right) \cdot z\right)\right), \color{blue}{t}, \left(\left(a \cdot 27\right) \cdot b + x \cdot 2\right)\right) \]
      7. associate-*l*N/A

        \[\leadsto \mathsf{fma.f64}\left(\left(\mathsf{neg}\left(y \cdot \left(9 \cdot z\right)\right)\right), t, \left(\left(a \cdot 27\right) \cdot b + x \cdot 2\right)\right) \]
      8. distribute-rgt-neg-inN/A

        \[\leadsto \mathsf{fma.f64}\left(\left(y \cdot \left(\mathsf{neg}\left(9 \cdot z\right)\right)\right), t, \left(\left(a \cdot 27\right) \cdot b + x \cdot 2\right)\right) \]
      9. *-lowering-*.f64N/A

        \[\leadsto \mathsf{fma.f64}\left(\mathsf{*.f64}\left(y, \left(\mathsf{neg}\left(9 \cdot z\right)\right)\right), t, \left(\left(a \cdot 27\right) \cdot b + x \cdot 2\right)\right) \]
      10. *-commutativeN/A

        \[\leadsto \mathsf{fma.f64}\left(\mathsf{*.f64}\left(y, \left(\mathsf{neg}\left(z \cdot 9\right)\right)\right), t, \left(\left(a \cdot 27\right) \cdot b + x \cdot 2\right)\right) \]
      11. distribute-rgt-neg-inN/A

        \[\leadsto \mathsf{fma.f64}\left(\mathsf{*.f64}\left(y, \left(z \cdot \left(\mathsf{neg}\left(9\right)\right)\right)\right), t, \left(\left(a \cdot 27\right) \cdot b + x \cdot 2\right)\right) \]
      12. *-lowering-*.f64N/A

        \[\leadsto \mathsf{fma.f64}\left(\mathsf{*.f64}\left(y, \mathsf{*.f64}\left(z, \left(\mathsf{neg}\left(9\right)\right)\right)\right), t, \left(\left(a \cdot 27\right) \cdot b + x \cdot 2\right)\right) \]
      13. metadata-evalN/A

        \[\leadsto \mathsf{fma.f64}\left(\mathsf{*.f64}\left(y, \mathsf{*.f64}\left(z, -9\right)\right), t, \left(\left(a \cdot 27\right) \cdot b + x \cdot 2\right)\right) \]
      14. associate-*l*N/A

        \[\leadsto \mathsf{fma.f64}\left(\mathsf{*.f64}\left(y, \mathsf{*.f64}\left(z, -9\right)\right), t, \left(a \cdot \left(27 \cdot b\right) + x \cdot 2\right)\right) \]
      15. accelerator-lowering-fma.f64N/A

        \[\leadsto \mathsf{fma.f64}\left(\mathsf{*.f64}\left(y, \mathsf{*.f64}\left(z, -9\right)\right), t, \mathsf{fma.f64}\left(a, \left(27 \cdot b\right), \left(x \cdot 2\right)\right)\right) \]
      16. *-lowering-*.f64N/A

        \[\leadsto \mathsf{fma.f64}\left(\mathsf{*.f64}\left(y, \mathsf{*.f64}\left(z, -9\right)\right), t, \mathsf{fma.f64}\left(a, \mathsf{*.f64}\left(27, b\right), \left(x \cdot 2\right)\right)\right) \]
      17. *-lowering-*.f6497.4%

        \[\leadsto \mathsf{fma.f64}\left(\mathsf{*.f64}\left(y, \mathsf{*.f64}\left(z, -9\right)\right), t, \mathsf{fma.f64}\left(a, \mathsf{*.f64}\left(27, b\right), \mathsf{*.f64}\left(x, 2\right)\right)\right) \]
    4. Applied egg-rr97.4%

      \[\leadsto \color{blue}{\mathsf{fma}\left(y \cdot \left(z \cdot -9\right), t, \mathsf{fma}\left(a, 27 \cdot b, x \cdot 2\right)\right)} \]
    5. Taylor expanded in y around 0

      \[\leadsto \color{blue}{2 \cdot x + 27 \cdot \left(a \cdot b\right)} \]
    6. Step-by-step derivation
      1. +-commutativeN/A

        \[\leadsto 27 \cdot \left(a \cdot b\right) + \color{blue}{2 \cdot x} \]
      2. accelerator-lowering-fma.f64N/A

        \[\leadsto \mathsf{fma.f64}\left(27, \color{blue}{\left(a \cdot b\right)}, \left(2 \cdot x\right)\right) \]
      3. *-lowering-*.f64N/A

        \[\leadsto \mathsf{fma.f64}\left(27, \mathsf{*.f64}\left(a, \color{blue}{b}\right), \left(2 \cdot x\right)\right) \]
      4. *-lowering-*.f6492.7%

        \[\leadsto \mathsf{fma.f64}\left(27, \mathsf{*.f64}\left(a, b\right), \mathsf{*.f64}\left(2, x\right)\right) \]
    7. Simplified92.7%

      \[\leadsto \color{blue}{\mathsf{fma}\left(27, a \cdot b, 2 \cdot x\right)} \]

    if -4.00000000000000006e100 < (*.f64 (*.f64 a #s(literal 27 binary64)) b) < 1.99999999999999999e89

    1. Initial program 97.4%

      \[\left(x \cdot 2 - \left(\left(y \cdot 9\right) \cdot z\right) \cdot t\right) + \left(a \cdot 27\right) \cdot b \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. sub-negN/A

        \[\leadsto \left(x \cdot 2 + \left(\mathsf{neg}\left(\left(\left(y \cdot 9\right) \cdot z\right) \cdot t\right)\right)\right) + \color{blue}{\left(a \cdot 27\right)} \cdot b \]
      2. +-commutativeN/A

        \[\leadsto \left(\left(\mathsf{neg}\left(\left(\left(y \cdot 9\right) \cdot z\right) \cdot t\right)\right) + x \cdot 2\right) + \color{blue}{\left(a \cdot 27\right)} \cdot b \]
      3. associate-+l+N/A

        \[\leadsto \left(\mathsf{neg}\left(\left(\left(y \cdot 9\right) \cdot z\right) \cdot t\right)\right) + \color{blue}{\left(x \cdot 2 + \left(a \cdot 27\right) \cdot b\right)} \]
      4. distribute-lft-neg-inN/A

        \[\leadsto \left(\mathsf{neg}\left(\left(y \cdot 9\right) \cdot z\right)\right) \cdot t + \left(\color{blue}{x \cdot 2} + \left(a \cdot 27\right) \cdot b\right) \]
      5. +-commutativeN/A

        \[\leadsto \left(\mathsf{neg}\left(\left(y \cdot 9\right) \cdot z\right)\right) \cdot t + \left(\left(a \cdot 27\right) \cdot b + \color{blue}{x \cdot 2}\right) \]
      6. accelerator-lowering-fma.f64N/A

        \[\leadsto \mathsf{fma.f64}\left(\left(\mathsf{neg}\left(\left(y \cdot 9\right) \cdot z\right)\right), \color{blue}{t}, \left(\left(a \cdot 27\right) \cdot b + x \cdot 2\right)\right) \]
      7. associate-*l*N/A

        \[\leadsto \mathsf{fma.f64}\left(\left(\mathsf{neg}\left(y \cdot \left(9 \cdot z\right)\right)\right), t, \left(\left(a \cdot 27\right) \cdot b + x \cdot 2\right)\right) \]
      8. distribute-rgt-neg-inN/A

        \[\leadsto \mathsf{fma.f64}\left(\left(y \cdot \left(\mathsf{neg}\left(9 \cdot z\right)\right)\right), t, \left(\left(a \cdot 27\right) \cdot b + x \cdot 2\right)\right) \]
      9. *-lowering-*.f64N/A

        \[\leadsto \mathsf{fma.f64}\left(\mathsf{*.f64}\left(y, \left(\mathsf{neg}\left(9 \cdot z\right)\right)\right), t, \left(\left(a \cdot 27\right) \cdot b + x \cdot 2\right)\right) \]
      10. *-commutativeN/A

        \[\leadsto \mathsf{fma.f64}\left(\mathsf{*.f64}\left(y, \left(\mathsf{neg}\left(z \cdot 9\right)\right)\right), t, \left(\left(a \cdot 27\right) \cdot b + x \cdot 2\right)\right) \]
      11. distribute-rgt-neg-inN/A

        \[\leadsto \mathsf{fma.f64}\left(\mathsf{*.f64}\left(y, \left(z \cdot \left(\mathsf{neg}\left(9\right)\right)\right)\right), t, \left(\left(a \cdot 27\right) \cdot b + x \cdot 2\right)\right) \]
      12. *-lowering-*.f64N/A

        \[\leadsto \mathsf{fma.f64}\left(\mathsf{*.f64}\left(y, \mathsf{*.f64}\left(z, \left(\mathsf{neg}\left(9\right)\right)\right)\right), t, \left(\left(a \cdot 27\right) \cdot b + x \cdot 2\right)\right) \]
      13. metadata-evalN/A

        \[\leadsto \mathsf{fma.f64}\left(\mathsf{*.f64}\left(y, \mathsf{*.f64}\left(z, -9\right)\right), t, \left(\left(a \cdot 27\right) \cdot b + x \cdot 2\right)\right) \]
      14. associate-*l*N/A

        \[\leadsto \mathsf{fma.f64}\left(\mathsf{*.f64}\left(y, \mathsf{*.f64}\left(z, -9\right)\right), t, \left(a \cdot \left(27 \cdot b\right) + x \cdot 2\right)\right) \]
      15. accelerator-lowering-fma.f64N/A

        \[\leadsto \mathsf{fma.f64}\left(\mathsf{*.f64}\left(y, \mathsf{*.f64}\left(z, -9\right)\right), t, \mathsf{fma.f64}\left(a, \left(27 \cdot b\right), \left(x \cdot 2\right)\right)\right) \]
      16. *-lowering-*.f64N/A

        \[\leadsto \mathsf{fma.f64}\left(\mathsf{*.f64}\left(y, \mathsf{*.f64}\left(z, -9\right)\right), t, \mathsf{fma.f64}\left(a, \mathsf{*.f64}\left(27, b\right), \left(x \cdot 2\right)\right)\right) \]
      17. *-lowering-*.f6497.3%

        \[\leadsto \mathsf{fma.f64}\left(\mathsf{*.f64}\left(y, \mathsf{*.f64}\left(z, -9\right)\right), t, \mathsf{fma.f64}\left(a, \mathsf{*.f64}\left(27, b\right), \mathsf{*.f64}\left(x, 2\right)\right)\right) \]
    4. Applied egg-rr97.3%

      \[\leadsto \color{blue}{\mathsf{fma}\left(y \cdot \left(z \cdot -9\right), t, \mathsf{fma}\left(a, 27 \cdot b, x \cdot 2\right)\right)} \]
    5. Taylor expanded in a around 0

      \[\leadsto \mathsf{fma.f64}\left(\mathsf{*.f64}\left(y, \mathsf{*.f64}\left(z, -9\right)\right), t, \color{blue}{\left(2 \cdot x\right)}\right) \]
    6. Step-by-step derivation
      1. *-lowering-*.f6488.1%

        \[\leadsto \mathsf{fma.f64}\left(\mathsf{*.f64}\left(y, \mathsf{*.f64}\left(z, -9\right)\right), t, \mathsf{*.f64}\left(2, x\right)\right) \]
    7. Simplified88.1%

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

    if 1.99999999999999999e89 < (*.f64 (*.f64 a #s(literal 27 binary64)) b)

    1. Initial program 89.3%

      \[\left(x \cdot 2 - \left(\left(y \cdot 9\right) \cdot z\right) \cdot t\right) + \left(a \cdot 27\right) \cdot b \]
    2. Add Preprocessing
    3. Taylor expanded in x around 0

      \[\leadsto \color{blue}{27 \cdot \left(a \cdot b\right) - 9 \cdot \left(t \cdot \left(y \cdot z\right)\right)} \]
    4. Step-by-step derivation
      1. cancel-sign-sub-invN/A

        \[\leadsto 27 \cdot \left(a \cdot b\right) + \color{blue}{\left(\mathsf{neg}\left(9\right)\right) \cdot \left(t \cdot \left(y \cdot z\right)\right)} \]
      2. metadata-evalN/A

        \[\leadsto 27 \cdot \left(a \cdot b\right) + -9 \cdot \left(\color{blue}{t} \cdot \left(y \cdot z\right)\right) \]
      3. +-commutativeN/A

        \[\leadsto -9 \cdot \left(t \cdot \left(y \cdot z\right)\right) + \color{blue}{27 \cdot \left(a \cdot b\right)} \]
      4. *-commutativeN/A

        \[\leadsto \left(t \cdot \left(y \cdot z\right)\right) \cdot -9 + \color{blue}{27} \cdot \left(a \cdot b\right) \]
      5. associate-*l*N/A

        \[\leadsto t \cdot \left(\left(y \cdot z\right) \cdot -9\right) + \color{blue}{27} \cdot \left(a \cdot b\right) \]
      6. *-commutativeN/A

        \[\leadsto t \cdot \left(-9 \cdot \left(y \cdot z\right)\right) + 27 \cdot \left(a \cdot b\right) \]
      7. accelerator-lowering-fma.f64N/A

        \[\leadsto \mathsf{fma.f64}\left(t, \color{blue}{\left(-9 \cdot \left(y \cdot z\right)\right)}, \left(27 \cdot \left(a \cdot b\right)\right)\right) \]
      8. +-lft-identityN/A

        \[\leadsto \mathsf{fma.f64}\left(t, \left(0 + \color{blue}{-9 \cdot \left(y \cdot z\right)}\right), \left(27 \cdot \left(a \cdot b\right)\right)\right) \]
      9. +-commutativeN/A

        \[\leadsto \mathsf{fma.f64}\left(t, \left(-9 \cdot \left(y \cdot z\right) + \color{blue}{0}\right), \left(27 \cdot \left(a \cdot b\right)\right)\right) \]
      10. *-commutativeN/A

        \[\leadsto \mathsf{fma.f64}\left(t, \left(\left(y \cdot z\right) \cdot -9 + 0\right), \left(27 \cdot \left(a \cdot b\right)\right)\right) \]
      11. accelerator-lowering-fma.f64N/A

        \[\leadsto \mathsf{fma.f64}\left(t, \mathsf{fma.f64}\left(\left(y \cdot z\right), \color{blue}{-9}, 0\right), \left(27 \cdot \left(a \cdot b\right)\right)\right) \]
      12. *-lowering-*.f64N/A

        \[\leadsto \mathsf{fma.f64}\left(t, \mathsf{fma.f64}\left(\mathsf{*.f64}\left(y, z\right), -9, 0\right), \left(27 \cdot \left(a \cdot b\right)\right)\right) \]
      13. +-rgt-identityN/A

        \[\leadsto \mathsf{fma.f64}\left(t, \mathsf{fma.f64}\left(\mathsf{*.f64}\left(y, z\right), -9, \color{blue}{0}\right), \left(27 \cdot \left(a \cdot b\right) + 0\right)\right) \]
      14. accelerator-lowering-fma.f64N/A

        \[\leadsto \mathsf{fma.f64}\left(t, \mathsf{fma.f64}\left(\mathsf{*.f64}\left(y, z\right), -9, \color{blue}{0}\right), \mathsf{fma.f64}\left(27, \left(a \cdot b\right), 0\right)\right) \]
      15. *-lowering-*.f6480.6%

        \[\leadsto \mathsf{fma.f64}\left(t, \mathsf{fma.f64}\left(\mathsf{*.f64}\left(y, z\right), -9, 0\right), \mathsf{fma.f64}\left(27, \mathsf{*.f64}\left(a, b\right), 0\right)\right) \]
    5. Simplified80.6%

      \[\leadsto \color{blue}{\mathsf{fma}\left(t, \mathsf{fma}\left(y \cdot z, -9, 0\right), \mathsf{fma}\left(27, a \cdot b, 0\right)\right)} \]
    6. Step-by-step derivation
      1. +-rgt-identityN/A

        \[\leadsto t \cdot \left(\left(y \cdot z\right) \cdot -9\right) + \left(27 \cdot \color{blue}{\left(a \cdot b\right)} + 0\right) \]
      2. +-rgt-identityN/A

        \[\leadsto t \cdot \left(\left(y \cdot z\right) \cdot -9\right) + 27 \cdot \color{blue}{\left(a \cdot b\right)} \]
      3. *-commutativeN/A

        \[\leadsto \left(\left(y \cdot z\right) \cdot -9\right) \cdot t + \color{blue}{27} \cdot \left(a \cdot b\right) \]
      4. associate-*r*N/A

        \[\leadsto \left(y \cdot \left(z \cdot -9\right)\right) \cdot t + 27 \cdot \left(a \cdot b\right) \]
      5. +-commutativeN/A

        \[\leadsto 27 \cdot \left(a \cdot b\right) + \color{blue}{\left(y \cdot \left(z \cdot -9\right)\right) \cdot t} \]
      6. *-commutativeN/A

        \[\leadsto 27 \cdot \left(b \cdot a\right) + \left(y \cdot \color{blue}{\left(z \cdot -9\right)}\right) \cdot t \]
      7. associate-*r*N/A

        \[\leadsto \left(27 \cdot b\right) \cdot a + \color{blue}{\left(y \cdot \left(z \cdot -9\right)\right)} \cdot t \]
      8. accelerator-lowering-fma.f64N/A

        \[\leadsto \mathsf{fma.f64}\left(\left(27 \cdot b\right), \color{blue}{a}, \left(\left(y \cdot \left(z \cdot -9\right)\right) \cdot t\right)\right) \]
      9. *-lowering-*.f64N/A

        \[\leadsto \mathsf{fma.f64}\left(\mathsf{*.f64}\left(27, b\right), a, \left(\left(y \cdot \left(z \cdot -9\right)\right) \cdot t\right)\right) \]
      10. +-rgt-identityN/A

        \[\leadsto \mathsf{fma.f64}\left(\mathsf{*.f64}\left(27, b\right), a, \left(\left(y \cdot \left(z \cdot -9\right)\right) \cdot t + 0\right)\right) \]
      11. associate-*r*N/A

        \[\leadsto \mathsf{fma.f64}\left(\mathsf{*.f64}\left(27, b\right), a, \left(\left(\left(y \cdot z\right) \cdot -9\right) \cdot t + 0\right)\right) \]
      12. *-commutativeN/A

        \[\leadsto \mathsf{fma.f64}\left(\mathsf{*.f64}\left(27, b\right), a, \left(\left(-9 \cdot \left(y \cdot z\right)\right) \cdot t + 0\right)\right) \]
      13. associate-*l*N/A

        \[\leadsto \mathsf{fma.f64}\left(\mathsf{*.f64}\left(27, b\right), a, \left(-9 \cdot \left(\left(y \cdot z\right) \cdot t\right) + 0\right)\right) \]
      14. accelerator-lowering-fma.f64N/A

        \[\leadsto \mathsf{fma.f64}\left(\mathsf{*.f64}\left(27, b\right), a, \mathsf{fma.f64}\left(-9, \left(\left(y \cdot z\right) \cdot t\right), 0\right)\right) \]
      15. *-lowering-*.f64N/A

        \[\leadsto \mathsf{fma.f64}\left(\mathsf{*.f64}\left(27, b\right), a, \mathsf{fma.f64}\left(-9, \mathsf{*.f64}\left(\left(y \cdot z\right), t\right), 0\right)\right) \]
      16. *-lowering-*.f6486.0%

        \[\leadsto \mathsf{fma.f64}\left(\mathsf{*.f64}\left(27, b\right), a, \mathsf{fma.f64}\left(-9, \mathsf{*.f64}\left(\mathsf{*.f64}\left(y, z\right), t\right), 0\right)\right) \]
    7. Applied egg-rr86.0%

      \[\leadsto \color{blue}{\mathsf{fma}\left(27 \cdot b, a, \mathsf{fma}\left(-9, \left(y \cdot z\right) \cdot t, 0\right)\right)} \]
    8. Step-by-step derivation
      1. +-rgt-identityN/A

        \[\leadsto \mathsf{fma.f64}\left(\mathsf{*.f64}\left(27, b\right), a, \left(-9 \cdot \left(\left(y \cdot z\right) \cdot t\right)\right)\right) \]
      2. associate-*l*N/A

        \[\leadsto \mathsf{fma.f64}\left(\mathsf{*.f64}\left(27, b\right), a, \left(-9 \cdot \left(y \cdot \left(z \cdot t\right)\right)\right)\right) \]
      3. associate-*r*N/A

        \[\leadsto \mathsf{fma.f64}\left(\mathsf{*.f64}\left(27, b\right), a, \left(\left(-9 \cdot y\right) \cdot \left(z \cdot t\right)\right)\right) \]
      4. *-commutativeN/A

        \[\leadsto \mathsf{fma.f64}\left(\mathsf{*.f64}\left(27, b\right), a, \left(\left(y \cdot -9\right) \cdot \left(z \cdot t\right)\right)\right) \]
      5. *-commutativeN/A

        \[\leadsto \mathsf{fma.f64}\left(\mathsf{*.f64}\left(27, b\right), a, \left(\left(z \cdot t\right) \cdot \left(y \cdot -9\right)\right)\right) \]
      6. associate-*l*N/A

        \[\leadsto \mathsf{fma.f64}\left(\mathsf{*.f64}\left(27, b\right), a, \left(z \cdot \left(t \cdot \left(y \cdot -9\right)\right)\right)\right) \]
      7. *-commutativeN/A

        \[\leadsto \mathsf{fma.f64}\left(\mathsf{*.f64}\left(27, b\right), a, \left(\left(t \cdot \left(y \cdot -9\right)\right) \cdot z\right)\right) \]
      8. *-lowering-*.f64N/A

        \[\leadsto \mathsf{fma.f64}\left(\mathsf{*.f64}\left(27, b\right), a, \mathsf{*.f64}\left(\left(t \cdot \left(y \cdot -9\right)\right), z\right)\right) \]
      9. *-lowering-*.f64N/A

        \[\leadsto \mathsf{fma.f64}\left(\mathsf{*.f64}\left(27, b\right), a, \mathsf{*.f64}\left(\mathsf{*.f64}\left(t, \left(y \cdot -9\right)\right), z\right)\right) \]
      10. *-lowering-*.f6483.5%

        \[\leadsto \mathsf{fma.f64}\left(\mathsf{*.f64}\left(27, b\right), a, \mathsf{*.f64}\left(\mathsf{*.f64}\left(t, \mathsf{*.f64}\left(y, -9\right)\right), z\right)\right) \]
    9. Applied egg-rr83.5%

      \[\leadsto \mathsf{fma}\left(27 \cdot b, a, \color{blue}{\left(t \cdot \left(y \cdot -9\right)\right) \cdot z}\right) \]
  3. Recombined 3 regimes into one program.
  4. Final simplification88.1%

    \[\leadsto \begin{array}{l} \mathbf{if}\;\left(a \cdot 27\right) \cdot b \leq -4 \cdot 10^{+100}:\\ \;\;\;\;\mathsf{fma}\left(27, a \cdot b, x \cdot 2\right)\\ \mathbf{elif}\;\left(a \cdot 27\right) \cdot b \leq 2 \cdot 10^{+89}:\\ \;\;\;\;\mathsf{fma}\left(y \cdot \left(z \cdot -9\right), t, x \cdot 2\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(27 \cdot b, a, z \cdot \left(t \cdot \left(y \cdot -9\right)\right)\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 7: 82.9% accurate, 0.6× speedup?

\[\begin{array}{l} [x, y, z, t, a, b] = \mathsf{sort}([x, y, z, t, a, b])\\\\ [x, y, z, t, a, b] = \mathsf{sort}([x, y, z, t, a, b])\\ \\ \begin{array}{l} t_1 := \left(a \cdot 27\right) \cdot b\\ \mathbf{if}\;t\_1 \leq -4 \cdot 10^{+100}:\\ \;\;\;\;\mathsf{fma}\left(27, a \cdot b, x \cdot 2\right)\\ \mathbf{elif}\;t\_1 \leq 2 \cdot 10^{+89}:\\ \;\;\;\;\mathsf{fma}\left(y \cdot \left(z \cdot -9\right), t, x \cdot 2\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(27, a \cdot b, \left(t \cdot -9\right) \cdot \left(y \cdot z\right)\right)\\ \end{array} \end{array} \]
NOTE: x, y, z, t, a, and b should be sorted in increasing order before calling this function.
NOTE: x, y, z, t, a, and b should be sorted in increasing order before calling this function.
(FPCore (x y z t a b)
 :precision binary64
 (let* ((t_1 (* (* a 27.0) b)))
   (if (<= t_1 -4e+100)
     (fma 27.0 (* a b) (* x 2.0))
     (if (<= t_1 2e+89)
       (fma (* y (* z -9.0)) t (* x 2.0))
       (fma 27.0 (* a b) (* (* t -9.0) (* y z)))))))
assert(x < y && y < z && z < t && t < a && a < b);
assert(x < y && y < z && z < t && t < a && a < b);
double code(double x, double y, double z, double t, double a, double b) {
	double t_1 = (a * 27.0) * b;
	double tmp;
	if (t_1 <= -4e+100) {
		tmp = fma(27.0, (a * b), (x * 2.0));
	} else if (t_1 <= 2e+89) {
		tmp = fma((y * (z * -9.0)), t, (x * 2.0));
	} else {
		tmp = fma(27.0, (a * b), ((t * -9.0) * (y * z)));
	}
	return tmp;
}
x, y, z, t, a, b = sort([x, y, z, t, a, b])
x, y, z, t, a, b = sort([x, y, z, t, a, b])
function code(x, y, z, t, a, b)
	t_1 = Float64(Float64(a * 27.0) * b)
	tmp = 0.0
	if (t_1 <= -4e+100)
		tmp = fma(27.0, Float64(a * b), Float64(x * 2.0));
	elseif (t_1 <= 2e+89)
		tmp = fma(Float64(y * Float64(z * -9.0)), t, Float64(x * 2.0));
	else
		tmp = fma(27.0, Float64(a * b), Float64(Float64(t * -9.0) * Float64(y * z)));
	end
	return tmp
end
NOTE: x, y, z, t, a, and b should be sorted in increasing order before calling this function.
NOTE: x, y, z, t, a, and b should be sorted in increasing order before calling this function.
code[x_, y_, z_, t_, a_, b_] := Block[{t$95$1 = N[(N[(a * 27.0), $MachinePrecision] * b), $MachinePrecision]}, If[LessEqual[t$95$1, -4e+100], N[(27.0 * N[(a * b), $MachinePrecision] + N[(x * 2.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$1, 2e+89], N[(N[(y * N[(z * -9.0), $MachinePrecision]), $MachinePrecision] * t + N[(x * 2.0), $MachinePrecision]), $MachinePrecision], N[(27.0 * N[(a * b), $MachinePrecision] + N[(N[(t * -9.0), $MachinePrecision] * N[(y * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
[x, y, z, t, a, b] = \mathsf{sort}([x, y, z, t, a, b])\\\\
[x, y, z, t, a, b] = \mathsf{sort}([x, y, z, t, a, b])\\
\\
\begin{array}{l}
t_1 := \left(a \cdot 27\right) \cdot b\\
\mathbf{if}\;t\_1 \leq -4 \cdot 10^{+100}:\\
\;\;\;\;\mathsf{fma}\left(27, a \cdot b, x \cdot 2\right)\\

\mathbf{elif}\;t\_1 \leq 2 \cdot 10^{+89}:\\
\;\;\;\;\mathsf{fma}\left(y \cdot \left(z \cdot -9\right), t, x \cdot 2\right)\\

\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(27, a \cdot b, \left(t \cdot -9\right) \cdot \left(y \cdot z\right)\right)\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if (*.f64 (*.f64 a #s(literal 27 binary64)) b) < -4.00000000000000006e100

    1. Initial program 97.4%

      \[\left(x \cdot 2 - \left(\left(y \cdot 9\right) \cdot z\right) \cdot t\right) + \left(a \cdot 27\right) \cdot b \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. sub-negN/A

        \[\leadsto \left(x \cdot 2 + \left(\mathsf{neg}\left(\left(\left(y \cdot 9\right) \cdot z\right) \cdot t\right)\right)\right) + \color{blue}{\left(a \cdot 27\right)} \cdot b \]
      2. +-commutativeN/A

        \[\leadsto \left(\left(\mathsf{neg}\left(\left(\left(y \cdot 9\right) \cdot z\right) \cdot t\right)\right) + x \cdot 2\right) + \color{blue}{\left(a \cdot 27\right)} \cdot b \]
      3. associate-+l+N/A

        \[\leadsto \left(\mathsf{neg}\left(\left(\left(y \cdot 9\right) \cdot z\right) \cdot t\right)\right) + \color{blue}{\left(x \cdot 2 + \left(a \cdot 27\right) \cdot b\right)} \]
      4. distribute-lft-neg-inN/A

        \[\leadsto \left(\mathsf{neg}\left(\left(y \cdot 9\right) \cdot z\right)\right) \cdot t + \left(\color{blue}{x \cdot 2} + \left(a \cdot 27\right) \cdot b\right) \]
      5. +-commutativeN/A

        \[\leadsto \left(\mathsf{neg}\left(\left(y \cdot 9\right) \cdot z\right)\right) \cdot t + \left(\left(a \cdot 27\right) \cdot b + \color{blue}{x \cdot 2}\right) \]
      6. accelerator-lowering-fma.f64N/A

        \[\leadsto \mathsf{fma.f64}\left(\left(\mathsf{neg}\left(\left(y \cdot 9\right) \cdot z\right)\right), \color{blue}{t}, \left(\left(a \cdot 27\right) \cdot b + x \cdot 2\right)\right) \]
      7. associate-*l*N/A

        \[\leadsto \mathsf{fma.f64}\left(\left(\mathsf{neg}\left(y \cdot \left(9 \cdot z\right)\right)\right), t, \left(\left(a \cdot 27\right) \cdot b + x \cdot 2\right)\right) \]
      8. distribute-rgt-neg-inN/A

        \[\leadsto \mathsf{fma.f64}\left(\left(y \cdot \left(\mathsf{neg}\left(9 \cdot z\right)\right)\right), t, \left(\left(a \cdot 27\right) \cdot b + x \cdot 2\right)\right) \]
      9. *-lowering-*.f64N/A

        \[\leadsto \mathsf{fma.f64}\left(\mathsf{*.f64}\left(y, \left(\mathsf{neg}\left(9 \cdot z\right)\right)\right), t, \left(\left(a \cdot 27\right) \cdot b + x \cdot 2\right)\right) \]
      10. *-commutativeN/A

        \[\leadsto \mathsf{fma.f64}\left(\mathsf{*.f64}\left(y, \left(\mathsf{neg}\left(z \cdot 9\right)\right)\right), t, \left(\left(a \cdot 27\right) \cdot b + x \cdot 2\right)\right) \]
      11. distribute-rgt-neg-inN/A

        \[\leadsto \mathsf{fma.f64}\left(\mathsf{*.f64}\left(y, \left(z \cdot \left(\mathsf{neg}\left(9\right)\right)\right)\right), t, \left(\left(a \cdot 27\right) \cdot b + x \cdot 2\right)\right) \]
      12. *-lowering-*.f64N/A

        \[\leadsto \mathsf{fma.f64}\left(\mathsf{*.f64}\left(y, \mathsf{*.f64}\left(z, \left(\mathsf{neg}\left(9\right)\right)\right)\right), t, \left(\left(a \cdot 27\right) \cdot b + x \cdot 2\right)\right) \]
      13. metadata-evalN/A

        \[\leadsto \mathsf{fma.f64}\left(\mathsf{*.f64}\left(y, \mathsf{*.f64}\left(z, -9\right)\right), t, \left(\left(a \cdot 27\right) \cdot b + x \cdot 2\right)\right) \]
      14. associate-*l*N/A

        \[\leadsto \mathsf{fma.f64}\left(\mathsf{*.f64}\left(y, \mathsf{*.f64}\left(z, -9\right)\right), t, \left(a \cdot \left(27 \cdot b\right) + x \cdot 2\right)\right) \]
      15. accelerator-lowering-fma.f64N/A

        \[\leadsto \mathsf{fma.f64}\left(\mathsf{*.f64}\left(y, \mathsf{*.f64}\left(z, -9\right)\right), t, \mathsf{fma.f64}\left(a, \left(27 \cdot b\right), \left(x \cdot 2\right)\right)\right) \]
      16. *-lowering-*.f64N/A

        \[\leadsto \mathsf{fma.f64}\left(\mathsf{*.f64}\left(y, \mathsf{*.f64}\left(z, -9\right)\right), t, \mathsf{fma.f64}\left(a, \mathsf{*.f64}\left(27, b\right), \left(x \cdot 2\right)\right)\right) \]
      17. *-lowering-*.f6497.4%

        \[\leadsto \mathsf{fma.f64}\left(\mathsf{*.f64}\left(y, \mathsf{*.f64}\left(z, -9\right)\right), t, \mathsf{fma.f64}\left(a, \mathsf{*.f64}\left(27, b\right), \mathsf{*.f64}\left(x, 2\right)\right)\right) \]
    4. Applied egg-rr97.4%

      \[\leadsto \color{blue}{\mathsf{fma}\left(y \cdot \left(z \cdot -9\right), t, \mathsf{fma}\left(a, 27 \cdot b, x \cdot 2\right)\right)} \]
    5. Taylor expanded in y around 0

      \[\leadsto \color{blue}{2 \cdot x + 27 \cdot \left(a \cdot b\right)} \]
    6. Step-by-step derivation
      1. +-commutativeN/A

        \[\leadsto 27 \cdot \left(a \cdot b\right) + \color{blue}{2 \cdot x} \]
      2. accelerator-lowering-fma.f64N/A

        \[\leadsto \mathsf{fma.f64}\left(27, \color{blue}{\left(a \cdot b\right)}, \left(2 \cdot x\right)\right) \]
      3. *-lowering-*.f64N/A

        \[\leadsto \mathsf{fma.f64}\left(27, \mathsf{*.f64}\left(a, \color{blue}{b}\right), \left(2 \cdot x\right)\right) \]
      4. *-lowering-*.f6492.7%

        \[\leadsto \mathsf{fma.f64}\left(27, \mathsf{*.f64}\left(a, b\right), \mathsf{*.f64}\left(2, x\right)\right) \]
    7. Simplified92.7%

      \[\leadsto \color{blue}{\mathsf{fma}\left(27, a \cdot b, 2 \cdot x\right)} \]

    if -4.00000000000000006e100 < (*.f64 (*.f64 a #s(literal 27 binary64)) b) < 1.99999999999999999e89

    1. Initial program 97.4%

      \[\left(x \cdot 2 - \left(\left(y \cdot 9\right) \cdot z\right) \cdot t\right) + \left(a \cdot 27\right) \cdot b \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. sub-negN/A

        \[\leadsto \left(x \cdot 2 + \left(\mathsf{neg}\left(\left(\left(y \cdot 9\right) \cdot z\right) \cdot t\right)\right)\right) + \color{blue}{\left(a \cdot 27\right)} \cdot b \]
      2. +-commutativeN/A

        \[\leadsto \left(\left(\mathsf{neg}\left(\left(\left(y \cdot 9\right) \cdot z\right) \cdot t\right)\right) + x \cdot 2\right) + \color{blue}{\left(a \cdot 27\right)} \cdot b \]
      3. associate-+l+N/A

        \[\leadsto \left(\mathsf{neg}\left(\left(\left(y \cdot 9\right) \cdot z\right) \cdot t\right)\right) + \color{blue}{\left(x \cdot 2 + \left(a \cdot 27\right) \cdot b\right)} \]
      4. distribute-lft-neg-inN/A

        \[\leadsto \left(\mathsf{neg}\left(\left(y \cdot 9\right) \cdot z\right)\right) \cdot t + \left(\color{blue}{x \cdot 2} + \left(a \cdot 27\right) \cdot b\right) \]
      5. +-commutativeN/A

        \[\leadsto \left(\mathsf{neg}\left(\left(y \cdot 9\right) \cdot z\right)\right) \cdot t + \left(\left(a \cdot 27\right) \cdot b + \color{blue}{x \cdot 2}\right) \]
      6. accelerator-lowering-fma.f64N/A

        \[\leadsto \mathsf{fma.f64}\left(\left(\mathsf{neg}\left(\left(y \cdot 9\right) \cdot z\right)\right), \color{blue}{t}, \left(\left(a \cdot 27\right) \cdot b + x \cdot 2\right)\right) \]
      7. associate-*l*N/A

        \[\leadsto \mathsf{fma.f64}\left(\left(\mathsf{neg}\left(y \cdot \left(9 \cdot z\right)\right)\right), t, \left(\left(a \cdot 27\right) \cdot b + x \cdot 2\right)\right) \]
      8. distribute-rgt-neg-inN/A

        \[\leadsto \mathsf{fma.f64}\left(\left(y \cdot \left(\mathsf{neg}\left(9 \cdot z\right)\right)\right), t, \left(\left(a \cdot 27\right) \cdot b + x \cdot 2\right)\right) \]
      9. *-lowering-*.f64N/A

        \[\leadsto \mathsf{fma.f64}\left(\mathsf{*.f64}\left(y, \left(\mathsf{neg}\left(9 \cdot z\right)\right)\right), t, \left(\left(a \cdot 27\right) \cdot b + x \cdot 2\right)\right) \]
      10. *-commutativeN/A

        \[\leadsto \mathsf{fma.f64}\left(\mathsf{*.f64}\left(y, \left(\mathsf{neg}\left(z \cdot 9\right)\right)\right), t, \left(\left(a \cdot 27\right) \cdot b + x \cdot 2\right)\right) \]
      11. distribute-rgt-neg-inN/A

        \[\leadsto \mathsf{fma.f64}\left(\mathsf{*.f64}\left(y, \left(z \cdot \left(\mathsf{neg}\left(9\right)\right)\right)\right), t, \left(\left(a \cdot 27\right) \cdot b + x \cdot 2\right)\right) \]
      12. *-lowering-*.f64N/A

        \[\leadsto \mathsf{fma.f64}\left(\mathsf{*.f64}\left(y, \mathsf{*.f64}\left(z, \left(\mathsf{neg}\left(9\right)\right)\right)\right), t, \left(\left(a \cdot 27\right) \cdot b + x \cdot 2\right)\right) \]
      13. metadata-evalN/A

        \[\leadsto \mathsf{fma.f64}\left(\mathsf{*.f64}\left(y, \mathsf{*.f64}\left(z, -9\right)\right), t, \left(\left(a \cdot 27\right) \cdot b + x \cdot 2\right)\right) \]
      14. associate-*l*N/A

        \[\leadsto \mathsf{fma.f64}\left(\mathsf{*.f64}\left(y, \mathsf{*.f64}\left(z, -9\right)\right), t, \left(a \cdot \left(27 \cdot b\right) + x \cdot 2\right)\right) \]
      15. accelerator-lowering-fma.f64N/A

        \[\leadsto \mathsf{fma.f64}\left(\mathsf{*.f64}\left(y, \mathsf{*.f64}\left(z, -9\right)\right), t, \mathsf{fma.f64}\left(a, \left(27 \cdot b\right), \left(x \cdot 2\right)\right)\right) \]
      16. *-lowering-*.f64N/A

        \[\leadsto \mathsf{fma.f64}\left(\mathsf{*.f64}\left(y, \mathsf{*.f64}\left(z, -9\right)\right), t, \mathsf{fma.f64}\left(a, \mathsf{*.f64}\left(27, b\right), \left(x \cdot 2\right)\right)\right) \]
      17. *-lowering-*.f6497.3%

        \[\leadsto \mathsf{fma.f64}\left(\mathsf{*.f64}\left(y, \mathsf{*.f64}\left(z, -9\right)\right), t, \mathsf{fma.f64}\left(a, \mathsf{*.f64}\left(27, b\right), \mathsf{*.f64}\left(x, 2\right)\right)\right) \]
    4. Applied egg-rr97.3%

      \[\leadsto \color{blue}{\mathsf{fma}\left(y \cdot \left(z \cdot -9\right), t, \mathsf{fma}\left(a, 27 \cdot b, x \cdot 2\right)\right)} \]
    5. Taylor expanded in a around 0

      \[\leadsto \mathsf{fma.f64}\left(\mathsf{*.f64}\left(y, \mathsf{*.f64}\left(z, -9\right)\right), t, \color{blue}{\left(2 \cdot x\right)}\right) \]
    6. Step-by-step derivation
      1. *-lowering-*.f6488.1%

        \[\leadsto \mathsf{fma.f64}\left(\mathsf{*.f64}\left(y, \mathsf{*.f64}\left(z, -9\right)\right), t, \mathsf{*.f64}\left(2, x\right)\right) \]
    7. Simplified88.1%

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

    if 1.99999999999999999e89 < (*.f64 (*.f64 a #s(literal 27 binary64)) b)

    1. Initial program 89.3%

      \[\left(x \cdot 2 - \left(\left(y \cdot 9\right) \cdot z\right) \cdot t\right) + \left(a \cdot 27\right) \cdot b \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. sub-negN/A

        \[\leadsto \left(x \cdot 2 + \left(\mathsf{neg}\left(\left(\left(y \cdot 9\right) \cdot z\right) \cdot t\right)\right)\right) + \color{blue}{\left(a \cdot 27\right)} \cdot b \]
      2. +-commutativeN/A

        \[\leadsto \left(\left(\mathsf{neg}\left(\left(\left(y \cdot 9\right) \cdot z\right) \cdot t\right)\right) + x \cdot 2\right) + \color{blue}{\left(a \cdot 27\right)} \cdot b \]
      3. associate-+l+N/A

        \[\leadsto \left(\mathsf{neg}\left(\left(\left(y \cdot 9\right) \cdot z\right) \cdot t\right)\right) + \color{blue}{\left(x \cdot 2 + \left(a \cdot 27\right) \cdot b\right)} \]
      4. distribute-lft-neg-inN/A

        \[\leadsto \left(\mathsf{neg}\left(\left(y \cdot 9\right) \cdot z\right)\right) \cdot t + \left(\color{blue}{x \cdot 2} + \left(a \cdot 27\right) \cdot b\right) \]
      5. +-commutativeN/A

        \[\leadsto \left(\mathsf{neg}\left(\left(y \cdot 9\right) \cdot z\right)\right) \cdot t + \left(\left(a \cdot 27\right) \cdot b + \color{blue}{x \cdot 2}\right) \]
      6. accelerator-lowering-fma.f64N/A

        \[\leadsto \mathsf{fma.f64}\left(\left(\mathsf{neg}\left(\left(y \cdot 9\right) \cdot z\right)\right), \color{blue}{t}, \left(\left(a \cdot 27\right) \cdot b + x \cdot 2\right)\right) \]
      7. associate-*l*N/A

        \[\leadsto \mathsf{fma.f64}\left(\left(\mathsf{neg}\left(y \cdot \left(9 \cdot z\right)\right)\right), t, \left(\left(a \cdot 27\right) \cdot b + x \cdot 2\right)\right) \]
      8. distribute-rgt-neg-inN/A

        \[\leadsto \mathsf{fma.f64}\left(\left(y \cdot \left(\mathsf{neg}\left(9 \cdot z\right)\right)\right), t, \left(\left(a \cdot 27\right) \cdot b + x \cdot 2\right)\right) \]
      9. *-lowering-*.f64N/A

        \[\leadsto \mathsf{fma.f64}\left(\mathsf{*.f64}\left(y, \left(\mathsf{neg}\left(9 \cdot z\right)\right)\right), t, \left(\left(a \cdot 27\right) \cdot b + x \cdot 2\right)\right) \]
      10. *-commutativeN/A

        \[\leadsto \mathsf{fma.f64}\left(\mathsf{*.f64}\left(y, \left(\mathsf{neg}\left(z \cdot 9\right)\right)\right), t, \left(\left(a \cdot 27\right) \cdot b + x \cdot 2\right)\right) \]
      11. distribute-rgt-neg-inN/A

        \[\leadsto \mathsf{fma.f64}\left(\mathsf{*.f64}\left(y, \left(z \cdot \left(\mathsf{neg}\left(9\right)\right)\right)\right), t, \left(\left(a \cdot 27\right) \cdot b + x \cdot 2\right)\right) \]
      12. *-lowering-*.f64N/A

        \[\leadsto \mathsf{fma.f64}\left(\mathsf{*.f64}\left(y, \mathsf{*.f64}\left(z, \left(\mathsf{neg}\left(9\right)\right)\right)\right), t, \left(\left(a \cdot 27\right) \cdot b + x \cdot 2\right)\right) \]
      13. metadata-evalN/A

        \[\leadsto \mathsf{fma.f64}\left(\mathsf{*.f64}\left(y, \mathsf{*.f64}\left(z, -9\right)\right), t, \left(\left(a \cdot 27\right) \cdot b + x \cdot 2\right)\right) \]
      14. associate-*l*N/A

        \[\leadsto \mathsf{fma.f64}\left(\mathsf{*.f64}\left(y, \mathsf{*.f64}\left(z, -9\right)\right), t, \left(a \cdot \left(27 \cdot b\right) + x \cdot 2\right)\right) \]
      15. accelerator-lowering-fma.f64N/A

        \[\leadsto \mathsf{fma.f64}\left(\mathsf{*.f64}\left(y, \mathsf{*.f64}\left(z, -9\right)\right), t, \mathsf{fma.f64}\left(a, \left(27 \cdot b\right), \left(x \cdot 2\right)\right)\right) \]
      16. *-lowering-*.f64N/A

        \[\leadsto \mathsf{fma.f64}\left(\mathsf{*.f64}\left(y, \mathsf{*.f64}\left(z, -9\right)\right), t, \mathsf{fma.f64}\left(a, \mathsf{*.f64}\left(27, b\right), \left(x \cdot 2\right)\right)\right) \]
      17. *-lowering-*.f6489.2%

        \[\leadsto \mathsf{fma.f64}\left(\mathsf{*.f64}\left(y, \mathsf{*.f64}\left(z, -9\right)\right), t, \mathsf{fma.f64}\left(a, \mathsf{*.f64}\left(27, b\right), \mathsf{*.f64}\left(x, 2\right)\right)\right) \]
    4. Applied egg-rr89.2%

      \[\leadsto \color{blue}{\mathsf{fma}\left(y \cdot \left(z \cdot -9\right), t, \mathsf{fma}\left(a, 27 \cdot b, x \cdot 2\right)\right)} \]
    5. Taylor expanded in x around 0

      \[\leadsto \color{blue}{-9 \cdot \left(t \cdot \left(y \cdot z\right)\right) + 27 \cdot \left(a \cdot b\right)} \]
    6. Step-by-step derivation
      1. +-commutativeN/A

        \[\leadsto 27 \cdot \left(a \cdot b\right) + \color{blue}{-9 \cdot \left(t \cdot \left(y \cdot z\right)\right)} \]
      2. accelerator-lowering-fma.f64N/A

        \[\leadsto \mathsf{fma.f64}\left(27, \color{blue}{\left(a \cdot b\right)}, \left(-9 \cdot \left(t \cdot \left(y \cdot z\right)\right)\right)\right) \]
      3. *-lowering-*.f64N/A

        \[\leadsto \mathsf{fma.f64}\left(27, \mathsf{*.f64}\left(a, \color{blue}{b}\right), \left(-9 \cdot \left(t \cdot \left(y \cdot z\right)\right)\right)\right) \]
      4. associate-*r*N/A

        \[\leadsto \mathsf{fma.f64}\left(27, \mathsf{*.f64}\left(a, b\right), \left(\left(-9 \cdot t\right) \cdot \left(y \cdot z\right)\right)\right) \]
      5. *-commutativeN/A

        \[\leadsto \mathsf{fma.f64}\left(27, \mathsf{*.f64}\left(a, b\right), \left(\left(y \cdot z\right) \cdot \left(-9 \cdot t\right)\right)\right) \]
      6. *-lowering-*.f64N/A

        \[\leadsto \mathsf{fma.f64}\left(27, \mathsf{*.f64}\left(a, b\right), \mathsf{*.f64}\left(\left(y \cdot z\right), \left(-9 \cdot t\right)\right)\right) \]
      7. *-lowering-*.f64N/A

        \[\leadsto \mathsf{fma.f64}\left(27, \mathsf{*.f64}\left(a, b\right), \mathsf{*.f64}\left(\mathsf{*.f64}\left(y, z\right), \left(-9 \cdot t\right)\right)\right) \]
      8. *-lowering-*.f6480.6%

        \[\leadsto \mathsf{fma.f64}\left(27, \mathsf{*.f64}\left(a, b\right), \mathsf{*.f64}\left(\mathsf{*.f64}\left(y, z\right), \mathsf{*.f64}\left(-9, t\right)\right)\right) \]
    7. Simplified80.6%

      \[\leadsto \color{blue}{\mathsf{fma}\left(27, a \cdot b, \left(y \cdot z\right) \cdot \left(-9 \cdot t\right)\right)} \]
  3. Recombined 3 regimes into one program.
  4. Final simplification87.7%

    \[\leadsto \begin{array}{l} \mathbf{if}\;\left(a \cdot 27\right) \cdot b \leq -4 \cdot 10^{+100}:\\ \;\;\;\;\mathsf{fma}\left(27, a \cdot b, x \cdot 2\right)\\ \mathbf{elif}\;\left(a \cdot 27\right) \cdot b \leq 2 \cdot 10^{+89}:\\ \;\;\;\;\mathsf{fma}\left(y \cdot \left(z \cdot -9\right), t, x \cdot 2\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(27, a \cdot b, \left(t \cdot -9\right) \cdot \left(y \cdot z\right)\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 8: 81.9% accurate, 0.7× speedup?

\[\begin{array}{l} [x, y, z, t, a, b] = \mathsf{sort}([x, y, z, t, a, b])\\\\ [x, y, z, t, a, b] = \mathsf{sort}([x, y, z, t, a, b])\\ \\ \begin{array}{l} t_1 := \left(a \cdot 27\right) \cdot b\\ \mathbf{if}\;t\_1 \leq -4 \cdot 10^{+100}:\\ \;\;\;\;\mathsf{fma}\left(27, a \cdot b, x \cdot 2\right)\\ \mathbf{elif}\;t\_1 \leq 2 \cdot 10^{+111}:\\ \;\;\;\;\mathsf{fma}\left(y \cdot \left(z \cdot -9\right), t, x \cdot 2\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(a \cdot 27, b, \mathsf{fma}\left(x, 2, 0\right)\right)\\ \end{array} \end{array} \]
NOTE: x, y, z, t, a, and b should be sorted in increasing order before calling this function.
NOTE: x, y, z, t, a, and b should be sorted in increasing order before calling this function.
(FPCore (x y z t a b)
 :precision binary64
 (let* ((t_1 (* (* a 27.0) b)))
   (if (<= t_1 -4e+100)
     (fma 27.0 (* a b) (* x 2.0))
     (if (<= t_1 2e+111)
       (fma (* y (* z -9.0)) t (* x 2.0))
       (fma (* a 27.0) b (fma x 2.0 0.0))))))
assert(x < y && y < z && z < t && t < a && a < b);
assert(x < y && y < z && z < t && t < a && a < b);
double code(double x, double y, double z, double t, double a, double b) {
	double t_1 = (a * 27.0) * b;
	double tmp;
	if (t_1 <= -4e+100) {
		tmp = fma(27.0, (a * b), (x * 2.0));
	} else if (t_1 <= 2e+111) {
		tmp = fma((y * (z * -9.0)), t, (x * 2.0));
	} else {
		tmp = fma((a * 27.0), b, fma(x, 2.0, 0.0));
	}
	return tmp;
}
x, y, z, t, a, b = sort([x, y, z, t, a, b])
x, y, z, t, a, b = sort([x, y, z, t, a, b])
function code(x, y, z, t, a, b)
	t_1 = Float64(Float64(a * 27.0) * b)
	tmp = 0.0
	if (t_1 <= -4e+100)
		tmp = fma(27.0, Float64(a * b), Float64(x * 2.0));
	elseif (t_1 <= 2e+111)
		tmp = fma(Float64(y * Float64(z * -9.0)), t, Float64(x * 2.0));
	else
		tmp = fma(Float64(a * 27.0), b, fma(x, 2.0, 0.0));
	end
	return tmp
end
NOTE: x, y, z, t, a, and b should be sorted in increasing order before calling this function.
NOTE: x, y, z, t, a, and b should be sorted in increasing order before calling this function.
code[x_, y_, z_, t_, a_, b_] := Block[{t$95$1 = N[(N[(a * 27.0), $MachinePrecision] * b), $MachinePrecision]}, If[LessEqual[t$95$1, -4e+100], N[(27.0 * N[(a * b), $MachinePrecision] + N[(x * 2.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$1, 2e+111], N[(N[(y * N[(z * -9.0), $MachinePrecision]), $MachinePrecision] * t + N[(x * 2.0), $MachinePrecision]), $MachinePrecision], N[(N[(a * 27.0), $MachinePrecision] * b + N[(x * 2.0 + 0.0), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
[x, y, z, t, a, b] = \mathsf{sort}([x, y, z, t, a, b])\\\\
[x, y, z, t, a, b] = \mathsf{sort}([x, y, z, t, a, b])\\
\\
\begin{array}{l}
t_1 := \left(a \cdot 27\right) \cdot b\\
\mathbf{if}\;t\_1 \leq -4 \cdot 10^{+100}:\\
\;\;\;\;\mathsf{fma}\left(27, a \cdot b, x \cdot 2\right)\\

\mathbf{elif}\;t\_1 \leq 2 \cdot 10^{+111}:\\
\;\;\;\;\mathsf{fma}\left(y \cdot \left(z \cdot -9\right), t, x \cdot 2\right)\\

\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(a \cdot 27, b, \mathsf{fma}\left(x, 2, 0\right)\right)\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if (*.f64 (*.f64 a #s(literal 27 binary64)) b) < -4.00000000000000006e100

    1. Initial program 97.4%

      \[\left(x \cdot 2 - \left(\left(y \cdot 9\right) \cdot z\right) \cdot t\right) + \left(a \cdot 27\right) \cdot b \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. sub-negN/A

        \[\leadsto \left(x \cdot 2 + \left(\mathsf{neg}\left(\left(\left(y \cdot 9\right) \cdot z\right) \cdot t\right)\right)\right) + \color{blue}{\left(a \cdot 27\right)} \cdot b \]
      2. +-commutativeN/A

        \[\leadsto \left(\left(\mathsf{neg}\left(\left(\left(y \cdot 9\right) \cdot z\right) \cdot t\right)\right) + x \cdot 2\right) + \color{blue}{\left(a \cdot 27\right)} \cdot b \]
      3. associate-+l+N/A

        \[\leadsto \left(\mathsf{neg}\left(\left(\left(y \cdot 9\right) \cdot z\right) \cdot t\right)\right) + \color{blue}{\left(x \cdot 2 + \left(a \cdot 27\right) \cdot b\right)} \]
      4. distribute-lft-neg-inN/A

        \[\leadsto \left(\mathsf{neg}\left(\left(y \cdot 9\right) \cdot z\right)\right) \cdot t + \left(\color{blue}{x \cdot 2} + \left(a \cdot 27\right) \cdot b\right) \]
      5. +-commutativeN/A

        \[\leadsto \left(\mathsf{neg}\left(\left(y \cdot 9\right) \cdot z\right)\right) \cdot t + \left(\left(a \cdot 27\right) \cdot b + \color{blue}{x \cdot 2}\right) \]
      6. accelerator-lowering-fma.f64N/A

        \[\leadsto \mathsf{fma.f64}\left(\left(\mathsf{neg}\left(\left(y \cdot 9\right) \cdot z\right)\right), \color{blue}{t}, \left(\left(a \cdot 27\right) \cdot b + x \cdot 2\right)\right) \]
      7. associate-*l*N/A

        \[\leadsto \mathsf{fma.f64}\left(\left(\mathsf{neg}\left(y \cdot \left(9 \cdot z\right)\right)\right), t, \left(\left(a \cdot 27\right) \cdot b + x \cdot 2\right)\right) \]
      8. distribute-rgt-neg-inN/A

        \[\leadsto \mathsf{fma.f64}\left(\left(y \cdot \left(\mathsf{neg}\left(9 \cdot z\right)\right)\right), t, \left(\left(a \cdot 27\right) \cdot b + x \cdot 2\right)\right) \]
      9. *-lowering-*.f64N/A

        \[\leadsto \mathsf{fma.f64}\left(\mathsf{*.f64}\left(y, \left(\mathsf{neg}\left(9 \cdot z\right)\right)\right), t, \left(\left(a \cdot 27\right) \cdot b + x \cdot 2\right)\right) \]
      10. *-commutativeN/A

        \[\leadsto \mathsf{fma.f64}\left(\mathsf{*.f64}\left(y, \left(\mathsf{neg}\left(z \cdot 9\right)\right)\right), t, \left(\left(a \cdot 27\right) \cdot b + x \cdot 2\right)\right) \]
      11. distribute-rgt-neg-inN/A

        \[\leadsto \mathsf{fma.f64}\left(\mathsf{*.f64}\left(y, \left(z \cdot \left(\mathsf{neg}\left(9\right)\right)\right)\right), t, \left(\left(a \cdot 27\right) \cdot b + x \cdot 2\right)\right) \]
      12. *-lowering-*.f64N/A

        \[\leadsto \mathsf{fma.f64}\left(\mathsf{*.f64}\left(y, \mathsf{*.f64}\left(z, \left(\mathsf{neg}\left(9\right)\right)\right)\right), t, \left(\left(a \cdot 27\right) \cdot b + x \cdot 2\right)\right) \]
      13. metadata-evalN/A

        \[\leadsto \mathsf{fma.f64}\left(\mathsf{*.f64}\left(y, \mathsf{*.f64}\left(z, -9\right)\right), t, \left(\left(a \cdot 27\right) \cdot b + x \cdot 2\right)\right) \]
      14. associate-*l*N/A

        \[\leadsto \mathsf{fma.f64}\left(\mathsf{*.f64}\left(y, \mathsf{*.f64}\left(z, -9\right)\right), t, \left(a \cdot \left(27 \cdot b\right) + x \cdot 2\right)\right) \]
      15. accelerator-lowering-fma.f64N/A

        \[\leadsto \mathsf{fma.f64}\left(\mathsf{*.f64}\left(y, \mathsf{*.f64}\left(z, -9\right)\right), t, \mathsf{fma.f64}\left(a, \left(27 \cdot b\right), \left(x \cdot 2\right)\right)\right) \]
      16. *-lowering-*.f64N/A

        \[\leadsto \mathsf{fma.f64}\left(\mathsf{*.f64}\left(y, \mathsf{*.f64}\left(z, -9\right)\right), t, \mathsf{fma.f64}\left(a, \mathsf{*.f64}\left(27, b\right), \left(x \cdot 2\right)\right)\right) \]
      17. *-lowering-*.f6497.4%

        \[\leadsto \mathsf{fma.f64}\left(\mathsf{*.f64}\left(y, \mathsf{*.f64}\left(z, -9\right)\right), t, \mathsf{fma.f64}\left(a, \mathsf{*.f64}\left(27, b\right), \mathsf{*.f64}\left(x, 2\right)\right)\right) \]
    4. Applied egg-rr97.4%

      \[\leadsto \color{blue}{\mathsf{fma}\left(y \cdot \left(z \cdot -9\right), t, \mathsf{fma}\left(a, 27 \cdot b, x \cdot 2\right)\right)} \]
    5. Taylor expanded in y around 0

      \[\leadsto \color{blue}{2 \cdot x + 27 \cdot \left(a \cdot b\right)} \]
    6. Step-by-step derivation
      1. +-commutativeN/A

        \[\leadsto 27 \cdot \left(a \cdot b\right) + \color{blue}{2 \cdot x} \]
      2. accelerator-lowering-fma.f64N/A

        \[\leadsto \mathsf{fma.f64}\left(27, \color{blue}{\left(a \cdot b\right)}, \left(2 \cdot x\right)\right) \]
      3. *-lowering-*.f64N/A

        \[\leadsto \mathsf{fma.f64}\left(27, \mathsf{*.f64}\left(a, \color{blue}{b}\right), \left(2 \cdot x\right)\right) \]
      4. *-lowering-*.f6492.7%

        \[\leadsto \mathsf{fma.f64}\left(27, \mathsf{*.f64}\left(a, b\right), \mathsf{*.f64}\left(2, x\right)\right) \]
    7. Simplified92.7%

      \[\leadsto \color{blue}{\mathsf{fma}\left(27, a \cdot b, 2 \cdot x\right)} \]

    if -4.00000000000000006e100 < (*.f64 (*.f64 a #s(literal 27 binary64)) b) < 1.99999999999999991e111

    1. Initial program 97.4%

      \[\left(x \cdot 2 - \left(\left(y \cdot 9\right) \cdot z\right) \cdot t\right) + \left(a \cdot 27\right) \cdot b \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. sub-negN/A

        \[\leadsto \left(x \cdot 2 + \left(\mathsf{neg}\left(\left(\left(y \cdot 9\right) \cdot z\right) \cdot t\right)\right)\right) + \color{blue}{\left(a \cdot 27\right)} \cdot b \]
      2. +-commutativeN/A

        \[\leadsto \left(\left(\mathsf{neg}\left(\left(\left(y \cdot 9\right) \cdot z\right) \cdot t\right)\right) + x \cdot 2\right) + \color{blue}{\left(a \cdot 27\right)} \cdot b \]
      3. associate-+l+N/A

        \[\leadsto \left(\mathsf{neg}\left(\left(\left(y \cdot 9\right) \cdot z\right) \cdot t\right)\right) + \color{blue}{\left(x \cdot 2 + \left(a \cdot 27\right) \cdot b\right)} \]
      4. distribute-lft-neg-inN/A

        \[\leadsto \left(\mathsf{neg}\left(\left(y \cdot 9\right) \cdot z\right)\right) \cdot t + \left(\color{blue}{x \cdot 2} + \left(a \cdot 27\right) \cdot b\right) \]
      5. +-commutativeN/A

        \[\leadsto \left(\mathsf{neg}\left(\left(y \cdot 9\right) \cdot z\right)\right) \cdot t + \left(\left(a \cdot 27\right) \cdot b + \color{blue}{x \cdot 2}\right) \]
      6. accelerator-lowering-fma.f64N/A

        \[\leadsto \mathsf{fma.f64}\left(\left(\mathsf{neg}\left(\left(y \cdot 9\right) \cdot z\right)\right), \color{blue}{t}, \left(\left(a \cdot 27\right) \cdot b + x \cdot 2\right)\right) \]
      7. associate-*l*N/A

        \[\leadsto \mathsf{fma.f64}\left(\left(\mathsf{neg}\left(y \cdot \left(9 \cdot z\right)\right)\right), t, \left(\left(a \cdot 27\right) \cdot b + x \cdot 2\right)\right) \]
      8. distribute-rgt-neg-inN/A

        \[\leadsto \mathsf{fma.f64}\left(\left(y \cdot \left(\mathsf{neg}\left(9 \cdot z\right)\right)\right), t, \left(\left(a \cdot 27\right) \cdot b + x \cdot 2\right)\right) \]
      9. *-lowering-*.f64N/A

        \[\leadsto \mathsf{fma.f64}\left(\mathsf{*.f64}\left(y, \left(\mathsf{neg}\left(9 \cdot z\right)\right)\right), t, \left(\left(a \cdot 27\right) \cdot b + x \cdot 2\right)\right) \]
      10. *-commutativeN/A

        \[\leadsto \mathsf{fma.f64}\left(\mathsf{*.f64}\left(y, \left(\mathsf{neg}\left(z \cdot 9\right)\right)\right), t, \left(\left(a \cdot 27\right) \cdot b + x \cdot 2\right)\right) \]
      11. distribute-rgt-neg-inN/A

        \[\leadsto \mathsf{fma.f64}\left(\mathsf{*.f64}\left(y, \left(z \cdot \left(\mathsf{neg}\left(9\right)\right)\right)\right), t, \left(\left(a \cdot 27\right) \cdot b + x \cdot 2\right)\right) \]
      12. *-lowering-*.f64N/A

        \[\leadsto \mathsf{fma.f64}\left(\mathsf{*.f64}\left(y, \mathsf{*.f64}\left(z, \left(\mathsf{neg}\left(9\right)\right)\right)\right), t, \left(\left(a \cdot 27\right) \cdot b + x \cdot 2\right)\right) \]
      13. metadata-evalN/A

        \[\leadsto \mathsf{fma.f64}\left(\mathsf{*.f64}\left(y, \mathsf{*.f64}\left(z, -9\right)\right), t, \left(\left(a \cdot 27\right) \cdot b + x \cdot 2\right)\right) \]
      14. associate-*l*N/A

        \[\leadsto \mathsf{fma.f64}\left(\mathsf{*.f64}\left(y, \mathsf{*.f64}\left(z, -9\right)\right), t, \left(a \cdot \left(27 \cdot b\right) + x \cdot 2\right)\right) \]
      15. accelerator-lowering-fma.f64N/A

        \[\leadsto \mathsf{fma.f64}\left(\mathsf{*.f64}\left(y, \mathsf{*.f64}\left(z, -9\right)\right), t, \mathsf{fma.f64}\left(a, \left(27 \cdot b\right), \left(x \cdot 2\right)\right)\right) \]
      16. *-lowering-*.f64N/A

        \[\leadsto \mathsf{fma.f64}\left(\mathsf{*.f64}\left(y, \mathsf{*.f64}\left(z, -9\right)\right), t, \mathsf{fma.f64}\left(a, \mathsf{*.f64}\left(27, b\right), \left(x \cdot 2\right)\right)\right) \]
      17. *-lowering-*.f6497.4%

        \[\leadsto \mathsf{fma.f64}\left(\mathsf{*.f64}\left(y, \mathsf{*.f64}\left(z, -9\right)\right), t, \mathsf{fma.f64}\left(a, \mathsf{*.f64}\left(27, b\right), \mathsf{*.f64}\left(x, 2\right)\right)\right) \]
    4. Applied egg-rr97.4%

      \[\leadsto \color{blue}{\mathsf{fma}\left(y \cdot \left(z \cdot -9\right), t, \mathsf{fma}\left(a, 27 \cdot b, x \cdot 2\right)\right)} \]
    5. Taylor expanded in a around 0

      \[\leadsto \mathsf{fma.f64}\left(\mathsf{*.f64}\left(y, \mathsf{*.f64}\left(z, -9\right)\right), t, \color{blue}{\left(2 \cdot x\right)}\right) \]
    6. Step-by-step derivation
      1. *-lowering-*.f6487.9%

        \[\leadsto \mathsf{fma.f64}\left(\mathsf{*.f64}\left(y, \mathsf{*.f64}\left(z, -9\right)\right), t, \mathsf{*.f64}\left(2, x\right)\right) \]
    7. Simplified87.9%

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

    if 1.99999999999999991e111 < (*.f64 (*.f64 a #s(literal 27 binary64)) b)

    1. Initial program 88.1%

      \[\left(x \cdot 2 - \left(\left(y \cdot 9\right) \cdot z\right) \cdot t\right) + \left(a \cdot 27\right) \cdot b \]
    2. Add Preprocessing
    3. Taylor expanded in x around inf

      \[\leadsto \mathsf{+.f64}\left(\color{blue}{\left(2 \cdot x\right)}, \mathsf{*.f64}\left(\mathsf{*.f64}\left(a, 27\right), b\right)\right) \]
    4. Step-by-step derivation
      1. +-rgt-identityN/A

        \[\leadsto \mathsf{+.f64}\left(\left(2 \cdot x + 0\right), \mathsf{*.f64}\left(\color{blue}{\mathsf{*.f64}\left(a, 27\right)}, b\right)\right) \]
      2. accelerator-lowering-fma.f6476.8%

        \[\leadsto \mathsf{+.f64}\left(\mathsf{fma.f64}\left(2, x, 0\right), \mathsf{*.f64}\left(\color{blue}{\mathsf{*.f64}\left(a, 27\right)}, b\right)\right) \]
    5. Simplified76.8%

      \[\leadsto \color{blue}{\mathsf{fma}\left(2, x, 0\right)} + \left(a \cdot 27\right) \cdot b \]
    6. Step-by-step derivation
      1. +-commutativeN/A

        \[\leadsto \left(a \cdot 27\right) \cdot b + \color{blue}{\left(2 \cdot x + 0\right)} \]
      2. accelerator-lowering-fma.f64N/A

        \[\leadsto \mathsf{fma.f64}\left(\left(a \cdot 27\right), \color{blue}{b}, \left(2 \cdot x + 0\right)\right) \]
      3. *-lowering-*.f64N/A

        \[\leadsto \mathsf{fma.f64}\left(\mathsf{*.f64}\left(a, 27\right), b, \left(2 \cdot x + 0\right)\right) \]
      4. *-commutativeN/A

        \[\leadsto \mathsf{fma.f64}\left(\mathsf{*.f64}\left(a, 27\right), b, \left(x \cdot 2 + 0\right)\right) \]
      5. accelerator-lowering-fma.f6476.8%

        \[\leadsto \mathsf{fma.f64}\left(\mathsf{*.f64}\left(a, 27\right), b, \mathsf{fma.f64}\left(x, 2, 0\right)\right) \]
    7. Applied egg-rr76.8%

      \[\leadsto \color{blue}{\mathsf{fma}\left(a \cdot 27, b, \mathsf{fma}\left(x, 2, 0\right)\right)} \]
  3. Recombined 3 regimes into one program.
  4. Final simplification87.2%

    \[\leadsto \begin{array}{l} \mathbf{if}\;\left(a \cdot 27\right) \cdot b \leq -4 \cdot 10^{+100}:\\ \;\;\;\;\mathsf{fma}\left(27, a \cdot b, x \cdot 2\right)\\ \mathbf{elif}\;\left(a \cdot 27\right) \cdot b \leq 2 \cdot 10^{+111}:\\ \;\;\;\;\mathsf{fma}\left(y \cdot \left(z \cdot -9\right), t, x \cdot 2\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(a \cdot 27, b, \mathsf{fma}\left(x, 2, 0\right)\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 9: 53.7% accurate, 0.9× speedup?

\[\begin{array}{l} [x, y, z, t, a, b] = \mathsf{sort}([x, y, z, t, a, b])\\\\ [x, y, z, t, a, b] = \mathsf{sort}([x, y, z, t, a, b])\\ \\ \begin{array}{l} t_1 := \left(a \cdot 27\right) \cdot b\\ \mathbf{if}\;t\_1 \leq -1 \cdot 10^{+41}:\\ \;\;\;\;27 \cdot \left(a \cdot b\right)\\ \mathbf{elif}\;t\_1 \leq 2 \cdot 10^{+111}:\\ \;\;\;\;x \cdot 2\\ \mathbf{else}:\\ \;\;\;\;t\_1\\ \end{array} \end{array} \]
NOTE: x, y, z, t, a, and b should be sorted in increasing order before calling this function.
NOTE: x, y, z, t, a, and b should be sorted in increasing order before calling this function.
(FPCore (x y z t a b)
 :precision binary64
 (let* ((t_1 (* (* a 27.0) b)))
   (if (<= t_1 -1e+41) (* 27.0 (* a b)) (if (<= t_1 2e+111) (* x 2.0) t_1))))
assert(x < y && y < z && z < t && t < a && a < b);
assert(x < y && y < z && z < t && t < a && a < b);
double code(double x, double y, double z, double t, double a, double b) {
	double t_1 = (a * 27.0) * b;
	double tmp;
	if (t_1 <= -1e+41) {
		tmp = 27.0 * (a * b);
	} else if (t_1 <= 2e+111) {
		tmp = x * 2.0;
	} else {
		tmp = t_1;
	}
	return tmp;
}
NOTE: x, y, z, t, a, and b should be sorted in increasing order before calling this function.
NOTE: x, y, z, t, a, and b should be sorted in increasing order before calling this function.
real(8) function code(x, y, z, t, a, b)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8), intent (in) :: t
    real(8), intent (in) :: a
    real(8), intent (in) :: b
    real(8) :: t_1
    real(8) :: tmp
    t_1 = (a * 27.0d0) * b
    if (t_1 <= (-1d+41)) then
        tmp = 27.0d0 * (a * b)
    else if (t_1 <= 2d+111) then
        tmp = x * 2.0d0
    else
        tmp = t_1
    end if
    code = tmp
end function
assert x < y && y < z && z < t && t < a && a < b;
assert x < y && y < z && z < t && t < a && a < b;
public static double code(double x, double y, double z, double t, double a, double b) {
	double t_1 = (a * 27.0) * b;
	double tmp;
	if (t_1 <= -1e+41) {
		tmp = 27.0 * (a * b);
	} else if (t_1 <= 2e+111) {
		tmp = x * 2.0;
	} else {
		tmp = t_1;
	}
	return tmp;
}
[x, y, z, t, a, b] = sort([x, y, z, t, a, b])
[x, y, z, t, a, b] = sort([x, y, z, t, a, b])
def code(x, y, z, t, a, b):
	t_1 = (a * 27.0) * b
	tmp = 0
	if t_1 <= -1e+41:
		tmp = 27.0 * (a * b)
	elif t_1 <= 2e+111:
		tmp = x * 2.0
	else:
		tmp = t_1
	return tmp
x, y, z, t, a, b = sort([x, y, z, t, a, b])
x, y, z, t, a, b = sort([x, y, z, t, a, b])
function code(x, y, z, t, a, b)
	t_1 = Float64(Float64(a * 27.0) * b)
	tmp = 0.0
	if (t_1 <= -1e+41)
		tmp = Float64(27.0 * Float64(a * b));
	elseif (t_1 <= 2e+111)
		tmp = Float64(x * 2.0);
	else
		tmp = t_1;
	end
	return tmp
end
x, y, z, t, a, b = num2cell(sort([x, y, z, t, a, b])){:}
x, y, z, t, a, b = num2cell(sort([x, y, z, t, a, b])){:}
function tmp_2 = code(x, y, z, t, a, b)
	t_1 = (a * 27.0) * b;
	tmp = 0.0;
	if (t_1 <= -1e+41)
		tmp = 27.0 * (a * b);
	elseif (t_1 <= 2e+111)
		tmp = x * 2.0;
	else
		tmp = t_1;
	end
	tmp_2 = tmp;
end
NOTE: x, y, z, t, a, and b should be sorted in increasing order before calling this function.
NOTE: x, y, z, t, a, and b should be sorted in increasing order before calling this function.
code[x_, y_, z_, t_, a_, b_] := Block[{t$95$1 = N[(N[(a * 27.0), $MachinePrecision] * b), $MachinePrecision]}, If[LessEqual[t$95$1, -1e+41], N[(27.0 * N[(a * b), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$1, 2e+111], N[(x * 2.0), $MachinePrecision], t$95$1]]]
\begin{array}{l}
[x, y, z, t, a, b] = \mathsf{sort}([x, y, z, t, a, b])\\\\
[x, y, z, t, a, b] = \mathsf{sort}([x, y, z, t, a, b])\\
\\
\begin{array}{l}
t_1 := \left(a \cdot 27\right) \cdot b\\
\mathbf{if}\;t\_1 \leq -1 \cdot 10^{+41}:\\
\;\;\;\;27 \cdot \left(a \cdot b\right)\\

\mathbf{elif}\;t\_1 \leq 2 \cdot 10^{+111}:\\
\;\;\;\;x \cdot 2\\

\mathbf{else}:\\
\;\;\;\;t\_1\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if (*.f64 (*.f64 a #s(literal 27 binary64)) b) < -1.00000000000000001e41

    1. Initial program 96.3%

      \[\left(x \cdot 2 - \left(\left(y \cdot 9\right) \cdot z\right) \cdot t\right) + \left(a \cdot 27\right) \cdot b \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. sub-negN/A

        \[\leadsto \left(x \cdot 2 + \left(\mathsf{neg}\left(\left(\left(y \cdot 9\right) \cdot z\right) \cdot t\right)\right)\right) + \color{blue}{\left(a \cdot 27\right)} \cdot b \]
      2. +-commutativeN/A

        \[\leadsto \left(\left(\mathsf{neg}\left(\left(\left(y \cdot 9\right) \cdot z\right) \cdot t\right)\right) + x \cdot 2\right) + \color{blue}{\left(a \cdot 27\right)} \cdot b \]
      3. associate-+l+N/A

        \[\leadsto \left(\mathsf{neg}\left(\left(\left(y \cdot 9\right) \cdot z\right) \cdot t\right)\right) + \color{blue}{\left(x \cdot 2 + \left(a \cdot 27\right) \cdot b\right)} \]
      4. distribute-lft-neg-inN/A

        \[\leadsto \left(\mathsf{neg}\left(\left(y \cdot 9\right) \cdot z\right)\right) \cdot t + \left(\color{blue}{x \cdot 2} + \left(a \cdot 27\right) \cdot b\right) \]
      5. +-commutativeN/A

        \[\leadsto \left(\mathsf{neg}\left(\left(y \cdot 9\right) \cdot z\right)\right) \cdot t + \left(\left(a \cdot 27\right) \cdot b + \color{blue}{x \cdot 2}\right) \]
      6. accelerator-lowering-fma.f64N/A

        \[\leadsto \mathsf{fma.f64}\left(\left(\mathsf{neg}\left(\left(y \cdot 9\right) \cdot z\right)\right), \color{blue}{t}, \left(\left(a \cdot 27\right) \cdot b + x \cdot 2\right)\right) \]
      7. associate-*l*N/A

        \[\leadsto \mathsf{fma.f64}\left(\left(\mathsf{neg}\left(y \cdot \left(9 \cdot z\right)\right)\right), t, \left(\left(a \cdot 27\right) \cdot b + x \cdot 2\right)\right) \]
      8. distribute-rgt-neg-inN/A

        \[\leadsto \mathsf{fma.f64}\left(\left(y \cdot \left(\mathsf{neg}\left(9 \cdot z\right)\right)\right), t, \left(\left(a \cdot 27\right) \cdot b + x \cdot 2\right)\right) \]
      9. *-lowering-*.f64N/A

        \[\leadsto \mathsf{fma.f64}\left(\mathsf{*.f64}\left(y, \left(\mathsf{neg}\left(9 \cdot z\right)\right)\right), t, \left(\left(a \cdot 27\right) \cdot b + x \cdot 2\right)\right) \]
      10. *-commutativeN/A

        \[\leadsto \mathsf{fma.f64}\left(\mathsf{*.f64}\left(y, \left(\mathsf{neg}\left(z \cdot 9\right)\right)\right), t, \left(\left(a \cdot 27\right) \cdot b + x \cdot 2\right)\right) \]
      11. distribute-rgt-neg-inN/A

        \[\leadsto \mathsf{fma.f64}\left(\mathsf{*.f64}\left(y, \left(z \cdot \left(\mathsf{neg}\left(9\right)\right)\right)\right), t, \left(\left(a \cdot 27\right) \cdot b + x \cdot 2\right)\right) \]
      12. *-lowering-*.f64N/A

        \[\leadsto \mathsf{fma.f64}\left(\mathsf{*.f64}\left(y, \mathsf{*.f64}\left(z, \left(\mathsf{neg}\left(9\right)\right)\right)\right), t, \left(\left(a \cdot 27\right) \cdot b + x \cdot 2\right)\right) \]
      13. metadata-evalN/A

        \[\leadsto \mathsf{fma.f64}\left(\mathsf{*.f64}\left(y, \mathsf{*.f64}\left(z, -9\right)\right), t, \left(\left(a \cdot 27\right) \cdot b + x \cdot 2\right)\right) \]
      14. associate-*l*N/A

        \[\leadsto \mathsf{fma.f64}\left(\mathsf{*.f64}\left(y, \mathsf{*.f64}\left(z, -9\right)\right), t, \left(a \cdot \left(27 \cdot b\right) + x \cdot 2\right)\right) \]
      15. accelerator-lowering-fma.f64N/A

        \[\leadsto \mathsf{fma.f64}\left(\mathsf{*.f64}\left(y, \mathsf{*.f64}\left(z, -9\right)\right), t, \mathsf{fma.f64}\left(a, \left(27 \cdot b\right), \left(x \cdot 2\right)\right)\right) \]
      16. *-lowering-*.f64N/A

        \[\leadsto \mathsf{fma.f64}\left(\mathsf{*.f64}\left(y, \mathsf{*.f64}\left(z, -9\right)\right), t, \mathsf{fma.f64}\left(a, \mathsf{*.f64}\left(27, b\right), \left(x \cdot 2\right)\right)\right) \]
      17. *-lowering-*.f6496.4%

        \[\leadsto \mathsf{fma.f64}\left(\mathsf{*.f64}\left(y, \mathsf{*.f64}\left(z, -9\right)\right), t, \mathsf{fma.f64}\left(a, \mathsf{*.f64}\left(27, b\right), \mathsf{*.f64}\left(x, 2\right)\right)\right) \]
    4. Applied egg-rr96.4%

      \[\leadsto \color{blue}{\mathsf{fma}\left(y \cdot \left(z \cdot -9\right), t, \mathsf{fma}\left(a, 27 \cdot b, x \cdot 2\right)\right)} \]
    5. Taylor expanded in a around inf

      \[\leadsto \color{blue}{27 \cdot \left(a \cdot b\right)} \]
    6. Step-by-step derivation
      1. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(27, \color{blue}{\left(a \cdot b\right)}\right) \]
      2. *-lowering-*.f6467.5%

        \[\leadsto \mathsf{*.f64}\left(27, \mathsf{*.f64}\left(a, \color{blue}{b}\right)\right) \]
    7. Simplified67.5%

      \[\leadsto \color{blue}{27 \cdot \left(a \cdot b\right)} \]

    if -1.00000000000000001e41 < (*.f64 (*.f64 a #s(literal 27 binary64)) b) < 1.99999999999999991e111

    1. Initial program 97.8%

      \[\left(x \cdot 2 - \left(\left(y \cdot 9\right) \cdot z\right) \cdot t\right) + \left(a \cdot 27\right) \cdot b \]
    2. Add Preprocessing
    3. Taylor expanded in x around inf

      \[\leadsto \color{blue}{2 \cdot x} \]
    4. Step-by-step derivation
      1. +-rgt-identityN/A

        \[\leadsto 2 \cdot x + \color{blue}{0} \]
      2. accelerator-lowering-fma.f6446.4%

        \[\leadsto \mathsf{fma.f64}\left(2, \color{blue}{x}, 0\right) \]
    5. Simplified46.4%

      \[\leadsto \color{blue}{\mathsf{fma}\left(2, x, 0\right)} \]
    6. Step-by-step derivation
      1. +-rgt-identityN/A

        \[\leadsto 2 \cdot \color{blue}{x} \]
      2. *-commutativeN/A

        \[\leadsto x \cdot \color{blue}{2} \]
      3. *-lowering-*.f6446.4%

        \[\leadsto \mathsf{*.f64}\left(x, \color{blue}{2}\right) \]
    7. Applied egg-rr46.4%

      \[\leadsto \color{blue}{x \cdot 2} \]

    if 1.99999999999999991e111 < (*.f64 (*.f64 a #s(literal 27 binary64)) b)

    1. Initial program 88.1%

      \[\left(x \cdot 2 - \left(\left(y \cdot 9\right) \cdot z\right) \cdot t\right) + \left(a \cdot 27\right) \cdot b \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. sub-negN/A

        \[\leadsto \left(x \cdot 2 + \left(\mathsf{neg}\left(\left(\left(y \cdot 9\right) \cdot z\right) \cdot t\right)\right)\right) + \color{blue}{\left(a \cdot 27\right)} \cdot b \]
      2. +-commutativeN/A

        \[\leadsto \left(\left(\mathsf{neg}\left(\left(\left(y \cdot 9\right) \cdot z\right) \cdot t\right)\right) + x \cdot 2\right) + \color{blue}{\left(a \cdot 27\right)} \cdot b \]
      3. associate-+l+N/A

        \[\leadsto \left(\mathsf{neg}\left(\left(\left(y \cdot 9\right) \cdot z\right) \cdot t\right)\right) + \color{blue}{\left(x \cdot 2 + \left(a \cdot 27\right) \cdot b\right)} \]
      4. distribute-lft-neg-inN/A

        \[\leadsto \left(\mathsf{neg}\left(\left(y \cdot 9\right) \cdot z\right)\right) \cdot t + \left(\color{blue}{x \cdot 2} + \left(a \cdot 27\right) \cdot b\right) \]
      5. +-commutativeN/A

        \[\leadsto \left(\mathsf{neg}\left(\left(y \cdot 9\right) \cdot z\right)\right) \cdot t + \left(\left(a \cdot 27\right) \cdot b + \color{blue}{x \cdot 2}\right) \]
      6. accelerator-lowering-fma.f64N/A

        \[\leadsto \mathsf{fma.f64}\left(\left(\mathsf{neg}\left(\left(y \cdot 9\right) \cdot z\right)\right), \color{blue}{t}, \left(\left(a \cdot 27\right) \cdot b + x \cdot 2\right)\right) \]
      7. associate-*l*N/A

        \[\leadsto \mathsf{fma.f64}\left(\left(\mathsf{neg}\left(y \cdot \left(9 \cdot z\right)\right)\right), t, \left(\left(a \cdot 27\right) \cdot b + x \cdot 2\right)\right) \]
      8. distribute-rgt-neg-inN/A

        \[\leadsto \mathsf{fma.f64}\left(\left(y \cdot \left(\mathsf{neg}\left(9 \cdot z\right)\right)\right), t, \left(\left(a \cdot 27\right) \cdot b + x \cdot 2\right)\right) \]
      9. *-lowering-*.f64N/A

        \[\leadsto \mathsf{fma.f64}\left(\mathsf{*.f64}\left(y, \left(\mathsf{neg}\left(9 \cdot z\right)\right)\right), t, \left(\left(a \cdot 27\right) \cdot b + x \cdot 2\right)\right) \]
      10. *-commutativeN/A

        \[\leadsto \mathsf{fma.f64}\left(\mathsf{*.f64}\left(y, \left(\mathsf{neg}\left(z \cdot 9\right)\right)\right), t, \left(\left(a \cdot 27\right) \cdot b + x \cdot 2\right)\right) \]
      11. distribute-rgt-neg-inN/A

        \[\leadsto \mathsf{fma.f64}\left(\mathsf{*.f64}\left(y, \left(z \cdot \left(\mathsf{neg}\left(9\right)\right)\right)\right), t, \left(\left(a \cdot 27\right) \cdot b + x \cdot 2\right)\right) \]
      12. *-lowering-*.f64N/A

        \[\leadsto \mathsf{fma.f64}\left(\mathsf{*.f64}\left(y, \mathsf{*.f64}\left(z, \left(\mathsf{neg}\left(9\right)\right)\right)\right), t, \left(\left(a \cdot 27\right) \cdot b + x \cdot 2\right)\right) \]
      13. metadata-evalN/A

        \[\leadsto \mathsf{fma.f64}\left(\mathsf{*.f64}\left(y, \mathsf{*.f64}\left(z, -9\right)\right), t, \left(\left(a \cdot 27\right) \cdot b + x \cdot 2\right)\right) \]
      14. associate-*l*N/A

        \[\leadsto \mathsf{fma.f64}\left(\mathsf{*.f64}\left(y, \mathsf{*.f64}\left(z, -9\right)\right), t, \left(a \cdot \left(27 \cdot b\right) + x \cdot 2\right)\right) \]
      15. accelerator-lowering-fma.f64N/A

        \[\leadsto \mathsf{fma.f64}\left(\mathsf{*.f64}\left(y, \mathsf{*.f64}\left(z, -9\right)\right), t, \mathsf{fma.f64}\left(a, \left(27 \cdot b\right), \left(x \cdot 2\right)\right)\right) \]
      16. *-lowering-*.f64N/A

        \[\leadsto \mathsf{fma.f64}\left(\mathsf{*.f64}\left(y, \mathsf{*.f64}\left(z, -9\right)\right), t, \mathsf{fma.f64}\left(a, \mathsf{*.f64}\left(27, b\right), \left(x \cdot 2\right)\right)\right) \]
      17. *-lowering-*.f6488.0%

        \[\leadsto \mathsf{fma.f64}\left(\mathsf{*.f64}\left(y, \mathsf{*.f64}\left(z, -9\right)\right), t, \mathsf{fma.f64}\left(a, \mathsf{*.f64}\left(27, b\right), \mathsf{*.f64}\left(x, 2\right)\right)\right) \]
    4. Applied egg-rr88.0%

      \[\leadsto \color{blue}{\mathsf{fma}\left(y \cdot \left(z \cdot -9\right), t, \mathsf{fma}\left(a, 27 \cdot b, x \cdot 2\right)\right)} \]
    5. Taylor expanded in a around inf

      \[\leadsto \color{blue}{27 \cdot \left(a \cdot b\right)} \]
    6. Step-by-step derivation
      1. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(27, \color{blue}{\left(a \cdot b\right)}\right) \]
      2. *-lowering-*.f6464.8%

        \[\leadsto \mathsf{*.f64}\left(27, \mathsf{*.f64}\left(a, \color{blue}{b}\right)\right) \]
    7. Simplified64.8%

      \[\leadsto \color{blue}{27 \cdot \left(a \cdot b\right)} \]
    8. Step-by-step derivation
      1. associate-*r*N/A

        \[\leadsto \left(27 \cdot a\right) \cdot \color{blue}{b} \]
      2. *-commutativeN/A

        \[\leadsto \left(a \cdot 27\right) \cdot b \]
      3. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\left(a \cdot 27\right), \color{blue}{b}\right) \]
      4. *-lowering-*.f6464.7%

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(a, 27\right), b\right) \]
    9. Applied egg-rr64.7%

      \[\leadsto \color{blue}{\left(a \cdot 27\right) \cdot b} \]
  3. Recombined 3 regimes into one program.
  4. Add Preprocessing

Alternative 10: 97.5% accurate, 0.9× speedup?

\[\begin{array}{l} [x, y, z, t, a, b] = \mathsf{sort}([x, y, z, t, a, b])\\\\ [x, y, z, t, a, b] = \mathsf{sort}([x, y, z, t, a, b])\\ \\ \begin{array}{l} \mathbf{if}\;z \leq -5.6 \cdot 10^{+122}:\\ \;\;\;\;\mathsf{fma}\left(27 \cdot b, a, z \cdot \left(t \cdot \left(y \cdot -9\right)\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(y \cdot \left(z \cdot -9\right), t, \mathsf{fma}\left(a, 27 \cdot b, x \cdot 2\right)\right)\\ \end{array} \end{array} \]
NOTE: x, y, z, t, a, and b should be sorted in increasing order before calling this function.
NOTE: x, y, z, t, a, and b should be sorted in increasing order before calling this function.
(FPCore (x y z t a b)
 :precision binary64
 (if (<= z -5.6e+122)
   (fma (* 27.0 b) a (* z (* t (* y -9.0))))
   (fma (* y (* z -9.0)) t (fma a (* 27.0 b) (* x 2.0)))))
assert(x < y && y < z && z < t && t < a && a < b);
assert(x < y && y < z && z < t && t < a && a < b);
double code(double x, double y, double z, double t, double a, double b) {
	double tmp;
	if (z <= -5.6e+122) {
		tmp = fma((27.0 * b), a, (z * (t * (y * -9.0))));
	} else {
		tmp = fma((y * (z * -9.0)), t, fma(a, (27.0 * b), (x * 2.0)));
	}
	return tmp;
}
x, y, z, t, a, b = sort([x, y, z, t, a, b])
x, y, z, t, a, b = sort([x, y, z, t, a, b])
function code(x, y, z, t, a, b)
	tmp = 0.0
	if (z <= -5.6e+122)
		tmp = fma(Float64(27.0 * b), a, Float64(z * Float64(t * Float64(y * -9.0))));
	else
		tmp = fma(Float64(y * Float64(z * -9.0)), t, fma(a, Float64(27.0 * b), Float64(x * 2.0)));
	end
	return tmp
end
NOTE: x, y, z, t, a, and b should be sorted in increasing order before calling this function.
NOTE: x, y, z, t, a, and b should be sorted in increasing order before calling this function.
code[x_, y_, z_, t_, a_, b_] := If[LessEqual[z, -5.6e+122], N[(N[(27.0 * b), $MachinePrecision] * a + N[(z * N[(t * N[(y * -9.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(y * N[(z * -9.0), $MachinePrecision]), $MachinePrecision] * t + N[(a * N[(27.0 * b), $MachinePrecision] + N[(x * 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[x, y, z, t, a, b] = \mathsf{sort}([x, y, z, t, a, b])\\\\
[x, y, z, t, a, b] = \mathsf{sort}([x, y, z, t, a, b])\\
\\
\begin{array}{l}
\mathbf{if}\;z \leq -5.6 \cdot 10^{+122}:\\
\;\;\;\;\mathsf{fma}\left(27 \cdot b, a, z \cdot \left(t \cdot \left(y \cdot -9\right)\right)\right)\\

\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(y \cdot \left(z \cdot -9\right), t, \mathsf{fma}\left(a, 27 \cdot b, x \cdot 2\right)\right)\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if z < -5.5999999999999999e122

    1. Initial program 87.5%

      \[\left(x \cdot 2 - \left(\left(y \cdot 9\right) \cdot z\right) \cdot t\right) + \left(a \cdot 27\right) \cdot b \]
    2. Add Preprocessing
    3. Taylor expanded in x around 0

      \[\leadsto \color{blue}{27 \cdot \left(a \cdot b\right) - 9 \cdot \left(t \cdot \left(y \cdot z\right)\right)} \]
    4. Step-by-step derivation
      1. cancel-sign-sub-invN/A

        \[\leadsto 27 \cdot \left(a \cdot b\right) + \color{blue}{\left(\mathsf{neg}\left(9\right)\right) \cdot \left(t \cdot \left(y \cdot z\right)\right)} \]
      2. metadata-evalN/A

        \[\leadsto 27 \cdot \left(a \cdot b\right) + -9 \cdot \left(\color{blue}{t} \cdot \left(y \cdot z\right)\right) \]
      3. +-commutativeN/A

        \[\leadsto -9 \cdot \left(t \cdot \left(y \cdot z\right)\right) + \color{blue}{27 \cdot \left(a \cdot b\right)} \]
      4. *-commutativeN/A

        \[\leadsto \left(t \cdot \left(y \cdot z\right)\right) \cdot -9 + \color{blue}{27} \cdot \left(a \cdot b\right) \]
      5. associate-*l*N/A

        \[\leadsto t \cdot \left(\left(y \cdot z\right) \cdot -9\right) + \color{blue}{27} \cdot \left(a \cdot b\right) \]
      6. *-commutativeN/A

        \[\leadsto t \cdot \left(-9 \cdot \left(y \cdot z\right)\right) + 27 \cdot \left(a \cdot b\right) \]
      7. accelerator-lowering-fma.f64N/A

        \[\leadsto \mathsf{fma.f64}\left(t, \color{blue}{\left(-9 \cdot \left(y \cdot z\right)\right)}, \left(27 \cdot \left(a \cdot b\right)\right)\right) \]
      8. +-lft-identityN/A

        \[\leadsto \mathsf{fma.f64}\left(t, \left(0 + \color{blue}{-9 \cdot \left(y \cdot z\right)}\right), \left(27 \cdot \left(a \cdot b\right)\right)\right) \]
      9. +-commutativeN/A

        \[\leadsto \mathsf{fma.f64}\left(t, \left(-9 \cdot \left(y \cdot z\right) + \color{blue}{0}\right), \left(27 \cdot \left(a \cdot b\right)\right)\right) \]
      10. *-commutativeN/A

        \[\leadsto \mathsf{fma.f64}\left(t, \left(\left(y \cdot z\right) \cdot -9 + 0\right), \left(27 \cdot \left(a \cdot b\right)\right)\right) \]
      11. accelerator-lowering-fma.f64N/A

        \[\leadsto \mathsf{fma.f64}\left(t, \mathsf{fma.f64}\left(\left(y \cdot z\right), \color{blue}{-9}, 0\right), \left(27 \cdot \left(a \cdot b\right)\right)\right) \]
      12. *-lowering-*.f64N/A

        \[\leadsto \mathsf{fma.f64}\left(t, \mathsf{fma.f64}\left(\mathsf{*.f64}\left(y, z\right), -9, 0\right), \left(27 \cdot \left(a \cdot b\right)\right)\right) \]
      13. +-rgt-identityN/A

        \[\leadsto \mathsf{fma.f64}\left(t, \mathsf{fma.f64}\left(\mathsf{*.f64}\left(y, z\right), -9, \color{blue}{0}\right), \left(27 \cdot \left(a \cdot b\right) + 0\right)\right) \]
      14. accelerator-lowering-fma.f64N/A

        \[\leadsto \mathsf{fma.f64}\left(t, \mathsf{fma.f64}\left(\mathsf{*.f64}\left(y, z\right), -9, \color{blue}{0}\right), \mathsf{fma.f64}\left(27, \left(a \cdot b\right), 0\right)\right) \]
      15. *-lowering-*.f6474.5%

        \[\leadsto \mathsf{fma.f64}\left(t, \mathsf{fma.f64}\left(\mathsf{*.f64}\left(y, z\right), -9, 0\right), \mathsf{fma.f64}\left(27, \mathsf{*.f64}\left(a, b\right), 0\right)\right) \]
    5. Simplified74.5%

      \[\leadsto \color{blue}{\mathsf{fma}\left(t, \mathsf{fma}\left(y \cdot z, -9, 0\right), \mathsf{fma}\left(27, a \cdot b, 0\right)\right)} \]
    6. Step-by-step derivation
      1. +-rgt-identityN/A

        \[\leadsto t \cdot \left(\left(y \cdot z\right) \cdot -9\right) + \left(27 \cdot \color{blue}{\left(a \cdot b\right)} + 0\right) \]
      2. +-rgt-identityN/A

        \[\leadsto t \cdot \left(\left(y \cdot z\right) \cdot -9\right) + 27 \cdot \color{blue}{\left(a \cdot b\right)} \]
      3. *-commutativeN/A

        \[\leadsto \left(\left(y \cdot z\right) \cdot -9\right) \cdot t + \color{blue}{27} \cdot \left(a \cdot b\right) \]
      4. associate-*r*N/A

        \[\leadsto \left(y \cdot \left(z \cdot -9\right)\right) \cdot t + 27 \cdot \left(a \cdot b\right) \]
      5. +-commutativeN/A

        \[\leadsto 27 \cdot \left(a \cdot b\right) + \color{blue}{\left(y \cdot \left(z \cdot -9\right)\right) \cdot t} \]
      6. *-commutativeN/A

        \[\leadsto 27 \cdot \left(b \cdot a\right) + \left(y \cdot \color{blue}{\left(z \cdot -9\right)}\right) \cdot t \]
      7. associate-*r*N/A

        \[\leadsto \left(27 \cdot b\right) \cdot a + \color{blue}{\left(y \cdot \left(z \cdot -9\right)\right)} \cdot t \]
      8. accelerator-lowering-fma.f64N/A

        \[\leadsto \mathsf{fma.f64}\left(\left(27 \cdot b\right), \color{blue}{a}, \left(\left(y \cdot \left(z \cdot -9\right)\right) \cdot t\right)\right) \]
      9. *-lowering-*.f64N/A

        \[\leadsto \mathsf{fma.f64}\left(\mathsf{*.f64}\left(27, b\right), a, \left(\left(y \cdot \left(z \cdot -9\right)\right) \cdot t\right)\right) \]
      10. +-rgt-identityN/A

        \[\leadsto \mathsf{fma.f64}\left(\mathsf{*.f64}\left(27, b\right), a, \left(\left(y \cdot \left(z \cdot -9\right)\right) \cdot t + 0\right)\right) \]
      11. associate-*r*N/A

        \[\leadsto \mathsf{fma.f64}\left(\mathsf{*.f64}\left(27, b\right), a, \left(\left(\left(y \cdot z\right) \cdot -9\right) \cdot t + 0\right)\right) \]
      12. *-commutativeN/A

        \[\leadsto \mathsf{fma.f64}\left(\mathsf{*.f64}\left(27, b\right), a, \left(\left(-9 \cdot \left(y \cdot z\right)\right) \cdot t + 0\right)\right) \]
      13. associate-*l*N/A

        \[\leadsto \mathsf{fma.f64}\left(\mathsf{*.f64}\left(27, b\right), a, \left(-9 \cdot \left(\left(y \cdot z\right) \cdot t\right) + 0\right)\right) \]
      14. accelerator-lowering-fma.f64N/A

        \[\leadsto \mathsf{fma.f64}\left(\mathsf{*.f64}\left(27, b\right), a, \mathsf{fma.f64}\left(-9, \left(\left(y \cdot z\right) \cdot t\right), 0\right)\right) \]
      15. *-lowering-*.f64N/A

        \[\leadsto \mathsf{fma.f64}\left(\mathsf{*.f64}\left(27, b\right), a, \mathsf{fma.f64}\left(-9, \mathsf{*.f64}\left(\left(y \cdot z\right), t\right), 0\right)\right) \]
      16. *-lowering-*.f6480.8%

        \[\leadsto \mathsf{fma.f64}\left(\mathsf{*.f64}\left(27, b\right), a, \mathsf{fma.f64}\left(-9, \mathsf{*.f64}\left(\mathsf{*.f64}\left(y, z\right), t\right), 0\right)\right) \]
    7. Applied egg-rr80.8%

      \[\leadsto \color{blue}{\mathsf{fma}\left(27 \cdot b, a, \mathsf{fma}\left(-9, \left(y \cdot z\right) \cdot t, 0\right)\right)} \]
    8. Step-by-step derivation
      1. +-rgt-identityN/A

        \[\leadsto \mathsf{fma.f64}\left(\mathsf{*.f64}\left(27, b\right), a, \left(-9 \cdot \left(\left(y \cdot z\right) \cdot t\right)\right)\right) \]
      2. associate-*l*N/A

        \[\leadsto \mathsf{fma.f64}\left(\mathsf{*.f64}\left(27, b\right), a, \left(-9 \cdot \left(y \cdot \left(z \cdot t\right)\right)\right)\right) \]
      3. associate-*r*N/A

        \[\leadsto \mathsf{fma.f64}\left(\mathsf{*.f64}\left(27, b\right), a, \left(\left(-9 \cdot y\right) \cdot \left(z \cdot t\right)\right)\right) \]
      4. *-commutativeN/A

        \[\leadsto \mathsf{fma.f64}\left(\mathsf{*.f64}\left(27, b\right), a, \left(\left(y \cdot -9\right) \cdot \left(z \cdot t\right)\right)\right) \]
      5. *-commutativeN/A

        \[\leadsto \mathsf{fma.f64}\left(\mathsf{*.f64}\left(27, b\right), a, \left(\left(z \cdot t\right) \cdot \left(y \cdot -9\right)\right)\right) \]
      6. associate-*l*N/A

        \[\leadsto \mathsf{fma.f64}\left(\mathsf{*.f64}\left(27, b\right), a, \left(z \cdot \left(t \cdot \left(y \cdot -9\right)\right)\right)\right) \]
      7. *-commutativeN/A

        \[\leadsto \mathsf{fma.f64}\left(\mathsf{*.f64}\left(27, b\right), a, \left(\left(t \cdot \left(y \cdot -9\right)\right) \cdot z\right)\right) \]
      8. *-lowering-*.f64N/A

        \[\leadsto \mathsf{fma.f64}\left(\mathsf{*.f64}\left(27, b\right), a, \mathsf{*.f64}\left(\left(t \cdot \left(y \cdot -9\right)\right), z\right)\right) \]
      9. *-lowering-*.f64N/A

        \[\leadsto \mathsf{fma.f64}\left(\mathsf{*.f64}\left(27, b\right), a, \mathsf{*.f64}\left(\mathsf{*.f64}\left(t, \left(y \cdot -9\right)\right), z\right)\right) \]
      10. *-lowering-*.f6483.8%

        \[\leadsto \mathsf{fma.f64}\left(\mathsf{*.f64}\left(27, b\right), a, \mathsf{*.f64}\left(\mathsf{*.f64}\left(t, \mathsf{*.f64}\left(y, -9\right)\right), z\right)\right) \]
    9. Applied egg-rr83.8%

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

    if -5.5999999999999999e122 < z

    1. Initial program 97.4%

      \[\left(x \cdot 2 - \left(\left(y \cdot 9\right) \cdot z\right) \cdot t\right) + \left(a \cdot 27\right) \cdot b \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. sub-negN/A

        \[\leadsto \left(x \cdot 2 + \left(\mathsf{neg}\left(\left(\left(y \cdot 9\right) \cdot z\right) \cdot t\right)\right)\right) + \color{blue}{\left(a \cdot 27\right)} \cdot b \]
      2. +-commutativeN/A

        \[\leadsto \left(\left(\mathsf{neg}\left(\left(\left(y \cdot 9\right) \cdot z\right) \cdot t\right)\right) + x \cdot 2\right) + \color{blue}{\left(a \cdot 27\right)} \cdot b \]
      3. associate-+l+N/A

        \[\leadsto \left(\mathsf{neg}\left(\left(\left(y \cdot 9\right) \cdot z\right) \cdot t\right)\right) + \color{blue}{\left(x \cdot 2 + \left(a \cdot 27\right) \cdot b\right)} \]
      4. distribute-lft-neg-inN/A

        \[\leadsto \left(\mathsf{neg}\left(\left(y \cdot 9\right) \cdot z\right)\right) \cdot t + \left(\color{blue}{x \cdot 2} + \left(a \cdot 27\right) \cdot b\right) \]
      5. +-commutativeN/A

        \[\leadsto \left(\mathsf{neg}\left(\left(y \cdot 9\right) \cdot z\right)\right) \cdot t + \left(\left(a \cdot 27\right) \cdot b + \color{blue}{x \cdot 2}\right) \]
      6. accelerator-lowering-fma.f64N/A

        \[\leadsto \mathsf{fma.f64}\left(\left(\mathsf{neg}\left(\left(y \cdot 9\right) \cdot z\right)\right), \color{blue}{t}, \left(\left(a \cdot 27\right) \cdot b + x \cdot 2\right)\right) \]
      7. associate-*l*N/A

        \[\leadsto \mathsf{fma.f64}\left(\left(\mathsf{neg}\left(y \cdot \left(9 \cdot z\right)\right)\right), t, \left(\left(a \cdot 27\right) \cdot b + x \cdot 2\right)\right) \]
      8. distribute-rgt-neg-inN/A

        \[\leadsto \mathsf{fma.f64}\left(\left(y \cdot \left(\mathsf{neg}\left(9 \cdot z\right)\right)\right), t, \left(\left(a \cdot 27\right) \cdot b + x \cdot 2\right)\right) \]
      9. *-lowering-*.f64N/A

        \[\leadsto \mathsf{fma.f64}\left(\mathsf{*.f64}\left(y, \left(\mathsf{neg}\left(9 \cdot z\right)\right)\right), t, \left(\left(a \cdot 27\right) \cdot b + x \cdot 2\right)\right) \]
      10. *-commutativeN/A

        \[\leadsto \mathsf{fma.f64}\left(\mathsf{*.f64}\left(y, \left(\mathsf{neg}\left(z \cdot 9\right)\right)\right), t, \left(\left(a \cdot 27\right) \cdot b + x \cdot 2\right)\right) \]
      11. distribute-rgt-neg-inN/A

        \[\leadsto \mathsf{fma.f64}\left(\mathsf{*.f64}\left(y, \left(z \cdot \left(\mathsf{neg}\left(9\right)\right)\right)\right), t, \left(\left(a \cdot 27\right) \cdot b + x \cdot 2\right)\right) \]
      12. *-lowering-*.f64N/A

        \[\leadsto \mathsf{fma.f64}\left(\mathsf{*.f64}\left(y, \mathsf{*.f64}\left(z, \left(\mathsf{neg}\left(9\right)\right)\right)\right), t, \left(\left(a \cdot 27\right) \cdot b + x \cdot 2\right)\right) \]
      13. metadata-evalN/A

        \[\leadsto \mathsf{fma.f64}\left(\mathsf{*.f64}\left(y, \mathsf{*.f64}\left(z, -9\right)\right), t, \left(\left(a \cdot 27\right) \cdot b + x \cdot 2\right)\right) \]
      14. associate-*l*N/A

        \[\leadsto \mathsf{fma.f64}\left(\mathsf{*.f64}\left(y, \mathsf{*.f64}\left(z, -9\right)\right), t, \left(a \cdot \left(27 \cdot b\right) + x \cdot 2\right)\right) \]
      15. accelerator-lowering-fma.f64N/A

        \[\leadsto \mathsf{fma.f64}\left(\mathsf{*.f64}\left(y, \mathsf{*.f64}\left(z, -9\right)\right), t, \mathsf{fma.f64}\left(a, \left(27 \cdot b\right), \left(x \cdot 2\right)\right)\right) \]
      16. *-lowering-*.f64N/A

        \[\leadsto \mathsf{fma.f64}\left(\mathsf{*.f64}\left(y, \mathsf{*.f64}\left(z, -9\right)\right), t, \mathsf{fma.f64}\left(a, \mathsf{*.f64}\left(27, b\right), \left(x \cdot 2\right)\right)\right) \]
      17. *-lowering-*.f6497.4%

        \[\leadsto \mathsf{fma.f64}\left(\mathsf{*.f64}\left(y, \mathsf{*.f64}\left(z, -9\right)\right), t, \mathsf{fma.f64}\left(a, \mathsf{*.f64}\left(27, b\right), \mathsf{*.f64}\left(x, 2\right)\right)\right) \]
    4. Applied egg-rr97.4%

      \[\leadsto \color{blue}{\mathsf{fma}\left(y \cdot \left(z \cdot -9\right), t, \mathsf{fma}\left(a, 27 \cdot b, x \cdot 2\right)\right)} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification95.7%

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \leq -5.6 \cdot 10^{+122}:\\ \;\;\;\;\mathsf{fma}\left(27 \cdot b, a, z \cdot \left(t \cdot \left(y \cdot -9\right)\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(y \cdot \left(z \cdot -9\right), t, \mathsf{fma}\left(a, 27 \cdot b, x \cdot 2\right)\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 11: 47.8% accurate, 1.1× speedup?

\[\begin{array}{l} [x, y, z, t, a, b] = \mathsf{sort}([x, y, z, t, a, b])\\\\ [x, y, z, t, a, b] = \mathsf{sort}([x, y, z, t, a, b])\\ \\ \begin{array}{l} \mathbf{if}\;x \cdot 2 \leq -1 \cdot 10^{-16}:\\ \;\;\;\;x \cdot 2\\ \mathbf{elif}\;x \cdot 2 \leq 1000000000:\\ \;\;\;\;27 \cdot \left(a \cdot b\right)\\ \mathbf{else}:\\ \;\;\;\;x \cdot 2\\ \end{array} \end{array} \]
NOTE: x, y, z, t, a, and b should be sorted in increasing order before calling this function.
NOTE: x, y, z, t, a, and b should be sorted in increasing order before calling this function.
(FPCore (x y z t a b)
 :precision binary64
 (if (<= (* x 2.0) -1e-16)
   (* x 2.0)
   (if (<= (* x 2.0) 1000000000.0) (* 27.0 (* a b)) (* x 2.0))))
assert(x < y && y < z && z < t && t < a && a < b);
assert(x < y && y < z && z < t && t < a && a < b);
double code(double x, double y, double z, double t, double a, double b) {
	double tmp;
	if ((x * 2.0) <= -1e-16) {
		tmp = x * 2.0;
	} else if ((x * 2.0) <= 1000000000.0) {
		tmp = 27.0 * (a * b);
	} else {
		tmp = x * 2.0;
	}
	return tmp;
}
NOTE: x, y, z, t, a, and b should be sorted in increasing order before calling this function.
NOTE: x, y, z, t, a, and b should be sorted in increasing order before calling this function.
real(8) function code(x, y, z, t, a, b)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8), intent (in) :: t
    real(8), intent (in) :: a
    real(8), intent (in) :: b
    real(8) :: tmp
    if ((x * 2.0d0) <= (-1d-16)) then
        tmp = x * 2.0d0
    else if ((x * 2.0d0) <= 1000000000.0d0) then
        tmp = 27.0d0 * (a * b)
    else
        tmp = x * 2.0d0
    end if
    code = tmp
end function
assert x < y && y < z && z < t && t < a && a < b;
assert x < y && y < z && z < t && t < a && a < b;
public static double code(double x, double y, double z, double t, double a, double b) {
	double tmp;
	if ((x * 2.0) <= -1e-16) {
		tmp = x * 2.0;
	} else if ((x * 2.0) <= 1000000000.0) {
		tmp = 27.0 * (a * b);
	} else {
		tmp = x * 2.0;
	}
	return tmp;
}
[x, y, z, t, a, b] = sort([x, y, z, t, a, b])
[x, y, z, t, a, b] = sort([x, y, z, t, a, b])
def code(x, y, z, t, a, b):
	tmp = 0
	if (x * 2.0) <= -1e-16:
		tmp = x * 2.0
	elif (x * 2.0) <= 1000000000.0:
		tmp = 27.0 * (a * b)
	else:
		tmp = x * 2.0
	return tmp
x, y, z, t, a, b = sort([x, y, z, t, a, b])
x, y, z, t, a, b = sort([x, y, z, t, a, b])
function code(x, y, z, t, a, b)
	tmp = 0.0
	if (Float64(x * 2.0) <= -1e-16)
		tmp = Float64(x * 2.0);
	elseif (Float64(x * 2.0) <= 1000000000.0)
		tmp = Float64(27.0 * Float64(a * b));
	else
		tmp = Float64(x * 2.0);
	end
	return tmp
end
x, y, z, t, a, b = num2cell(sort([x, y, z, t, a, b])){:}
x, y, z, t, a, b = num2cell(sort([x, y, z, t, a, b])){:}
function tmp_2 = code(x, y, z, t, a, b)
	tmp = 0.0;
	if ((x * 2.0) <= -1e-16)
		tmp = x * 2.0;
	elseif ((x * 2.0) <= 1000000000.0)
		tmp = 27.0 * (a * b);
	else
		tmp = x * 2.0;
	end
	tmp_2 = tmp;
end
NOTE: x, y, z, t, a, and b should be sorted in increasing order before calling this function.
NOTE: x, y, z, t, a, and b should be sorted in increasing order before calling this function.
code[x_, y_, z_, t_, a_, b_] := If[LessEqual[N[(x * 2.0), $MachinePrecision], -1e-16], N[(x * 2.0), $MachinePrecision], If[LessEqual[N[(x * 2.0), $MachinePrecision], 1000000000.0], N[(27.0 * N[(a * b), $MachinePrecision]), $MachinePrecision], N[(x * 2.0), $MachinePrecision]]]
\begin{array}{l}
[x, y, z, t, a, b] = \mathsf{sort}([x, y, z, t, a, b])\\\\
[x, y, z, t, a, b] = \mathsf{sort}([x, y, z, t, a, b])\\
\\
\begin{array}{l}
\mathbf{if}\;x \cdot 2 \leq -1 \cdot 10^{-16}:\\
\;\;\;\;x \cdot 2\\

\mathbf{elif}\;x \cdot 2 \leq 1000000000:\\
\;\;\;\;27 \cdot \left(a \cdot b\right)\\

\mathbf{else}:\\
\;\;\;\;x \cdot 2\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (*.f64 x #s(literal 2 binary64)) < -9.9999999999999998e-17 or 1e9 < (*.f64 x #s(literal 2 binary64))

    1. Initial program 97.7%

      \[\left(x \cdot 2 - \left(\left(y \cdot 9\right) \cdot z\right) \cdot t\right) + \left(a \cdot 27\right) \cdot b \]
    2. Add Preprocessing
    3. Taylor expanded in x around inf

      \[\leadsto \color{blue}{2 \cdot x} \]
    4. Step-by-step derivation
      1. +-rgt-identityN/A

        \[\leadsto 2 \cdot x + \color{blue}{0} \]
      2. accelerator-lowering-fma.f6456.9%

        \[\leadsto \mathsf{fma.f64}\left(2, \color{blue}{x}, 0\right) \]
    5. Simplified56.9%

      \[\leadsto \color{blue}{\mathsf{fma}\left(2, x, 0\right)} \]
    6. Step-by-step derivation
      1. +-rgt-identityN/A

        \[\leadsto 2 \cdot \color{blue}{x} \]
      2. *-commutativeN/A

        \[\leadsto x \cdot \color{blue}{2} \]
      3. *-lowering-*.f6456.9%

        \[\leadsto \mathsf{*.f64}\left(x, \color{blue}{2}\right) \]
    7. Applied egg-rr56.9%

      \[\leadsto \color{blue}{x \cdot 2} \]

    if -9.9999999999999998e-17 < (*.f64 x #s(literal 2 binary64)) < 1e9

    1. Initial program 94.7%

      \[\left(x \cdot 2 - \left(\left(y \cdot 9\right) \cdot z\right) \cdot t\right) + \left(a \cdot 27\right) \cdot b \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. sub-negN/A

        \[\leadsto \left(x \cdot 2 + \left(\mathsf{neg}\left(\left(\left(y \cdot 9\right) \cdot z\right) \cdot t\right)\right)\right) + \color{blue}{\left(a \cdot 27\right)} \cdot b \]
      2. +-commutativeN/A

        \[\leadsto \left(\left(\mathsf{neg}\left(\left(\left(y \cdot 9\right) \cdot z\right) \cdot t\right)\right) + x \cdot 2\right) + \color{blue}{\left(a \cdot 27\right)} \cdot b \]
      3. associate-+l+N/A

        \[\leadsto \left(\mathsf{neg}\left(\left(\left(y \cdot 9\right) \cdot z\right) \cdot t\right)\right) + \color{blue}{\left(x \cdot 2 + \left(a \cdot 27\right) \cdot b\right)} \]
      4. distribute-lft-neg-inN/A

        \[\leadsto \left(\mathsf{neg}\left(\left(y \cdot 9\right) \cdot z\right)\right) \cdot t + \left(\color{blue}{x \cdot 2} + \left(a \cdot 27\right) \cdot b\right) \]
      5. +-commutativeN/A

        \[\leadsto \left(\mathsf{neg}\left(\left(y \cdot 9\right) \cdot z\right)\right) \cdot t + \left(\left(a \cdot 27\right) \cdot b + \color{blue}{x \cdot 2}\right) \]
      6. accelerator-lowering-fma.f64N/A

        \[\leadsto \mathsf{fma.f64}\left(\left(\mathsf{neg}\left(\left(y \cdot 9\right) \cdot z\right)\right), \color{blue}{t}, \left(\left(a \cdot 27\right) \cdot b + x \cdot 2\right)\right) \]
      7. associate-*l*N/A

        \[\leadsto \mathsf{fma.f64}\left(\left(\mathsf{neg}\left(y \cdot \left(9 \cdot z\right)\right)\right), t, \left(\left(a \cdot 27\right) \cdot b + x \cdot 2\right)\right) \]
      8. distribute-rgt-neg-inN/A

        \[\leadsto \mathsf{fma.f64}\left(\left(y \cdot \left(\mathsf{neg}\left(9 \cdot z\right)\right)\right), t, \left(\left(a \cdot 27\right) \cdot b + x \cdot 2\right)\right) \]
      9. *-lowering-*.f64N/A

        \[\leadsto \mathsf{fma.f64}\left(\mathsf{*.f64}\left(y, \left(\mathsf{neg}\left(9 \cdot z\right)\right)\right), t, \left(\left(a \cdot 27\right) \cdot b + x \cdot 2\right)\right) \]
      10. *-commutativeN/A

        \[\leadsto \mathsf{fma.f64}\left(\mathsf{*.f64}\left(y, \left(\mathsf{neg}\left(z \cdot 9\right)\right)\right), t, \left(\left(a \cdot 27\right) \cdot b + x \cdot 2\right)\right) \]
      11. distribute-rgt-neg-inN/A

        \[\leadsto \mathsf{fma.f64}\left(\mathsf{*.f64}\left(y, \left(z \cdot \left(\mathsf{neg}\left(9\right)\right)\right)\right), t, \left(\left(a \cdot 27\right) \cdot b + x \cdot 2\right)\right) \]
      12. *-lowering-*.f64N/A

        \[\leadsto \mathsf{fma.f64}\left(\mathsf{*.f64}\left(y, \mathsf{*.f64}\left(z, \left(\mathsf{neg}\left(9\right)\right)\right)\right), t, \left(\left(a \cdot 27\right) \cdot b + x \cdot 2\right)\right) \]
      13. metadata-evalN/A

        \[\leadsto \mathsf{fma.f64}\left(\mathsf{*.f64}\left(y, \mathsf{*.f64}\left(z, -9\right)\right), t, \left(\left(a \cdot 27\right) \cdot b + x \cdot 2\right)\right) \]
      14. associate-*l*N/A

        \[\leadsto \mathsf{fma.f64}\left(\mathsf{*.f64}\left(y, \mathsf{*.f64}\left(z, -9\right)\right), t, \left(a \cdot \left(27 \cdot b\right) + x \cdot 2\right)\right) \]
      15. accelerator-lowering-fma.f64N/A

        \[\leadsto \mathsf{fma.f64}\left(\mathsf{*.f64}\left(y, \mathsf{*.f64}\left(z, -9\right)\right), t, \mathsf{fma.f64}\left(a, \left(27 \cdot b\right), \left(x \cdot 2\right)\right)\right) \]
      16. *-lowering-*.f64N/A

        \[\leadsto \mathsf{fma.f64}\left(\mathsf{*.f64}\left(y, \mathsf{*.f64}\left(z, -9\right)\right), t, \mathsf{fma.f64}\left(a, \mathsf{*.f64}\left(27, b\right), \left(x \cdot 2\right)\right)\right) \]
      17. *-lowering-*.f6494.7%

        \[\leadsto \mathsf{fma.f64}\left(\mathsf{*.f64}\left(y, \mathsf{*.f64}\left(z, -9\right)\right), t, \mathsf{fma.f64}\left(a, \mathsf{*.f64}\left(27, b\right), \mathsf{*.f64}\left(x, 2\right)\right)\right) \]
    4. Applied egg-rr94.7%

      \[\leadsto \color{blue}{\mathsf{fma}\left(y \cdot \left(z \cdot -9\right), t, \mathsf{fma}\left(a, 27 \cdot b, x \cdot 2\right)\right)} \]
    5. Taylor expanded in a around inf

      \[\leadsto \color{blue}{27 \cdot \left(a \cdot b\right)} \]
    6. Step-by-step derivation
      1. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(27, \color{blue}{\left(a \cdot b\right)}\right) \]
      2. *-lowering-*.f6444.2%

        \[\leadsto \mathsf{*.f64}\left(27, \mathsf{*.f64}\left(a, \color{blue}{b}\right)\right) \]
    7. Simplified44.2%

      \[\leadsto \color{blue}{27 \cdot \left(a \cdot b\right)} \]
  3. Recombined 2 regimes into one program.
  4. Add Preprocessing

Alternative 12: 93.6% accurate, 1.1× speedup?

\[\begin{array}{l} [x, y, z, t, a, b] = \mathsf{sort}([x, y, z, t, a, b])\\\\ [x, y, z, t, a, b] = \mathsf{sort}([x, y, z, t, a, b])\\ \\ \mathsf{fma}\left(y \cdot t, z \cdot -9, \mathsf{fma}\left(a, 27 \cdot b, x \cdot 2\right)\right) \end{array} \]
NOTE: x, y, z, t, a, and b should be sorted in increasing order before calling this function.
NOTE: x, y, z, t, a, and b should be sorted in increasing order before calling this function.
(FPCore (x y z t a b)
 :precision binary64
 (fma (* y t) (* z -9.0) (fma a (* 27.0 b) (* x 2.0))))
assert(x < y && y < z && z < t && t < a && a < b);
assert(x < y && y < z && z < t && t < a && a < b);
double code(double x, double y, double z, double t, double a, double b) {
	return fma((y * t), (z * -9.0), fma(a, (27.0 * b), (x * 2.0)));
}
x, y, z, t, a, b = sort([x, y, z, t, a, b])
x, y, z, t, a, b = sort([x, y, z, t, a, b])
function code(x, y, z, t, a, b)
	return fma(Float64(y * t), Float64(z * -9.0), fma(a, Float64(27.0 * b), Float64(x * 2.0)))
end
NOTE: x, y, z, t, a, and b should be sorted in increasing order before calling this function.
NOTE: x, y, z, t, a, and b should be sorted in increasing order before calling this function.
code[x_, y_, z_, t_, a_, b_] := N[(N[(y * t), $MachinePrecision] * N[(z * -9.0), $MachinePrecision] + N[(a * N[(27.0 * b), $MachinePrecision] + N[(x * 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
[x, y, z, t, a, b] = \mathsf{sort}([x, y, z, t, a, b])\\\\
[x, y, z, t, a, b] = \mathsf{sort}([x, y, z, t, a, b])\\
\\
\mathsf{fma}\left(y \cdot t, z \cdot -9, \mathsf{fma}\left(a, 27 \cdot b, x \cdot 2\right)\right)
\end{array}
Derivation
  1. Initial program 96.2%

    \[\left(x \cdot 2 - \left(\left(y \cdot 9\right) \cdot z\right) \cdot t\right) + \left(a \cdot 27\right) \cdot b \]
  2. Add Preprocessing
  3. Step-by-step derivation
    1. sub-negN/A

      \[\leadsto \left(x \cdot 2 + \left(\mathsf{neg}\left(\left(\left(y \cdot 9\right) \cdot z\right) \cdot t\right)\right)\right) + \color{blue}{\left(a \cdot 27\right)} \cdot b \]
    2. +-commutativeN/A

      \[\leadsto \left(\left(\mathsf{neg}\left(\left(\left(y \cdot 9\right) \cdot z\right) \cdot t\right)\right) + x \cdot 2\right) + \color{blue}{\left(a \cdot 27\right)} \cdot b \]
    3. associate-+l+N/A

      \[\leadsto \left(\mathsf{neg}\left(\left(\left(y \cdot 9\right) \cdot z\right) \cdot t\right)\right) + \color{blue}{\left(x \cdot 2 + \left(a \cdot 27\right) \cdot b\right)} \]
    4. *-commutativeN/A

      \[\leadsto \left(\mathsf{neg}\left(t \cdot \left(\left(y \cdot 9\right) \cdot z\right)\right)\right) + \left(\color{blue}{x} \cdot 2 + \left(a \cdot 27\right) \cdot b\right) \]
    5. associate-*l*N/A

      \[\leadsto \left(\mathsf{neg}\left(t \cdot \left(y \cdot \left(9 \cdot z\right)\right)\right)\right) + \left(x \cdot 2 + \left(a \cdot 27\right) \cdot b\right) \]
    6. associate-*r*N/A

      \[\leadsto \left(\mathsf{neg}\left(\left(t \cdot y\right) \cdot \left(9 \cdot z\right)\right)\right) + \left(\color{blue}{x} \cdot 2 + \left(a \cdot 27\right) \cdot b\right) \]
    7. distribute-rgt-neg-inN/A

      \[\leadsto \left(t \cdot y\right) \cdot \left(\mathsf{neg}\left(9 \cdot z\right)\right) + \left(\color{blue}{x \cdot 2} + \left(a \cdot 27\right) \cdot b\right) \]
    8. +-commutativeN/A

      \[\leadsto \left(t \cdot y\right) \cdot \left(\mathsf{neg}\left(9 \cdot z\right)\right) + \left(\left(a \cdot 27\right) \cdot b + \color{blue}{x \cdot 2}\right) \]
    9. accelerator-lowering-fma.f64N/A

      \[\leadsto \mathsf{fma.f64}\left(\left(t \cdot y\right), \color{blue}{\left(\mathsf{neg}\left(9 \cdot z\right)\right)}, \left(\left(a \cdot 27\right) \cdot b + x \cdot 2\right)\right) \]
    10. *-commutativeN/A

      \[\leadsto \mathsf{fma.f64}\left(\left(y \cdot t\right), \left(\mathsf{neg}\left(\color{blue}{9 \cdot z}\right)\right), \left(\left(a \cdot 27\right) \cdot b + x \cdot 2\right)\right) \]
    11. *-lowering-*.f64N/A

      \[\leadsto \mathsf{fma.f64}\left(\mathsf{*.f64}\left(y, t\right), \left(\mathsf{neg}\left(\color{blue}{9 \cdot z}\right)\right), \left(\left(a \cdot 27\right) \cdot b + x \cdot 2\right)\right) \]
    12. *-commutativeN/A

      \[\leadsto \mathsf{fma.f64}\left(\mathsf{*.f64}\left(y, t\right), \left(\mathsf{neg}\left(z \cdot 9\right)\right), \left(\left(a \cdot 27\right) \cdot b + x \cdot 2\right)\right) \]
    13. distribute-rgt-neg-inN/A

      \[\leadsto \mathsf{fma.f64}\left(\mathsf{*.f64}\left(y, t\right), \left(z \cdot \color{blue}{\left(\mathsf{neg}\left(9\right)\right)}\right), \left(\left(a \cdot 27\right) \cdot b + x \cdot 2\right)\right) \]
    14. *-lowering-*.f64N/A

      \[\leadsto \mathsf{fma.f64}\left(\mathsf{*.f64}\left(y, t\right), \mathsf{*.f64}\left(z, \color{blue}{\left(\mathsf{neg}\left(9\right)\right)}\right), \left(\left(a \cdot 27\right) \cdot b + x \cdot 2\right)\right) \]
    15. metadata-evalN/A

      \[\leadsto \mathsf{fma.f64}\left(\mathsf{*.f64}\left(y, t\right), \mathsf{*.f64}\left(z, -9\right), \left(\left(a \cdot 27\right) \cdot b + x \cdot 2\right)\right) \]
    16. associate-*l*N/A

      \[\leadsto \mathsf{fma.f64}\left(\mathsf{*.f64}\left(y, t\right), \mathsf{*.f64}\left(z, -9\right), \left(a \cdot \left(27 \cdot b\right) + x \cdot 2\right)\right) \]
    17. accelerator-lowering-fma.f64N/A

      \[\leadsto \mathsf{fma.f64}\left(\mathsf{*.f64}\left(y, t\right), \mathsf{*.f64}\left(z, -9\right), \mathsf{fma.f64}\left(a, \left(27 \cdot b\right), \left(x \cdot 2\right)\right)\right) \]
    18. *-lowering-*.f64N/A

      \[\leadsto \mathsf{fma.f64}\left(\mathsf{*.f64}\left(y, t\right), \mathsf{*.f64}\left(z, -9\right), \mathsf{fma.f64}\left(a, \mathsf{*.f64}\left(27, b\right), \left(x \cdot 2\right)\right)\right) \]
    19. *-lowering-*.f6493.5%

      \[\leadsto \mathsf{fma.f64}\left(\mathsf{*.f64}\left(y, t\right), \mathsf{*.f64}\left(z, -9\right), \mathsf{fma.f64}\left(a, \mathsf{*.f64}\left(27, b\right), \mathsf{*.f64}\left(x, 2\right)\right)\right) \]
  4. Applied egg-rr93.5%

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

Alternative 13: 75.6% accurate, 1.3× speedup?

\[\begin{array}{l} [x, y, z, t, a, b] = \mathsf{sort}([x, y, z, t, a, b])\\\\ [x, y, z, t, a, b] = \mathsf{sort}([x, y, z, t, a, b])\\ \\ \begin{array}{l} \mathbf{if}\;z \leq -1.65 \cdot 10^{+41}:\\ \;\;\;\;\left(z \cdot -9\right) \cdot \left(y \cdot t\right)\\ \mathbf{elif}\;z \leq 3.9 \cdot 10^{-35}:\\ \;\;\;\;\mathsf{fma}\left(27, a \cdot b, x \cdot 2\right)\\ \mathbf{else}:\\ \;\;\;\;t \cdot \left(z \cdot \left(y \cdot -9\right)\right)\\ \end{array} \end{array} \]
NOTE: x, y, z, t, a, and b should be sorted in increasing order before calling this function.
NOTE: x, y, z, t, a, and b should be sorted in increasing order before calling this function.
(FPCore (x y z t a b)
 :precision binary64
 (if (<= z -1.65e+41)
   (* (* z -9.0) (* y t))
   (if (<= z 3.9e-35) (fma 27.0 (* a b) (* x 2.0)) (* t (* z (* y -9.0))))))
assert(x < y && y < z && z < t && t < a && a < b);
assert(x < y && y < z && z < t && t < a && a < b);
double code(double x, double y, double z, double t, double a, double b) {
	double tmp;
	if (z <= -1.65e+41) {
		tmp = (z * -9.0) * (y * t);
	} else if (z <= 3.9e-35) {
		tmp = fma(27.0, (a * b), (x * 2.0));
	} else {
		tmp = t * (z * (y * -9.0));
	}
	return tmp;
}
x, y, z, t, a, b = sort([x, y, z, t, a, b])
x, y, z, t, a, b = sort([x, y, z, t, a, b])
function code(x, y, z, t, a, b)
	tmp = 0.0
	if (z <= -1.65e+41)
		tmp = Float64(Float64(z * -9.0) * Float64(y * t));
	elseif (z <= 3.9e-35)
		tmp = fma(27.0, Float64(a * b), Float64(x * 2.0));
	else
		tmp = Float64(t * Float64(z * Float64(y * -9.0)));
	end
	return tmp
end
NOTE: x, y, z, t, a, and b should be sorted in increasing order before calling this function.
NOTE: x, y, z, t, a, and b should be sorted in increasing order before calling this function.
code[x_, y_, z_, t_, a_, b_] := If[LessEqual[z, -1.65e+41], N[(N[(z * -9.0), $MachinePrecision] * N[(y * t), $MachinePrecision]), $MachinePrecision], If[LessEqual[z, 3.9e-35], N[(27.0 * N[(a * b), $MachinePrecision] + N[(x * 2.0), $MachinePrecision]), $MachinePrecision], N[(t * N[(z * N[(y * -9.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
[x, y, z, t, a, b] = \mathsf{sort}([x, y, z, t, a, b])\\\\
[x, y, z, t, a, b] = \mathsf{sort}([x, y, z, t, a, b])\\
\\
\begin{array}{l}
\mathbf{if}\;z \leq -1.65 \cdot 10^{+41}:\\
\;\;\;\;\left(z \cdot -9\right) \cdot \left(y \cdot t\right)\\

\mathbf{elif}\;z \leq 3.9 \cdot 10^{-35}:\\
\;\;\;\;\mathsf{fma}\left(27, a \cdot b, x \cdot 2\right)\\

\mathbf{else}:\\
\;\;\;\;t \cdot \left(z \cdot \left(y \cdot -9\right)\right)\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if z < -1.65e41

    1. Initial program 93.3%

      \[\left(x \cdot 2 - \left(\left(y \cdot 9\right) \cdot z\right) \cdot t\right) + \left(a \cdot 27\right) \cdot b \]
    2. Add Preprocessing
    3. Taylor expanded in y around inf

      \[\leadsto \color{blue}{-9 \cdot \left(t \cdot \left(y \cdot z\right)\right)} \]
    4. Step-by-step derivation
      1. +-lft-identityN/A

        \[\leadsto 0 + \color{blue}{-9 \cdot \left(t \cdot \left(y \cdot z\right)\right)} \]
      2. +-commutativeN/A

        \[\leadsto -9 \cdot \left(t \cdot \left(y \cdot z\right)\right) + \color{blue}{0} \]
      3. *-commutativeN/A

        \[\leadsto \left(t \cdot \left(y \cdot z\right)\right) \cdot -9 + 0 \]
      4. associate-*l*N/A

        \[\leadsto t \cdot \left(\left(y \cdot z\right) \cdot -9\right) + 0 \]
      5. *-commutativeN/A

        \[\leadsto t \cdot \left(-9 \cdot \left(y \cdot z\right)\right) + 0 \]
      6. accelerator-lowering-fma.f64N/A

        \[\leadsto \mathsf{fma.f64}\left(t, \color{blue}{\left(-9 \cdot \left(y \cdot z\right)\right)}, 0\right) \]
      7. +-lft-identityN/A

        \[\leadsto \mathsf{fma.f64}\left(t, \left(0 + \color{blue}{-9 \cdot \left(y \cdot z\right)}\right), 0\right) \]
      8. +-commutativeN/A

        \[\leadsto \mathsf{fma.f64}\left(t, \left(-9 \cdot \left(y \cdot z\right) + \color{blue}{0}\right), 0\right) \]
      9. *-commutativeN/A

        \[\leadsto \mathsf{fma.f64}\left(t, \left(\left(y \cdot z\right) \cdot -9 + 0\right), 0\right) \]
      10. accelerator-lowering-fma.f64N/A

        \[\leadsto \mathsf{fma.f64}\left(t, \mathsf{fma.f64}\left(\left(y \cdot z\right), \color{blue}{-9}, 0\right), 0\right) \]
      11. *-lowering-*.f6450.5%

        \[\leadsto \mathsf{fma.f64}\left(t, \mathsf{fma.f64}\left(\mathsf{*.f64}\left(y, z\right), -9, 0\right), 0\right) \]
    5. Simplified50.5%

      \[\leadsto \color{blue}{\mathsf{fma}\left(t, \mathsf{fma}\left(y \cdot z, -9, 0\right), 0\right)} \]
    6. Step-by-step derivation
      1. +-rgt-identityN/A

        \[\leadsto t \cdot \left(\left(y \cdot z\right) \cdot -9\right) + 0 \]
      2. *-commutativeN/A

        \[\leadsto \left(\left(y \cdot z\right) \cdot -9\right) \cdot t + 0 \]
      3. associate-*r*N/A

        \[\leadsto \left(y \cdot \left(z \cdot -9\right)\right) \cdot t + 0 \]
      4. +-rgt-identityN/A

        \[\leadsto \left(y \cdot \left(z \cdot -9\right)\right) \cdot \color{blue}{t} \]
      5. *-commutativeN/A

        \[\leadsto \left(\left(z \cdot -9\right) \cdot y\right) \cdot t \]
      6. associate-*l*N/A

        \[\leadsto \left(z \cdot -9\right) \cdot \color{blue}{\left(y \cdot t\right)} \]
      7. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\left(z \cdot -9\right), \color{blue}{\left(y \cdot t\right)}\right) \]
      8. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(z, -9\right), \left(\color{blue}{y} \cdot t\right)\right) \]
      9. *-lowering-*.f6451.8%

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(z, -9\right), \mathsf{*.f64}\left(y, \color{blue}{t}\right)\right) \]
    7. Applied egg-rr51.8%

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

    if -1.65e41 < z < 3.8999999999999998e-35

    1. Initial program 98.6%

      \[\left(x \cdot 2 - \left(\left(y \cdot 9\right) \cdot z\right) \cdot t\right) + \left(a \cdot 27\right) \cdot b \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. sub-negN/A

        \[\leadsto \left(x \cdot 2 + \left(\mathsf{neg}\left(\left(\left(y \cdot 9\right) \cdot z\right) \cdot t\right)\right)\right) + \color{blue}{\left(a \cdot 27\right)} \cdot b \]
      2. +-commutativeN/A

        \[\leadsto \left(\left(\mathsf{neg}\left(\left(\left(y \cdot 9\right) \cdot z\right) \cdot t\right)\right) + x \cdot 2\right) + \color{blue}{\left(a \cdot 27\right)} \cdot b \]
      3. associate-+l+N/A

        \[\leadsto \left(\mathsf{neg}\left(\left(\left(y \cdot 9\right) \cdot z\right) \cdot t\right)\right) + \color{blue}{\left(x \cdot 2 + \left(a \cdot 27\right) \cdot b\right)} \]
      4. distribute-lft-neg-inN/A

        \[\leadsto \left(\mathsf{neg}\left(\left(y \cdot 9\right) \cdot z\right)\right) \cdot t + \left(\color{blue}{x \cdot 2} + \left(a \cdot 27\right) \cdot b\right) \]
      5. +-commutativeN/A

        \[\leadsto \left(\mathsf{neg}\left(\left(y \cdot 9\right) \cdot z\right)\right) \cdot t + \left(\left(a \cdot 27\right) \cdot b + \color{blue}{x \cdot 2}\right) \]
      6. accelerator-lowering-fma.f64N/A

        \[\leadsto \mathsf{fma.f64}\left(\left(\mathsf{neg}\left(\left(y \cdot 9\right) \cdot z\right)\right), \color{blue}{t}, \left(\left(a \cdot 27\right) \cdot b + x \cdot 2\right)\right) \]
      7. associate-*l*N/A

        \[\leadsto \mathsf{fma.f64}\left(\left(\mathsf{neg}\left(y \cdot \left(9 \cdot z\right)\right)\right), t, \left(\left(a \cdot 27\right) \cdot b + x \cdot 2\right)\right) \]
      8. distribute-rgt-neg-inN/A

        \[\leadsto \mathsf{fma.f64}\left(\left(y \cdot \left(\mathsf{neg}\left(9 \cdot z\right)\right)\right), t, \left(\left(a \cdot 27\right) \cdot b + x \cdot 2\right)\right) \]
      9. *-lowering-*.f64N/A

        \[\leadsto \mathsf{fma.f64}\left(\mathsf{*.f64}\left(y, \left(\mathsf{neg}\left(9 \cdot z\right)\right)\right), t, \left(\left(a \cdot 27\right) \cdot b + x \cdot 2\right)\right) \]
      10. *-commutativeN/A

        \[\leadsto \mathsf{fma.f64}\left(\mathsf{*.f64}\left(y, \left(\mathsf{neg}\left(z \cdot 9\right)\right)\right), t, \left(\left(a \cdot 27\right) \cdot b + x \cdot 2\right)\right) \]
      11. distribute-rgt-neg-inN/A

        \[\leadsto \mathsf{fma.f64}\left(\mathsf{*.f64}\left(y, \left(z \cdot \left(\mathsf{neg}\left(9\right)\right)\right)\right), t, \left(\left(a \cdot 27\right) \cdot b + x \cdot 2\right)\right) \]
      12. *-lowering-*.f64N/A

        \[\leadsto \mathsf{fma.f64}\left(\mathsf{*.f64}\left(y, \mathsf{*.f64}\left(z, \left(\mathsf{neg}\left(9\right)\right)\right)\right), t, \left(\left(a \cdot 27\right) \cdot b + x \cdot 2\right)\right) \]
      13. metadata-evalN/A

        \[\leadsto \mathsf{fma.f64}\left(\mathsf{*.f64}\left(y, \mathsf{*.f64}\left(z, -9\right)\right), t, \left(\left(a \cdot 27\right) \cdot b + x \cdot 2\right)\right) \]
      14. associate-*l*N/A

        \[\leadsto \mathsf{fma.f64}\left(\mathsf{*.f64}\left(y, \mathsf{*.f64}\left(z, -9\right)\right), t, \left(a \cdot \left(27 \cdot b\right) + x \cdot 2\right)\right) \]
      15. accelerator-lowering-fma.f64N/A

        \[\leadsto \mathsf{fma.f64}\left(\mathsf{*.f64}\left(y, \mathsf{*.f64}\left(z, -9\right)\right), t, \mathsf{fma.f64}\left(a, \left(27 \cdot b\right), \left(x \cdot 2\right)\right)\right) \]
      16. *-lowering-*.f64N/A

        \[\leadsto \mathsf{fma.f64}\left(\mathsf{*.f64}\left(y, \mathsf{*.f64}\left(z, -9\right)\right), t, \mathsf{fma.f64}\left(a, \mathsf{*.f64}\left(27, b\right), \left(x \cdot 2\right)\right)\right) \]
      17. *-lowering-*.f6498.5%

        \[\leadsto \mathsf{fma.f64}\left(\mathsf{*.f64}\left(y, \mathsf{*.f64}\left(z, -9\right)\right), t, \mathsf{fma.f64}\left(a, \mathsf{*.f64}\left(27, b\right), \mathsf{*.f64}\left(x, 2\right)\right)\right) \]
    4. Applied egg-rr98.5%

      \[\leadsto \color{blue}{\mathsf{fma}\left(y \cdot \left(z \cdot -9\right), t, \mathsf{fma}\left(a, 27 \cdot b, x \cdot 2\right)\right)} \]
    5. Taylor expanded in y around 0

      \[\leadsto \color{blue}{2 \cdot x + 27 \cdot \left(a \cdot b\right)} \]
    6. Step-by-step derivation
      1. +-commutativeN/A

        \[\leadsto 27 \cdot \left(a \cdot b\right) + \color{blue}{2 \cdot x} \]
      2. accelerator-lowering-fma.f64N/A

        \[\leadsto \mathsf{fma.f64}\left(27, \color{blue}{\left(a \cdot b\right)}, \left(2 \cdot x\right)\right) \]
      3. *-lowering-*.f64N/A

        \[\leadsto \mathsf{fma.f64}\left(27, \mathsf{*.f64}\left(a, \color{blue}{b}\right), \left(2 \cdot x\right)\right) \]
      4. *-lowering-*.f6474.8%

        \[\leadsto \mathsf{fma.f64}\left(27, \mathsf{*.f64}\left(a, b\right), \mathsf{*.f64}\left(2, x\right)\right) \]
    7. Simplified74.8%

      \[\leadsto \color{blue}{\mathsf{fma}\left(27, a \cdot b, 2 \cdot x\right)} \]

    if 3.8999999999999998e-35 < z

    1. Initial program 94.6%

      \[\left(x \cdot 2 - \left(\left(y \cdot 9\right) \cdot z\right) \cdot t\right) + \left(a \cdot 27\right) \cdot b \]
    2. Add Preprocessing
    3. Taylor expanded in y around inf

      \[\leadsto \color{blue}{-9 \cdot \left(t \cdot \left(y \cdot z\right)\right)} \]
    4. Step-by-step derivation
      1. +-lft-identityN/A

        \[\leadsto 0 + \color{blue}{-9 \cdot \left(t \cdot \left(y \cdot z\right)\right)} \]
      2. +-commutativeN/A

        \[\leadsto -9 \cdot \left(t \cdot \left(y \cdot z\right)\right) + \color{blue}{0} \]
      3. *-commutativeN/A

        \[\leadsto \left(t \cdot \left(y \cdot z\right)\right) \cdot -9 + 0 \]
      4. associate-*l*N/A

        \[\leadsto t \cdot \left(\left(y \cdot z\right) \cdot -9\right) + 0 \]
      5. *-commutativeN/A

        \[\leadsto t \cdot \left(-9 \cdot \left(y \cdot z\right)\right) + 0 \]
      6. accelerator-lowering-fma.f64N/A

        \[\leadsto \mathsf{fma.f64}\left(t, \color{blue}{\left(-9 \cdot \left(y \cdot z\right)\right)}, 0\right) \]
      7. +-lft-identityN/A

        \[\leadsto \mathsf{fma.f64}\left(t, \left(0 + \color{blue}{-9 \cdot \left(y \cdot z\right)}\right), 0\right) \]
      8. +-commutativeN/A

        \[\leadsto \mathsf{fma.f64}\left(t, \left(-9 \cdot \left(y \cdot z\right) + \color{blue}{0}\right), 0\right) \]
      9. *-commutativeN/A

        \[\leadsto \mathsf{fma.f64}\left(t, \left(\left(y \cdot z\right) \cdot -9 + 0\right), 0\right) \]
      10. accelerator-lowering-fma.f64N/A

        \[\leadsto \mathsf{fma.f64}\left(t, \mathsf{fma.f64}\left(\left(y \cdot z\right), \color{blue}{-9}, 0\right), 0\right) \]
      11. *-lowering-*.f6450.6%

        \[\leadsto \mathsf{fma.f64}\left(t, \mathsf{fma.f64}\left(\mathsf{*.f64}\left(y, z\right), -9, 0\right), 0\right) \]
    5. Simplified50.6%

      \[\leadsto \color{blue}{\mathsf{fma}\left(t, \mathsf{fma}\left(y \cdot z, -9, 0\right), 0\right)} \]
    6. Step-by-step derivation
      1. +-rgt-identityN/A

        \[\leadsto t \cdot \left(\left(y \cdot z\right) \cdot -9\right) + 0 \]
      2. *-commutativeN/A

        \[\leadsto \left(\left(y \cdot z\right) \cdot -9\right) \cdot t + 0 \]
      3. associate-*r*N/A

        \[\leadsto \left(y \cdot \left(z \cdot -9\right)\right) \cdot t + 0 \]
      4. +-rgt-identityN/A

        \[\leadsto \left(y \cdot \left(z \cdot -9\right)\right) \cdot \color{blue}{t} \]
      5. *-commutativeN/A

        \[\leadsto \left(\left(z \cdot -9\right) \cdot y\right) \cdot t \]
      6. associate-*l*N/A

        \[\leadsto \left(z \cdot -9\right) \cdot \color{blue}{\left(y \cdot t\right)} \]
      7. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\left(z \cdot -9\right), \color{blue}{\left(y \cdot t\right)}\right) \]
      8. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(z, -9\right), \left(\color{blue}{y} \cdot t\right)\right) \]
      9. *-lowering-*.f6450.5%

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(z, -9\right), \mathsf{*.f64}\left(y, \color{blue}{t}\right)\right) \]
    7. Applied egg-rr50.5%

      \[\leadsto \color{blue}{\left(z \cdot -9\right) \cdot \left(y \cdot t\right)} \]
    8. Step-by-step derivation
      1. associate-*r*N/A

        \[\leadsto \left(\left(z \cdot -9\right) \cdot y\right) \cdot \color{blue}{t} \]
      2. *-commutativeN/A

        \[\leadsto \left(\left(-9 \cdot z\right) \cdot y\right) \cdot t \]
      3. associate-*r*N/A

        \[\leadsto \left(-9 \cdot \left(z \cdot y\right)\right) \cdot t \]
      4. *-commutativeN/A

        \[\leadsto \left(-9 \cdot \left(y \cdot z\right)\right) \cdot t \]
      5. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\left(-9 \cdot \left(y \cdot z\right)\right), \color{blue}{t}\right) \]
      6. *-commutativeN/A

        \[\leadsto \mathsf{*.f64}\left(\left(-9 \cdot \left(z \cdot y\right)\right), t\right) \]
      7. associate-*r*N/A

        \[\leadsto \mathsf{*.f64}\left(\left(\left(-9 \cdot z\right) \cdot y\right), t\right) \]
      8. *-commutativeN/A

        \[\leadsto \mathsf{*.f64}\left(\left(\left(z \cdot -9\right) \cdot y\right), t\right) \]
      9. associate-*l*N/A

        \[\leadsto \mathsf{*.f64}\left(\left(z \cdot \left(-9 \cdot y\right)\right), t\right) \]
      10. *-commutativeN/A

        \[\leadsto \mathsf{*.f64}\left(\left(z \cdot \left(y \cdot -9\right)\right), t\right) \]
      11. *-lowering-*.f64N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(z, \left(y \cdot -9\right)\right), t\right) \]
      12. *-lowering-*.f6450.6%

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(z, \mathsf{*.f64}\left(y, -9\right)\right), t\right) \]
    9. Applied egg-rr50.6%

      \[\leadsto \color{blue}{\left(z \cdot \left(y \cdot -9\right)\right) \cdot t} \]
  3. Recombined 3 regimes into one program.
  4. Final simplification62.3%

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \leq -1.65 \cdot 10^{+41}:\\ \;\;\;\;\left(z \cdot -9\right) \cdot \left(y \cdot t\right)\\ \mathbf{elif}\;z \leq 3.9 \cdot 10^{-35}:\\ \;\;\;\;\mathsf{fma}\left(27, a \cdot b, x \cdot 2\right)\\ \mathbf{else}:\\ \;\;\;\;t \cdot \left(z \cdot \left(y \cdot -9\right)\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 14: 31.0% accurate, 6.2× speedup?

\[\begin{array}{l} [x, y, z, t, a, b] = \mathsf{sort}([x, y, z, t, a, b])\\\\ [x, y, z, t, a, b] = \mathsf{sort}([x, y, z, t, a, b])\\ \\ x \cdot 2 \end{array} \]
NOTE: x, y, z, t, a, and b should be sorted in increasing order before calling this function.
NOTE: x, y, z, t, a, and b should be sorted in increasing order before calling this function.
(FPCore (x y z t a b) :precision binary64 (* x 2.0))
assert(x < y && y < z && z < t && t < a && a < b);
assert(x < y && y < z && z < t && t < a && a < b);
double code(double x, double y, double z, double t, double a, double b) {
	return x * 2.0;
}
NOTE: x, y, z, t, a, and b should be sorted in increasing order before calling this function.
NOTE: x, y, z, t, a, and b should be sorted in increasing order before calling this function.
real(8) function code(x, y, z, t, a, b)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8), intent (in) :: t
    real(8), intent (in) :: a
    real(8), intent (in) :: b
    code = x * 2.0d0
end function
assert x < y && y < z && z < t && t < a && a < b;
assert x < y && y < z && z < t && t < a && a < b;
public static double code(double x, double y, double z, double t, double a, double b) {
	return x * 2.0;
}
[x, y, z, t, a, b] = sort([x, y, z, t, a, b])
[x, y, z, t, a, b] = sort([x, y, z, t, a, b])
def code(x, y, z, t, a, b):
	return x * 2.0
x, y, z, t, a, b = sort([x, y, z, t, a, b])
x, y, z, t, a, b = sort([x, y, z, t, a, b])
function code(x, y, z, t, a, b)
	return Float64(x * 2.0)
end
x, y, z, t, a, b = num2cell(sort([x, y, z, t, a, b])){:}
x, y, z, t, a, b = num2cell(sort([x, y, z, t, a, b])){:}
function tmp = code(x, y, z, t, a, b)
	tmp = x * 2.0;
end
NOTE: x, y, z, t, a, and b should be sorted in increasing order before calling this function.
NOTE: x, y, z, t, a, and b should be sorted in increasing order before calling this function.
code[x_, y_, z_, t_, a_, b_] := N[(x * 2.0), $MachinePrecision]
\begin{array}{l}
[x, y, z, t, a, b] = \mathsf{sort}([x, y, z, t, a, b])\\\\
[x, y, z, t, a, b] = \mathsf{sort}([x, y, z, t, a, b])\\
\\
x \cdot 2
\end{array}
Derivation
  1. Initial program 96.2%

    \[\left(x \cdot 2 - \left(\left(y \cdot 9\right) \cdot z\right) \cdot t\right) + \left(a \cdot 27\right) \cdot b \]
  2. Add Preprocessing
  3. Taylor expanded in x around inf

    \[\leadsto \color{blue}{2 \cdot x} \]
  4. Step-by-step derivation
    1. +-rgt-identityN/A

      \[\leadsto 2 \cdot x + \color{blue}{0} \]
    2. accelerator-lowering-fma.f6435.0%

      \[\leadsto \mathsf{fma.f64}\left(2, \color{blue}{x}, 0\right) \]
  5. Simplified35.0%

    \[\leadsto \color{blue}{\mathsf{fma}\left(2, x, 0\right)} \]
  6. Step-by-step derivation
    1. +-rgt-identityN/A

      \[\leadsto 2 \cdot \color{blue}{x} \]
    2. *-commutativeN/A

      \[\leadsto x \cdot \color{blue}{2} \]
    3. *-lowering-*.f6435.0%

      \[\leadsto \mathsf{*.f64}\left(x, \color{blue}{2}\right) \]
  7. Applied egg-rr35.0%

    \[\leadsto \color{blue}{x \cdot 2} \]
  8. Add Preprocessing

Developer Target 1: 95.0% accurate, 0.9× speedup?

\[\begin{array}{l} \\ \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} \end{array} \]
(FPCore (x y z t a b)
 :precision binary64
 (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))))
double code(double x, double y, double z, double t, double a, double b) {
	double tmp;
	if (y < 7.590524218811189e-161) {
		tmp = ((x * 2.0) - (((y * 9.0) * z) * t)) + (a * (27.0 * b));
	} else {
		tmp = ((x * 2.0) - (9.0 * (y * (t * z)))) + ((a * 27.0) * b);
	}
	return tmp;
}
real(8) function code(x, y, z, t, a, b)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8), intent (in) :: t
    real(8), intent (in) :: a
    real(8), intent (in) :: b
    real(8) :: tmp
    if (y < 7.590524218811189d-161) then
        tmp = ((x * 2.0d0) - (((y * 9.0d0) * z) * t)) + (a * (27.0d0 * b))
    else
        tmp = ((x * 2.0d0) - (9.0d0 * (y * (t * z)))) + ((a * 27.0d0) * b)
    end if
    code = tmp
end function
public static double code(double x, double y, double z, double t, double a, double b) {
	double tmp;
	if (y < 7.590524218811189e-161) {
		tmp = ((x * 2.0) - (((y * 9.0) * z) * t)) + (a * (27.0 * b));
	} else {
		tmp = ((x * 2.0) - (9.0 * (y * (t * z)))) + ((a * 27.0) * b);
	}
	return tmp;
}
def code(x, y, z, t, a, b):
	tmp = 0
	if y < 7.590524218811189e-161:
		tmp = ((x * 2.0) - (((y * 9.0) * z) * t)) + (a * (27.0 * b))
	else:
		tmp = ((x * 2.0) - (9.0 * (y * (t * z)))) + ((a * 27.0) * b)
	return tmp
function code(x, y, z, t, a, b)
	tmp = 0.0
	if (y < 7.590524218811189e-161)
		tmp = Float64(Float64(Float64(x * 2.0) - Float64(Float64(Float64(y * 9.0) * z) * t)) + Float64(a * Float64(27.0 * b)));
	else
		tmp = Float64(Float64(Float64(x * 2.0) - Float64(9.0 * Float64(y * Float64(t * z)))) + Float64(Float64(a * 27.0) * b));
	end
	return tmp
end
function tmp_2 = code(x, y, z, t, a, b)
	tmp = 0.0;
	if (y < 7.590524218811189e-161)
		tmp = ((x * 2.0) - (((y * 9.0) * z) * t)) + (a * (27.0 * b));
	else
		tmp = ((x * 2.0) - (9.0 * (y * (t * z)))) + ((a * 27.0) * b);
	end
	tmp_2 = tmp;
end
code[x_, y_, z_, t_, a_, b_] := If[Less[y, 7.590524218811189e-161], N[(N[(N[(x * 2.0), $MachinePrecision] - N[(N[(N[(y * 9.0), $MachinePrecision] * z), $MachinePrecision] * t), $MachinePrecision]), $MachinePrecision] + N[(a * N[(27.0 * b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[(x * 2.0), $MachinePrecision] - N[(9.0 * N[(y * N[(t * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(N[(a * 27.0), $MachinePrecision] * b), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\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}
\end{array}

Reproduce

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

  :alt
  (! :herbie-platform default (if (< y 7590524218811189/100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000) (+ (- (* x 2) (* (* (* y 9) z) t)) (* a (* 27 b))) (+ (- (* x 2) (* 9 (* y (* t z)))) (* (* a 27) b))))

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