Linear.V4:$cdot from linear-1.19.1.3, C

Percentage Accurate: 96.2% → 99.1%
Time: 11.3s
Alternatives: 14
Speedup: 1.3×

Specification

?
\[\begin{array}{l} \\ \left(\left(x \cdot y + z \cdot t\right) + a \cdot b\right) + c \cdot i \end{array} \]
(FPCore (x y z t a b c i)
 :precision binary64
 (+ (+ (+ (* x y) (* z t)) (* a b)) (* c i)))
double code(double x, double y, double z, double t, double a, double b, double c, double i) {
	return (((x * y) + (z * t)) + (a * b)) + (c * i);
}
real(8) function code(x, y, z, t, a, b, c, i)
    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), intent (in) :: c
    real(8), intent (in) :: i
    code = (((x * y) + (z * t)) + (a * b)) + (c * i)
end function
public static double code(double x, double y, double z, double t, double a, double b, double c, double i) {
	return (((x * y) + (z * t)) + (a * b)) + (c * i);
}
def code(x, y, z, t, a, b, c, i):
	return (((x * y) + (z * t)) + (a * b)) + (c * i)
function code(x, y, z, t, a, b, c, i)
	return Float64(Float64(Float64(Float64(x * y) + Float64(z * t)) + Float64(a * b)) + Float64(c * i))
end
function tmp = code(x, y, z, t, a, b, c, i)
	tmp = (((x * y) + (z * t)) + (a * b)) + (c * i);
end
code[x_, y_, z_, t_, a_, b_, c_, i_] := N[(N[(N[(N[(x * y), $MachinePrecision] + N[(z * t), $MachinePrecision]), $MachinePrecision] + N[(a * b), $MachinePrecision]), $MachinePrecision] + N[(c * i), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
\left(\left(x \cdot y + z \cdot t\right) + a \cdot b\right) + c \cdot i
\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: 96.2% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \left(\left(x \cdot y + z \cdot t\right) + a \cdot b\right) + c \cdot i \end{array} \]
(FPCore (x y z t a b c i)
 :precision binary64
 (+ (+ (+ (* x y) (* z t)) (* a b)) (* c i)))
double code(double x, double y, double z, double t, double a, double b, double c, double i) {
	return (((x * y) + (z * t)) + (a * b)) + (c * i);
}
real(8) function code(x, y, z, t, a, b, c, i)
    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), intent (in) :: c
    real(8), intent (in) :: i
    code = (((x * y) + (z * t)) + (a * b)) + (c * i)
end function
public static double code(double x, double y, double z, double t, double a, double b, double c, double i) {
	return (((x * y) + (z * t)) + (a * b)) + (c * i);
}
def code(x, y, z, t, a, b, c, i):
	return (((x * y) + (z * t)) + (a * b)) + (c * i)
function code(x, y, z, t, a, b, c, i)
	return Float64(Float64(Float64(Float64(x * y) + Float64(z * t)) + Float64(a * b)) + Float64(c * i))
end
function tmp = code(x, y, z, t, a, b, c, i)
	tmp = (((x * y) + (z * t)) + (a * b)) + (c * i);
end
code[x_, y_, z_, t_, a_, b_, c_, i_] := N[(N[(N[(N[(x * y), $MachinePrecision] + N[(z * t), $MachinePrecision]), $MachinePrecision] + N[(a * b), $MachinePrecision]), $MachinePrecision] + N[(c * i), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
\left(\left(x \cdot y + z \cdot t\right) + a \cdot b\right) + c \cdot i
\end{array}

Alternative 1: 99.1% accurate, 0.3× speedup?

\[\begin{array}{l} [x, y, z, t, a, b, c, i] = \mathsf{sort}([x, y, z, t, a, b, c, i])\\ \\ \begin{array}{l} t_1 := \left(\left(x \cdot y + z \cdot t\right) + a \cdot b\right) + c \cdot i\\ \mathbf{if}\;t\_1 \leq \infty:\\ \;\;\;\;t\_1\\ \mathbf{else}:\\ \;\;\;\;c \cdot \mathsf{fma}\left(a, \frac{b}{c}, \mathsf{fma}\left(x, \frac{y}{c}, \mathsf{fma}\left(t, \frac{z}{c}, i\right)\right)\right)\\ \end{array} \end{array} \]
NOTE: x, y, z, t, a, b, c, and i should be sorted in increasing order before calling this function.
(FPCore (x y z t a b c i)
 :precision binary64
 (let* ((t_1 (+ (+ (+ (* x y) (* z t)) (* a b)) (* c i))))
   (if (<= t_1 INFINITY)
     t_1
     (* c (fma a (/ b c) (fma x (/ y c) (fma t (/ z c) i)))))))
assert(x < y && y < z && z < t && t < a && a < b && b < c && c < i);
double code(double x, double y, double z, double t, double a, double b, double c, double i) {
	double t_1 = (((x * y) + (z * t)) + (a * b)) + (c * i);
	double tmp;
	if (t_1 <= ((double) INFINITY)) {
		tmp = t_1;
	} else {
		tmp = c * fma(a, (b / c), fma(x, (y / c), fma(t, (z / c), i)));
	}
	return tmp;
}
x, y, z, t, a, b, c, i = sort([x, y, z, t, a, b, c, i])
function code(x, y, z, t, a, b, c, i)
	t_1 = Float64(Float64(Float64(Float64(x * y) + Float64(z * t)) + Float64(a * b)) + Float64(c * i))
	tmp = 0.0
	if (t_1 <= Inf)
		tmp = t_1;
	else
		tmp = Float64(c * fma(a, Float64(b / c), fma(x, Float64(y / c), fma(t, Float64(z / c), i))));
	end
	return tmp
end
NOTE: x, y, z, t, a, b, c, and i should be sorted in increasing order before calling this function.
code[x_, y_, z_, t_, a_, b_, c_, i_] := Block[{t$95$1 = N[(N[(N[(N[(x * y), $MachinePrecision] + N[(z * t), $MachinePrecision]), $MachinePrecision] + N[(a * b), $MachinePrecision]), $MachinePrecision] + N[(c * i), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$1, Infinity], t$95$1, N[(c * N[(a * N[(b / c), $MachinePrecision] + N[(x * N[(y / c), $MachinePrecision] + N[(t * N[(z / c), $MachinePrecision] + i), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
[x, y, z, t, a, b, c, i] = \mathsf{sort}([x, y, z, t, a, b, c, i])\\
\\
\begin{array}{l}
t_1 := \left(\left(x \cdot y + z \cdot t\right) + a \cdot b\right) + c \cdot i\\
\mathbf{if}\;t\_1 \leq \infty:\\
\;\;\;\;t\_1\\

\mathbf{else}:\\
\;\;\;\;c \cdot \mathsf{fma}\left(a, \frac{b}{c}, \mathsf{fma}\left(x, \frac{y}{c}, \mathsf{fma}\left(t, \frac{z}{c}, i\right)\right)\right)\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (+.f64 (+.f64 (+.f64 (*.f64 x y) (*.f64 z t)) (*.f64 a b)) (*.f64 c i)) < +inf.0

    1. Initial program 100.0%

      \[\left(\left(x \cdot y + z \cdot t\right) + a \cdot b\right) + c \cdot i \]
    2. Add Preprocessing

    if +inf.0 < (+.f64 (+.f64 (+.f64 (*.f64 x y) (*.f64 z t)) (*.f64 a b)) (*.f64 c i))

    1. Initial program 0.0%

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

      \[\leadsto \color{blue}{c \cdot \left(i + \left(\frac{a \cdot b}{c} + \left(\frac{t \cdot z}{c} + \frac{x \cdot y}{c}\right)\right)\right)} \]
    4. Step-by-step derivation
      1. *-lowering-*.f64N/A

        \[\leadsto \color{blue}{c \cdot \left(i + \left(\frac{a \cdot b}{c} + \left(\frac{t \cdot z}{c} + \frac{x \cdot y}{c}\right)\right)\right)} \]
      2. +-commutativeN/A

        \[\leadsto c \cdot \color{blue}{\left(\left(\frac{a \cdot b}{c} + \left(\frac{t \cdot z}{c} + \frac{x \cdot y}{c}\right)\right) + i\right)} \]
      3. associate-+l+N/A

        \[\leadsto c \cdot \color{blue}{\left(\frac{a \cdot b}{c} + \left(\left(\frac{t \cdot z}{c} + \frac{x \cdot y}{c}\right) + i\right)\right)} \]
      4. associate-/l*N/A

        \[\leadsto c \cdot \left(\color{blue}{a \cdot \frac{b}{c}} + \left(\left(\frac{t \cdot z}{c} + \frac{x \cdot y}{c}\right) + i\right)\right) \]
      5. accelerator-lowering-fma.f64N/A

        \[\leadsto c \cdot \color{blue}{\mathsf{fma}\left(a, \frac{b}{c}, \left(\frac{t \cdot z}{c} + \frac{x \cdot y}{c}\right) + i\right)} \]
      6. /-lowering-/.f64N/A

        \[\leadsto c \cdot \mathsf{fma}\left(a, \color{blue}{\frac{b}{c}}, \left(\frac{t \cdot z}{c} + \frac{x \cdot y}{c}\right) + i\right) \]
      7. +-commutativeN/A

        \[\leadsto c \cdot \mathsf{fma}\left(a, \frac{b}{c}, \color{blue}{\left(\frac{x \cdot y}{c} + \frac{t \cdot z}{c}\right)} + i\right) \]
      8. associate-+l+N/A

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

        \[\leadsto c \cdot \mathsf{fma}\left(a, \frac{b}{c}, \color{blue}{x \cdot \frac{y}{c}} + \left(\frac{t \cdot z}{c} + i\right)\right) \]
      10. accelerator-lowering-fma.f64N/A

        \[\leadsto c \cdot \mathsf{fma}\left(a, \frac{b}{c}, \color{blue}{\mathsf{fma}\left(x, \frac{y}{c}, \frac{t \cdot z}{c} + i\right)}\right) \]
      11. /-lowering-/.f64N/A

        \[\leadsto c \cdot \mathsf{fma}\left(a, \frac{b}{c}, \mathsf{fma}\left(x, \color{blue}{\frac{y}{c}}, \frac{t \cdot z}{c} + i\right)\right) \]
      12. associate-/l*N/A

        \[\leadsto c \cdot \mathsf{fma}\left(a, \frac{b}{c}, \mathsf{fma}\left(x, \frac{y}{c}, \color{blue}{t \cdot \frac{z}{c}} + i\right)\right) \]
      13. accelerator-lowering-fma.f64N/A

        \[\leadsto c \cdot \mathsf{fma}\left(a, \frac{b}{c}, \mathsf{fma}\left(x, \frac{y}{c}, \color{blue}{\mathsf{fma}\left(t, \frac{z}{c}, i\right)}\right)\right) \]
      14. /-lowering-/.f6488.9

        \[\leadsto c \cdot \mathsf{fma}\left(a, \frac{b}{c}, \mathsf{fma}\left(x, \frac{y}{c}, \mathsf{fma}\left(t, \color{blue}{\frac{z}{c}}, i\right)\right)\right) \]
    5. Simplified88.9%

      \[\leadsto \color{blue}{c \cdot \mathsf{fma}\left(a, \frac{b}{c}, \mathsf{fma}\left(x, \frac{y}{c}, \mathsf{fma}\left(t, \frac{z}{c}, i\right)\right)\right)} \]
  3. Recombined 2 regimes into one program.
  4. Add Preprocessing

Alternative 2: 66.1% accurate, 0.4× speedup?

\[\begin{array}{l} [x, y, z, t, a, b, c, i] = \mathsf{sort}([x, y, z, t, a, b, c, i])\\ \\ \begin{array}{l} \mathbf{if}\;c \cdot i \leq -5 \cdot 10^{+140}:\\ \;\;\;\;\mathsf{fma}\left(i, c, a \cdot b\right)\\ \mathbf{elif}\;c \cdot i \leq -1 \cdot 10^{+81}:\\ \;\;\;\;\mathsf{fma}\left(c, i, z \cdot t\right)\\ \mathbf{elif}\;c \cdot i \leq -2 \cdot 10^{-18}:\\ \;\;\;\;\mathsf{fma}\left(y, x, c \cdot i\right)\\ \mathbf{elif}\;c \cdot i \leq -1.2 \cdot 10^{-295}:\\ \;\;\;\;\mathsf{fma}\left(z, t, a \cdot b\right)\\ \mathbf{elif}\;c \cdot i \leq 2 \cdot 10^{+98}:\\ \;\;\;\;\mathsf{fma}\left(z, t, x \cdot y\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(z, t, c \cdot i\right)\\ \end{array} \end{array} \]
NOTE: x, y, z, t, a, b, c, and i should be sorted in increasing order before calling this function.
(FPCore (x y z t a b c i)
 :precision binary64
 (if (<= (* c i) -5e+140)
   (fma i c (* a b))
   (if (<= (* c i) -1e+81)
     (fma c i (* z t))
     (if (<= (* c i) -2e-18)
       (fma y x (* c i))
       (if (<= (* c i) -1.2e-295)
         (fma z t (* a b))
         (if (<= (* c i) 2e+98) (fma z t (* x y)) (fma z t (* c i))))))))
assert(x < y && y < z && z < t && t < a && a < b && b < c && c < i);
double code(double x, double y, double z, double t, double a, double b, double c, double i) {
	double tmp;
	if ((c * i) <= -5e+140) {
		tmp = fma(i, c, (a * b));
	} else if ((c * i) <= -1e+81) {
		tmp = fma(c, i, (z * t));
	} else if ((c * i) <= -2e-18) {
		tmp = fma(y, x, (c * i));
	} else if ((c * i) <= -1.2e-295) {
		tmp = fma(z, t, (a * b));
	} else if ((c * i) <= 2e+98) {
		tmp = fma(z, t, (x * y));
	} else {
		tmp = fma(z, t, (c * i));
	}
	return tmp;
}
x, y, z, t, a, b, c, i = sort([x, y, z, t, a, b, c, i])
function code(x, y, z, t, a, b, c, i)
	tmp = 0.0
	if (Float64(c * i) <= -5e+140)
		tmp = fma(i, c, Float64(a * b));
	elseif (Float64(c * i) <= -1e+81)
		tmp = fma(c, i, Float64(z * t));
	elseif (Float64(c * i) <= -2e-18)
		tmp = fma(y, x, Float64(c * i));
	elseif (Float64(c * i) <= -1.2e-295)
		tmp = fma(z, t, Float64(a * b));
	elseif (Float64(c * i) <= 2e+98)
		tmp = fma(z, t, Float64(x * y));
	else
		tmp = fma(z, t, Float64(c * i));
	end
	return tmp
end
NOTE: x, y, z, t, a, b, c, and i should be sorted in increasing order before calling this function.
code[x_, y_, z_, t_, a_, b_, c_, i_] := If[LessEqual[N[(c * i), $MachinePrecision], -5e+140], N[(i * c + N[(a * b), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(c * i), $MachinePrecision], -1e+81], N[(c * i + N[(z * t), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(c * i), $MachinePrecision], -2e-18], N[(y * x + N[(c * i), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(c * i), $MachinePrecision], -1.2e-295], N[(z * t + N[(a * b), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(c * i), $MachinePrecision], 2e+98], N[(z * t + N[(x * y), $MachinePrecision]), $MachinePrecision], N[(z * t + N[(c * i), $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}
[x, y, z, t, a, b, c, i] = \mathsf{sort}([x, y, z, t, a, b, c, i])\\
\\
\begin{array}{l}
\mathbf{if}\;c \cdot i \leq -5 \cdot 10^{+140}:\\
\;\;\;\;\mathsf{fma}\left(i, c, a \cdot b\right)\\

\mathbf{elif}\;c \cdot i \leq -1 \cdot 10^{+81}:\\
\;\;\;\;\mathsf{fma}\left(c, i, z \cdot t\right)\\

\mathbf{elif}\;c \cdot i \leq -2 \cdot 10^{-18}:\\
\;\;\;\;\mathsf{fma}\left(y, x, c \cdot i\right)\\

\mathbf{elif}\;c \cdot i \leq -1.2 \cdot 10^{-295}:\\
\;\;\;\;\mathsf{fma}\left(z, t, a \cdot b\right)\\

\mathbf{elif}\;c \cdot i \leq 2 \cdot 10^{+98}:\\
\;\;\;\;\mathsf{fma}\left(z, t, x \cdot y\right)\\

\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(z, t, c \cdot i\right)\\


\end{array}
\end{array}
Derivation
  1. Split input into 6 regimes
  2. if (*.f64 c i) < -5.00000000000000008e140

    1. Initial program 86.4%

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

      \[\leadsto \color{blue}{a \cdot b} + c \cdot i \]
    4. Step-by-step derivation
      1. *-lowering-*.f6488.9

        \[\leadsto \color{blue}{a \cdot b} + c \cdot i \]
    5. Simplified88.9%

      \[\leadsto \color{blue}{a \cdot b} + c \cdot i \]
    6. Step-by-step derivation
      1. +-commutativeN/A

        \[\leadsto \color{blue}{c \cdot i + a \cdot b} \]
      2. *-commutativeN/A

        \[\leadsto \color{blue}{i \cdot c} + a \cdot b \]
      3. accelerator-lowering-fma.f64N/A

        \[\leadsto \color{blue}{\mathsf{fma}\left(i, c, a \cdot b\right)} \]
      4. *-lowering-*.f6491.2

        \[\leadsto \mathsf{fma}\left(i, c, \color{blue}{a \cdot b}\right) \]
    7. Applied egg-rr91.2%

      \[\leadsto \color{blue}{\mathsf{fma}\left(i, c, a \cdot b\right)} \]

    if -5.00000000000000008e140 < (*.f64 c i) < -9.99999999999999921e80

    1. Initial program 86.6%

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

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

        \[\leadsto \color{blue}{\left(c \cdot i + t \cdot z\right) + a \cdot b} \]
      2. associate-+l+N/A

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

        \[\leadsto c \cdot i + \color{blue}{\left(a \cdot b + t \cdot z\right)} \]
      4. accelerator-lowering-fma.f64N/A

        \[\leadsto \color{blue}{\mathsf{fma}\left(c, i, a \cdot b + t \cdot z\right)} \]
      5. accelerator-lowering-fma.f64N/A

        \[\leadsto \mathsf{fma}\left(c, i, \color{blue}{\mathsf{fma}\left(a, b, t \cdot z\right)}\right) \]
      6. *-lowering-*.f6493.2

        \[\leadsto \mathsf{fma}\left(c, i, \mathsf{fma}\left(a, b, \color{blue}{t \cdot z}\right)\right) \]
    5. Simplified93.2%

      \[\leadsto \color{blue}{\mathsf{fma}\left(c, i, \mathsf{fma}\left(a, b, t \cdot z\right)\right)} \]
    6. Taylor expanded in a around 0

      \[\leadsto \mathsf{fma}\left(c, i, \color{blue}{t \cdot z}\right) \]
    7. Step-by-step derivation
      1. *-lowering-*.f6480.1

        \[\leadsto \mathsf{fma}\left(c, i, \color{blue}{t \cdot z}\right) \]
    8. Simplified80.1%

      \[\leadsto \mathsf{fma}\left(c, i, \color{blue}{t \cdot z}\right) \]

    if -9.99999999999999921e80 < (*.f64 c i) < -2.0000000000000001e-18

    1. Initial program 93.3%

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

      \[\leadsto \color{blue}{x \cdot y} + c \cdot i \]
    4. Step-by-step derivation
      1. *-lowering-*.f6486.8

        \[\leadsto \color{blue}{x \cdot y} + c \cdot i \]
    5. Simplified86.8%

      \[\leadsto \color{blue}{x \cdot y} + c \cdot i \]
    6. Step-by-step derivation
      1. *-commutativeN/A

        \[\leadsto \color{blue}{y \cdot x} + c \cdot i \]
      2. accelerator-lowering-fma.f64N/A

        \[\leadsto \color{blue}{\mathsf{fma}\left(y, x, c \cdot i\right)} \]
      3. *-lowering-*.f6486.8

        \[\leadsto \mathsf{fma}\left(y, x, \color{blue}{c \cdot i}\right) \]
    7. Applied egg-rr86.8%

      \[\leadsto \color{blue}{\mathsf{fma}\left(y, x, c \cdot i\right)} \]

    if -2.0000000000000001e-18 < (*.f64 c i) < -1.1999999999999999e-295

    1. Initial program 97.7%

      \[\left(\left(x \cdot y + z \cdot t\right) + a \cdot b\right) + c \cdot i \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. associate-+l+N/A

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

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

        \[\leadsto \color{blue}{z \cdot t + \left(x \cdot y + \left(a \cdot b + c \cdot i\right)\right)} \]
      4. accelerator-lowering-fma.f64N/A

        \[\leadsto \color{blue}{\mathsf{fma}\left(z, t, x \cdot y + \left(a \cdot b + c \cdot i\right)\right)} \]
      5. accelerator-lowering-fma.f64N/A

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

        \[\leadsto \mathsf{fma}\left(z, t, \mathsf{fma}\left(x, y, \color{blue}{\mathsf{fma}\left(a, b, c \cdot i\right)}\right)\right) \]
      7. *-lowering-*.f64100.0

        \[\leadsto \mathsf{fma}\left(z, t, \mathsf{fma}\left(x, y, \mathsf{fma}\left(a, b, \color{blue}{c \cdot i}\right)\right)\right) \]
    4. Applied egg-rr100.0%

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

      \[\leadsto \mathsf{fma}\left(z, t, \color{blue}{a \cdot b}\right) \]
    6. Step-by-step derivation
      1. *-lowering-*.f6485.3

        \[\leadsto \mathsf{fma}\left(z, t, \color{blue}{a \cdot b}\right) \]
    7. Simplified85.3%

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

    if -1.1999999999999999e-295 < (*.f64 c i) < 2e98

    1. Initial program 100.0%

      \[\left(\left(x \cdot y + z \cdot t\right) + a \cdot b\right) + c \cdot i \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. associate-+l+N/A

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

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

        \[\leadsto \color{blue}{z \cdot t + \left(x \cdot y + \left(a \cdot b + c \cdot i\right)\right)} \]
      4. accelerator-lowering-fma.f64N/A

        \[\leadsto \color{blue}{\mathsf{fma}\left(z, t, x \cdot y + \left(a \cdot b + c \cdot i\right)\right)} \]
      5. accelerator-lowering-fma.f64N/A

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

        \[\leadsto \mathsf{fma}\left(z, t, \mathsf{fma}\left(x, y, \color{blue}{\mathsf{fma}\left(a, b, c \cdot i\right)}\right)\right) \]
      7. *-lowering-*.f64100.0

        \[\leadsto \mathsf{fma}\left(z, t, \mathsf{fma}\left(x, y, \mathsf{fma}\left(a, b, \color{blue}{c \cdot i}\right)\right)\right) \]
    4. Applied egg-rr100.0%

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

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

        \[\leadsto \mathsf{fma}\left(z, t, \color{blue}{x \cdot y}\right) \]
    7. Simplified73.9%

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

    if 2e98 < (*.f64 c i)

    1. Initial program 86.2%

      \[\left(\left(x \cdot y + z \cdot t\right) + a \cdot b\right) + c \cdot i \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. associate-+l+N/A

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

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

        \[\leadsto \color{blue}{z \cdot t + \left(x \cdot y + \left(a \cdot b + c \cdot i\right)\right)} \]
      4. accelerator-lowering-fma.f64N/A

        \[\leadsto \color{blue}{\mathsf{fma}\left(z, t, x \cdot y + \left(a \cdot b + c \cdot i\right)\right)} \]
      5. accelerator-lowering-fma.f64N/A

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

        \[\leadsto \mathsf{fma}\left(z, t, \mathsf{fma}\left(x, y, \color{blue}{\mathsf{fma}\left(a, b, c \cdot i\right)}\right)\right) \]
      7. *-lowering-*.f6493.1

        \[\leadsto \mathsf{fma}\left(z, t, \mathsf{fma}\left(x, y, \mathsf{fma}\left(a, b, \color{blue}{c \cdot i}\right)\right)\right) \]
    4. Applied egg-rr93.1%

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

      \[\leadsto \mathsf{fma}\left(z, t, \color{blue}{c \cdot i}\right) \]
    6. Step-by-step derivation
      1. *-lowering-*.f6478.0

        \[\leadsto \mathsf{fma}\left(z, t, \color{blue}{c \cdot i}\right) \]
    7. Simplified78.0%

      \[\leadsto \mathsf{fma}\left(z, t, \color{blue}{c \cdot i}\right) \]
  3. Recombined 6 regimes into one program.
  4. Final simplification80.9%

    \[\leadsto \begin{array}{l} \mathbf{if}\;c \cdot i \leq -5 \cdot 10^{+140}:\\ \;\;\;\;\mathsf{fma}\left(i, c, a \cdot b\right)\\ \mathbf{elif}\;c \cdot i \leq -1 \cdot 10^{+81}:\\ \;\;\;\;\mathsf{fma}\left(c, i, z \cdot t\right)\\ \mathbf{elif}\;c \cdot i \leq -2 \cdot 10^{-18}:\\ \;\;\;\;\mathsf{fma}\left(y, x, c \cdot i\right)\\ \mathbf{elif}\;c \cdot i \leq -1.2 \cdot 10^{-295}:\\ \;\;\;\;\mathsf{fma}\left(z, t, a \cdot b\right)\\ \mathbf{elif}\;c \cdot i \leq 2 \cdot 10^{+98}:\\ \;\;\;\;\mathsf{fma}\left(z, t, x \cdot y\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(z, t, c \cdot i\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 3: 89.5% accurate, 0.7× speedup?

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

\mathbf{elif}\;c \cdot i \leq 2 \cdot 10^{+98}:\\
\;\;\;\;\mathsf{fma}\left(z, t, \mathsf{fma}\left(a, b, x \cdot y\right)\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (*.f64 c i) < -2.00000000000000012e63 or 2e98 < (*.f64 c i)

    1. Initial program 86.7%

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

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

        \[\leadsto \color{blue}{\left(c \cdot i + t \cdot z\right) + a \cdot b} \]
      2. associate-+l+N/A

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

        \[\leadsto c \cdot i + \color{blue}{\left(a \cdot b + t \cdot z\right)} \]
      4. accelerator-lowering-fma.f64N/A

        \[\leadsto \color{blue}{\mathsf{fma}\left(c, i, a \cdot b + t \cdot z\right)} \]
      5. accelerator-lowering-fma.f64N/A

        \[\leadsto \mathsf{fma}\left(c, i, \color{blue}{\mathsf{fma}\left(a, b, t \cdot z\right)}\right) \]
      6. *-lowering-*.f6490.7

        \[\leadsto \mathsf{fma}\left(c, i, \mathsf{fma}\left(a, b, \color{blue}{t \cdot z}\right)\right) \]
    5. Simplified90.7%

      \[\leadsto \color{blue}{\mathsf{fma}\left(c, i, \mathsf{fma}\left(a, b, t \cdot z\right)\right)} \]

    if -2.00000000000000012e63 < (*.f64 c i) < 2e98

    1. Initial program 98.5%

      \[\left(\left(x \cdot y + z \cdot t\right) + a \cdot b\right) + c \cdot i \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. associate-+l+N/A

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

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

        \[\leadsto \color{blue}{z \cdot t + \left(x \cdot y + \left(a \cdot b + c \cdot i\right)\right)} \]
      4. accelerator-lowering-fma.f64N/A

        \[\leadsto \color{blue}{\mathsf{fma}\left(z, t, x \cdot y + \left(a \cdot b + c \cdot i\right)\right)} \]
      5. accelerator-lowering-fma.f64N/A

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

        \[\leadsto \mathsf{fma}\left(z, t, \mathsf{fma}\left(x, y, \color{blue}{\mathsf{fma}\left(a, b, c \cdot i\right)}\right)\right) \]
      7. *-lowering-*.f6499.2

        \[\leadsto \mathsf{fma}\left(z, t, \mathsf{fma}\left(x, y, \mathsf{fma}\left(a, b, \color{blue}{c \cdot i}\right)\right)\right) \]
    4. Applied egg-rr99.2%

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

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

        \[\leadsto \mathsf{fma}\left(z, t, \color{blue}{\mathsf{fma}\left(a, b, x \cdot y\right)}\right) \]
      2. *-lowering-*.f6493.7

        \[\leadsto \mathsf{fma}\left(z, t, \mathsf{fma}\left(a, b, \color{blue}{x \cdot y}\right)\right) \]
    7. Simplified93.7%

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

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

Alternative 4: 89.6% accurate, 0.7× speedup?

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

\mathbf{elif}\;c \cdot i \leq 2 \cdot 10^{+98}:\\
\;\;\;\;\mathsf{fma}\left(x, y, t\_1\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (*.f64 c i) < -2.00000000000000012e63 or 2e98 < (*.f64 c i)

    1. Initial program 86.7%

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

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

        \[\leadsto \color{blue}{\left(c \cdot i + t \cdot z\right) + a \cdot b} \]
      2. associate-+l+N/A

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

        \[\leadsto c \cdot i + \color{blue}{\left(a \cdot b + t \cdot z\right)} \]
      4. accelerator-lowering-fma.f64N/A

        \[\leadsto \color{blue}{\mathsf{fma}\left(c, i, a \cdot b + t \cdot z\right)} \]
      5. accelerator-lowering-fma.f64N/A

        \[\leadsto \mathsf{fma}\left(c, i, \color{blue}{\mathsf{fma}\left(a, b, t \cdot z\right)}\right) \]
      6. *-lowering-*.f6490.7

        \[\leadsto \mathsf{fma}\left(c, i, \mathsf{fma}\left(a, b, \color{blue}{t \cdot z}\right)\right) \]
    5. Simplified90.7%

      \[\leadsto \color{blue}{\mathsf{fma}\left(c, i, \mathsf{fma}\left(a, b, t \cdot z\right)\right)} \]

    if -2.00000000000000012e63 < (*.f64 c i) < 2e98

    1. Initial program 98.5%

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

      \[\leadsto \color{blue}{a \cdot b + \left(t \cdot z + x \cdot y\right)} \]
    4. Step-by-step derivation
      1. associate-+r+N/A

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

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

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

        \[\leadsto \mathsf{fma}\left(x, y, \color{blue}{\mathsf{fma}\left(a, b, t \cdot z\right)}\right) \]
      5. *-lowering-*.f6493.7

        \[\leadsto \mathsf{fma}\left(x, y, \mathsf{fma}\left(a, b, \color{blue}{t \cdot z}\right)\right) \]
    5. Simplified93.7%

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

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

Alternative 5: 88.7% accurate, 0.7× speedup?

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

\mathbf{elif}\;z \cdot t \leq 5 \cdot 10^{+104}:\\
\;\;\;\;\mathsf{fma}\left(a, b, \mathsf{fma}\left(c, i, x \cdot y\right)\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (*.f64 z t) < -1.9999999999999999e-60 or 4.9999999999999997e104 < (*.f64 z t)

    1. Initial program 91.4%

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

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

        \[\leadsto \color{blue}{\left(c \cdot i + t \cdot z\right) + a \cdot b} \]
      2. associate-+l+N/A

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

        \[\leadsto c \cdot i + \color{blue}{\left(a \cdot b + t \cdot z\right)} \]
      4. accelerator-lowering-fma.f64N/A

        \[\leadsto \color{blue}{\mathsf{fma}\left(c, i, a \cdot b + t \cdot z\right)} \]
      5. accelerator-lowering-fma.f64N/A

        \[\leadsto \mathsf{fma}\left(c, i, \color{blue}{\mathsf{fma}\left(a, b, t \cdot z\right)}\right) \]
      6. *-lowering-*.f6490.1

        \[\leadsto \mathsf{fma}\left(c, i, \mathsf{fma}\left(a, b, \color{blue}{t \cdot z}\right)\right) \]
    5. Simplified90.1%

      \[\leadsto \color{blue}{\mathsf{fma}\left(c, i, \mathsf{fma}\left(a, b, t \cdot z\right)\right)} \]

    if -1.9999999999999999e-60 < (*.f64 z t) < 4.9999999999999997e104

    1. Initial program 94.8%

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

      \[\leadsto \color{blue}{a \cdot b + \left(c \cdot i + x \cdot y\right)} \]
    4. Step-by-step derivation
      1. accelerator-lowering-fma.f64N/A

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

        \[\leadsto \mathsf{fma}\left(a, b, \color{blue}{\mathsf{fma}\left(c, i, x \cdot y\right)}\right) \]
      3. *-lowering-*.f6491.3

        \[\leadsto \mathsf{fma}\left(a, b, \mathsf{fma}\left(c, i, \color{blue}{x \cdot y}\right)\right) \]
    5. Simplified91.3%

      \[\leadsto \color{blue}{\mathsf{fma}\left(a, b, \mathsf{fma}\left(c, i, x \cdot y\right)\right)} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification90.6%

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

Alternative 6: 86.9% accurate, 0.7× speedup?

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

\mathbf{elif}\;z \cdot t \leq 10^{+152}:\\
\;\;\;\;\mathsf{fma}\left(a, b, \mathsf{fma}\left(c, i, x \cdot y\right)\right)\\

\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(c, i, z \cdot t\right)\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if (*.f64 z t) < -9.99999999999999991e131

    1. Initial program 90.6%

      \[\left(\left(x \cdot y + z \cdot t\right) + a \cdot b\right) + c \cdot i \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. associate-+l+N/A

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

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

        \[\leadsto \color{blue}{z \cdot t + \left(x \cdot y + \left(a \cdot b + c \cdot i\right)\right)} \]
      4. accelerator-lowering-fma.f64N/A

        \[\leadsto \color{blue}{\mathsf{fma}\left(z, t, x \cdot y + \left(a \cdot b + c \cdot i\right)\right)} \]
      5. accelerator-lowering-fma.f64N/A

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

        \[\leadsto \mathsf{fma}\left(z, t, \mathsf{fma}\left(x, y, \color{blue}{\mathsf{fma}\left(a, b, c \cdot i\right)}\right)\right) \]
      7. *-lowering-*.f6496.2

        \[\leadsto \mathsf{fma}\left(z, t, \mathsf{fma}\left(x, y, \mathsf{fma}\left(a, b, \color{blue}{c \cdot i}\right)\right)\right) \]
    4. Applied egg-rr96.2%

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

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

        \[\leadsto \mathsf{fma}\left(z, t, \color{blue}{a \cdot b}\right) \]
    7. Simplified86.9%

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

    if -9.99999999999999991e131 < (*.f64 z t) < 1e152

    1. Initial program 96.4%

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

      \[\leadsto \color{blue}{a \cdot b + \left(c \cdot i + x \cdot y\right)} \]
    4. Step-by-step derivation
      1. accelerator-lowering-fma.f64N/A

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

        \[\leadsto \mathsf{fma}\left(a, b, \color{blue}{\mathsf{fma}\left(c, i, x \cdot y\right)}\right) \]
      3. *-lowering-*.f6486.3

        \[\leadsto \mathsf{fma}\left(a, b, \mathsf{fma}\left(c, i, \color{blue}{x \cdot y}\right)\right) \]
    5. Simplified86.3%

      \[\leadsto \color{blue}{\mathsf{fma}\left(a, b, \mathsf{fma}\left(c, i, x \cdot y\right)\right)} \]

    if 1e152 < (*.f64 z t)

    1. Initial program 79.4%

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

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

        \[\leadsto \color{blue}{\left(c \cdot i + t \cdot z\right) + a \cdot b} \]
      2. associate-+l+N/A

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

        \[\leadsto c \cdot i + \color{blue}{\left(a \cdot b + t \cdot z\right)} \]
      4. accelerator-lowering-fma.f64N/A

        \[\leadsto \color{blue}{\mathsf{fma}\left(c, i, a \cdot b + t \cdot z\right)} \]
      5. accelerator-lowering-fma.f64N/A

        \[\leadsto \mathsf{fma}\left(c, i, \color{blue}{\mathsf{fma}\left(a, b, t \cdot z\right)}\right) \]
      6. *-lowering-*.f6491.2

        \[\leadsto \mathsf{fma}\left(c, i, \mathsf{fma}\left(a, b, \color{blue}{t \cdot z}\right)\right) \]
    5. Simplified91.2%

      \[\leadsto \color{blue}{\mathsf{fma}\left(c, i, \mathsf{fma}\left(a, b, t \cdot z\right)\right)} \]
    6. Taylor expanded in a around 0

      \[\leadsto \mathsf{fma}\left(c, i, \color{blue}{t \cdot z}\right) \]
    7. Step-by-step derivation
      1. *-lowering-*.f6481.3

        \[\leadsto \mathsf{fma}\left(c, i, \color{blue}{t \cdot z}\right) \]
    8. Simplified81.3%

      \[\leadsto \mathsf{fma}\left(c, i, \color{blue}{t \cdot z}\right) \]
  3. Recombined 3 regimes into one program.
  4. Final simplification85.7%

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

Alternative 7: 66.4% accurate, 0.9× speedup?

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

\mathbf{elif}\;a \cdot b \leq 1.65 \cdot 10^{+160}:\\
\;\;\;\;\mathsf{fma}\left(z, t, c \cdot i\right)\\

\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(i, c, a \cdot b\right)\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if (*.f64 a b) < -2.4e118

    1. Initial program 81.8%

      \[\left(\left(x \cdot y + z \cdot t\right) + a \cdot b\right) + c \cdot i \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. associate-+l+N/A

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

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

        \[\leadsto \color{blue}{z \cdot t + \left(x \cdot y + \left(a \cdot b + c \cdot i\right)\right)} \]
      4. accelerator-lowering-fma.f64N/A

        \[\leadsto \color{blue}{\mathsf{fma}\left(z, t, x \cdot y + \left(a \cdot b + c \cdot i\right)\right)} \]
      5. accelerator-lowering-fma.f64N/A

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

        \[\leadsto \mathsf{fma}\left(z, t, \mathsf{fma}\left(x, y, \color{blue}{\mathsf{fma}\left(a, b, c \cdot i\right)}\right)\right) \]
      7. *-lowering-*.f6486.3

        \[\leadsto \mathsf{fma}\left(z, t, \mathsf{fma}\left(x, y, \mathsf{fma}\left(a, b, \color{blue}{c \cdot i}\right)\right)\right) \]
    4. Applied egg-rr86.3%

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

      \[\leadsto \mathsf{fma}\left(z, t, \color{blue}{a \cdot b}\right) \]
    6. Step-by-step derivation
      1. *-lowering-*.f6477.3

        \[\leadsto \mathsf{fma}\left(z, t, \color{blue}{a \cdot b}\right) \]
    7. Simplified77.3%

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

    if -2.4e118 < (*.f64 a b) < 1.6499999999999999e160

    1. Initial program 95.6%

      \[\left(\left(x \cdot y + z \cdot t\right) + a \cdot b\right) + c \cdot i \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. associate-+l+N/A

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

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

        \[\leadsto \color{blue}{z \cdot t + \left(x \cdot y + \left(a \cdot b + c \cdot i\right)\right)} \]
      4. accelerator-lowering-fma.f64N/A

        \[\leadsto \color{blue}{\mathsf{fma}\left(z, t, x \cdot y + \left(a \cdot b + c \cdot i\right)\right)} \]
      5. accelerator-lowering-fma.f64N/A

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

        \[\leadsto \mathsf{fma}\left(z, t, \mathsf{fma}\left(x, y, \color{blue}{\mathsf{fma}\left(a, b, c \cdot i\right)}\right)\right) \]
      7. *-lowering-*.f6499.4

        \[\leadsto \mathsf{fma}\left(z, t, \mathsf{fma}\left(x, y, \mathsf{fma}\left(a, b, \color{blue}{c \cdot i}\right)\right)\right) \]
    4. Applied egg-rr99.4%

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

      \[\leadsto \mathsf{fma}\left(z, t, \color{blue}{c \cdot i}\right) \]
    6. Step-by-step derivation
      1. *-lowering-*.f6471.9

        \[\leadsto \mathsf{fma}\left(z, t, \color{blue}{c \cdot i}\right) \]
    7. Simplified71.9%

      \[\leadsto \mathsf{fma}\left(z, t, \color{blue}{c \cdot i}\right) \]

    if 1.6499999999999999e160 < (*.f64 a b)

    1. Initial program 93.1%

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

      \[\leadsto \color{blue}{a \cdot b} + c \cdot i \]
    4. Step-by-step derivation
      1. *-lowering-*.f6486.2

        \[\leadsto \color{blue}{a \cdot b} + c \cdot i \]
    5. Simplified86.2%

      \[\leadsto \color{blue}{a \cdot b} + c \cdot i \]
    6. Step-by-step derivation
      1. +-commutativeN/A

        \[\leadsto \color{blue}{c \cdot i + a \cdot b} \]
      2. *-commutativeN/A

        \[\leadsto \color{blue}{i \cdot c} + a \cdot b \]
      3. accelerator-lowering-fma.f64N/A

        \[\leadsto \color{blue}{\mathsf{fma}\left(i, c, a \cdot b\right)} \]
      4. *-lowering-*.f6489.7

        \[\leadsto \mathsf{fma}\left(i, c, \color{blue}{a \cdot b}\right) \]
    7. Applied egg-rr89.7%

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

Alternative 8: 66.2% accurate, 0.9× speedup?

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

\mathbf{elif}\;a \cdot b \leq 10^{+160}:\\
\;\;\;\;\mathsf{fma}\left(c, i, z \cdot t\right)\\

\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(i, c, a \cdot b\right)\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if (*.f64 a b) < -2.40000000000000006e124

    1. Initial program 81.8%

      \[\left(\left(x \cdot y + z \cdot t\right) + a \cdot b\right) + c \cdot i \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. associate-+l+N/A

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

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

        \[\leadsto \color{blue}{z \cdot t + \left(x \cdot y + \left(a \cdot b + c \cdot i\right)\right)} \]
      4. accelerator-lowering-fma.f64N/A

        \[\leadsto \color{blue}{\mathsf{fma}\left(z, t, x \cdot y + \left(a \cdot b + c \cdot i\right)\right)} \]
      5. accelerator-lowering-fma.f64N/A

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

        \[\leadsto \mathsf{fma}\left(z, t, \mathsf{fma}\left(x, y, \color{blue}{\mathsf{fma}\left(a, b, c \cdot i\right)}\right)\right) \]
      7. *-lowering-*.f6486.3

        \[\leadsto \mathsf{fma}\left(z, t, \mathsf{fma}\left(x, y, \mathsf{fma}\left(a, b, \color{blue}{c \cdot i}\right)\right)\right) \]
    4. Applied egg-rr86.3%

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

      \[\leadsto \mathsf{fma}\left(z, t, \color{blue}{a \cdot b}\right) \]
    6. Step-by-step derivation
      1. *-lowering-*.f6477.3

        \[\leadsto \mathsf{fma}\left(z, t, \color{blue}{a \cdot b}\right) \]
    7. Simplified77.3%

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

    if -2.40000000000000006e124 < (*.f64 a b) < 1.00000000000000001e160

    1. Initial program 95.6%

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

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

        \[\leadsto \color{blue}{\left(c \cdot i + t \cdot z\right) + a \cdot b} \]
      2. associate-+l+N/A

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

        \[\leadsto c \cdot i + \color{blue}{\left(a \cdot b + t \cdot z\right)} \]
      4. accelerator-lowering-fma.f64N/A

        \[\leadsto \color{blue}{\mathsf{fma}\left(c, i, a \cdot b + t \cdot z\right)} \]
      5. accelerator-lowering-fma.f64N/A

        \[\leadsto \mathsf{fma}\left(c, i, \color{blue}{\mathsf{fma}\left(a, b, t \cdot z\right)}\right) \]
      6. *-lowering-*.f6478.0

        \[\leadsto \mathsf{fma}\left(c, i, \mathsf{fma}\left(a, b, \color{blue}{t \cdot z}\right)\right) \]
    5. Simplified78.0%

      \[\leadsto \color{blue}{\mathsf{fma}\left(c, i, \mathsf{fma}\left(a, b, t \cdot z\right)\right)} \]
    6. Taylor expanded in a around 0

      \[\leadsto \mathsf{fma}\left(c, i, \color{blue}{t \cdot z}\right) \]
    7. Step-by-step derivation
      1. *-lowering-*.f6471.4

        \[\leadsto \mathsf{fma}\left(c, i, \color{blue}{t \cdot z}\right) \]
    8. Simplified71.4%

      \[\leadsto \mathsf{fma}\left(c, i, \color{blue}{t \cdot z}\right) \]

    if 1.00000000000000001e160 < (*.f64 a b)

    1. Initial program 93.1%

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

      \[\leadsto \color{blue}{a \cdot b} + c \cdot i \]
    4. Step-by-step derivation
      1. *-lowering-*.f6486.2

        \[\leadsto \color{blue}{a \cdot b} + c \cdot i \]
    5. Simplified86.2%

      \[\leadsto \color{blue}{a \cdot b} + c \cdot i \]
    6. Step-by-step derivation
      1. +-commutativeN/A

        \[\leadsto \color{blue}{c \cdot i + a \cdot b} \]
      2. *-commutativeN/A

        \[\leadsto \color{blue}{i \cdot c} + a \cdot b \]
      3. accelerator-lowering-fma.f64N/A

        \[\leadsto \color{blue}{\mathsf{fma}\left(i, c, a \cdot b\right)} \]
      4. *-lowering-*.f6489.7

        \[\leadsto \mathsf{fma}\left(i, c, \color{blue}{a \cdot b}\right) \]
    7. Applied egg-rr89.7%

      \[\leadsto \color{blue}{\mathsf{fma}\left(i, c, a \cdot b\right)} \]
  3. Recombined 3 regimes into one program.
  4. Final simplification74.5%

    \[\leadsto \begin{array}{l} \mathbf{if}\;a \cdot b \leq -2.4 \cdot 10^{+124}:\\ \;\;\;\;\mathsf{fma}\left(z, t, a \cdot b\right)\\ \mathbf{elif}\;a \cdot b \leq 10^{+160}:\\ \;\;\;\;\mathsf{fma}\left(c, i, z \cdot t\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(i, c, a \cdot b\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 9: 65.6% accurate, 0.9× speedup?

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

\mathbf{elif}\;a \cdot b \leq 5.4 \cdot 10^{+159}:\\
\;\;\;\;\mathsf{fma}\left(c, i, z \cdot t\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (*.f64 a b) < -1.00000000000000002e151 or 5.40000000000000016e159 < (*.f64 a b)

    1. Initial program 87.1%

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

      \[\leadsto \color{blue}{a \cdot b} + c \cdot i \]
    4. Step-by-step derivation
      1. *-lowering-*.f6479.7

        \[\leadsto \color{blue}{a \cdot b} + c \cdot i \]
    5. Simplified79.7%

      \[\leadsto \color{blue}{a \cdot b} + c \cdot i \]
    6. Step-by-step derivation
      1. +-commutativeN/A

        \[\leadsto \color{blue}{c \cdot i + a \cdot b} \]
      2. *-commutativeN/A

        \[\leadsto \color{blue}{i \cdot c} + a \cdot b \]
      3. accelerator-lowering-fma.f64N/A

        \[\leadsto \color{blue}{\mathsf{fma}\left(i, c, a \cdot b\right)} \]
      4. *-lowering-*.f6484.0

        \[\leadsto \mathsf{fma}\left(i, c, \color{blue}{a \cdot b}\right) \]
    7. Applied egg-rr84.0%

      \[\leadsto \color{blue}{\mathsf{fma}\left(i, c, a \cdot b\right)} \]

    if -1.00000000000000002e151 < (*.f64 a b) < 5.40000000000000016e159

    1. Initial program 95.1%

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

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

        \[\leadsto \color{blue}{\left(c \cdot i + t \cdot z\right) + a \cdot b} \]
      2. associate-+l+N/A

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

        \[\leadsto c \cdot i + \color{blue}{\left(a \cdot b + t \cdot z\right)} \]
      4. accelerator-lowering-fma.f64N/A

        \[\leadsto \color{blue}{\mathsf{fma}\left(c, i, a \cdot b + t \cdot z\right)} \]
      5. accelerator-lowering-fma.f64N/A

        \[\leadsto \mathsf{fma}\left(c, i, \color{blue}{\mathsf{fma}\left(a, b, t \cdot z\right)}\right) \]
      6. *-lowering-*.f6477.3

        \[\leadsto \mathsf{fma}\left(c, i, \mathsf{fma}\left(a, b, \color{blue}{t \cdot z}\right)\right) \]
    5. Simplified77.3%

      \[\leadsto \color{blue}{\mathsf{fma}\left(c, i, \mathsf{fma}\left(a, b, t \cdot z\right)\right)} \]
    6. Taylor expanded in a around 0

      \[\leadsto \mathsf{fma}\left(c, i, \color{blue}{t \cdot z}\right) \]
    7. Step-by-step derivation
      1. *-lowering-*.f6470.8

        \[\leadsto \mathsf{fma}\left(c, i, \color{blue}{t \cdot z}\right) \]
    8. Simplified70.8%

      \[\leadsto \mathsf{fma}\left(c, i, \color{blue}{t \cdot z}\right) \]
  3. Recombined 2 regimes into one program.
  4. Final simplification74.4%

    \[\leadsto \begin{array}{l} \mathbf{if}\;a \cdot b \leq -1 \cdot 10^{+151}:\\ \;\;\;\;\mathsf{fma}\left(i, c, a \cdot b\right)\\ \mathbf{elif}\;a \cdot b \leq 5.4 \cdot 10^{+159}:\\ \;\;\;\;\mathsf{fma}\left(c, i, z \cdot t\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(i, c, a \cdot b\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 10: 62.9% accurate, 0.9× speedup?

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

\mathbf{elif}\;a \cdot b \leq 7 \cdot 10^{+198}:\\
\;\;\;\;\mathsf{fma}\left(c, i, z \cdot t\right)\\

\mathbf{else}:\\
\;\;\;\;a \cdot b\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (*.f64 a b) < -3.99999999999999969e134 or 7.00000000000000026e198 < (*.f64 a b)

    1. Initial program 85.3%

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

      \[\leadsto \color{blue}{a \cdot b} \]
    4. Step-by-step derivation
      1. *-lowering-*.f6473.8

        \[\leadsto \color{blue}{a \cdot b} \]
    5. Simplified73.8%

      \[\leadsto \color{blue}{a \cdot b} \]

    if -3.99999999999999969e134 < (*.f64 a b) < 7.00000000000000026e198

    1. Initial program 95.7%

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

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

        \[\leadsto \color{blue}{\left(c \cdot i + t \cdot z\right) + a \cdot b} \]
      2. associate-+l+N/A

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

        \[\leadsto c \cdot i + \color{blue}{\left(a \cdot b + t \cdot z\right)} \]
      4. accelerator-lowering-fma.f64N/A

        \[\leadsto \color{blue}{\mathsf{fma}\left(c, i, a \cdot b + t \cdot z\right)} \]
      5. accelerator-lowering-fma.f64N/A

        \[\leadsto \mathsf{fma}\left(c, i, \color{blue}{\mathsf{fma}\left(a, b, t \cdot z\right)}\right) \]
      6. *-lowering-*.f6478.0

        \[\leadsto \mathsf{fma}\left(c, i, \mathsf{fma}\left(a, b, \color{blue}{t \cdot z}\right)\right) \]
    5. Simplified78.0%

      \[\leadsto \color{blue}{\mathsf{fma}\left(c, i, \mathsf{fma}\left(a, b, t \cdot z\right)\right)} \]
    6. Taylor expanded in a around 0

      \[\leadsto \mathsf{fma}\left(c, i, \color{blue}{t \cdot z}\right) \]
    7. Step-by-step derivation
      1. *-lowering-*.f6471.6

        \[\leadsto \mathsf{fma}\left(c, i, \color{blue}{t \cdot z}\right) \]
    8. Simplified71.6%

      \[\leadsto \mathsf{fma}\left(c, i, \color{blue}{t \cdot z}\right) \]
  3. Recombined 2 regimes into one program.
  4. Final simplification72.2%

    \[\leadsto \begin{array}{l} \mathbf{if}\;a \cdot b \leq -4 \cdot 10^{+134}:\\ \;\;\;\;a \cdot b\\ \mathbf{elif}\;a \cdot b \leq 7 \cdot 10^{+198}:\\ \;\;\;\;\mathsf{fma}\left(c, i, z \cdot t\right)\\ \mathbf{else}:\\ \;\;\;\;a \cdot b\\ \end{array} \]
  5. Add Preprocessing

Alternative 11: 43.1% accurate, 1.1× speedup?

\[\begin{array}{l} [x, y, z, t, a, b, c, i] = \mathsf{sort}([x, y, z, t, a, b, c, i])\\ \\ \begin{array}{l} \mathbf{if}\;c \cdot i \leq -1.25 \cdot 10^{+141}:\\ \;\;\;\;c \cdot i\\ \mathbf{elif}\;c \cdot i \leq 7.8 \cdot 10^{+91}:\\ \;\;\;\;z \cdot t\\ \mathbf{else}:\\ \;\;\;\;c \cdot i\\ \end{array} \end{array} \]
NOTE: x, y, z, t, a, b, c, and i should be sorted in increasing order before calling this function.
(FPCore (x y z t a b c i)
 :precision binary64
 (if (<= (* c i) -1.25e+141)
   (* c i)
   (if (<= (* c i) 7.8e+91) (* z t) (* c i))))
assert(x < y && y < z && z < t && t < a && a < b && b < c && c < i);
double code(double x, double y, double z, double t, double a, double b, double c, double i) {
	double tmp;
	if ((c * i) <= -1.25e+141) {
		tmp = c * i;
	} else if ((c * i) <= 7.8e+91) {
		tmp = z * t;
	} else {
		tmp = c * i;
	}
	return tmp;
}
NOTE: x, y, z, t, a, b, c, and i should be sorted in increasing order before calling this function.
real(8) function code(x, y, z, t, a, b, c, i)
    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), intent (in) :: c
    real(8), intent (in) :: i
    real(8) :: tmp
    if ((c * i) <= (-1.25d+141)) then
        tmp = c * i
    else if ((c * i) <= 7.8d+91) then
        tmp = z * t
    else
        tmp = c * i
    end if
    code = tmp
end function
assert x < y && y < z && z < t && t < a && a < b && b < c && c < i;
public static double code(double x, double y, double z, double t, double a, double b, double c, double i) {
	double tmp;
	if ((c * i) <= -1.25e+141) {
		tmp = c * i;
	} else if ((c * i) <= 7.8e+91) {
		tmp = z * t;
	} else {
		tmp = c * i;
	}
	return tmp;
}
[x, y, z, t, a, b, c, i] = sort([x, y, z, t, a, b, c, i])
def code(x, y, z, t, a, b, c, i):
	tmp = 0
	if (c * i) <= -1.25e+141:
		tmp = c * i
	elif (c * i) <= 7.8e+91:
		tmp = z * t
	else:
		tmp = c * i
	return tmp
x, y, z, t, a, b, c, i = sort([x, y, z, t, a, b, c, i])
function code(x, y, z, t, a, b, c, i)
	tmp = 0.0
	if (Float64(c * i) <= -1.25e+141)
		tmp = Float64(c * i);
	elseif (Float64(c * i) <= 7.8e+91)
		tmp = Float64(z * t);
	else
		tmp = Float64(c * i);
	end
	return tmp
end
x, y, z, t, a, b, c, i = num2cell(sort([x, y, z, t, a, b, c, i])){:}
function tmp_2 = code(x, y, z, t, a, b, c, i)
	tmp = 0.0;
	if ((c * i) <= -1.25e+141)
		tmp = c * i;
	elseif ((c * i) <= 7.8e+91)
		tmp = z * t;
	else
		tmp = c * i;
	end
	tmp_2 = tmp;
end
NOTE: x, y, z, t, a, b, c, and i should be sorted in increasing order before calling this function.
code[x_, y_, z_, t_, a_, b_, c_, i_] := If[LessEqual[N[(c * i), $MachinePrecision], -1.25e+141], N[(c * i), $MachinePrecision], If[LessEqual[N[(c * i), $MachinePrecision], 7.8e+91], N[(z * t), $MachinePrecision], N[(c * i), $MachinePrecision]]]
\begin{array}{l}
[x, y, z, t, a, b, c, i] = \mathsf{sort}([x, y, z, t, a, b, c, i])\\
\\
\begin{array}{l}
\mathbf{if}\;c \cdot i \leq -1.25 \cdot 10^{+141}:\\
\;\;\;\;c \cdot i\\

\mathbf{elif}\;c \cdot i \leq 7.8 \cdot 10^{+91}:\\
\;\;\;\;z \cdot t\\

\mathbf{else}:\\
\;\;\;\;c \cdot i\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (*.f64 c i) < -1.25000000000000006e141 or 7.79999999999999935e91 < (*.f64 c i)

    1. Initial program 86.2%

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

      \[\leadsto \color{blue}{c \cdot i} \]
    4. Step-by-step derivation
      1. *-lowering-*.f6467.5

        \[\leadsto \color{blue}{c \cdot i} \]
    5. Simplified67.5%

      \[\leadsto \color{blue}{c \cdot i} \]

    if -1.25000000000000006e141 < (*.f64 c i) < 7.79999999999999935e91

    1. Initial program 97.4%

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

      \[\leadsto \color{blue}{t \cdot z} \]
    4. Step-by-step derivation
      1. *-lowering-*.f6440.4

        \[\leadsto \color{blue}{t \cdot z} \]
    5. Simplified40.4%

      \[\leadsto \color{blue}{t \cdot z} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification51.2%

    \[\leadsto \begin{array}{l} \mathbf{if}\;c \cdot i \leq -1.25 \cdot 10^{+141}:\\ \;\;\;\;c \cdot i\\ \mathbf{elif}\;c \cdot i \leq 7.8 \cdot 10^{+91}:\\ \;\;\;\;z \cdot t\\ \mathbf{else}:\\ \;\;\;\;c \cdot i\\ \end{array} \]
  5. Add Preprocessing

Alternative 12: 42.2% accurate, 1.1× speedup?

\[\begin{array}{l} [x, y, z, t, a, b, c, i] = \mathsf{sort}([x, y, z, t, a, b, c, i])\\ \\ \begin{array}{l} \mathbf{if}\;a \cdot b \leq -5.2 \cdot 10^{+93}:\\ \;\;\;\;a \cdot b\\ \mathbf{elif}\;a \cdot b \leq 1.55 \cdot 10^{+196}:\\ \;\;\;\;c \cdot i\\ \mathbf{else}:\\ \;\;\;\;a \cdot b\\ \end{array} \end{array} \]
NOTE: x, y, z, t, a, b, c, and i should be sorted in increasing order before calling this function.
(FPCore (x y z t a b c i)
 :precision binary64
 (if (<= (* a b) -5.2e+93)
   (* a b)
   (if (<= (* a b) 1.55e+196) (* c i) (* a b))))
assert(x < y && y < z && z < t && t < a && a < b && b < c && c < i);
double code(double x, double y, double z, double t, double a, double b, double c, double i) {
	double tmp;
	if ((a * b) <= -5.2e+93) {
		tmp = a * b;
	} else if ((a * b) <= 1.55e+196) {
		tmp = c * i;
	} else {
		tmp = a * b;
	}
	return tmp;
}
NOTE: x, y, z, t, a, b, c, and i should be sorted in increasing order before calling this function.
real(8) function code(x, y, z, t, a, b, c, i)
    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), intent (in) :: c
    real(8), intent (in) :: i
    real(8) :: tmp
    if ((a * b) <= (-5.2d+93)) then
        tmp = a * b
    else if ((a * b) <= 1.55d+196) then
        tmp = c * i
    else
        tmp = a * b
    end if
    code = tmp
end function
assert x < y && y < z && z < t && t < a && a < b && b < c && c < i;
public static double code(double x, double y, double z, double t, double a, double b, double c, double i) {
	double tmp;
	if ((a * b) <= -5.2e+93) {
		tmp = a * b;
	} else if ((a * b) <= 1.55e+196) {
		tmp = c * i;
	} else {
		tmp = a * b;
	}
	return tmp;
}
[x, y, z, t, a, b, c, i] = sort([x, y, z, t, a, b, c, i])
def code(x, y, z, t, a, b, c, i):
	tmp = 0
	if (a * b) <= -5.2e+93:
		tmp = a * b
	elif (a * b) <= 1.55e+196:
		tmp = c * i
	else:
		tmp = a * b
	return tmp
x, y, z, t, a, b, c, i = sort([x, y, z, t, a, b, c, i])
function code(x, y, z, t, a, b, c, i)
	tmp = 0.0
	if (Float64(a * b) <= -5.2e+93)
		tmp = Float64(a * b);
	elseif (Float64(a * b) <= 1.55e+196)
		tmp = Float64(c * i);
	else
		tmp = Float64(a * b);
	end
	return tmp
end
x, y, z, t, a, b, c, i = num2cell(sort([x, y, z, t, a, b, c, i])){:}
function tmp_2 = code(x, y, z, t, a, b, c, i)
	tmp = 0.0;
	if ((a * b) <= -5.2e+93)
		tmp = a * b;
	elseif ((a * b) <= 1.55e+196)
		tmp = c * i;
	else
		tmp = a * b;
	end
	tmp_2 = tmp;
end
NOTE: x, y, z, t, a, b, c, and i should be sorted in increasing order before calling this function.
code[x_, y_, z_, t_, a_, b_, c_, i_] := If[LessEqual[N[(a * b), $MachinePrecision], -5.2e+93], N[(a * b), $MachinePrecision], If[LessEqual[N[(a * b), $MachinePrecision], 1.55e+196], N[(c * i), $MachinePrecision], N[(a * b), $MachinePrecision]]]
\begin{array}{l}
[x, y, z, t, a, b, c, i] = \mathsf{sort}([x, y, z, t, a, b, c, i])\\
\\
\begin{array}{l}
\mathbf{if}\;a \cdot b \leq -5.2 \cdot 10^{+93}:\\
\;\;\;\;a \cdot b\\

\mathbf{elif}\;a \cdot b \leq 1.55 \cdot 10^{+196}:\\
\;\;\;\;c \cdot i\\

\mathbf{else}:\\
\;\;\;\;a \cdot b\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (*.f64 a b) < -5.19999999999999999e93 or 1.55000000000000005e196 < (*.f64 a b)

    1. Initial program 86.1%

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

      \[\leadsto \color{blue}{a \cdot b} \]
    4. Step-by-step derivation
      1. *-lowering-*.f6469.9

        \[\leadsto \color{blue}{a \cdot b} \]
    5. Simplified69.9%

      \[\leadsto \color{blue}{a \cdot b} \]

    if -5.19999999999999999e93 < (*.f64 a b) < 1.55000000000000005e196

    1. Initial program 95.6%

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

      \[\leadsto \color{blue}{c \cdot i} \]
    4. Step-by-step derivation
      1. *-lowering-*.f6438.5

        \[\leadsto \color{blue}{c \cdot i} \]
    5. Simplified38.5%

      \[\leadsto \color{blue}{c \cdot i} \]
  3. Recombined 2 regimes into one program.
  4. Add Preprocessing

Alternative 13: 98.2% accurate, 1.3× speedup?

\[\begin{array}{l} [x, y, z, t, a, b, c, i] = \mathsf{sort}([x, y, z, t, a, b, c, i])\\ \\ \mathsf{fma}\left(z, t, \mathsf{fma}\left(x, y, \mathsf{fma}\left(a, b, c \cdot i\right)\right)\right) \end{array} \]
NOTE: x, y, z, t, a, b, c, and i should be sorted in increasing order before calling this function.
(FPCore (x y z t a b c i)
 :precision binary64
 (fma z t (fma x y (fma a b (* c i)))))
assert(x < y && y < z && z < t && t < a && a < b && b < c && c < i);
double code(double x, double y, double z, double t, double a, double b, double c, double i) {
	return fma(z, t, fma(x, y, fma(a, b, (c * i))));
}
x, y, z, t, a, b, c, i = sort([x, y, z, t, a, b, c, i])
function code(x, y, z, t, a, b, c, i)
	return fma(z, t, fma(x, y, fma(a, b, Float64(c * i))))
end
NOTE: x, y, z, t, a, b, c, and i should be sorted in increasing order before calling this function.
code[x_, y_, z_, t_, a_, b_, c_, i_] := N[(z * t + N[(x * y + N[(a * b + N[(c * i), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
[x, y, z, t, a, b, c, i] = \mathsf{sort}([x, y, z, t, a, b, c, i])\\
\\
\mathsf{fma}\left(z, t, \mathsf{fma}\left(x, y, \mathsf{fma}\left(a, b, c \cdot i\right)\right)\right)
\end{array}
Derivation
  1. Initial program 92.9%

    \[\left(\left(x \cdot y + z \cdot t\right) + a \cdot b\right) + c \cdot i \]
  2. Add Preprocessing
  3. Step-by-step derivation
    1. associate-+l+N/A

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

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

      \[\leadsto \color{blue}{z \cdot t + \left(x \cdot y + \left(a \cdot b + c \cdot i\right)\right)} \]
    4. accelerator-lowering-fma.f64N/A

      \[\leadsto \color{blue}{\mathsf{fma}\left(z, t, x \cdot y + \left(a \cdot b + c \cdot i\right)\right)} \]
    5. accelerator-lowering-fma.f64N/A

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

      \[\leadsto \mathsf{fma}\left(z, t, \mathsf{fma}\left(x, y, \color{blue}{\mathsf{fma}\left(a, b, c \cdot i\right)}\right)\right) \]
    7. *-lowering-*.f6496.5

      \[\leadsto \mathsf{fma}\left(z, t, \mathsf{fma}\left(x, y, \mathsf{fma}\left(a, b, \color{blue}{c \cdot i}\right)\right)\right) \]
  4. Applied egg-rr96.5%

    \[\leadsto \color{blue}{\mathsf{fma}\left(z, t, \mathsf{fma}\left(x, y, \mathsf{fma}\left(a, b, c \cdot i\right)\right)\right)} \]
  5. Add Preprocessing

Alternative 14: 27.3% accurate, 5.0× speedup?

\[\begin{array}{l} [x, y, z, t, a, b, c, i] = \mathsf{sort}([x, y, z, t, a, b, c, i])\\ \\ a \cdot b \end{array} \]
NOTE: x, y, z, t, a, b, c, and i should be sorted in increasing order before calling this function.
(FPCore (x y z t a b c i) :precision binary64 (* a b))
assert(x < y && y < z && z < t && t < a && a < b && b < c && c < i);
double code(double x, double y, double z, double t, double a, double b, double c, double i) {
	return a * b;
}
NOTE: x, y, z, t, a, b, c, and i should be sorted in increasing order before calling this function.
real(8) function code(x, y, z, t, a, b, c, i)
    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), intent (in) :: c
    real(8), intent (in) :: i
    code = a * b
end function
assert x < y && y < z && z < t && t < a && a < b && b < c && c < i;
public static double code(double x, double y, double z, double t, double a, double b, double c, double i) {
	return a * b;
}
[x, y, z, t, a, b, c, i] = sort([x, y, z, t, a, b, c, i])
def code(x, y, z, t, a, b, c, i):
	return a * b
x, y, z, t, a, b, c, i = sort([x, y, z, t, a, b, c, i])
function code(x, y, z, t, a, b, c, i)
	return Float64(a * b)
end
x, y, z, t, a, b, c, i = num2cell(sort([x, y, z, t, a, b, c, i])){:}
function tmp = code(x, y, z, t, a, b, c, i)
	tmp = a * b;
end
NOTE: x, y, z, t, a, b, c, and i should be sorted in increasing order before calling this function.
code[x_, y_, z_, t_, a_, b_, c_, i_] := N[(a * b), $MachinePrecision]
\begin{array}{l}
[x, y, z, t, a, b, c, i] = \mathsf{sort}([x, y, z, t, a, b, c, i])\\
\\
a \cdot b
\end{array}
Derivation
  1. Initial program 92.9%

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

    \[\leadsto \color{blue}{a \cdot b} \]
  4. Step-by-step derivation
    1. *-lowering-*.f6425.4

      \[\leadsto \color{blue}{a \cdot b} \]
  5. Simplified25.4%

    \[\leadsto \color{blue}{a \cdot b} \]
  6. Add Preprocessing

Reproduce

?
herbie shell --seed 2024198 
(FPCore (x y z t a b c i)
  :name "Linear.V4:$cdot from linear-1.19.1.3, C"
  :precision binary64
  (+ (+ (+ (* x y) (* z t)) (* a b)) (* c i)))