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

Percentage Accurate: 95.8% → 97.7%
Time: 10.3s
Alternatives: 14
Speedup: 0.4×

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: 95.8% 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: 97.7% accurate, 0.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;c \cdot i \leq 5 \cdot 10^{+257}:\\ \;\;\;\;\mathsf{fma}\left(c, i, \mathsf{fma}\left(a, b, \mathsf{fma}\left(x, y, z \cdot t\right)\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(x, y, \mathsf{fma}\left(a, b, c \cdot i\right)\right)\\ \end{array} \end{array} \]
(FPCore (x y z t a b c i)
 :precision binary64
 (if (<= (* c i) 5e+257)
   (fma c i (fma a b (fma x y (* z t))))
   (fma x y (fma a b (* 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+257) {
		tmp = fma(c, i, fma(a, b, fma(x, y, (z * t))));
	} else {
		tmp = fma(x, y, fma(a, b, (c * i)));
	}
	return tmp;
}
function code(x, y, z, t, a, b, c, i)
	tmp = 0.0
	if (Float64(c * i) <= 5e+257)
		tmp = fma(c, i, fma(a, b, fma(x, y, Float64(z * t))));
	else
		tmp = fma(x, y, fma(a, b, Float64(c * i)));
	end
	return tmp
end
code[x_, y_, z_, t_, a_, b_, c_, i_] := If[LessEqual[N[(c * i), $MachinePrecision], 5e+257], N[(c * i + N[(a * b + N[(x * y + N[(z * t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x * y + N[(a * b + N[(c * i), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;c \cdot i \leq 5 \cdot 10^{+257}:\\
\;\;\;\;\mathsf{fma}\left(c, i, \mathsf{fma}\left(a, b, \mathsf{fma}\left(x, y, z \cdot t\right)\right)\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (*.f64 c i) < 5.00000000000000028e257

    1. Initial program 98.2%

      \[\left(\left(x \cdot y + z \cdot t\right) + a \cdot b\right) + c \cdot i \]
    2. Step-by-step derivation
      1. +-commutative98.2%

        \[\leadsto \color{blue}{c \cdot i + \left(\left(x \cdot y + z \cdot t\right) + a \cdot b\right)} \]
      2. fma-def99.1%

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

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

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

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

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

    if 5.00000000000000028e257 < (*.f64 c i)

    1. Initial program 69.2%

      \[\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 73.1%

      \[\leadsto \color{blue}{a \cdot b + \left(c \cdot i + x \cdot y\right)} \]
    4. Step-by-step derivation
      1. associate-+r+73.1%

        \[\leadsto \color{blue}{\left(a \cdot b + c \cdot i\right) + x \cdot y} \]
      2. fma-udef84.6%

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

        \[\leadsto \color{blue}{x \cdot y + \mathsf{fma}\left(a, b, c \cdot i\right)} \]
      4. fma-def100.0%

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

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

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

Alternative 2: 96.6% accurate, 0.1× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;c \cdot i \leq 5 \cdot 10^{+257}:\\ \;\;\;\;\mathsf{fma}\left(c, i, \left(a \cdot b + x \cdot y\right) + z \cdot t\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(x, y, \mathsf{fma}\left(a, b, c \cdot i\right)\right)\\ \end{array} \end{array} \]
(FPCore (x y z t a b c i)
 :precision binary64
 (if (<= (* c i) 5e+257)
   (fma c i (+ (+ (* a b) (* x y)) (* z t)))
   (fma x y (fma a b (* 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+257) {
		tmp = fma(c, i, (((a * b) + (x * y)) + (z * t)));
	} else {
		tmp = fma(x, y, fma(a, b, (c * i)));
	}
	return tmp;
}
function code(x, y, z, t, a, b, c, i)
	tmp = 0.0
	if (Float64(c * i) <= 5e+257)
		tmp = fma(c, i, Float64(Float64(Float64(a * b) + Float64(x * y)) + Float64(z * t)));
	else
		tmp = fma(x, y, fma(a, b, Float64(c * i)));
	end
	return tmp
end
code[x_, y_, z_, t_, a_, b_, c_, i_] := If[LessEqual[N[(c * i), $MachinePrecision], 5e+257], N[(c * i + N[(N[(N[(a * b), $MachinePrecision] + N[(x * y), $MachinePrecision]), $MachinePrecision] + N[(z * t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x * y + N[(a * b + N[(c * i), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;c \cdot i \leq 5 \cdot 10^{+257}:\\
\;\;\;\;\mathsf{fma}\left(c, i, \left(a \cdot b + x \cdot y\right) + z \cdot t\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (*.f64 c i) < 5.00000000000000028e257

    1. Initial program 98.2%

      \[\left(\left(x \cdot y + z \cdot t\right) + a \cdot b\right) + c \cdot i \]
    2. Step-by-step derivation
      1. +-commutative98.2%

        \[\leadsto \color{blue}{c \cdot i + \left(\left(x \cdot y + z \cdot t\right) + a \cdot b\right)} \]
      2. fma-def99.1%

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

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

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

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

      \[\leadsto \color{blue}{\mathsf{fma}\left(c, i, \mathsf{fma}\left(a, b, \mathsf{fma}\left(x, y, z \cdot t\right)\right)\right)} \]
    4. Add Preprocessing
    5. Step-by-step derivation
      1. fma-def100.0%

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

        \[\leadsto \mathsf{fma}\left(c, i, \color{blue}{a \cdot b + \left(x \cdot y + z \cdot t\right)}\right) \]
      3. associate-+r+99.1%

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

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

    if 5.00000000000000028e257 < (*.f64 c i)

    1. Initial program 69.2%

      \[\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 73.1%

      \[\leadsto \color{blue}{a \cdot b + \left(c \cdot i + x \cdot y\right)} \]
    4. Step-by-step derivation
      1. associate-+r+73.1%

        \[\leadsto \color{blue}{\left(a \cdot b + c \cdot i\right) + x \cdot y} \]
      2. fma-udef84.6%

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

        \[\leadsto \color{blue}{x \cdot y + \mathsf{fma}\left(a, b, c \cdot i\right)} \]
      4. fma-def100.0%

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

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

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

Alternative 3: 96.8% accurate, 0.1× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;c \cdot i \leq 5 \cdot 10^{+307}:\\ \;\;\;\;\mathsf{fma}\left(c, i, \left(a \cdot b + x \cdot y\right) + z \cdot t\right)\\ \mathbf{else}:\\ \;\;\;\;c \cdot i\\ \end{array} \end{array} \]
(FPCore (x y z t a b c i)
 :precision binary64
 (if (<= (* c i) 5e+307) (fma c i (+ (+ (* a b) (* x y)) (* z t))) (* 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+307) {
		tmp = fma(c, i, (((a * b) + (x * y)) + (z * t)));
	} else {
		tmp = c * i;
	}
	return tmp;
}
function code(x, y, z, t, a, b, c, i)
	tmp = 0.0
	if (Float64(c * i) <= 5e+307)
		tmp = fma(c, i, Float64(Float64(Float64(a * b) + Float64(x * y)) + Float64(z * t)));
	else
		tmp = Float64(c * i);
	end
	return tmp
end
code[x_, y_, z_, t_, a_, b_, c_, i_] := If[LessEqual[N[(c * i), $MachinePrecision], 5e+307], N[(c * i + N[(N[(N[(a * b), $MachinePrecision] + N[(x * y), $MachinePrecision]), $MachinePrecision] + N[(z * t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(c * i), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;c \cdot i \leq 5 \cdot 10^{+307}:\\
\;\;\;\;\mathsf{fma}\left(c, i, \left(a \cdot b + x \cdot y\right) + z \cdot t\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (*.f64 c i) < 5e307

    1. Initial program 98.3%

      \[\left(\left(x \cdot y + z \cdot t\right) + a \cdot b\right) + c \cdot i \]
    2. Step-by-step derivation
      1. +-commutative98.3%

        \[\leadsto \color{blue}{c \cdot i + \left(\left(x \cdot y + z \cdot t\right) + a \cdot b\right)} \]
      2. fma-def99.1%

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

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

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

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

      \[\leadsto \color{blue}{\mathsf{fma}\left(c, i, \mathsf{fma}\left(a, b, \mathsf{fma}\left(x, y, z \cdot t\right)\right)\right)} \]
    4. Add Preprocessing
    5. Step-by-step derivation
      1. fma-def100.0%

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

        \[\leadsto \mathsf{fma}\left(c, i, \color{blue}{a \cdot b + \left(x \cdot y + z \cdot t\right)}\right) \]
      3. associate-+r+99.1%

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

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

    if 5e307 < (*.f64 c i)

    1. Initial program 61.9%

      \[\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 100.0%

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

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

Alternative 4: 61.7% accurate, 0.3× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_1 := a \cdot b + z \cdot t\\ \mathbf{if}\;c \cdot i \leq -1.25 \cdot 10^{+185}:\\ \;\;\;\;c \cdot i\\ \mathbf{elif}\;c \cdot i \leq -3.1 \cdot 10^{+66}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;c \cdot i \leq -8 \cdot 10^{-10}:\\ \;\;\;\;x \cdot y\\ \mathbf{elif}\;c \cdot i \leq 2.55 \cdot 10^{+116} \lor \neg \left(c \cdot i \leq 1.18 \cdot 10^{+138}\right) \land c \cdot i \leq 1.2 \cdot 10^{+193}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;c \cdot i\\ \end{array} \end{array} \]
(FPCore (x y z t a b c i)
 :precision binary64
 (let* ((t_1 (+ (* a b) (* z t))))
   (if (<= (* c i) -1.25e+185)
     (* c i)
     (if (<= (* c i) -3.1e+66)
       t_1
       (if (<= (* c i) -8e-10)
         (* x y)
         (if (or (<= (* c i) 2.55e+116)
                 (and (not (<= (* c i) 1.18e+138)) (<= (* c i) 1.2e+193)))
           t_1
           (* c i)))))))
double code(double x, double y, double z, double t, double a, double b, double c, double i) {
	double t_1 = (a * b) + (z * t);
	double tmp;
	if ((c * i) <= -1.25e+185) {
		tmp = c * i;
	} else if ((c * i) <= -3.1e+66) {
		tmp = t_1;
	} else if ((c * i) <= -8e-10) {
		tmp = x * y;
	} else if (((c * i) <= 2.55e+116) || (!((c * i) <= 1.18e+138) && ((c * i) <= 1.2e+193))) {
		tmp = t_1;
	} else {
		tmp = c * i;
	}
	return tmp;
}
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) :: t_1
    real(8) :: tmp
    t_1 = (a * b) + (z * t)
    if ((c * i) <= (-1.25d+185)) then
        tmp = c * i
    else if ((c * i) <= (-3.1d+66)) then
        tmp = t_1
    else if ((c * i) <= (-8d-10)) then
        tmp = x * y
    else if (((c * i) <= 2.55d+116) .or. (.not. ((c * i) <= 1.18d+138)) .and. ((c * i) <= 1.2d+193)) then
        tmp = t_1
    else
        tmp = c * i
    end if
    code = tmp
end function
public static double code(double x, double y, double z, double t, double a, double b, double c, double i) {
	double t_1 = (a * b) + (z * t);
	double tmp;
	if ((c * i) <= -1.25e+185) {
		tmp = c * i;
	} else if ((c * i) <= -3.1e+66) {
		tmp = t_1;
	} else if ((c * i) <= -8e-10) {
		tmp = x * y;
	} else if (((c * i) <= 2.55e+116) || (!((c * i) <= 1.18e+138) && ((c * i) <= 1.2e+193))) {
		tmp = t_1;
	} else {
		tmp = c * i;
	}
	return tmp;
}
def code(x, y, z, t, a, b, c, i):
	t_1 = (a * b) + (z * t)
	tmp = 0
	if (c * i) <= -1.25e+185:
		tmp = c * i
	elif (c * i) <= -3.1e+66:
		tmp = t_1
	elif (c * i) <= -8e-10:
		tmp = x * y
	elif ((c * i) <= 2.55e+116) or (not ((c * i) <= 1.18e+138) and ((c * i) <= 1.2e+193)):
		tmp = t_1
	else:
		tmp = c * i
	return tmp
function code(x, y, z, t, a, b, c, i)
	t_1 = Float64(Float64(a * b) + Float64(z * t))
	tmp = 0.0
	if (Float64(c * i) <= -1.25e+185)
		tmp = Float64(c * i);
	elseif (Float64(c * i) <= -3.1e+66)
		tmp = t_1;
	elseif (Float64(c * i) <= -8e-10)
		tmp = Float64(x * y);
	elseif ((Float64(c * i) <= 2.55e+116) || (!(Float64(c * i) <= 1.18e+138) && (Float64(c * i) <= 1.2e+193)))
		tmp = t_1;
	else
		tmp = Float64(c * i);
	end
	return tmp
end
function tmp_2 = code(x, y, z, t, a, b, c, i)
	t_1 = (a * b) + (z * t);
	tmp = 0.0;
	if ((c * i) <= -1.25e+185)
		tmp = c * i;
	elseif ((c * i) <= -3.1e+66)
		tmp = t_1;
	elseif ((c * i) <= -8e-10)
		tmp = x * y;
	elseif (((c * i) <= 2.55e+116) || (~(((c * i) <= 1.18e+138)) && ((c * i) <= 1.2e+193)))
		tmp = t_1;
	else
		tmp = c * i;
	end
	tmp_2 = tmp;
end
code[x_, y_, z_, t_, a_, b_, c_, i_] := Block[{t$95$1 = N[(N[(a * b), $MachinePrecision] + N[(z * t), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(c * i), $MachinePrecision], -1.25e+185], N[(c * i), $MachinePrecision], If[LessEqual[N[(c * i), $MachinePrecision], -3.1e+66], t$95$1, If[LessEqual[N[(c * i), $MachinePrecision], -8e-10], N[(x * y), $MachinePrecision], If[Or[LessEqual[N[(c * i), $MachinePrecision], 2.55e+116], And[N[Not[LessEqual[N[(c * i), $MachinePrecision], 1.18e+138]], $MachinePrecision], LessEqual[N[(c * i), $MachinePrecision], 1.2e+193]]], t$95$1, N[(c * i), $MachinePrecision]]]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_1 := a \cdot b + z \cdot t\\
\mathbf{if}\;c \cdot i \leq -1.25 \cdot 10^{+185}:\\
\;\;\;\;c \cdot i\\

\mathbf{elif}\;c \cdot i \leq -3.1 \cdot 10^{+66}:\\
\;\;\;\;t_1\\

\mathbf{elif}\;c \cdot i \leq -8 \cdot 10^{-10}:\\
\;\;\;\;x \cdot y\\

\mathbf{elif}\;c \cdot i \leq 2.55 \cdot 10^{+116} \lor \neg \left(c \cdot i \leq 1.18 \cdot 10^{+138}\right) \land c \cdot i \leq 1.2 \cdot 10^{+193}:\\
\;\;\;\;t_1\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if (*.f64 c i) < -1.24999999999999997e185 or 2.55e116 < (*.f64 c i) < 1.18000000000000007e138 or 1.2e193 < (*.f64 c i)

    1. Initial program 87.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 84.6%

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

    if -1.24999999999999997e185 < (*.f64 c i) < -3.10000000000000019e66 or -8.00000000000000029e-10 < (*.f64 c i) < 2.55e116 or 1.18000000000000007e138 < (*.f64 c i) < 1.2e193

    1. Initial program 98.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 72.7%

      \[\leadsto \color{blue}{\left(a \cdot b + t \cdot z\right)} + c \cdot i \]
    4. Taylor expanded in c around 0 66.7%

      \[\leadsto \color{blue}{a \cdot b + t \cdot z} \]

    if -3.10000000000000019e66 < (*.f64 c i) < -8.00000000000000029e-10

    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. Taylor expanded in x around inf 58.6%

      \[\leadsto \color{blue}{x \cdot y} \]
  3. Recombined 3 regimes into one program.
  4. Final simplification71.4%

    \[\leadsto \begin{array}{l} \mathbf{if}\;c \cdot i \leq -1.25 \cdot 10^{+185}:\\ \;\;\;\;c \cdot i\\ \mathbf{elif}\;c \cdot i \leq -3.1 \cdot 10^{+66}:\\ \;\;\;\;a \cdot b + z \cdot t\\ \mathbf{elif}\;c \cdot i \leq -8 \cdot 10^{-10}:\\ \;\;\;\;x \cdot y\\ \mathbf{elif}\;c \cdot i \leq 2.55 \cdot 10^{+116} \lor \neg \left(c \cdot i \leq 1.18 \cdot 10^{+138}\right) \land c \cdot i \leq 1.2 \cdot 10^{+193}:\\ \;\;\;\;a \cdot b + z \cdot t\\ \mathbf{else}:\\ \;\;\;\;c \cdot i\\ \end{array} \]
  5. Add Preprocessing

Alternative 5: 42.5% accurate, 0.3× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;c \cdot i \leq -8.2 \cdot 10^{+185}:\\ \;\;\;\;c \cdot i\\ \mathbf{elif}\;c \cdot i \leq -1.1 \cdot 10^{-12}:\\ \;\;\;\;x \cdot y\\ \mathbf{elif}\;c \cdot i \leq -2.4 \cdot 10^{-135}:\\ \;\;\;\;z \cdot t\\ \mathbf{elif}\;c \cdot i \leq -2 \cdot 10^{-313}:\\ \;\;\;\;a \cdot b\\ \mathbf{elif}\;c \cdot i \leq 4.4 \cdot 10^{-274}:\\ \;\;\;\;z \cdot t\\ \mathbf{elif}\;c \cdot i \leq 1.55 \cdot 10^{+68}:\\ \;\;\;\;a \cdot b\\ \mathbf{else}:\\ \;\;\;\;c \cdot i\\ \end{array} \end{array} \]
(FPCore (x y z t a b c i)
 :precision binary64
 (if (<= (* c i) -8.2e+185)
   (* c i)
   (if (<= (* c i) -1.1e-12)
     (* x y)
     (if (<= (* c i) -2.4e-135)
       (* z t)
       (if (<= (* c i) -2e-313)
         (* a b)
         (if (<= (* c i) 4.4e-274)
           (* z t)
           (if (<= (* c i) 1.55e+68) (* a b) (* 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) <= -8.2e+185) {
		tmp = c * i;
	} else if ((c * i) <= -1.1e-12) {
		tmp = x * y;
	} else if ((c * i) <= -2.4e-135) {
		tmp = z * t;
	} else if ((c * i) <= -2e-313) {
		tmp = a * b;
	} else if ((c * i) <= 4.4e-274) {
		tmp = z * t;
	} else if ((c * i) <= 1.55e+68) {
		tmp = a * b;
	} else {
		tmp = c * i;
	}
	return tmp;
}
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) <= (-8.2d+185)) then
        tmp = c * i
    else if ((c * i) <= (-1.1d-12)) then
        tmp = x * y
    else if ((c * i) <= (-2.4d-135)) then
        tmp = z * t
    else if ((c * i) <= (-2d-313)) then
        tmp = a * b
    else if ((c * i) <= 4.4d-274) then
        tmp = z * t
    else if ((c * i) <= 1.55d+68) then
        tmp = a * b
    else
        tmp = c * i
    end if
    code = tmp
end function
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) <= -8.2e+185) {
		tmp = c * i;
	} else if ((c * i) <= -1.1e-12) {
		tmp = x * y;
	} else if ((c * i) <= -2.4e-135) {
		tmp = z * t;
	} else if ((c * i) <= -2e-313) {
		tmp = a * b;
	} else if ((c * i) <= 4.4e-274) {
		tmp = z * t;
	} else if ((c * i) <= 1.55e+68) {
		tmp = a * b;
	} else {
		tmp = c * i;
	}
	return tmp;
}
def code(x, y, z, t, a, b, c, i):
	tmp = 0
	if (c * i) <= -8.2e+185:
		tmp = c * i
	elif (c * i) <= -1.1e-12:
		tmp = x * y
	elif (c * i) <= -2.4e-135:
		tmp = z * t
	elif (c * i) <= -2e-313:
		tmp = a * b
	elif (c * i) <= 4.4e-274:
		tmp = z * t
	elif (c * i) <= 1.55e+68:
		tmp = a * b
	else:
		tmp = c * i
	return tmp
function code(x, y, z, t, a, b, c, i)
	tmp = 0.0
	if (Float64(c * i) <= -8.2e+185)
		tmp = Float64(c * i);
	elseif (Float64(c * i) <= -1.1e-12)
		tmp = Float64(x * y);
	elseif (Float64(c * i) <= -2.4e-135)
		tmp = Float64(z * t);
	elseif (Float64(c * i) <= -2e-313)
		tmp = Float64(a * b);
	elseif (Float64(c * i) <= 4.4e-274)
		tmp = Float64(z * t);
	elseif (Float64(c * i) <= 1.55e+68)
		tmp = Float64(a * b);
	else
		tmp = Float64(c * i);
	end
	return tmp
end
function tmp_2 = code(x, y, z, t, a, b, c, i)
	tmp = 0.0;
	if ((c * i) <= -8.2e+185)
		tmp = c * i;
	elseif ((c * i) <= -1.1e-12)
		tmp = x * y;
	elseif ((c * i) <= -2.4e-135)
		tmp = z * t;
	elseif ((c * i) <= -2e-313)
		tmp = a * b;
	elseif ((c * i) <= 4.4e-274)
		tmp = z * t;
	elseif ((c * i) <= 1.55e+68)
		tmp = a * b;
	else
		tmp = c * i;
	end
	tmp_2 = tmp;
end
code[x_, y_, z_, t_, a_, b_, c_, i_] := If[LessEqual[N[(c * i), $MachinePrecision], -8.2e+185], N[(c * i), $MachinePrecision], If[LessEqual[N[(c * i), $MachinePrecision], -1.1e-12], N[(x * y), $MachinePrecision], If[LessEqual[N[(c * i), $MachinePrecision], -2.4e-135], N[(z * t), $MachinePrecision], If[LessEqual[N[(c * i), $MachinePrecision], -2e-313], N[(a * b), $MachinePrecision], If[LessEqual[N[(c * i), $MachinePrecision], 4.4e-274], N[(z * t), $MachinePrecision], If[LessEqual[N[(c * i), $MachinePrecision], 1.55e+68], N[(a * b), $MachinePrecision], N[(c * i), $MachinePrecision]]]]]]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;c \cdot i \leq -8.2 \cdot 10^{+185}:\\
\;\;\;\;c \cdot i\\

\mathbf{elif}\;c \cdot i \leq -1.1 \cdot 10^{-12}:\\
\;\;\;\;x \cdot y\\

\mathbf{elif}\;c \cdot i \leq -2.4 \cdot 10^{-135}:\\
\;\;\;\;z \cdot t\\

\mathbf{elif}\;c \cdot i \leq -2 \cdot 10^{-313}:\\
\;\;\;\;a \cdot b\\

\mathbf{elif}\;c \cdot i \leq 4.4 \cdot 10^{-274}:\\
\;\;\;\;z \cdot t\\

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if (*.f64 c i) < -8.2e185 or 1.5499999999999999e68 < (*.f64 c i)

    1. Initial program 88.4%

      \[\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 73.0%

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

    if -8.2e185 < (*.f64 c i) < -1.09999999999999996e-12

    1. Initial program 97.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 inf 46.9%

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

    if -1.09999999999999996e-12 < (*.f64 c i) < -2.3999999999999999e-135 or -1.99999999998e-313 < (*.f64 c i) < 4.3999999999999999e-274

    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. Taylor expanded in z around inf 50.9%

      \[\leadsto \color{blue}{t \cdot z} \]

    if -2.3999999999999999e-135 < (*.f64 c i) < -1.99999999998e-313 or 4.3999999999999999e-274 < (*.f64 c i) < 1.5499999999999999e68

    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. Taylor expanded in a around inf 43.1%

      \[\leadsto \color{blue}{a \cdot b} \]
  3. Recombined 4 regimes into one program.
  4. Final simplification56.1%

    \[\leadsto \begin{array}{l} \mathbf{if}\;c \cdot i \leq -8.2 \cdot 10^{+185}:\\ \;\;\;\;c \cdot i\\ \mathbf{elif}\;c \cdot i \leq -1.1 \cdot 10^{-12}:\\ \;\;\;\;x \cdot y\\ \mathbf{elif}\;c \cdot i \leq -2.4 \cdot 10^{-135}:\\ \;\;\;\;z \cdot t\\ \mathbf{elif}\;c \cdot i \leq -2 \cdot 10^{-313}:\\ \;\;\;\;a \cdot b\\ \mathbf{elif}\;c \cdot i \leq 4.4 \cdot 10^{-274}:\\ \;\;\;\;z \cdot t\\ \mathbf{elif}\;c \cdot i \leq 1.55 \cdot 10^{+68}:\\ \;\;\;\;a \cdot b\\ \mathbf{else}:\\ \;\;\;\;c \cdot i\\ \end{array} \]
  5. Add Preprocessing

Alternative 6: 84.7% accurate, 0.4× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;c \cdot i \leq -6.3 \cdot 10^{+190}:\\ \;\;\;\;c \cdot i + x \cdot y\\ \mathbf{elif}\;c \cdot i \leq 1.45 \cdot 10^{+69} \lor \neg \left(c \cdot i \leq 2.45 \cdot 10^{+134}\right) \land c \cdot i \leq 1.3 \cdot 10^{+195}:\\ \;\;\;\;a \cdot b + \left(x \cdot y + z \cdot t\right)\\ \mathbf{else}:\\ \;\;\;\;c \cdot i + z \cdot t\\ \end{array} \end{array} \]
(FPCore (x y z t a b c i)
 :precision binary64
 (if (<= (* c i) -6.3e+190)
   (+ (* c i) (* x y))
   (if (or (<= (* c i) 1.45e+69)
           (and (not (<= (* c i) 2.45e+134)) (<= (* c i) 1.3e+195)))
     (+ (* a b) (+ (* x y) (* z t)))
     (+ (* c i) (* z t)))))
double code(double x, double y, double z, double t, double a, double b, double c, double i) {
	double tmp;
	if ((c * i) <= -6.3e+190) {
		tmp = (c * i) + (x * y);
	} else if (((c * i) <= 1.45e+69) || (!((c * i) <= 2.45e+134) && ((c * i) <= 1.3e+195))) {
		tmp = (a * b) + ((x * y) + (z * t));
	} else {
		tmp = (c * i) + (z * t);
	}
	return tmp;
}
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) <= (-6.3d+190)) then
        tmp = (c * i) + (x * y)
    else if (((c * i) <= 1.45d+69) .or. (.not. ((c * i) <= 2.45d+134)) .and. ((c * i) <= 1.3d+195)) then
        tmp = (a * b) + ((x * y) + (z * t))
    else
        tmp = (c * i) + (z * t)
    end if
    code = tmp
end function
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) <= -6.3e+190) {
		tmp = (c * i) + (x * y);
	} else if (((c * i) <= 1.45e+69) || (!((c * i) <= 2.45e+134) && ((c * i) <= 1.3e+195))) {
		tmp = (a * b) + ((x * y) + (z * t));
	} else {
		tmp = (c * i) + (z * t);
	}
	return tmp;
}
def code(x, y, z, t, a, b, c, i):
	tmp = 0
	if (c * i) <= -6.3e+190:
		tmp = (c * i) + (x * y)
	elif ((c * i) <= 1.45e+69) or (not ((c * i) <= 2.45e+134) and ((c * i) <= 1.3e+195)):
		tmp = (a * b) + ((x * y) + (z * t))
	else:
		tmp = (c * i) + (z * t)
	return tmp
function code(x, y, z, t, a, b, c, i)
	tmp = 0.0
	if (Float64(c * i) <= -6.3e+190)
		tmp = Float64(Float64(c * i) + Float64(x * y));
	elseif ((Float64(c * i) <= 1.45e+69) || (!(Float64(c * i) <= 2.45e+134) && (Float64(c * i) <= 1.3e+195)))
		tmp = Float64(Float64(a * b) + Float64(Float64(x * y) + Float64(z * t)));
	else
		tmp = Float64(Float64(c * i) + Float64(z * t));
	end
	return tmp
end
function tmp_2 = code(x, y, z, t, a, b, c, i)
	tmp = 0.0;
	if ((c * i) <= -6.3e+190)
		tmp = (c * i) + (x * y);
	elseif (((c * i) <= 1.45e+69) || (~(((c * i) <= 2.45e+134)) && ((c * i) <= 1.3e+195)))
		tmp = (a * b) + ((x * y) + (z * t));
	else
		tmp = (c * i) + (z * t);
	end
	tmp_2 = tmp;
end
code[x_, y_, z_, t_, a_, b_, c_, i_] := If[LessEqual[N[(c * i), $MachinePrecision], -6.3e+190], N[(N[(c * i), $MachinePrecision] + N[(x * y), $MachinePrecision]), $MachinePrecision], If[Or[LessEqual[N[(c * i), $MachinePrecision], 1.45e+69], And[N[Not[LessEqual[N[(c * i), $MachinePrecision], 2.45e+134]], $MachinePrecision], LessEqual[N[(c * i), $MachinePrecision], 1.3e+195]]], N[(N[(a * b), $MachinePrecision] + N[(N[(x * y), $MachinePrecision] + N[(z * t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(c * i), $MachinePrecision] + N[(z * t), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;c \cdot i \leq -6.3 \cdot 10^{+190}:\\
\;\;\;\;c \cdot i + x \cdot y\\

\mathbf{elif}\;c \cdot i \leq 1.45 \cdot 10^{+69} \lor \neg \left(c \cdot i \leq 2.45 \cdot 10^{+134}\right) \land c \cdot i \leq 1.3 \cdot 10^{+195}:\\
\;\;\;\;a \cdot b + \left(x \cdot y + z \cdot t\right)\\

\mathbf{else}:\\
\;\;\;\;c \cdot i + z \cdot t\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if (*.f64 c i) < -6.3000000000000002e190

    1. Initial program 94.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 0 91.7%

      \[\leadsto \color{blue}{\left(t \cdot z + x \cdot y\right)} + c \cdot i \]
    4. Taylor expanded in t around 0 88.9%

      \[\leadsto \color{blue}{c \cdot i + x \cdot y} \]

    if -6.3000000000000002e190 < (*.f64 c i) < 1.4499999999999999e69 or 2.44999999999999998e134 < (*.f64 c i) < 1.30000000000000001e195

    1. Initial program 99.4%

      \[\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 92.8%

      \[\leadsto \color{blue}{a \cdot b + \left(t \cdot z + x \cdot y\right)} \]

    if 1.4499999999999999e69 < (*.f64 c i) < 2.44999999999999998e134 or 1.30000000000000001e195 < (*.f64 c i)

    1. Initial program 81.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 0 85.6%

      \[\leadsto \color{blue}{\left(t \cdot z + x \cdot y\right)} + c \cdot i \]
    4. Taylor expanded in x around 0 90.2%

      \[\leadsto \color{blue}{c \cdot i + t \cdot z} \]
  3. Recombined 3 regimes into one program.
  4. Final simplification91.8%

    \[\leadsto \begin{array}{l} \mathbf{if}\;c \cdot i \leq -6.3 \cdot 10^{+190}:\\ \;\;\;\;c \cdot i + x \cdot y\\ \mathbf{elif}\;c \cdot i \leq 1.45 \cdot 10^{+69} \lor \neg \left(c \cdot i \leq 2.45 \cdot 10^{+134}\right) \land c \cdot i \leq 1.3 \cdot 10^{+195}:\\ \;\;\;\;a \cdot b + \left(x \cdot y + z \cdot t\right)\\ \mathbf{else}:\\ \;\;\;\;c \cdot i + z \cdot t\\ \end{array} \]
  5. Add Preprocessing

Alternative 7: 61.1% accurate, 0.4× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \cdot y \leq -4.5 \cdot 10^{+270}:\\ \;\;\;\;x \cdot y\\ \mathbf{elif}\;x \cdot y \leq -1.55 \cdot 10^{+159} \lor \neg \left(x \cdot y \leq -5 \cdot 10^{+74}\right) \land x \cdot y \leq 2.1 \cdot 10^{-168}:\\ \;\;\;\;c \cdot i + z \cdot t\\ \mathbf{else}:\\ \;\;\;\;a \cdot b + x \cdot y\\ \end{array} \end{array} \]
(FPCore (x y z t a b c i)
 :precision binary64
 (if (<= (* x y) -4.5e+270)
   (* x y)
   (if (or (<= (* x y) -1.55e+159)
           (and (not (<= (* x y) -5e+74)) (<= (* x y) 2.1e-168)))
     (+ (* c i) (* z t))
     (+ (* a b) (* x y)))))
double code(double x, double y, double z, double t, double a, double b, double c, double i) {
	double tmp;
	if ((x * y) <= -4.5e+270) {
		tmp = x * y;
	} else if (((x * y) <= -1.55e+159) || (!((x * y) <= -5e+74) && ((x * y) <= 2.1e-168))) {
		tmp = (c * i) + (z * t);
	} else {
		tmp = (a * b) + (x * y);
	}
	return tmp;
}
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 ((x * y) <= (-4.5d+270)) then
        tmp = x * y
    else if (((x * y) <= (-1.55d+159)) .or. (.not. ((x * y) <= (-5d+74))) .and. ((x * y) <= 2.1d-168)) then
        tmp = (c * i) + (z * t)
    else
        tmp = (a * b) + (x * y)
    end if
    code = tmp
end function
public static double code(double x, double y, double z, double t, double a, double b, double c, double i) {
	double tmp;
	if ((x * y) <= -4.5e+270) {
		tmp = x * y;
	} else if (((x * y) <= -1.55e+159) || (!((x * y) <= -5e+74) && ((x * y) <= 2.1e-168))) {
		tmp = (c * i) + (z * t);
	} else {
		tmp = (a * b) + (x * y);
	}
	return tmp;
}
def code(x, y, z, t, a, b, c, i):
	tmp = 0
	if (x * y) <= -4.5e+270:
		tmp = x * y
	elif ((x * y) <= -1.55e+159) or (not ((x * y) <= -5e+74) and ((x * y) <= 2.1e-168)):
		tmp = (c * i) + (z * t)
	else:
		tmp = (a * b) + (x * y)
	return tmp
function code(x, y, z, t, a, b, c, i)
	tmp = 0.0
	if (Float64(x * y) <= -4.5e+270)
		tmp = Float64(x * y);
	elseif ((Float64(x * y) <= -1.55e+159) || (!(Float64(x * y) <= -5e+74) && (Float64(x * y) <= 2.1e-168)))
		tmp = Float64(Float64(c * i) + Float64(z * t));
	else
		tmp = Float64(Float64(a * b) + Float64(x * y));
	end
	return tmp
end
function tmp_2 = code(x, y, z, t, a, b, c, i)
	tmp = 0.0;
	if ((x * y) <= -4.5e+270)
		tmp = x * y;
	elseif (((x * y) <= -1.55e+159) || (~(((x * y) <= -5e+74)) && ((x * y) <= 2.1e-168)))
		tmp = (c * i) + (z * t);
	else
		tmp = (a * b) + (x * y);
	end
	tmp_2 = tmp;
end
code[x_, y_, z_, t_, a_, b_, c_, i_] := If[LessEqual[N[(x * y), $MachinePrecision], -4.5e+270], N[(x * y), $MachinePrecision], If[Or[LessEqual[N[(x * y), $MachinePrecision], -1.55e+159], And[N[Not[LessEqual[N[(x * y), $MachinePrecision], -5e+74]], $MachinePrecision], LessEqual[N[(x * y), $MachinePrecision], 2.1e-168]]], N[(N[(c * i), $MachinePrecision] + N[(z * t), $MachinePrecision]), $MachinePrecision], N[(N[(a * b), $MachinePrecision] + N[(x * y), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;x \cdot y \leq -4.5 \cdot 10^{+270}:\\
\;\;\;\;x \cdot y\\

\mathbf{elif}\;x \cdot y \leq -1.55 \cdot 10^{+159} \lor \neg \left(x \cdot y \leq -5 \cdot 10^{+74}\right) \land x \cdot y \leq 2.1 \cdot 10^{-168}:\\
\;\;\;\;c \cdot i + z \cdot t\\

\mathbf{else}:\\
\;\;\;\;a \cdot b + x \cdot y\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if (*.f64 x y) < -4.5000000000000004e270

    1. Initial program 78.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 78.3%

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

    if -4.5000000000000004e270 < (*.f64 x y) < -1.5499999999999999e159 or -4.99999999999999963e74 < (*.f64 x y) < 2.09999999999999994e-168

    1. Initial program 98.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 0 80.9%

      \[\leadsto \color{blue}{\left(t \cdot z + x \cdot y\right)} + c \cdot i \]
    4. Taylor expanded in x around 0 75.8%

      \[\leadsto \color{blue}{c \cdot i + t \cdot z} \]

    if -1.5499999999999999e159 < (*.f64 x y) < -4.99999999999999963e74 or 2.09999999999999994e-168 < (*.f64 x y)

    1. Initial program 95.5%

      \[\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 88.6%

      \[\leadsto \color{blue}{a \cdot b + \left(c \cdot i + x \cdot y\right)} \]
    4. Step-by-step derivation
      1. associate-+r+88.6%

        \[\leadsto \color{blue}{\left(a \cdot b + c \cdot i\right) + x \cdot y} \]
      2. fma-udef90.4%

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

        \[\leadsto \color{blue}{x \cdot y + \mathsf{fma}\left(a, b, c \cdot i\right)} \]
      4. fma-def90.4%

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

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

      \[\leadsto \color{blue}{a \cdot b + x \cdot y} \]
  3. Recombined 3 regimes into one program.
  4. Final simplification74.8%

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \cdot y \leq -4.5 \cdot 10^{+270}:\\ \;\;\;\;x \cdot y\\ \mathbf{elif}\;x \cdot y \leq -1.55 \cdot 10^{+159} \lor \neg \left(x \cdot y \leq -5 \cdot 10^{+74}\right) \land x \cdot y \leq 2.1 \cdot 10^{-168}:\\ \;\;\;\;c \cdot i + z \cdot t\\ \mathbf{else}:\\ \;\;\;\;a \cdot b + x \cdot y\\ \end{array} \]
  5. Add Preprocessing

Alternative 8: 97.0% accurate, 0.4× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_1 := c \cdot i + \left(a \cdot b + \left(x \cdot y + z \cdot t\right)\right)\\ \mathbf{if}\;t_1 \leq \infty:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;c \cdot i\\ \end{array} \end{array} \]
(FPCore (x y z t a b c i)
 :precision binary64
 (let* ((t_1 (+ (* c i) (+ (* a b) (+ (* x y) (* z t))))))
   (if (<= t_1 INFINITY) t_1 (* c i))))
double code(double x, double y, double z, double t, double a, double b, double c, double i) {
	double t_1 = (c * i) + ((a * b) + ((x * y) + (z * t)));
	double tmp;
	if (t_1 <= ((double) INFINITY)) {
		tmp = t_1;
	} else {
		tmp = c * i;
	}
	return tmp;
}
public static double code(double x, double y, double z, double t, double a, double b, double c, double i) {
	double t_1 = (c * i) + ((a * b) + ((x * y) + (z * t)));
	double tmp;
	if (t_1 <= Double.POSITIVE_INFINITY) {
		tmp = t_1;
	} else {
		tmp = c * i;
	}
	return tmp;
}
def code(x, y, z, t, a, b, c, i):
	t_1 = (c * i) + ((a * b) + ((x * y) + (z * t)))
	tmp = 0
	if t_1 <= math.inf:
		tmp = t_1
	else:
		tmp = c * i
	return tmp
function code(x, y, z, t, a, b, c, i)
	t_1 = Float64(Float64(c * i) + Float64(Float64(a * b) + Float64(Float64(x * y) + Float64(z * t))))
	tmp = 0.0
	if (t_1 <= Inf)
		tmp = t_1;
	else
		tmp = Float64(c * i);
	end
	return tmp
end
function tmp_2 = code(x, y, z, t, a, b, c, i)
	t_1 = (c * i) + ((a * b) + ((x * y) + (z * t)));
	tmp = 0.0;
	if (t_1 <= Inf)
		tmp = t_1;
	else
		tmp = c * i;
	end
	tmp_2 = tmp;
end
code[x_, y_, z_, t_, a_, b_, c_, i_] := Block[{t$95$1 = N[(N[(c * i), $MachinePrecision] + N[(N[(a * b), $MachinePrecision] + N[(N[(x * y), $MachinePrecision] + N[(z * t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$1, Infinity], t$95$1, N[(c * i), $MachinePrecision]]]
\begin{array}{l}

\\
\begin{array}{l}
t_1 := c \cdot i + \left(a \cdot b + \left(x \cdot y + z \cdot t\right)\right)\\
\mathbf{if}\;t_1 \leq \infty:\\
\;\;\;\;t_1\\

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


\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 67.4%

      \[\leadsto \color{blue}{c \cdot i} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification98.5%

    \[\leadsto \begin{array}{l} \mathbf{if}\;c \cdot i + \left(a \cdot b + \left(x \cdot y + z \cdot t\right)\right) \leq \infty:\\ \;\;\;\;c \cdot i + \left(a \cdot b + \left(x \cdot y + z \cdot t\right)\right)\\ \mathbf{else}:\\ \;\;\;\;c \cdot i\\ \end{array} \]
  5. Add Preprocessing

Alternative 9: 54.3% accurate, 0.6× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_1 := a \cdot b + z \cdot t\\ \mathbf{if}\;i \leq -1.66 \cdot 10^{-9}:\\ \;\;\;\;c \cdot i\\ \mathbf{elif}\;i \leq 3 \cdot 10^{-302}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;i \leq 4.8 \cdot 10^{+70}:\\ \;\;\;\;a \cdot b + x \cdot y\\ \mathbf{elif}\;i \leq 7.6 \cdot 10^{+192}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;c \cdot i\\ \end{array} \end{array} \]
(FPCore (x y z t a b c i)
 :precision binary64
 (let* ((t_1 (+ (* a b) (* z t))))
   (if (<= i -1.66e-9)
     (* c i)
     (if (<= i 3e-302)
       t_1
       (if (<= i 4.8e+70)
         (+ (* a b) (* x y))
         (if (<= i 7.6e+192) t_1 (* c i)))))))
double code(double x, double y, double z, double t, double a, double b, double c, double i) {
	double t_1 = (a * b) + (z * t);
	double tmp;
	if (i <= -1.66e-9) {
		tmp = c * i;
	} else if (i <= 3e-302) {
		tmp = t_1;
	} else if (i <= 4.8e+70) {
		tmp = (a * b) + (x * y);
	} else if (i <= 7.6e+192) {
		tmp = t_1;
	} else {
		tmp = c * i;
	}
	return tmp;
}
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) :: t_1
    real(8) :: tmp
    t_1 = (a * b) + (z * t)
    if (i <= (-1.66d-9)) then
        tmp = c * i
    else if (i <= 3d-302) then
        tmp = t_1
    else if (i <= 4.8d+70) then
        tmp = (a * b) + (x * y)
    else if (i <= 7.6d+192) then
        tmp = t_1
    else
        tmp = c * i
    end if
    code = tmp
end function
public static double code(double x, double y, double z, double t, double a, double b, double c, double i) {
	double t_1 = (a * b) + (z * t);
	double tmp;
	if (i <= -1.66e-9) {
		tmp = c * i;
	} else if (i <= 3e-302) {
		tmp = t_1;
	} else if (i <= 4.8e+70) {
		tmp = (a * b) + (x * y);
	} else if (i <= 7.6e+192) {
		tmp = t_1;
	} else {
		tmp = c * i;
	}
	return tmp;
}
def code(x, y, z, t, a, b, c, i):
	t_1 = (a * b) + (z * t)
	tmp = 0
	if i <= -1.66e-9:
		tmp = c * i
	elif i <= 3e-302:
		tmp = t_1
	elif i <= 4.8e+70:
		tmp = (a * b) + (x * y)
	elif i <= 7.6e+192:
		tmp = t_1
	else:
		tmp = c * i
	return tmp
function code(x, y, z, t, a, b, c, i)
	t_1 = Float64(Float64(a * b) + Float64(z * t))
	tmp = 0.0
	if (i <= -1.66e-9)
		tmp = Float64(c * i);
	elseif (i <= 3e-302)
		tmp = t_1;
	elseif (i <= 4.8e+70)
		tmp = Float64(Float64(a * b) + Float64(x * y));
	elseif (i <= 7.6e+192)
		tmp = t_1;
	else
		tmp = Float64(c * i);
	end
	return tmp
end
function tmp_2 = code(x, y, z, t, a, b, c, i)
	t_1 = (a * b) + (z * t);
	tmp = 0.0;
	if (i <= -1.66e-9)
		tmp = c * i;
	elseif (i <= 3e-302)
		tmp = t_1;
	elseif (i <= 4.8e+70)
		tmp = (a * b) + (x * y);
	elseif (i <= 7.6e+192)
		tmp = t_1;
	else
		tmp = c * i;
	end
	tmp_2 = tmp;
end
code[x_, y_, z_, t_, a_, b_, c_, i_] := Block[{t$95$1 = N[(N[(a * b), $MachinePrecision] + N[(z * t), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[i, -1.66e-9], N[(c * i), $MachinePrecision], If[LessEqual[i, 3e-302], t$95$1, If[LessEqual[i, 4.8e+70], N[(N[(a * b), $MachinePrecision] + N[(x * y), $MachinePrecision]), $MachinePrecision], If[LessEqual[i, 7.6e+192], t$95$1, N[(c * i), $MachinePrecision]]]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_1 := a \cdot b + z \cdot t\\
\mathbf{if}\;i \leq -1.66 \cdot 10^{-9}:\\
\;\;\;\;c \cdot i\\

\mathbf{elif}\;i \leq 3 \cdot 10^{-302}:\\
\;\;\;\;t_1\\

\mathbf{elif}\;i \leq 4.8 \cdot 10^{+70}:\\
\;\;\;\;a \cdot b + x \cdot y\\

\mathbf{elif}\;i \leq 7.6 \cdot 10^{+192}:\\
\;\;\;\;t_1\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if i < -1.6600000000000001e-9 or 7.5999999999999999e192 < i

    1. Initial program 90.9%

      \[\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 55.2%

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

    if -1.6600000000000001e-9 < i < 2.99999999999999989e-302 or 4.79999999999999974e70 < i < 7.5999999999999999e192

    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. Taylor expanded in x around 0 76.6%

      \[\leadsto \color{blue}{\left(a \cdot b + t \cdot z\right)} + c \cdot i \]
    4. Taylor expanded in c around 0 61.3%

      \[\leadsto \color{blue}{a \cdot b + t \cdot z} \]

    if 2.99999999999999989e-302 < i < 4.79999999999999974e70

    1. Initial program 97.5%

      \[\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 78.0%

      \[\leadsto \color{blue}{a \cdot b + \left(c \cdot i + x \cdot y\right)} \]
    4. Step-by-step derivation
      1. associate-+r+78.0%

        \[\leadsto \color{blue}{\left(a \cdot b + c \cdot i\right) + x \cdot y} \]
      2. fma-udef79.3%

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

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

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

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

      \[\leadsto \color{blue}{a \cdot b + x \cdot y} \]
  3. Recombined 3 regimes into one program.
  4. Final simplification58.4%

    \[\leadsto \begin{array}{l} \mathbf{if}\;i \leq -1.66 \cdot 10^{-9}:\\ \;\;\;\;c \cdot i\\ \mathbf{elif}\;i \leq 3 \cdot 10^{-302}:\\ \;\;\;\;a \cdot b + z \cdot t\\ \mathbf{elif}\;i \leq 4.8 \cdot 10^{+70}:\\ \;\;\;\;a \cdot b + x \cdot y\\ \mathbf{elif}\;i \leq 7.6 \cdot 10^{+192}:\\ \;\;\;\;a \cdot b + z \cdot t\\ \mathbf{else}:\\ \;\;\;\;c \cdot i\\ \end{array} \]
  5. Add Preprocessing

Alternative 10: 86.6% accurate, 0.6× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;c \cdot i \leq -5.5 \cdot 10^{+186}:\\ \;\;\;\;c \cdot i + x \cdot y\\ \mathbf{elif}\;c \cdot i \leq 1.18 \cdot 10^{+57}:\\ \;\;\;\;a \cdot b + \left(x \cdot y + z \cdot t\right)\\ \mathbf{else}:\\ \;\;\;\;c \cdot i + \left(a \cdot b + z \cdot t\right)\\ \end{array} \end{array} \]
(FPCore (x y z t a b c i)
 :precision binary64
 (if (<= (* c i) -5.5e+186)
   (+ (* c i) (* x y))
   (if (<= (* c i) 1.18e+57)
     (+ (* a b) (+ (* x y) (* z t)))
     (+ (* c i) (+ (* a b) (* z t))))))
double code(double x, double y, double z, double t, double a, double b, double c, double i) {
	double tmp;
	if ((c * i) <= -5.5e+186) {
		tmp = (c * i) + (x * y);
	} else if ((c * i) <= 1.18e+57) {
		tmp = (a * b) + ((x * y) + (z * t));
	} else {
		tmp = (c * i) + ((a * b) + (z * t));
	}
	return tmp;
}
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) <= (-5.5d+186)) then
        tmp = (c * i) + (x * y)
    else if ((c * i) <= 1.18d+57) then
        tmp = (a * b) + ((x * y) + (z * t))
    else
        tmp = (c * i) + ((a * b) + (z * t))
    end if
    code = tmp
end function
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) <= -5.5e+186) {
		tmp = (c * i) + (x * y);
	} else if ((c * i) <= 1.18e+57) {
		tmp = (a * b) + ((x * y) + (z * t));
	} else {
		tmp = (c * i) + ((a * b) + (z * t));
	}
	return tmp;
}
def code(x, y, z, t, a, b, c, i):
	tmp = 0
	if (c * i) <= -5.5e+186:
		tmp = (c * i) + (x * y)
	elif (c * i) <= 1.18e+57:
		tmp = (a * b) + ((x * y) + (z * t))
	else:
		tmp = (c * i) + ((a * b) + (z * t))
	return tmp
function code(x, y, z, t, a, b, c, i)
	tmp = 0.0
	if (Float64(c * i) <= -5.5e+186)
		tmp = Float64(Float64(c * i) + Float64(x * y));
	elseif (Float64(c * i) <= 1.18e+57)
		tmp = Float64(Float64(a * b) + Float64(Float64(x * y) + Float64(z * t)));
	else
		tmp = Float64(Float64(c * i) + Float64(Float64(a * b) + Float64(z * t)));
	end
	return tmp
end
function tmp_2 = code(x, y, z, t, a, b, c, i)
	tmp = 0.0;
	if ((c * i) <= -5.5e+186)
		tmp = (c * i) + (x * y);
	elseif ((c * i) <= 1.18e+57)
		tmp = (a * b) + ((x * y) + (z * t));
	else
		tmp = (c * i) + ((a * b) + (z * t));
	end
	tmp_2 = tmp;
end
code[x_, y_, z_, t_, a_, b_, c_, i_] := If[LessEqual[N[(c * i), $MachinePrecision], -5.5e+186], N[(N[(c * i), $MachinePrecision] + N[(x * y), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(c * i), $MachinePrecision], 1.18e+57], N[(N[(a * b), $MachinePrecision] + N[(N[(x * y), $MachinePrecision] + N[(z * t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(c * i), $MachinePrecision] + N[(N[(a * b), $MachinePrecision] + N[(z * t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;c \cdot i \leq -5.5 \cdot 10^{+186}:\\
\;\;\;\;c \cdot i + x \cdot y\\

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

\mathbf{else}:\\
\;\;\;\;c \cdot i + \left(a \cdot b + z \cdot t\right)\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if (*.f64 c i) < -5.4999999999999996e186

    1. Initial program 94.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 0 91.7%

      \[\leadsto \color{blue}{\left(t \cdot z + x \cdot y\right)} + c \cdot i \]
    4. Taylor expanded in t around 0 88.9%

      \[\leadsto \color{blue}{c \cdot i + x \cdot y} \]

    if -5.4999999999999996e186 < (*.f64 c i) < 1.18e57

    1. Initial program 99.3%

      \[\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 93.1%

      \[\leadsto \color{blue}{a \cdot b + \left(t \cdot z + x \cdot y\right)} \]

    if 1.18e57 < (*.f64 c i)

    1. Initial program 85.5%

      \[\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 82.7%

      \[\leadsto \color{blue}{\left(a \cdot b + t \cdot z\right)} + c \cdot i \]
  3. Recombined 3 regimes into one program.
  4. Final simplification90.0%

    \[\leadsto \begin{array}{l} \mathbf{if}\;c \cdot i \leq -5.5 \cdot 10^{+186}:\\ \;\;\;\;c \cdot i + x \cdot y\\ \mathbf{elif}\;c \cdot i \leq 1.18 \cdot 10^{+57}:\\ \;\;\;\;a \cdot b + \left(x \cdot y + z \cdot t\right)\\ \mathbf{else}:\\ \;\;\;\;c \cdot i + \left(a \cdot b + z \cdot t\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 11: 88.0% accurate, 0.6× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_1 := x \cdot y + z \cdot t\\ \mathbf{if}\;a \cdot b \leq -1.75 \cdot 10^{-5}:\\ \;\;\;\;c \cdot i + \left(a \cdot b + z \cdot t\right)\\ \mathbf{elif}\;a \cdot b \leq 4.1 \cdot 10^{+49}:\\ \;\;\;\;c \cdot i + t_1\\ \mathbf{else}:\\ \;\;\;\;a \cdot b + t_1\\ \end{array} \end{array} \]
(FPCore (x y z t a b c i)
 :precision binary64
 (let* ((t_1 (+ (* x y) (* z t))))
   (if (<= (* a b) -1.75e-5)
     (+ (* c i) (+ (* a b) (* z t)))
     (if (<= (* a b) 4.1e+49) (+ (* c i) t_1) (+ (* a b) t_1)))))
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);
	double tmp;
	if ((a * b) <= -1.75e-5) {
		tmp = (c * i) + ((a * b) + (z * t));
	} else if ((a * b) <= 4.1e+49) {
		tmp = (c * i) + t_1;
	} else {
		tmp = (a * b) + t_1;
	}
	return tmp;
}
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) :: t_1
    real(8) :: tmp
    t_1 = (x * y) + (z * t)
    if ((a * b) <= (-1.75d-5)) then
        tmp = (c * i) + ((a * b) + (z * t))
    else if ((a * b) <= 4.1d+49) then
        tmp = (c * i) + t_1
    else
        tmp = (a * b) + t_1
    end if
    code = tmp
end function
public static 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);
	double tmp;
	if ((a * b) <= -1.75e-5) {
		tmp = (c * i) + ((a * b) + (z * t));
	} else if ((a * b) <= 4.1e+49) {
		tmp = (c * i) + t_1;
	} else {
		tmp = (a * b) + t_1;
	}
	return tmp;
}
def code(x, y, z, t, a, b, c, i):
	t_1 = (x * y) + (z * t)
	tmp = 0
	if (a * b) <= -1.75e-5:
		tmp = (c * i) + ((a * b) + (z * t))
	elif (a * b) <= 4.1e+49:
		tmp = (c * i) + t_1
	else:
		tmp = (a * b) + t_1
	return tmp
function code(x, y, z, t, a, b, c, i)
	t_1 = Float64(Float64(x * y) + Float64(z * t))
	tmp = 0.0
	if (Float64(a * b) <= -1.75e-5)
		tmp = Float64(Float64(c * i) + Float64(Float64(a * b) + Float64(z * t)));
	elseif (Float64(a * b) <= 4.1e+49)
		tmp = Float64(Float64(c * i) + t_1);
	else
		tmp = Float64(Float64(a * b) + t_1);
	end
	return tmp
end
function tmp_2 = code(x, y, z, t, a, b, c, i)
	t_1 = (x * y) + (z * t);
	tmp = 0.0;
	if ((a * b) <= -1.75e-5)
		tmp = (c * i) + ((a * b) + (z * t));
	elseif ((a * b) <= 4.1e+49)
		tmp = (c * i) + t_1;
	else
		tmp = (a * b) + t_1;
	end
	tmp_2 = tmp;
end
code[x_, y_, z_, t_, a_, b_, c_, i_] := Block[{t$95$1 = N[(N[(x * y), $MachinePrecision] + N[(z * t), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(a * b), $MachinePrecision], -1.75e-5], N[(N[(c * i), $MachinePrecision] + N[(N[(a * b), $MachinePrecision] + N[(z * t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(a * b), $MachinePrecision], 4.1e+49], N[(N[(c * i), $MachinePrecision] + t$95$1), $MachinePrecision], N[(N[(a * b), $MachinePrecision] + t$95$1), $MachinePrecision]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_1 := x \cdot y + z \cdot t\\
\mathbf{if}\;a \cdot b \leq -1.75 \cdot 10^{-5}:\\
\;\;\;\;c \cdot i + \left(a \cdot b + z \cdot t\right)\\

\mathbf{elif}\;a \cdot b \leq 4.1 \cdot 10^{+49}:\\
\;\;\;\;c \cdot i + t_1\\

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


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

    1. Initial program 91.8%

      \[\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 82.9%

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

    if -1.7499999999999998e-5 < (*.f64 a b) < 4.1e49

    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 a around 0 95.8%

      \[\leadsto \color{blue}{\left(t \cdot z + x \cdot y\right)} + c \cdot i \]

    if 4.1e49 < (*.f64 a b)

    1. Initial program 91.7%

      \[\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 90.2%

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

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

Alternative 12: 60.0% accurate, 0.7× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \leq -2.25 \cdot 10^{+165}:\\ \;\;\;\;c \cdot i + x \cdot y\\ \mathbf{elif}\;x \leq -7.5 \cdot 10^{+99} \lor \neg \left(x \leq 2.25 \cdot 10^{-95}\right):\\ \;\;\;\;a \cdot b + x \cdot y\\ \mathbf{else}:\\ \;\;\;\;c \cdot i + z \cdot t\\ \end{array} \end{array} \]
(FPCore (x y z t a b c i)
 :precision binary64
 (if (<= x -2.25e+165)
   (+ (* c i) (* x y))
   (if (or (<= x -7.5e+99) (not (<= x 2.25e-95)))
     (+ (* a b) (* x y))
     (+ (* c i) (* z t)))))
double code(double x, double y, double z, double t, double a, double b, double c, double i) {
	double tmp;
	if (x <= -2.25e+165) {
		tmp = (c * i) + (x * y);
	} else if ((x <= -7.5e+99) || !(x <= 2.25e-95)) {
		tmp = (a * b) + (x * y);
	} else {
		tmp = (c * i) + (z * t);
	}
	return tmp;
}
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 (x <= (-2.25d+165)) then
        tmp = (c * i) + (x * y)
    else if ((x <= (-7.5d+99)) .or. (.not. (x <= 2.25d-95))) then
        tmp = (a * b) + (x * y)
    else
        tmp = (c * i) + (z * t)
    end if
    code = tmp
end function
public static double code(double x, double y, double z, double t, double a, double b, double c, double i) {
	double tmp;
	if (x <= -2.25e+165) {
		tmp = (c * i) + (x * y);
	} else if ((x <= -7.5e+99) || !(x <= 2.25e-95)) {
		tmp = (a * b) + (x * y);
	} else {
		tmp = (c * i) + (z * t);
	}
	return tmp;
}
def code(x, y, z, t, a, b, c, i):
	tmp = 0
	if x <= -2.25e+165:
		tmp = (c * i) + (x * y)
	elif (x <= -7.5e+99) or not (x <= 2.25e-95):
		tmp = (a * b) + (x * y)
	else:
		tmp = (c * i) + (z * t)
	return tmp
function code(x, y, z, t, a, b, c, i)
	tmp = 0.0
	if (x <= -2.25e+165)
		tmp = Float64(Float64(c * i) + Float64(x * y));
	elseif ((x <= -7.5e+99) || !(x <= 2.25e-95))
		tmp = Float64(Float64(a * b) + Float64(x * y));
	else
		tmp = Float64(Float64(c * i) + Float64(z * t));
	end
	return tmp
end
function tmp_2 = code(x, y, z, t, a, b, c, i)
	tmp = 0.0;
	if (x <= -2.25e+165)
		tmp = (c * i) + (x * y);
	elseif ((x <= -7.5e+99) || ~((x <= 2.25e-95)))
		tmp = (a * b) + (x * y);
	else
		tmp = (c * i) + (z * t);
	end
	tmp_2 = tmp;
end
code[x_, y_, z_, t_, a_, b_, c_, i_] := If[LessEqual[x, -2.25e+165], N[(N[(c * i), $MachinePrecision] + N[(x * y), $MachinePrecision]), $MachinePrecision], If[Or[LessEqual[x, -7.5e+99], N[Not[LessEqual[x, 2.25e-95]], $MachinePrecision]], N[(N[(a * b), $MachinePrecision] + N[(x * y), $MachinePrecision]), $MachinePrecision], N[(N[(c * i), $MachinePrecision] + N[(z * t), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;x \leq -2.25 \cdot 10^{+165}:\\
\;\;\;\;c \cdot i + x \cdot y\\

\mathbf{elif}\;x \leq -7.5 \cdot 10^{+99} \lor \neg \left(x \leq 2.25 \cdot 10^{-95}\right):\\
\;\;\;\;a \cdot b + x \cdot y\\

\mathbf{else}:\\
\;\;\;\;c \cdot i + z \cdot t\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if x < -2.2499999999999998e165

    1. Initial program 96.7%

      \[\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 0 77.0%

      \[\leadsto \color{blue}{\left(t \cdot z + x \cdot y\right)} + c \cdot i \]
    4. Taylor expanded in t around 0 67.2%

      \[\leadsto \color{blue}{c \cdot i + x \cdot y} \]

    if -2.2499999999999998e165 < x < -7.49999999999999963e99 or 2.25e-95 < x

    1. Initial program 91.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 77.2%

      \[\leadsto \color{blue}{a \cdot b + \left(c \cdot i + x \cdot y\right)} \]
    4. Step-by-step derivation
      1. associate-+r+77.2%

        \[\leadsto \color{blue}{\left(a \cdot b + c \cdot i\right) + x \cdot y} \]
      2. fma-udef79.2%

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

        \[\leadsto \color{blue}{x \cdot y + \mathsf{fma}\left(a, b, c \cdot i\right)} \]
      4. fma-def81.2%

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

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

      \[\leadsto \color{blue}{a \cdot b + x \cdot y} \]

    if -7.49999999999999963e99 < x < 2.25e-95

    1. Initial program 97.6%

      \[\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 0 73.2%

      \[\leadsto \color{blue}{\left(t \cdot z + x \cdot y\right)} + c \cdot i \]
    4. Taylor expanded in x around 0 66.0%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -2.25 \cdot 10^{+165}:\\ \;\;\;\;c \cdot i + x \cdot y\\ \mathbf{elif}\;x \leq -7.5 \cdot 10^{+99} \lor \neg \left(x \leq 2.25 \cdot 10^{-95}\right):\\ \;\;\;\;a \cdot b + x \cdot y\\ \mathbf{else}:\\ \;\;\;\;c \cdot i + z \cdot t\\ \end{array} \]
  5. Add Preprocessing

Alternative 13: 42.5% accurate, 0.9× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;c \cdot i \leq -8.5 \cdot 10^{+184} \lor \neg \left(c \cdot i \leq 1.9 \cdot 10^{+68}\right):\\ \;\;\;\;c \cdot i\\ \mathbf{else}:\\ \;\;\;\;a \cdot b\\ \end{array} \end{array} \]
(FPCore (x y z t a b c i)
 :precision binary64
 (if (or (<= (* c i) -8.5e+184) (not (<= (* c i) 1.9e+68))) (* c i) (* a b)))
double code(double x, double y, double z, double t, double a, double b, double c, double i) {
	double tmp;
	if (((c * i) <= -8.5e+184) || !((c * i) <= 1.9e+68)) {
		tmp = c * i;
	} else {
		tmp = a * b;
	}
	return tmp;
}
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) <= (-8.5d+184)) .or. (.not. ((c * i) <= 1.9d+68))) then
        tmp = c * i
    else
        tmp = a * b
    end if
    code = tmp
end function
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) <= -8.5e+184) || !((c * i) <= 1.9e+68)) {
		tmp = c * i;
	} else {
		tmp = a * b;
	}
	return tmp;
}
def code(x, y, z, t, a, b, c, i):
	tmp = 0
	if ((c * i) <= -8.5e+184) or not ((c * i) <= 1.9e+68):
		tmp = c * i
	else:
		tmp = a * b
	return tmp
function code(x, y, z, t, a, b, c, i)
	tmp = 0.0
	if ((Float64(c * i) <= -8.5e+184) || !(Float64(c * i) <= 1.9e+68))
		tmp = Float64(c * i);
	else
		tmp = Float64(a * b);
	end
	return tmp
end
function tmp_2 = code(x, y, z, t, a, b, c, i)
	tmp = 0.0;
	if (((c * i) <= -8.5e+184) || ~(((c * i) <= 1.9e+68)))
		tmp = c * i;
	else
		tmp = a * b;
	end
	tmp_2 = tmp;
end
code[x_, y_, z_, t_, a_, b_, c_, i_] := If[Or[LessEqual[N[(c * i), $MachinePrecision], -8.5e+184], N[Not[LessEqual[N[(c * i), $MachinePrecision], 1.9e+68]], $MachinePrecision]], N[(c * i), $MachinePrecision], N[(a * b), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;c \cdot i \leq -8.5 \cdot 10^{+184} \lor \neg \left(c \cdot i \leq 1.9 \cdot 10^{+68}\right):\\
\;\;\;\;c \cdot i\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (*.f64 c i) < -8.50000000000000043e184 or 1.9e68 < (*.f64 c i)

    1. Initial program 88.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 inf 72.3%

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

    if -8.50000000000000043e184 < (*.f64 c i) < 1.9e68

    1. Initial program 99.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 35.8%

      \[\leadsto \color{blue}{a \cdot b} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification49.5%

    \[\leadsto \begin{array}{l} \mathbf{if}\;c \cdot i \leq -8.5 \cdot 10^{+184} \lor \neg \left(c \cdot i \leq 1.9 \cdot 10^{+68}\right):\\ \;\;\;\;c \cdot i\\ \mathbf{else}:\\ \;\;\;\;a \cdot b\\ \end{array} \]
  5. Add Preprocessing

Alternative 14: 27.2% accurate, 5.0× speedup?

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

\\
a \cdot b
\end{array}
Derivation
  1. Initial program 95.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 27.5%

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

    \[\leadsto a \cdot b \]
  5. Add Preprocessing

Reproduce

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