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

Percentage Accurate: 95.4% → 97.5%
Time: 12.3s
Alternatives: 15
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 15 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.4% 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.5% accurate, 0.1× speedup?

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

\\
\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 + \mathsf{fma}\left(y, x, \mathsf{fma}\left(z, t, a \cdot b\right)\right)\\

\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(y, x, a \cdot b\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
    3. Step-by-step derivation
      1. associate-+l+100.0%

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

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

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

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

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

    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 z around 0 18.2%

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

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

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

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

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

      \[\leadsto \color{blue}{a \cdot b + x \cdot y} \]
    7. Step-by-step derivation
      1. +-commutative18.2%

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

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

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

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

    \[\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 + \mathsf{fma}\left(y, x, \mathsf{fma}\left(z, t, a \cdot b\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(y, x, a \cdot b\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 2: 97.8% accurate, 0.0× speedup?

\[\begin{array}{l} \\ \mathsf{fma}\left(c, i, \mathsf{fma}\left(x, y, \mathsf{fma}\left(z, t, a \cdot b\right)\right)\right) \end{array} \]
(FPCore (x y z t a b c i)
 :precision binary64
 (fma c i (fma x y (fma z t (* a b)))))
double code(double x, double y, double z, double t, double a, double b, double c, double i) {
	return fma(c, i, fma(x, y, fma(z, t, (a * b))));
}
function code(x, y, z, t, a, b, c, i)
	return fma(c, i, fma(x, y, fma(z, t, Float64(a * b))))
end
code[x_, y_, z_, t_, a_, b_, c_, i_] := N[(c * i + N[(x * y + N[(z * t + N[(a * b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
\mathsf{fma}\left(c, i, \mathsf{fma}\left(x, y, \mathsf{fma}\left(z, t, a \cdot b\right)\right)\right)
\end{array}
Derivation
  1. Initial program 95.7%

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

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

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

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

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

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

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

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

Alternative 3: 97.5% accurate, 0.1× 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}:\\ \;\;\;\;\mathsf{fma}\left(y, x, a \cdot b\right)\\ \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 (fma y x (* a b)))))
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 = fma(y, x, (a * b));
	}
	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 = fma(y, x, Float64(a * b));
	end
	return 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[(y * x + N[(a * b), $MachinePrecision]), $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}:\\
\;\;\;\;\mathsf{fma}\left(y, x, a \cdot b\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 z around 0 18.2%

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

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

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

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

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

      \[\leadsto \color{blue}{a \cdot b + x \cdot y} \]
    7. Step-by-step derivation
      1. +-commutative18.2%

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

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

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

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

    \[\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}:\\ \;\;\;\;\mathsf{fma}\left(y, x, a \cdot b\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 4: 65.6% accurate, 0.3× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_1 := a \cdot b + x \cdot y\\ t_2 := c \cdot i + z \cdot t\\ t_3 := a \cdot b + c \cdot i\\ \mathbf{if}\;x \cdot y \leq -1.55 \cdot 10^{+185}:\\ \;\;\;\;t\_1\\ \mathbf{elif}\;x \cdot y \leq -2.3 \cdot 10^{+156}:\\ \;\;\;\;t\_2\\ \mathbf{elif}\;x \cdot y \leq -5 \cdot 10^{+19}:\\ \;\;\;\;t\_1\\ \mathbf{elif}\;x \cdot y \leq -7.8 \cdot 10^{-164}:\\ \;\;\;\;t\_2\\ \mathbf{elif}\;x \cdot y \leq -1.45 \cdot 10^{-296}:\\ \;\;\;\;t\_3\\ \mathbf{elif}\;x \cdot y \leq 240:\\ \;\;\;\;t\_2\\ \mathbf{elif}\;x \cdot y \leq 1.9 \cdot 10^{+97}:\\ \;\;\;\;t\_3\\ \mathbf{else}:\\ \;\;\;\;t\_1\\ \end{array} \end{array} \]
(FPCore (x y z t a b c i)
 :precision binary64
 (let* ((t_1 (+ (* a b) (* x y)))
        (t_2 (+ (* c i) (* z t)))
        (t_3 (+ (* a b) (* c i))))
   (if (<= (* x y) -1.55e+185)
     t_1
     (if (<= (* x y) -2.3e+156)
       t_2
       (if (<= (* x y) -5e+19)
         t_1
         (if (<= (* x y) -7.8e-164)
           t_2
           (if (<= (* x y) -1.45e-296)
             t_3
             (if (<= (* x y) 240.0)
               t_2
               (if (<= (* x y) 1.9e+97) t_3 t_1)))))))))
double code(double x, double y, double z, double t, double a, double b, double c, double i) {
	double t_1 = (a * b) + (x * y);
	double t_2 = (c * i) + (z * t);
	double t_3 = (a * b) + (c * i);
	double tmp;
	if ((x * y) <= -1.55e+185) {
		tmp = t_1;
	} else if ((x * y) <= -2.3e+156) {
		tmp = t_2;
	} else if ((x * y) <= -5e+19) {
		tmp = t_1;
	} else if ((x * y) <= -7.8e-164) {
		tmp = t_2;
	} else if ((x * y) <= -1.45e-296) {
		tmp = t_3;
	} else if ((x * y) <= 240.0) {
		tmp = t_2;
	} else if ((x * y) <= 1.9e+97) {
		tmp = t_3;
	} else {
		tmp = 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) :: t_2
    real(8) :: t_3
    real(8) :: tmp
    t_1 = (a * b) + (x * y)
    t_2 = (c * i) + (z * t)
    t_3 = (a * b) + (c * i)
    if ((x * y) <= (-1.55d+185)) then
        tmp = t_1
    else if ((x * y) <= (-2.3d+156)) then
        tmp = t_2
    else if ((x * y) <= (-5d+19)) then
        tmp = t_1
    else if ((x * y) <= (-7.8d-164)) then
        tmp = t_2
    else if ((x * y) <= (-1.45d-296)) then
        tmp = t_3
    else if ((x * y) <= 240.0d0) then
        tmp = t_2
    else if ((x * y) <= 1.9d+97) then
        tmp = t_3
    else
        tmp = 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 = (a * b) + (x * y);
	double t_2 = (c * i) + (z * t);
	double t_3 = (a * b) + (c * i);
	double tmp;
	if ((x * y) <= -1.55e+185) {
		tmp = t_1;
	} else if ((x * y) <= -2.3e+156) {
		tmp = t_2;
	} else if ((x * y) <= -5e+19) {
		tmp = t_1;
	} else if ((x * y) <= -7.8e-164) {
		tmp = t_2;
	} else if ((x * y) <= -1.45e-296) {
		tmp = t_3;
	} else if ((x * y) <= 240.0) {
		tmp = t_2;
	} else if ((x * y) <= 1.9e+97) {
		tmp = t_3;
	} else {
		tmp = t_1;
	}
	return tmp;
}
def code(x, y, z, t, a, b, c, i):
	t_1 = (a * b) + (x * y)
	t_2 = (c * i) + (z * t)
	t_3 = (a * b) + (c * i)
	tmp = 0
	if (x * y) <= -1.55e+185:
		tmp = t_1
	elif (x * y) <= -2.3e+156:
		tmp = t_2
	elif (x * y) <= -5e+19:
		tmp = t_1
	elif (x * y) <= -7.8e-164:
		tmp = t_2
	elif (x * y) <= -1.45e-296:
		tmp = t_3
	elif (x * y) <= 240.0:
		tmp = t_2
	elif (x * y) <= 1.9e+97:
		tmp = t_3
	else:
		tmp = t_1
	return tmp
function code(x, y, z, t, a, b, c, i)
	t_1 = Float64(Float64(a * b) + Float64(x * y))
	t_2 = Float64(Float64(c * i) + Float64(z * t))
	t_3 = Float64(Float64(a * b) + Float64(c * i))
	tmp = 0.0
	if (Float64(x * y) <= -1.55e+185)
		tmp = t_1;
	elseif (Float64(x * y) <= -2.3e+156)
		tmp = t_2;
	elseif (Float64(x * y) <= -5e+19)
		tmp = t_1;
	elseif (Float64(x * y) <= -7.8e-164)
		tmp = t_2;
	elseif (Float64(x * y) <= -1.45e-296)
		tmp = t_3;
	elseif (Float64(x * y) <= 240.0)
		tmp = t_2;
	elseif (Float64(x * y) <= 1.9e+97)
		tmp = t_3;
	else
		tmp = t_1;
	end
	return tmp
end
function tmp_2 = code(x, y, z, t, a, b, c, i)
	t_1 = (a * b) + (x * y);
	t_2 = (c * i) + (z * t);
	t_3 = (a * b) + (c * i);
	tmp = 0.0;
	if ((x * y) <= -1.55e+185)
		tmp = t_1;
	elseif ((x * y) <= -2.3e+156)
		tmp = t_2;
	elseif ((x * y) <= -5e+19)
		tmp = t_1;
	elseif ((x * y) <= -7.8e-164)
		tmp = t_2;
	elseif ((x * y) <= -1.45e-296)
		tmp = t_3;
	elseif ((x * y) <= 240.0)
		tmp = t_2;
	elseif ((x * y) <= 1.9e+97)
		tmp = t_3;
	else
		tmp = t_1;
	end
	tmp_2 = tmp;
end
code[x_, y_, z_, t_, a_, b_, c_, i_] := Block[{t$95$1 = N[(N[(a * b), $MachinePrecision] + N[(x * y), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(N[(c * i), $MachinePrecision] + N[(z * t), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$3 = N[(N[(a * b), $MachinePrecision] + N[(c * i), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(x * y), $MachinePrecision], -1.55e+185], t$95$1, If[LessEqual[N[(x * y), $MachinePrecision], -2.3e+156], t$95$2, If[LessEqual[N[(x * y), $MachinePrecision], -5e+19], t$95$1, If[LessEqual[N[(x * y), $MachinePrecision], -7.8e-164], t$95$2, If[LessEqual[N[(x * y), $MachinePrecision], -1.45e-296], t$95$3, If[LessEqual[N[(x * y), $MachinePrecision], 240.0], t$95$2, If[LessEqual[N[(x * y), $MachinePrecision], 1.9e+97], t$95$3, t$95$1]]]]]]]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_1 := a \cdot b + x \cdot y\\
t_2 := c \cdot i + z \cdot t\\
t_3 := a \cdot b + c \cdot i\\
\mathbf{if}\;x \cdot y \leq -1.55 \cdot 10^{+185}:\\
\;\;\;\;t\_1\\

\mathbf{elif}\;x \cdot y \leq -2.3 \cdot 10^{+156}:\\
\;\;\;\;t\_2\\

\mathbf{elif}\;x \cdot y \leq -5 \cdot 10^{+19}:\\
\;\;\;\;t\_1\\

\mathbf{elif}\;x \cdot y \leq -7.8 \cdot 10^{-164}:\\
\;\;\;\;t\_2\\

\mathbf{elif}\;x \cdot y \leq -1.45 \cdot 10^{-296}:\\
\;\;\;\;t\_3\\

\mathbf{elif}\;x \cdot y \leq 240:\\
\;\;\;\;t\_2\\

\mathbf{elif}\;x \cdot y \leq 1.9 \cdot 10^{+97}:\\
\;\;\;\;t\_3\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if (*.f64 x y) < -1.55e185 or -2.2999999999999999e156 < (*.f64 x y) < -5e19 or 1.90000000000000018e97 < (*.f64 x y)

    1. Initial program 93.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 84.8%

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

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

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

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

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

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

    if -1.55e185 < (*.f64 x y) < -2.2999999999999999e156 or -5e19 < (*.f64 x y) < -7.7999999999999997e-164 or -1.44999999999999991e-296 < (*.f64 x y) < 240

    1. Initial program 96.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+96.9%

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

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

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

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

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

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

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

    if -7.7999999999999997e-164 < (*.f64 x y) < -1.44999999999999991e-296 or 240 < (*.f64 x y) < 1.90000000000000018e97

    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 0 91.9%

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

      \[\leadsto \color{blue}{a \cdot b + c \cdot i} \]
  3. Recombined 3 regimes into one program.
  4. Final simplification78.3%

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \cdot y \leq -1.55 \cdot 10^{+185}:\\ \;\;\;\;a \cdot b + x \cdot y\\ \mathbf{elif}\;x \cdot y \leq -2.3 \cdot 10^{+156}:\\ \;\;\;\;c \cdot i + z \cdot t\\ \mathbf{elif}\;x \cdot y \leq -5 \cdot 10^{+19}:\\ \;\;\;\;a \cdot b + x \cdot y\\ \mathbf{elif}\;x \cdot y \leq -7.8 \cdot 10^{-164}:\\ \;\;\;\;c \cdot i + z \cdot t\\ \mathbf{elif}\;x \cdot y \leq -1.45 \cdot 10^{-296}:\\ \;\;\;\;a \cdot b + c \cdot i\\ \mathbf{elif}\;x \cdot y \leq 240:\\ \;\;\;\;c \cdot i + z \cdot t\\ \mathbf{elif}\;x \cdot y \leq 1.9 \cdot 10^{+97}:\\ \;\;\;\;a \cdot b + c \cdot i\\ \mathbf{else}:\\ \;\;\;\;a \cdot b + x \cdot y\\ \end{array} \]
  5. Add Preprocessing

Alternative 5: 61.8% accurate, 0.3× speedup?

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

\\
\begin{array}{l}
t_1 := a \cdot b + c \cdot i\\
\mathbf{if}\;x \cdot y \leq -1.55 \cdot 10^{+185}:\\
\;\;\;\;x \cdot y\\

\mathbf{elif}\;x \cdot y \leq -1.75 \cdot 10^{+149}:\\
\;\;\;\;t\_1\\

\mathbf{elif}\;x \cdot y \leq -5.8 \cdot 10^{+128}:\\
\;\;\;\;x \cdot y\\

\mathbf{elif}\;x \cdot y \leq -2.2 \cdot 10^{-118}:\\
\;\;\;\;t\_1\\

\mathbf{elif}\;x \cdot y \leq -1.18 \cdot 10^{-147}:\\
\;\;\;\;z \cdot t\\

\mathbf{elif}\;x \cdot y \leq 4.4 \cdot 10^{+158}:\\
\;\;\;\;t\_1\\

\mathbf{else}:\\
\;\;\;\;x \cdot y\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if (*.f64 x y) < -1.55e185 or -1.75000000000000006e149 < (*.f64 x y) < -5.8000000000000001e128 or 4.4000000000000002e158 < (*.f64 x y)

    1. Initial program 90.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 82.7%

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

    if -1.55e185 < (*.f64 x y) < -1.75000000000000006e149 or -5.8000000000000001e128 < (*.f64 x y) < -2.19999999999999984e-118 or -1.18000000000000003e-147 < (*.f64 x y) < 4.4000000000000002e158

    1. Initial program 97.3%

      \[\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}{\left(a \cdot b + x \cdot y\right)} + c \cdot i \]
    4. Taylor expanded in x around 0 65.1%

      \[\leadsto \color{blue}{a \cdot b + c \cdot i} \]

    if -2.19999999999999984e-118 < (*.f64 x y) < -1.18000000000000003e-147

    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 97.9%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \cdot y \leq -1.55 \cdot 10^{+185}:\\ \;\;\;\;x \cdot y\\ \mathbf{elif}\;x \cdot y \leq -1.75 \cdot 10^{+149}:\\ \;\;\;\;a \cdot b + c \cdot i\\ \mathbf{elif}\;x \cdot y \leq -5.8 \cdot 10^{+128}:\\ \;\;\;\;x \cdot y\\ \mathbf{elif}\;x \cdot y \leq -2.2 \cdot 10^{-118}:\\ \;\;\;\;a \cdot b + c \cdot i\\ \mathbf{elif}\;x \cdot y \leq -1.18 \cdot 10^{-147}:\\ \;\;\;\;z \cdot t\\ \mathbf{elif}\;x \cdot y \leq 4.4 \cdot 10^{+158}:\\ \;\;\;\;a \cdot b + c \cdot i\\ \mathbf{else}:\\ \;\;\;\;x \cdot y\\ \end{array} \]
  5. Add Preprocessing

Alternative 6: 64.6% accurate, 0.4× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_1 := a \cdot b + x \cdot y\\ \mathbf{if}\;a \cdot b \leq -1.95 \cdot 10^{+98}:\\ \;\;\;\;t\_1\\ \mathbf{elif}\;a \cdot b \leq 9.5 \cdot 10^{-253}:\\ \;\;\;\;x \cdot y + c \cdot i\\ \mathbf{elif}\;a \cdot b \leq 4.2 \cdot 10^{+32} \lor \neg \left(a \cdot b \leq 1.9 \cdot 10^{+146}\right) \land a \cdot b \leq 5.2 \cdot 10^{+172}:\\ \;\;\;\;c \cdot i + z \cdot t\\ \mathbf{else}:\\ \;\;\;\;t\_1\\ \end{array} \end{array} \]
(FPCore (x y z t a b c i)
 :precision binary64
 (let* ((t_1 (+ (* a b) (* x y))))
   (if (<= (* a b) -1.95e+98)
     t_1
     (if (<= (* a b) 9.5e-253)
       (+ (* x y) (* c i))
       (if (or (<= (* a b) 4.2e+32)
               (and (not (<= (* a b) 1.9e+146)) (<= (* a b) 5.2e+172)))
         (+ (* c i) (* z t))
         t_1)))))
double code(double x, double y, double z, double t, double a, double b, double c, double i) {
	double t_1 = (a * b) + (x * y);
	double tmp;
	if ((a * b) <= -1.95e+98) {
		tmp = t_1;
	} else if ((a * b) <= 9.5e-253) {
		tmp = (x * y) + (c * i);
	} else if (((a * b) <= 4.2e+32) || (!((a * b) <= 1.9e+146) && ((a * b) <= 5.2e+172))) {
		tmp = (c * i) + (z * t);
	} else {
		tmp = 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 = (a * b) + (x * y)
    if ((a * b) <= (-1.95d+98)) then
        tmp = t_1
    else if ((a * b) <= 9.5d-253) then
        tmp = (x * y) + (c * i)
    else if (((a * b) <= 4.2d+32) .or. (.not. ((a * b) <= 1.9d+146)) .and. ((a * b) <= 5.2d+172)) then
        tmp = (c * i) + (z * t)
    else
        tmp = 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 = (a * b) + (x * y);
	double tmp;
	if ((a * b) <= -1.95e+98) {
		tmp = t_1;
	} else if ((a * b) <= 9.5e-253) {
		tmp = (x * y) + (c * i);
	} else if (((a * b) <= 4.2e+32) || (!((a * b) <= 1.9e+146) && ((a * b) <= 5.2e+172))) {
		tmp = (c * i) + (z * t);
	} else {
		tmp = t_1;
	}
	return tmp;
}
def code(x, y, z, t, a, b, c, i):
	t_1 = (a * b) + (x * y)
	tmp = 0
	if (a * b) <= -1.95e+98:
		tmp = t_1
	elif (a * b) <= 9.5e-253:
		tmp = (x * y) + (c * i)
	elif ((a * b) <= 4.2e+32) or (not ((a * b) <= 1.9e+146) and ((a * b) <= 5.2e+172)):
		tmp = (c * i) + (z * t)
	else:
		tmp = t_1
	return tmp
function code(x, y, z, t, a, b, c, i)
	t_1 = Float64(Float64(a * b) + Float64(x * y))
	tmp = 0.0
	if (Float64(a * b) <= -1.95e+98)
		tmp = t_1;
	elseif (Float64(a * b) <= 9.5e-253)
		tmp = Float64(Float64(x * y) + Float64(c * i));
	elseif ((Float64(a * b) <= 4.2e+32) || (!(Float64(a * b) <= 1.9e+146) && (Float64(a * b) <= 5.2e+172)))
		tmp = Float64(Float64(c * i) + Float64(z * t));
	else
		tmp = t_1;
	end
	return tmp
end
function tmp_2 = code(x, y, z, t, a, b, c, i)
	t_1 = (a * b) + (x * y);
	tmp = 0.0;
	if ((a * b) <= -1.95e+98)
		tmp = t_1;
	elseif ((a * b) <= 9.5e-253)
		tmp = (x * y) + (c * i);
	elseif (((a * b) <= 4.2e+32) || (~(((a * b) <= 1.9e+146)) && ((a * b) <= 5.2e+172)))
		tmp = (c * i) + (z * t);
	else
		tmp = t_1;
	end
	tmp_2 = tmp;
end
code[x_, y_, z_, t_, a_, b_, c_, i_] := Block[{t$95$1 = N[(N[(a * b), $MachinePrecision] + N[(x * y), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(a * b), $MachinePrecision], -1.95e+98], t$95$1, If[LessEqual[N[(a * b), $MachinePrecision], 9.5e-253], N[(N[(x * y), $MachinePrecision] + N[(c * i), $MachinePrecision]), $MachinePrecision], If[Or[LessEqual[N[(a * b), $MachinePrecision], 4.2e+32], And[N[Not[LessEqual[N[(a * b), $MachinePrecision], 1.9e+146]], $MachinePrecision], LessEqual[N[(a * b), $MachinePrecision], 5.2e+172]]], N[(N[(c * i), $MachinePrecision] + N[(z * t), $MachinePrecision]), $MachinePrecision], t$95$1]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_1 := a \cdot b + x \cdot y\\
\mathbf{if}\;a \cdot b \leq -1.95 \cdot 10^{+98}:\\
\;\;\;\;t\_1\\

\mathbf{elif}\;a \cdot b \leq 9.5 \cdot 10^{-253}:\\
\;\;\;\;x \cdot y + c \cdot i\\

\mathbf{elif}\;a \cdot b \leq 4.2 \cdot 10^{+32} \lor \neg \left(a \cdot b \leq 1.9 \cdot 10^{+146}\right) \land a \cdot b \leq 5.2 \cdot 10^{+172}:\\
\;\;\;\;c \cdot i + z \cdot t\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if (*.f64 a b) < -1.95e98 or 4.2000000000000001e32 < (*.f64 a b) < 1.8999999999999999e146 or 5.2e172 < (*.f64 a b)

    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 z around 0 82.0%

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

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

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

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

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

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

    if -1.95e98 < (*.f64 a b) < 9.5e-253

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

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

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

    if 9.5e-253 < (*.f64 a b) < 4.2000000000000001e32 or 1.8999999999999999e146 < (*.f64 a b) < 5.2e172

    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+100.0%

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;a \cdot b \leq -1.95 \cdot 10^{+98}:\\ \;\;\;\;a \cdot b + x \cdot y\\ \mathbf{elif}\;a \cdot b \leq 9.5 \cdot 10^{-253}:\\ \;\;\;\;x \cdot y + c \cdot i\\ \mathbf{elif}\;a \cdot b \leq 4.2 \cdot 10^{+32} \lor \neg \left(a \cdot b \leq 1.9 \cdot 10^{+146}\right) \land a \cdot b \leq 5.2 \cdot 10^{+172}:\\ \;\;\;\;c \cdot i + z \cdot t\\ \mathbf{else}:\\ \;\;\;\;a \cdot b + x \cdot y\\ \end{array} \]
  5. Add Preprocessing

Alternative 7: 83.9% accurate, 0.4× speedup?

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

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

\mathbf{elif}\;c \cdot i \leq 1.9 \cdot 10^{-16}:\\
\;\;\;\;t\_1\\

\mathbf{elif}\;c \cdot i \leq 3250000:\\
\;\;\;\;t\_2\\

\mathbf{elif}\;c \cdot i \leq 3.9 \cdot 10^{+140}:\\
\;\;\;\;t\_1\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if (*.f64 c i) < -5.20000000000000032e118 or 1.90000000000000006e-16 < (*.f64 c i) < 3.25e6

    1. Initial program 92.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 88.5%

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

      \[\leadsto \color{blue}{a \cdot b + c \cdot i} \]

    if -5.20000000000000032e118 < (*.f64 c i) < 1.90000000000000006e-16 or 3.25e6 < (*.f64 c i) < 3.89999999999999974e140

    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 93.8%

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

    if 3.89999999999999974e140 < (*.f64 c i)

    1. Initial program 84.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+84.2%

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;c \cdot i \leq -5.2 \cdot 10^{+118}:\\ \;\;\;\;a \cdot b + c \cdot i\\ \mathbf{elif}\;c \cdot i \leq 1.9 \cdot 10^{-16}:\\ \;\;\;\;a \cdot b + \left(x \cdot y + z \cdot t\right)\\ \mathbf{elif}\;c \cdot i \leq 3250000:\\ \;\;\;\;a \cdot b + c \cdot i\\ \mathbf{elif}\;c \cdot i \leq 3.9 \cdot 10^{+140}:\\ \;\;\;\;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 8: 43.1% accurate, 0.4× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;a \cdot b \leq -1.85 \cdot 10^{+98}:\\
\;\;\;\;a \cdot b\\

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

\mathbf{elif}\;a \cdot b \leq 6.1 \cdot 10^{-227}:\\
\;\;\;\;x \cdot y\\

\mathbf{elif}\;a \cdot b \leq 7.2 \cdot 10^{-15}:\\
\;\;\;\;z \cdot t\\

\mathbf{elif}\;a \cdot b \leq 2.9 \cdot 10^{+133}:\\
\;\;\;\;x \cdot y\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if (*.f64 a b) < -1.8499999999999999e98 or 2.9000000000000001e133 < (*.f64 a b)

    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 71.4%

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

    if -1.8499999999999999e98 < (*.f64 a b) < -5.49999999999999988e-275

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

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

    if -5.49999999999999988e-275 < (*.f64 a b) < 6.1000000000000002e-227 or 7.2000000000000002e-15 < (*.f64 a b) < 2.9000000000000001e133

    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 inf 51.1%

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

    if 6.1000000000000002e-227 < (*.f64 a b) < 7.2000000000000002e-15

    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 52.8%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;a \cdot b \leq -1.85 \cdot 10^{+98}:\\ \;\;\;\;a \cdot b\\ \mathbf{elif}\;a \cdot b \leq -5.5 \cdot 10^{-275}:\\ \;\;\;\;c \cdot i\\ \mathbf{elif}\;a \cdot b \leq 6.1 \cdot 10^{-227}:\\ \;\;\;\;x \cdot y\\ \mathbf{elif}\;a \cdot b \leq 7.2 \cdot 10^{-15}:\\ \;\;\;\;z \cdot t\\ \mathbf{elif}\;a \cdot b \leq 2.9 \cdot 10^{+133}:\\ \;\;\;\;x \cdot y\\ \mathbf{else}:\\ \;\;\;\;a \cdot b\\ \end{array} \]
  5. Add Preprocessing

Alternative 9: 97.1% 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}:\\ \;\;\;\;a \cdot b + x \cdot y\\ \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 (+ (* a b) (* x y)))))
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 = (a * b) + (x * y);
	}
	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 = (a * b) + (x * y);
	}
	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 = (a * b) + (x * y)
	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(Float64(a * b) + Float64(x * y));
	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 = (a * b) + (x * y);
	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[(N[(a * b), $MachinePrecision] + N[(x * y), $MachinePrecision]), $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}:\\
\;\;\;\;a \cdot b + x \cdot y\\


\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 z around 0 18.2%

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

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

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

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

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

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

    \[\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}:\\ \;\;\;\;a \cdot b + x \cdot y\\ \end{array} \]
  5. Add Preprocessing

Alternative 10: 41.9% accurate, 0.5× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;a \cdot b \leq -1.95 \cdot 10^{+98}:\\
\;\;\;\;a \cdot b\\

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

\mathbf{elif}\;a \cdot b \leq 3.4 \cdot 10^{-23}:\\
\;\;\;\;z \cdot t\\

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if (*.f64 a b) < -1.95e98 or 5.79999999999999971e80 < (*.f64 a b)

    1. Initial program 93.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 inf 68.0%

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

    if -1.95e98 < (*.f64 a b) < 4.30000000000000004e-150 or 3.4000000000000001e-23 < (*.f64 a b) < 5.79999999999999971e80

    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 c around inf 38.2%

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

    if 4.30000000000000004e-150 < (*.f64 a b) < 3.4000000000000001e-23

    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 61.4%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;a \cdot b \leq -1.95 \cdot 10^{+98}:\\ \;\;\;\;a \cdot b\\ \mathbf{elif}\;a \cdot b \leq 4.3 \cdot 10^{-150}:\\ \;\;\;\;c \cdot i\\ \mathbf{elif}\;a \cdot b \leq 3.4 \cdot 10^{-23}:\\ \;\;\;\;z \cdot t\\ \mathbf{elif}\;a \cdot b \leq 5.8 \cdot 10^{+80}:\\ \;\;\;\;c \cdot i\\ \mathbf{else}:\\ \;\;\;\;a \cdot b\\ \end{array} \]
  5. Add Preprocessing

Alternative 11: 87.5% accurate, 0.6× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \cdot y \leq -48000000000 \lor \neg \left(x \cdot y \leq 1.02 \cdot 10^{+95}\right):\\ \;\;\;\;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 (or (<= (* x y) -48000000000.0) (not (<= (* x y) 1.02e+95)))
   (+ (* 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 (((x * y) <= -48000000000.0) || !((x * y) <= 1.02e+95)) {
		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 (((x * y) <= (-48000000000.0d0)) .or. (.not. ((x * y) <= 1.02d+95))) 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 (((x * y) <= -48000000000.0) || !((x * y) <= 1.02e+95)) {
		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 ((x * y) <= -48000000000.0) or not ((x * y) <= 1.02e+95):
		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(x * y) <= -48000000000.0) || !(Float64(x * y) <= 1.02e+95))
		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 (((x * y) <= -48000000000.0) || ~(((x * y) <= 1.02e+95)))
		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[Or[LessEqual[N[(x * y), $MachinePrecision], -48000000000.0], N[Not[LessEqual[N[(x * y), $MachinePrecision], 1.02e+95]], $MachinePrecision]], 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}\;x \cdot y \leq -48000000000 \lor \neg \left(x \cdot y \leq 1.02 \cdot 10^{+95}\right):\\
\;\;\;\;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 2 regimes
  2. if (*.f64 x y) < -4.8e10 or 1.0200000000000001e95 < (*.f64 x y)

    1. Initial program 94.1%

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

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

    if -4.8e10 < (*.f64 x y) < 1.0200000000000001e95

    1. Initial program 96.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 92.2%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \cdot y \leq -48000000000 \lor \neg \left(x \cdot y \leq 1.02 \cdot 10^{+95}\right):\\ \;\;\;\;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 12: 87.5% accurate, 0.6× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_1 := x \cdot y + z \cdot t\\ \mathbf{if}\;a \cdot b \leq -4.2 \cdot 10^{+99} \lor \neg \left(a \cdot b \leq 7.8 \cdot 10^{+31}\right):\\ \;\;\;\;a \cdot b + t\_1\\ \mathbf{else}:\\ \;\;\;\;c \cdot i + 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 (or (<= (* a b) -4.2e+99) (not (<= (* a b) 7.8e+31)))
     (+ (* a b) t_1)
     (+ (* c i) 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) <= -4.2e+99) || !((a * b) <= 7.8e+31)) {
		tmp = (a * b) + t_1;
	} else {
		tmp = (c * i) + 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) <= (-4.2d+99)) .or. (.not. ((a * b) <= 7.8d+31))) then
        tmp = (a * b) + t_1
    else
        tmp = (c * i) + 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) <= -4.2e+99) || !((a * b) <= 7.8e+31)) {
		tmp = (a * b) + t_1;
	} else {
		tmp = (c * i) + 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) <= -4.2e+99) or not ((a * b) <= 7.8e+31):
		tmp = (a * b) + t_1
	else:
		tmp = (c * i) + 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) <= -4.2e+99) || !(Float64(a * b) <= 7.8e+31))
		tmp = Float64(Float64(a * b) + t_1);
	else
		tmp = Float64(Float64(c * i) + 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) <= -4.2e+99) || ~(((a * b) <= 7.8e+31)))
		tmp = (a * b) + t_1;
	else
		tmp = (c * i) + 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[Or[LessEqual[N[(a * b), $MachinePrecision], -4.2e+99], N[Not[LessEqual[N[(a * b), $MachinePrecision], 7.8e+31]], $MachinePrecision]], N[(N[(a * b), $MachinePrecision] + t$95$1), $MachinePrecision], N[(N[(c * i), $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 -4.2 \cdot 10^{+99} \lor \neg \left(a \cdot b \leq 7.8 \cdot 10^{+31}\right):\\
\;\;\;\;a \cdot b + t\_1\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (*.f64 a b) < -4.2000000000000002e99 or 7.79999999999999999e31 < (*.f64 a b)

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

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

    if -4.2000000000000002e99 < (*.f64 a b) < 7.79999999999999999e31

    1. Initial program 98.1%

      \[\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+98.1%

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

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

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

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

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

      \[\leadsto \color{blue}{\left(t \cdot z + x \cdot y\right)} + c \cdot i \]
  3. Recombined 2 regimes into one program.
  4. Final simplification92.1%

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

Alternative 13: 65.2% accurate, 0.7× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;x \cdot y \leq -35000000000 \lor \neg \left(x \cdot y \leq 3.8 \cdot 10^{+94}\right):\\
\;\;\;\;a \cdot b + x \cdot y\\

\mathbf{else}:\\
\;\;\;\;a \cdot b + c \cdot i\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (*.f64 x y) < -3.5e10 or 3.7999999999999996e94 < (*.f64 x y)

    1. Initial program 94.1%

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

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

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

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

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

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

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

    if -3.5e10 < (*.f64 x y) < 3.7999999999999996e94

    1. Initial program 96.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 70.8%

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

      \[\leadsto \color{blue}{a \cdot b + c \cdot i} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification70.6%

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \cdot y \leq -35000000000 \lor \neg \left(x \cdot y \leq 3.8 \cdot 10^{+94}\right):\\ \;\;\;\;a \cdot b + x \cdot y\\ \mathbf{else}:\\ \;\;\;\;a \cdot b + c \cdot i\\ \end{array} \]
  5. Add Preprocessing

Alternative 14: 42.0% accurate, 0.9× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;a \cdot b \leq -1.85 \cdot 10^{+98} \lor \neg \left(a \cdot b \leq 2.05 \cdot 10^{+85}\right):\\
\;\;\;\;a \cdot b\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (*.f64 a b) < -1.8499999999999999e98 or 2.04999999999999989e85 < (*.f64 a b)

    1. Initial program 93.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 inf 68.0%

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

    if -1.8499999999999999e98 < (*.f64 a b) < 2.04999999999999989e85

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

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

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

Alternative 15: 26.8% 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.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 inf 27.9%

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

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

Reproduce

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