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

Percentage Accurate: 95.7% → 97.7%
Time: 7.2s
Alternatives: 12
Speedup: 0.5×

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 12 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.7% 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.1× speedup?

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

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

\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(b, a, z \cdot t\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 \]

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

      \[\leadsto \color{blue}{\left(a \cdot b + t \cdot z\right)} + c \cdot i \]
    3. Step-by-step derivation
      1. *-commutative40.0%

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

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

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

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

      \[\leadsto \color{blue}{a \cdot b + t \cdot z} \]
    6. Step-by-step derivation
      1. *-commutative40.0%

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

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

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

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

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

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

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

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

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

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

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

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

    \[\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. Final simplification98.0%

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

Alternative 3: 97.2% accurate, 0.5× speedup?

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

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

\mathbf{else}:\\
\;\;\;\;a \cdot b + z \cdot t\\


\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 \]

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

      \[\leadsto \color{blue}{\left(a \cdot b + t \cdot z\right)} + c \cdot i \]
    3. Step-by-step derivation
      1. *-commutative40.0%

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

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

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

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

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

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

Alternative 4: 44.5% accurate, 0.5× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;a \cdot b \leq -1.6 \cdot 10^{+79}:\\ \;\;\;\;a \cdot b\\ \mathbf{elif}\;a \cdot b \leq -2.5 \cdot 10^{-293}:\\ \;\;\;\;z \cdot t\\ \mathbf{elif}\;a \cdot b \leq 3 \cdot 10^{-157}:\\ \;\;\;\;x \cdot y\\ \mathbf{elif}\;a \cdot b \leq 7.5 \cdot 10^{-72}:\\ \;\;\;\;c \cdot i\\ \mathbf{elif}\;a \cdot b \leq 1.65 \cdot 10^{-49}:\\ \;\;\;\;x \cdot y\\ \mathbf{elif}\;a \cdot b \leq 4.3 \cdot 10^{+49}:\\ \;\;\;\;z \cdot t\\ \mathbf{else}:\\ \;\;\;\;a \cdot b\\ \end{array} \end{array} \]
(FPCore (x y z t a b c i)
 :precision binary64
 (if (<= (* a b) -1.6e+79)
   (* a b)
   (if (<= (* a b) -2.5e-293)
     (* z t)
     (if (<= (* a b) 3e-157)
       (* x y)
       (if (<= (* a b) 7.5e-72)
         (* c i)
         (if (<= (* a b) 1.65e-49)
           (* x y)
           (if (<= (* a b) 4.3e+49) (* z t) (* 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.6e+79) {
		tmp = a * b;
	} else if ((a * b) <= -2.5e-293) {
		tmp = z * t;
	} else if ((a * b) <= 3e-157) {
		tmp = x * y;
	} else if ((a * b) <= 7.5e-72) {
		tmp = c * i;
	} else if ((a * b) <= 1.65e-49) {
		tmp = x * y;
	} else if ((a * b) <= 4.3e+49) {
		tmp = z * t;
	} 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.6d+79)) then
        tmp = a * b
    else if ((a * b) <= (-2.5d-293)) then
        tmp = z * t
    else if ((a * b) <= 3d-157) then
        tmp = x * y
    else if ((a * b) <= 7.5d-72) then
        tmp = c * i
    else if ((a * b) <= 1.65d-49) then
        tmp = x * y
    else if ((a * b) <= 4.3d+49) then
        tmp = z * t
    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.6e+79) {
		tmp = a * b;
	} else if ((a * b) <= -2.5e-293) {
		tmp = z * t;
	} else if ((a * b) <= 3e-157) {
		tmp = x * y;
	} else if ((a * b) <= 7.5e-72) {
		tmp = c * i;
	} else if ((a * b) <= 1.65e-49) {
		tmp = x * y;
	} else if ((a * b) <= 4.3e+49) {
		tmp = z * t;
	} else {
		tmp = a * b;
	}
	return tmp;
}
def code(x, y, z, t, a, b, c, i):
	tmp = 0
	if (a * b) <= -1.6e+79:
		tmp = a * b
	elif (a * b) <= -2.5e-293:
		tmp = z * t
	elif (a * b) <= 3e-157:
		tmp = x * y
	elif (a * b) <= 7.5e-72:
		tmp = c * i
	elif (a * b) <= 1.65e-49:
		tmp = x * y
	elif (a * b) <= 4.3e+49:
		tmp = z * t
	else:
		tmp = a * b
	return tmp
function code(x, y, z, t, a, b, c, i)
	tmp = 0.0
	if (Float64(a * b) <= -1.6e+79)
		tmp = Float64(a * b);
	elseif (Float64(a * b) <= -2.5e-293)
		tmp = Float64(z * t);
	elseif (Float64(a * b) <= 3e-157)
		tmp = Float64(x * y);
	elseif (Float64(a * b) <= 7.5e-72)
		tmp = Float64(c * i);
	elseif (Float64(a * b) <= 1.65e-49)
		tmp = Float64(x * y);
	elseif (Float64(a * b) <= 4.3e+49)
		tmp = Float64(z * t);
	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.6e+79)
		tmp = a * b;
	elseif ((a * b) <= -2.5e-293)
		tmp = z * t;
	elseif ((a * b) <= 3e-157)
		tmp = x * y;
	elseif ((a * b) <= 7.5e-72)
		tmp = c * i;
	elseif ((a * b) <= 1.65e-49)
		tmp = x * y;
	elseif ((a * b) <= 4.3e+49)
		tmp = z * t;
	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.6e+79], N[(a * b), $MachinePrecision], If[LessEqual[N[(a * b), $MachinePrecision], -2.5e-293], N[(z * t), $MachinePrecision], If[LessEqual[N[(a * b), $MachinePrecision], 3e-157], N[(x * y), $MachinePrecision], If[LessEqual[N[(a * b), $MachinePrecision], 7.5e-72], N[(c * i), $MachinePrecision], If[LessEqual[N[(a * b), $MachinePrecision], 1.65e-49], N[(x * y), $MachinePrecision], If[LessEqual[N[(a * b), $MachinePrecision], 4.3e+49], N[(z * t), $MachinePrecision], N[(a * b), $MachinePrecision]]]]]]]
\begin{array}{l}

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

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

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

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

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

\mathbf{elif}\;a \cdot b \leq 4.3 \cdot 10^{+49}:\\
\;\;\;\;z \cdot t\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if (*.f64 a b) < -1.60000000000000001e79 or 4.2999999999999999e49 < (*.f64 a b)

    1. Initial program 93.8%

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

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

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

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

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

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

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

    if -1.60000000000000001e79 < (*.f64 a b) < -2.5000000000000001e-293 or 1.65e-49 < (*.f64 a b) < 4.2999999999999999e49

    1. Initial program 96.5%

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

      \[\leadsto \color{blue}{\left(a \cdot b + t \cdot z\right)} + c \cdot i \]
    3. Step-by-step derivation
      1. *-commutative76.6%

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

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

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

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

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

    if -2.5000000000000001e-293 < (*.f64 a b) < 3e-157 or 7.5000000000000004e-72 < (*.f64 a b) < 1.65e-49

    1. Initial program 98.3%

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

      \[\leadsto \color{blue}{y \cdot x} + c \cdot i \]
    3. Taylor expanded in y around inf 50.4%

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

    if 3e-157 < (*.f64 a b) < 7.5000000000000004e-72

    1. Initial program 100.0%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;a \cdot b \leq -1.6 \cdot 10^{+79}:\\ \;\;\;\;a \cdot b\\ \mathbf{elif}\;a \cdot b \leq -2.5 \cdot 10^{-293}:\\ \;\;\;\;z \cdot t\\ \mathbf{elif}\;a \cdot b \leq 3 \cdot 10^{-157}:\\ \;\;\;\;x \cdot y\\ \mathbf{elif}\;a \cdot b \leq 7.5 \cdot 10^{-72}:\\ \;\;\;\;c \cdot i\\ \mathbf{elif}\;a \cdot b \leq 1.65 \cdot 10^{-49}:\\ \;\;\;\;x \cdot y\\ \mathbf{elif}\;a \cdot b \leq 4.3 \cdot 10^{+49}:\\ \;\;\;\;z \cdot t\\ \mathbf{else}:\\ \;\;\;\;a \cdot b\\ \end{array} \]

Alternative 5: 63.7% accurate, 0.5× speedup?

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

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

\mathbf{elif}\;a \cdot b \leq -3.6 \cdot 10^{-289}:\\
\;\;\;\;c \cdot i + z \cdot t\\

\mathbf{elif}\;a \cdot b \leq 2.8 \cdot 10^{-49}:\\
\;\;\;\;t_1\\

\mathbf{elif}\;a \cdot b \leq 2.3 \cdot 10^{+87}:\\
\;\;\;\;t_2\\

\mathbf{elif}\;a \cdot b \leq 4.8 \cdot 10^{+230}:\\
\;\;\;\;t_1\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if (*.f64 a b) < -8.6000000000000007e56 or 2.79999999999999997e-49 < (*.f64 a b) < 2.3000000000000002e87

    1. Initial program 96.0%

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

      \[\leadsto \color{blue}{\left(a \cdot b + t \cdot z\right)} + c \cdot i \]
    3. Step-by-step derivation
      1. *-commutative86.9%

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

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

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

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

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

    if -8.6000000000000007e56 < (*.f64 a b) < -3.6e-289

    1. Initial program 95.1%

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

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

    if -3.6e-289 < (*.f64 a b) < 2.79999999999999997e-49 or 2.3000000000000002e87 < (*.f64 a b) < 4.79999999999999996e230

    1. Initial program 98.9%

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

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

    if 4.79999999999999996e230 < (*.f64 a b)

    1. Initial program 87.5%

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

      \[\leadsto \color{blue}{\left(a \cdot b + t \cdot z\right)} + c \cdot i \]
    3. Step-by-step derivation
      1. *-commutative91.7%

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;a \cdot b \leq -8.6 \cdot 10^{+56}:\\ \;\;\;\;a \cdot b + z \cdot t\\ \mathbf{elif}\;a \cdot b \leq -3.6 \cdot 10^{-289}:\\ \;\;\;\;c \cdot i + z \cdot t\\ \mathbf{elif}\;a \cdot b \leq 2.8 \cdot 10^{-49}:\\ \;\;\;\;c \cdot i + x \cdot y\\ \mathbf{elif}\;a \cdot b \leq 2.3 \cdot 10^{+87}:\\ \;\;\;\;a \cdot b + z \cdot t\\ \mathbf{elif}\;a \cdot b \leq 4.8 \cdot 10^{+230}:\\ \;\;\;\;c \cdot i + x \cdot y\\ \mathbf{else}:\\ \;\;\;\;a \cdot b\\ \end{array} \]

Alternative 6: 64.8% accurate, 0.6× speedup?

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

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

\mathbf{elif}\;a \cdot b \leq 0:\\
\;\;\;\;t_1\\

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

\mathbf{elif}\;a \cdot b \leq 4400000000:\\
\;\;\;\;t_1\\

\mathbf{else}:\\
\;\;\;\;t_2\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if (*.f64 a b) < -4.00000000000000037e56 or 4.4e9 < (*.f64 a b)

    1. Initial program 94.5%

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

      \[\leadsto \color{blue}{\left(a \cdot b + t \cdot z\right)} + c \cdot i \]
    3. Step-by-step derivation
      1. *-commutative84.9%

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

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

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

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

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

    if -4.00000000000000037e56 < (*.f64 a b) < -0.0 or 1.12e-197 < (*.f64 a b) < 4.4e9

    1. Initial program 97.7%

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

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

    if -0.0 < (*.f64 a b) < 1.12e-197

    1. Initial program 92.9%

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

      \[\leadsto \color{blue}{y \cdot x} + c \cdot i \]
    3. Taylor expanded in y around inf 72.0%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;a \cdot b \leq -4 \cdot 10^{+56}:\\ \;\;\;\;a \cdot b + z \cdot t\\ \mathbf{elif}\;a \cdot b \leq 0:\\ \;\;\;\;c \cdot i + z \cdot t\\ \mathbf{elif}\;a \cdot b \leq 1.12 \cdot 10^{-197}:\\ \;\;\;\;x \cdot y\\ \mathbf{elif}\;a \cdot b \leq 4400000000:\\ \;\;\;\;c \cdot i + z \cdot t\\ \mathbf{else}:\\ \;\;\;\;a \cdot b + z \cdot t\\ \end{array} \]

Alternative 7: 50.3% accurate, 0.8× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_1 := a \cdot b + c \cdot i\\ \mathbf{if}\;x \leq -1.6 \cdot 10^{+253}:\\ \;\;\;\;x \cdot y\\ \mathbf{elif}\;x \leq -8 \cdot 10^{+177}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq -8.5 \cdot 10^{+134}:\\ \;\;\;\;x \cdot y\\ \mathbf{elif}\;x \leq -7 \cdot 10^{-142}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq -2.3 \cdot 10^{-176}:\\ \;\;\;\;z \cdot t\\ \mathbf{elif}\;x \leq 8 \cdot 10^{-90}:\\ \;\;\;\;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 -1.6e+253)
     (* x y)
     (if (<= x -8e+177)
       t_1
       (if (<= x -8.5e+134)
         (* x y)
         (if (<= x -7e-142)
           t_1
           (if (<= x -2.3e-176) (* z t) (if (<= x 8e-90) 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 <= -1.6e+253) {
		tmp = x * y;
	} else if (x <= -8e+177) {
		tmp = t_1;
	} else if (x <= -8.5e+134) {
		tmp = x * y;
	} else if (x <= -7e-142) {
		tmp = t_1;
	} else if (x <= -2.3e-176) {
		tmp = z * t;
	} else if (x <= 8e-90) {
		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 <= (-1.6d+253)) then
        tmp = x * y
    else if (x <= (-8d+177)) then
        tmp = t_1
    else if (x <= (-8.5d+134)) then
        tmp = x * y
    else if (x <= (-7d-142)) then
        tmp = t_1
    else if (x <= (-2.3d-176)) then
        tmp = z * t
    else if (x <= 8d-90) 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 <= -1.6e+253) {
		tmp = x * y;
	} else if (x <= -8e+177) {
		tmp = t_1;
	} else if (x <= -8.5e+134) {
		tmp = x * y;
	} else if (x <= -7e-142) {
		tmp = t_1;
	} else if (x <= -2.3e-176) {
		tmp = z * t;
	} else if (x <= 8e-90) {
		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 <= -1.6e+253:
		tmp = x * y
	elif x <= -8e+177:
		tmp = t_1
	elif x <= -8.5e+134:
		tmp = x * y
	elif x <= -7e-142:
		tmp = t_1
	elif x <= -2.3e-176:
		tmp = z * t
	elif x <= 8e-90:
		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 (x <= -1.6e+253)
		tmp = Float64(x * y);
	elseif (x <= -8e+177)
		tmp = t_1;
	elseif (x <= -8.5e+134)
		tmp = Float64(x * y);
	elseif (x <= -7e-142)
		tmp = t_1;
	elseif (x <= -2.3e-176)
		tmp = Float64(z * t);
	elseif (x <= 8e-90)
		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 <= -1.6e+253)
		tmp = x * y;
	elseif (x <= -8e+177)
		tmp = t_1;
	elseif (x <= -8.5e+134)
		tmp = x * y;
	elseif (x <= -7e-142)
		tmp = t_1;
	elseif (x <= -2.3e-176)
		tmp = z * t;
	elseif (x <= 8e-90)
		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[x, -1.6e+253], N[(x * y), $MachinePrecision], If[LessEqual[x, -8e+177], t$95$1, If[LessEqual[x, -8.5e+134], N[(x * y), $MachinePrecision], If[LessEqual[x, -7e-142], t$95$1, If[LessEqual[x, -2.3e-176], N[(z * t), $MachinePrecision], If[LessEqual[x, 8e-90], t$95$1, N[(x * y), $MachinePrecision]]]]]]]]
\begin{array}{l}

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

\mathbf{elif}\;x \leq -8 \cdot 10^{+177}:\\
\;\;\;\;t_1\\

\mathbf{elif}\;x \leq -8.5 \cdot 10^{+134}:\\
\;\;\;\;x \cdot y\\

\mathbf{elif}\;x \leq -7 \cdot 10^{-142}:\\
\;\;\;\;t_1\\

\mathbf{elif}\;x \leq -2.3 \cdot 10^{-176}:\\
\;\;\;\;z \cdot t\\

\mathbf{elif}\;x \leq 8 \cdot 10^{-90}:\\
\;\;\;\;t_1\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if x < -1.6000000000000002e253 or -8.0000000000000001e177 < x < -8.50000000000000024e134 or 7.99999999999999996e-90 < x

    1. Initial program 92.6%

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

      \[\leadsto \color{blue}{y \cdot x} + c \cdot i \]
    3. Taylor expanded in y around inf 50.3%

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

    if -1.6000000000000002e253 < x < -8.0000000000000001e177 or -8.50000000000000024e134 < x < -7.00000000000000029e-142 or -2.3000000000000001e-176 < x < 7.99999999999999996e-90

    1. Initial program 98.6%

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

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

    if -7.00000000000000029e-142 < x < -2.3000000000000001e-176

    1. Initial program 100.0%

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

      \[\leadsto \color{blue}{\left(a \cdot b + t \cdot z\right)} + c \cdot i \]
    3. Step-by-step derivation
      1. *-commutative100.0%

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -1.6 \cdot 10^{+253}:\\ \;\;\;\;x \cdot y\\ \mathbf{elif}\;x \leq -8 \cdot 10^{+177}:\\ \;\;\;\;a \cdot b + c \cdot i\\ \mathbf{elif}\;x \leq -8.5 \cdot 10^{+134}:\\ \;\;\;\;x \cdot y\\ \mathbf{elif}\;x \leq -7 \cdot 10^{-142}:\\ \;\;\;\;a \cdot b + c \cdot i\\ \mathbf{elif}\;x \leq -2.3 \cdot 10^{-176}:\\ \;\;\;\;z \cdot t\\ \mathbf{elif}\;x \leq 8 \cdot 10^{-90}:\\ \;\;\;\;a \cdot b + c \cdot i\\ \mathbf{else}:\\ \;\;\;\;x \cdot y\\ \end{array} \]

Alternative 8: 44.0% accurate, 0.8× speedup?

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

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

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

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

\mathbf{elif}\;a \cdot b \leq 3.2 \cdot 10^{+49}:\\
\;\;\;\;z \cdot t\\

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


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

    1. Initial program 93.8%

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

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

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

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

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

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

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

    if -3.59999999999999995e80 < (*.f64 a b) < -1.05e-280 or 2.0999999999999999e-49 < (*.f64 a b) < 3.20000000000000014e49

    1. Initial program 96.5%

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

      \[\leadsto \color{blue}{\left(a \cdot b + t \cdot z\right)} + c \cdot i \]
    3. Step-by-step derivation
      1. *-commutative76.3%

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

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

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

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

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

    if -1.05e-280 < (*.f64 a b) < 2.0999999999999999e-49

    1. Initial program 98.6%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;a \cdot b \leq -3.6 \cdot 10^{+80}:\\ \;\;\;\;a \cdot b\\ \mathbf{elif}\;a \cdot b \leq -1.05 \cdot 10^{-280}:\\ \;\;\;\;z \cdot t\\ \mathbf{elif}\;a \cdot b \leq 2.1 \cdot 10^{-49}:\\ \;\;\;\;c \cdot i\\ \mathbf{elif}\;a \cdot b \leq 3.2 \cdot 10^{+49}:\\ \;\;\;\;z \cdot t\\ \mathbf{else}:\\ \;\;\;\;a \cdot b\\ \end{array} \]

Alternative 9: 73.5% accurate, 0.8× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_1 := c \cdot i + \left(a \cdot b + z \cdot t\right)\\ t_2 := c \cdot i + x \cdot y\\ \mathbf{if}\;y \leq -1.06 \cdot 10^{-44}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;y \leq 7.5 \cdot 10^{+59}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y \leq 8 \cdot 10^{+153}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;y \leq 7.2 \cdot 10^{+228}:\\ \;\;\;\;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 (+ (* c i) (+ (* a b) (* z t)))) (t_2 (+ (* c i) (* x y))))
   (if (<= y -1.06e-44)
     t_2
     (if (<= y 7.5e+59)
       t_1
       (if (<= y 8e+153) t_2 (if (<= y 7.2e+228) 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 = (c * i) + ((a * b) + (z * t));
	double t_2 = (c * i) + (x * y);
	double tmp;
	if (y <= -1.06e-44) {
		tmp = t_2;
	} else if (y <= 7.5e+59) {
		tmp = t_1;
	} else if (y <= 8e+153) {
		tmp = t_2;
	} else if (y <= 7.2e+228) {
		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) :: t_2
    real(8) :: tmp
    t_1 = (c * i) + ((a * b) + (z * t))
    t_2 = (c * i) + (x * y)
    if (y <= (-1.06d-44)) then
        tmp = t_2
    else if (y <= 7.5d+59) then
        tmp = t_1
    else if (y <= 8d+153) then
        tmp = t_2
    else if (y <= 7.2d+228) 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 = (c * i) + ((a * b) + (z * t));
	double t_2 = (c * i) + (x * y);
	double tmp;
	if (y <= -1.06e-44) {
		tmp = t_2;
	} else if (y <= 7.5e+59) {
		tmp = t_1;
	} else if (y <= 8e+153) {
		tmp = t_2;
	} else if (y <= 7.2e+228) {
		tmp = t_1;
	} else {
		tmp = x * y;
	}
	return tmp;
}
def code(x, y, z, t, a, b, c, i):
	t_1 = (c * i) + ((a * b) + (z * t))
	t_2 = (c * i) + (x * y)
	tmp = 0
	if y <= -1.06e-44:
		tmp = t_2
	elif y <= 7.5e+59:
		tmp = t_1
	elif y <= 8e+153:
		tmp = t_2
	elif y <= 7.2e+228:
		tmp = t_1
	else:
		tmp = 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(z * t)))
	t_2 = Float64(Float64(c * i) + Float64(x * y))
	tmp = 0.0
	if (y <= -1.06e-44)
		tmp = t_2;
	elseif (y <= 7.5e+59)
		tmp = t_1;
	elseif (y <= 8e+153)
		tmp = t_2;
	elseif (y <= 7.2e+228)
		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 = (c * i) + ((a * b) + (z * t));
	t_2 = (c * i) + (x * y);
	tmp = 0.0;
	if (y <= -1.06e-44)
		tmp = t_2;
	elseif (y <= 7.5e+59)
		tmp = t_1;
	elseif (y <= 8e+153)
		tmp = t_2;
	elseif (y <= 7.2e+228)
		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[(c * i), $MachinePrecision] + N[(N[(a * b), $MachinePrecision] + N[(z * t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(N[(c * i), $MachinePrecision] + N[(x * y), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y, -1.06e-44], t$95$2, If[LessEqual[y, 7.5e+59], t$95$1, If[LessEqual[y, 8e+153], t$95$2, If[LessEqual[y, 7.2e+228], t$95$1, N[(x * y), $MachinePrecision]]]]]]]
\begin{array}{l}

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

\mathbf{elif}\;y \leq 7.5 \cdot 10^{+59}:\\
\;\;\;\;t_1\\

\mathbf{elif}\;y \leq 8 \cdot 10^{+153}:\\
\;\;\;\;t_2\\

\mathbf{elif}\;y \leq 7.2 \cdot 10^{+228}:\\
\;\;\;\;t_1\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if y < -1.0599999999999999e-44 or 7.4999999999999996e59 < y < 8e153

    1. Initial program 94.5%

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

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

    if -1.0599999999999999e-44 < y < 7.4999999999999996e59 or 8e153 < y < 7.2e228

    1. Initial program 98.6%

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

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

    if 7.2e228 < y

    1. Initial program 83.3%

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

      \[\leadsto \color{blue}{y \cdot x} + c \cdot i \]
    3. Taylor expanded in y around inf 84.3%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -1.06 \cdot 10^{-44}:\\ \;\;\;\;c \cdot i + x \cdot y\\ \mathbf{elif}\;y \leq 7.5 \cdot 10^{+59}:\\ \;\;\;\;c \cdot i + \left(a \cdot b + z \cdot t\right)\\ \mathbf{elif}\;y \leq 8 \cdot 10^{+153}:\\ \;\;\;\;c \cdot i + x \cdot y\\ \mathbf{elif}\;y \leq 7.2 \cdot 10^{+228}:\\ \;\;\;\;c \cdot i + \left(a \cdot b + z \cdot t\right)\\ \mathbf{else}:\\ \;\;\;\;x \cdot y\\ \end{array} \]

Alternative 10: 61.7% accurate, 1.3× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;c \leq -3.5 \cdot 10^{+117} \lor \neg \left(c \leq 3.4 \cdot 10^{-41}\right):\\
\;\;\;\;a \cdot b + c \cdot i\\

\mathbf{else}:\\
\;\;\;\;a \cdot b + z \cdot t\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if c < -3.49999999999999983e117 or 3.3999999999999998e-41 < c

    1. Initial program 94.9%

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

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

    if -3.49999999999999983e117 < c < 3.3999999999999998e-41

    1. Initial program 96.8%

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;c \leq -3.5 \cdot 10^{+117} \lor \neg \left(c \leq 3.4 \cdot 10^{-41}\right):\\ \;\;\;\;a \cdot b + c \cdot i\\ \mathbf{else}:\\ \;\;\;\;a \cdot b + z \cdot t\\ \end{array} \]

Alternative 11: 44.0% accurate, 1.3× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;a \cdot b \leq -2 \cdot 10^{+57}:\\ \;\;\;\;a \cdot b\\ \mathbf{elif}\;a \cdot b \leq 9.6 \cdot 10^{+24}:\\ \;\;\;\;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) -2e+57) (* a b) (if (<= (* a b) 9.6e+24) (* 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) <= -2e+57) {
		tmp = a * b;
	} else if ((a * b) <= 9.6e+24) {
		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) <= (-2d+57)) then
        tmp = a * b
    else if ((a * b) <= 9.6d+24) 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) <= -2e+57) {
		tmp = a * b;
	} else if ((a * b) <= 9.6e+24) {
		tmp = c * i;
	} else {
		tmp = a * b;
	}
	return tmp;
}
def code(x, y, z, t, a, b, c, i):
	tmp = 0
	if (a * b) <= -2e+57:
		tmp = a * b
	elif (a * b) <= 9.6e+24:
		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) <= -2e+57)
		tmp = Float64(a * b);
	elseif (Float64(a * b) <= 9.6e+24)
		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) <= -2e+57)
		tmp = a * b;
	elseif ((a * b) <= 9.6e+24)
		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], -2e+57], N[(a * b), $MachinePrecision], If[LessEqual[N[(a * b), $MachinePrecision], 9.6e+24], N[(c * i), $MachinePrecision], N[(a * b), $MachinePrecision]]]
\begin{array}{l}

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (*.f64 a b) < -2.0000000000000001e57 or 9.6000000000000003e24 < (*.f64 a b)

    1. Initial program 94.4%

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

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

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

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

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

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

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

    if -2.0000000000000001e57 < (*.f64 a b) < 9.6000000000000003e24

    1. Initial program 97.3%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;a \cdot b \leq -2 \cdot 10^{+57}:\\ \;\;\;\;a \cdot b\\ \mathbf{elif}\;a \cdot b \leq 9.6 \cdot 10^{+24}:\\ \;\;\;\;c \cdot i\\ \mathbf{else}:\\ \;\;\;\;a \cdot b\\ \end{array} \]

Alternative 12: 28.7% 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 96.1%

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

    \[\leadsto \color{blue}{\left(a \cdot b + t \cdot z\right)} + c \cdot i \]
  3. Step-by-step derivation
    1. *-commutative74.5%

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

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

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

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

    \[\leadsto \color{blue}{a \cdot b} \]
  6. Final simplification28.2%

    \[\leadsto a \cdot b \]

Reproduce

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