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

Percentage Accurate: 95.8% → 97.8%
Time: 9.5s
Alternatives: 13
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 13 alternatives:

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

Initial Program: 95.8% accurate, 1.0× speedup?

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

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

Alternative 1: 97.8% accurate, 0.0× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 2: 96.8% accurate, 0.5× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_1 := x \cdot y + z \cdot t\\ t_2 := \left(a \cdot b + t_1\right) + c \cdot i\\ \mathbf{if}\;t_2 \leq \infty:\\ \;\;\;\;t_2\\ \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))) (t_2 (+ (+ (* a b) t_1) (* c i))))
   (if (<= t_2 INFINITY) t_2 (+ (* 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 t_2 = ((a * b) + t_1) + (c * i);
	double tmp;
	if (t_2 <= ((double) INFINITY)) {
		tmp = t_2;
	} else {
		tmp = (c * i) + t_1;
	}
	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 = (x * y) + (z * t);
	double t_2 = ((a * b) + t_1) + (c * i);
	double tmp;
	if (t_2 <= Double.POSITIVE_INFINITY) {
		tmp = t_2;
	} else {
		tmp = (c * i) + t_1;
	}
	return tmp;
}
def code(x, y, z, t, a, b, c, i):
	t_1 = (x * y) + (z * t)
	t_2 = ((a * b) + t_1) + (c * i)
	tmp = 0
	if t_2 <= math.inf:
		tmp = t_2
	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))
	t_2 = Float64(Float64(Float64(a * b) + t_1) + Float64(c * i))
	tmp = 0.0
	if (t_2 <= Inf)
		tmp = t_2;
	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);
	t_2 = ((a * b) + t_1) + (c * i);
	tmp = 0.0;
	if (t_2 <= Inf)
		tmp = t_2;
	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]}, Block[{t$95$2 = N[(N[(N[(a * b), $MachinePrecision] + t$95$1), $MachinePrecision] + N[(c * i), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$2, Infinity], t$95$2, N[(N[(c * i), $MachinePrecision] + t$95$1), $MachinePrecision]]]]
\begin{array}{l}

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

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


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

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

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

Alternative 3: 42.0% accurate, 0.6× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;c \cdot i \leq -1.4 \cdot 10^{+98}:\\ \;\;\;\;c \cdot i\\ \mathbf{elif}\;c \cdot i \leq -1.75 \cdot 10^{-183}:\\ \;\;\;\;z \cdot t\\ \mathbf{elif}\;c \cdot i \leq 0:\\ \;\;\;\;a \cdot b\\ \mathbf{elif}\;c \cdot i \leq 2.05 \cdot 10^{-38}:\\ \;\;\;\;z \cdot t\\ \mathbf{elif}\;c \cdot i \leq 5.7 \cdot 10^{+76}:\\ \;\;\;\;a \cdot b\\ \mathbf{else}:\\ \;\;\;\;c \cdot i\\ \end{array} \end{array} \]
(FPCore (x y z t a b c i)
 :precision binary64
 (if (<= (* c i) -1.4e+98)
   (* c i)
   (if (<= (* c i) -1.75e-183)
     (* z t)
     (if (<= (* c i) 0.0)
       (* a b)
       (if (<= (* c i) 2.05e-38)
         (* z t)
         (if (<= (* c i) 5.7e+76) (* a b) (* c i)))))))
double code(double x, double y, double z, double t, double a, double b, double c, double i) {
	double tmp;
	if ((c * i) <= -1.4e+98) {
		tmp = c * i;
	} else if ((c * i) <= -1.75e-183) {
		tmp = z * t;
	} else if ((c * i) <= 0.0) {
		tmp = a * b;
	} else if ((c * i) <= 2.05e-38) {
		tmp = z * t;
	} else if ((c * i) <= 5.7e+76) {
		tmp = a * b;
	} else {
		tmp = c * i;
	}
	return tmp;
}
real(8) function code(x, y, z, t, a, b, c, i)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8), intent (in) :: t
    real(8), intent (in) :: a
    real(8), intent (in) :: b
    real(8), intent (in) :: c
    real(8), intent (in) :: i
    real(8) :: tmp
    if ((c * i) <= (-1.4d+98)) then
        tmp = c * i
    else if ((c * i) <= (-1.75d-183)) then
        tmp = z * t
    else if ((c * i) <= 0.0d0) then
        tmp = a * b
    else if ((c * i) <= 2.05d-38) then
        tmp = z * t
    else if ((c * i) <= 5.7d+76) then
        tmp = a * b
    else
        tmp = c * i
    end if
    code = tmp
end function
public static double code(double x, double y, double z, double t, double a, double b, double c, double i) {
	double tmp;
	if ((c * i) <= -1.4e+98) {
		tmp = c * i;
	} else if ((c * i) <= -1.75e-183) {
		tmp = z * t;
	} else if ((c * i) <= 0.0) {
		tmp = a * b;
	} else if ((c * i) <= 2.05e-38) {
		tmp = z * t;
	} else if ((c * i) <= 5.7e+76) {
		tmp = a * b;
	} else {
		tmp = c * i;
	}
	return tmp;
}
def code(x, y, z, t, a, b, c, i):
	tmp = 0
	if (c * i) <= -1.4e+98:
		tmp = c * i
	elif (c * i) <= -1.75e-183:
		tmp = z * t
	elif (c * i) <= 0.0:
		tmp = a * b
	elif (c * i) <= 2.05e-38:
		tmp = z * t
	elif (c * i) <= 5.7e+76:
		tmp = a * b
	else:
		tmp = c * i
	return tmp
function code(x, y, z, t, a, b, c, i)
	tmp = 0.0
	if (Float64(c * i) <= -1.4e+98)
		tmp = Float64(c * i);
	elseif (Float64(c * i) <= -1.75e-183)
		tmp = Float64(z * t);
	elseif (Float64(c * i) <= 0.0)
		tmp = Float64(a * b);
	elseif (Float64(c * i) <= 2.05e-38)
		tmp = Float64(z * t);
	elseif (Float64(c * i) <= 5.7e+76)
		tmp = Float64(a * b);
	else
		tmp = Float64(c * i);
	end
	return tmp
end
function tmp_2 = code(x, y, z, t, a, b, c, i)
	tmp = 0.0;
	if ((c * i) <= -1.4e+98)
		tmp = c * i;
	elseif ((c * i) <= -1.75e-183)
		tmp = z * t;
	elseif ((c * i) <= 0.0)
		tmp = a * b;
	elseif ((c * i) <= 2.05e-38)
		tmp = z * t;
	elseif ((c * i) <= 5.7e+76)
		tmp = a * b;
	else
		tmp = c * i;
	end
	tmp_2 = tmp;
end
code[x_, y_, z_, t_, a_, b_, c_, i_] := If[LessEqual[N[(c * i), $MachinePrecision], -1.4e+98], N[(c * i), $MachinePrecision], If[LessEqual[N[(c * i), $MachinePrecision], -1.75e-183], N[(z * t), $MachinePrecision], If[LessEqual[N[(c * i), $MachinePrecision], 0.0], N[(a * b), $MachinePrecision], If[LessEqual[N[(c * i), $MachinePrecision], 2.05e-38], N[(z * t), $MachinePrecision], If[LessEqual[N[(c * i), $MachinePrecision], 5.7e+76], N[(a * b), $MachinePrecision], N[(c * i), $MachinePrecision]]]]]]
\begin{array}{l}

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

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

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

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

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

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


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

    1. Initial program 94.7%

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

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

    if -1.4e98 < (*.f64 c i) < -1.74999999999999996e-183 or -0.0 < (*.f64 c i) < 2.0499999999999999e-38

    1. Initial program 97.7%

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

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

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

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

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

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

      \[\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. Step-by-step derivation
      1. fma-udef97.7%

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

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

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

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

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

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

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

    if -1.74999999999999996e-183 < (*.f64 c i) < -0.0 or 2.0499999999999999e-38 < (*.f64 c i) < 5.70000000000000004e76

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;c \cdot i \leq -1.4 \cdot 10^{+98}:\\ \;\;\;\;c \cdot i\\ \mathbf{elif}\;c \cdot i \leq -1.75 \cdot 10^{-183}:\\ \;\;\;\;z \cdot t\\ \mathbf{elif}\;c \cdot i \leq 0:\\ \;\;\;\;a \cdot b\\ \mathbf{elif}\;c \cdot i \leq 2.05 \cdot 10^{-38}:\\ \;\;\;\;z \cdot t\\ \mathbf{elif}\;c \cdot i \leq 5.7 \cdot 10^{+76}:\\ \;\;\;\;a \cdot b\\ \mathbf{else}:\\ \;\;\;\;c \cdot i\\ \end{array} \]

Alternative 4: 63.8% accurate, 0.6× speedup?

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

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

\mathbf{elif}\;x \cdot y \leq -7.8 \cdot 10^{+29}:\\
\;\;\;\;a \cdot b + z \cdot t\\

\mathbf{elif}\;x \cdot y \leq -8.2 \cdot 10^{+27}:\\
\;\;\;\;x \cdot y\\

\mathbf{elif}\;x \cdot y \leq 3 \cdot 10^{+140}:\\
\;\;\;\;a \cdot b + c \cdot i\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if (*.f64 x y) < -7.49999999999999992e139 or -7.79999999999999937e29 < (*.f64 x y) < -8.2000000000000005e27

    1. Initial program 93.3%

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

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

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

    if -7.49999999999999992e139 < (*.f64 x y) < -7.79999999999999937e29

    1. Initial program 95.2%

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

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

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

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

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

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

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

    if -8.2000000000000005e27 < (*.f64 x y) < 2.99999999999999997e140

    1. Initial program 98.7%

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

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

    if 2.99999999999999997e140 < (*.f64 x y)

    1. Initial program 92.1%

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \cdot y \leq -7.5 \cdot 10^{+139}:\\ \;\;\;\;x \cdot y\\ \mathbf{elif}\;x \cdot y \leq -7.8 \cdot 10^{+29}:\\ \;\;\;\;a \cdot b + z \cdot t\\ \mathbf{elif}\;x \cdot y \leq -8.2 \cdot 10^{+27}:\\ \;\;\;\;x \cdot y\\ \mathbf{elif}\;x \cdot y \leq 3 \cdot 10^{+140}:\\ \;\;\;\;a \cdot b + c \cdot i\\ \mathbf{else}:\\ \;\;\;\;x \cdot y + a \cdot b\\ \end{array} \]

Alternative 5: 64.9% accurate, 0.6× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_1 := x \cdot y + a \cdot b\\ t_2 := c \cdot i + z \cdot t\\ \mathbf{if}\;c \cdot i \leq -33000000:\\ \;\;\;\;t_2\\ \mathbf{elif}\;c \cdot i \leq 9.5 \cdot 10^{-300}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;c \cdot i \leq 7 \cdot 10^{-220}:\\ \;\;\;\;a \cdot b + z \cdot t\\ \mathbf{elif}\;c \cdot i \leq 8.5 \cdot 10^{+138}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;t_2\\ \end{array} \end{array} \]
(FPCore (x y z t a b c i)
 :precision binary64
 (let* ((t_1 (+ (* x y) (* a b))) (t_2 (+ (* c i) (* z t))))
   (if (<= (* c i) -33000000.0)
     t_2
     (if (<= (* c i) 9.5e-300)
       t_1
       (if (<= (* c i) 7e-220)
         (+ (* a b) (* z t))
         (if (<= (* c i) 8.5e+138) 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 = (x * y) + (a * b);
	double t_2 = (c * i) + (z * t);
	double tmp;
	if ((c * i) <= -33000000.0) {
		tmp = t_2;
	} else if ((c * i) <= 9.5e-300) {
		tmp = t_1;
	} else if ((c * i) <= 7e-220) {
		tmp = (a * b) + (z * t);
	} else if ((c * i) <= 8.5e+138) {
		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 = (x * y) + (a * b)
    t_2 = (c * i) + (z * t)
    if ((c * i) <= (-33000000.0d0)) then
        tmp = t_2
    else if ((c * i) <= 9.5d-300) then
        tmp = t_1
    else if ((c * i) <= 7d-220) then
        tmp = (a * b) + (z * t)
    else if ((c * i) <= 8.5d+138) 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 = (x * y) + (a * b);
	double t_2 = (c * i) + (z * t);
	double tmp;
	if ((c * i) <= -33000000.0) {
		tmp = t_2;
	} else if ((c * i) <= 9.5e-300) {
		tmp = t_1;
	} else if ((c * i) <= 7e-220) {
		tmp = (a * b) + (z * t);
	} else if ((c * i) <= 8.5e+138) {
		tmp = t_1;
	} else {
		tmp = t_2;
	}
	return tmp;
}
def code(x, y, z, t, a, b, c, i):
	t_1 = (x * y) + (a * b)
	t_2 = (c * i) + (z * t)
	tmp = 0
	if (c * i) <= -33000000.0:
		tmp = t_2
	elif (c * i) <= 9.5e-300:
		tmp = t_1
	elif (c * i) <= 7e-220:
		tmp = (a * b) + (z * t)
	elif (c * i) <= 8.5e+138:
		tmp = t_1
	else:
		tmp = t_2
	return tmp
function code(x, y, z, t, a, b, c, i)
	t_1 = Float64(Float64(x * y) + Float64(a * b))
	t_2 = Float64(Float64(c * i) + Float64(z * t))
	tmp = 0.0
	if (Float64(c * i) <= -33000000.0)
		tmp = t_2;
	elseif (Float64(c * i) <= 9.5e-300)
		tmp = t_1;
	elseif (Float64(c * i) <= 7e-220)
		tmp = Float64(Float64(a * b) + Float64(z * t));
	elseif (Float64(c * i) <= 8.5e+138)
		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 = (x * y) + (a * b);
	t_2 = (c * i) + (z * t);
	tmp = 0.0;
	if ((c * i) <= -33000000.0)
		tmp = t_2;
	elseif ((c * i) <= 9.5e-300)
		tmp = t_1;
	elseif ((c * i) <= 7e-220)
		tmp = (a * b) + (z * t);
	elseif ((c * i) <= 8.5e+138)
		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[(x * y), $MachinePrecision] + N[(a * b), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(N[(c * i), $MachinePrecision] + N[(z * t), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(c * i), $MachinePrecision], -33000000.0], t$95$2, If[LessEqual[N[(c * i), $MachinePrecision], 9.5e-300], t$95$1, If[LessEqual[N[(c * i), $MachinePrecision], 7e-220], N[(N[(a * b), $MachinePrecision] + N[(z * t), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(c * i), $MachinePrecision], 8.5e+138], t$95$1, t$95$2]]]]]]
\begin{array}{l}

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

\mathbf{elif}\;c \cdot i \leq 9.5 \cdot 10^{-300}:\\
\;\;\;\;t_1\\

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

\mathbf{elif}\;c \cdot i \leq 8.5 \cdot 10^{+138}:\\
\;\;\;\;t_1\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if (*.f64 c i) < -3.3e7 or 8.5000000000000006e138 < (*.f64 c i)

    1. Initial program 95.0%

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

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

    if -3.3e7 < (*.f64 c i) < 9.5000000000000007e-300 or 6.99999999999999975e-220 < (*.f64 c i) < 8.5000000000000006e138

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

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

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

    if 9.5000000000000007e-300 < (*.f64 c i) < 6.99999999999999975e-220

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;c \cdot i \leq -33000000:\\ \;\;\;\;c \cdot i + z \cdot t\\ \mathbf{elif}\;c \cdot i \leq 9.5 \cdot 10^{-300}:\\ \;\;\;\;x \cdot y + a \cdot b\\ \mathbf{elif}\;c \cdot i \leq 7 \cdot 10^{-220}:\\ \;\;\;\;a \cdot b + z \cdot t\\ \mathbf{elif}\;c \cdot i \leq 8.5 \cdot 10^{+138}:\\ \;\;\;\;x \cdot y + a \cdot b\\ \mathbf{else}:\\ \;\;\;\;c \cdot i + z \cdot t\\ \end{array} \]

Alternative 6: 65.1% accurate, 0.6× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_1 := x \cdot y + a \cdot b\\ \mathbf{if}\;c \cdot i \leq -33000000:\\ \;\;\;\;c \cdot i + z \cdot t\\ \mathbf{elif}\;c \cdot i \leq 8.5 \cdot 10^{-300}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;c \cdot i \leq 1.05 \cdot 10^{-220}:\\ \;\;\;\;a \cdot b + z \cdot t\\ \mathbf{elif}\;c \cdot i \leq 2.7 \cdot 10^{+75}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;x \cdot y + c \cdot i\\ \end{array} \end{array} \]
(FPCore (x y z t a b c i)
 :precision binary64
 (let* ((t_1 (+ (* x y) (* a b))))
   (if (<= (* c i) -33000000.0)
     (+ (* c i) (* z t))
     (if (<= (* c i) 8.5e-300)
       t_1
       (if (<= (* c i) 1.05e-220)
         (+ (* a b) (* z t))
         (if (<= (* c i) 2.7e+75) t_1 (+ (* x y) (* c i))))))))
double code(double x, double y, double z, double t, double a, double b, double c, double i) {
	double t_1 = (x * y) + (a * b);
	double tmp;
	if ((c * i) <= -33000000.0) {
		tmp = (c * i) + (z * t);
	} else if ((c * i) <= 8.5e-300) {
		tmp = t_1;
	} else if ((c * i) <= 1.05e-220) {
		tmp = (a * b) + (z * t);
	} else if ((c * i) <= 2.7e+75) {
		tmp = t_1;
	} else {
		tmp = (x * y) + (c * i);
	}
	return tmp;
}
real(8) function code(x, y, z, t, a, b, c, i)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8), intent (in) :: t
    real(8), intent (in) :: a
    real(8), intent (in) :: b
    real(8), intent (in) :: c
    real(8), intent (in) :: i
    real(8) :: t_1
    real(8) :: tmp
    t_1 = (x * y) + (a * b)
    if ((c * i) <= (-33000000.0d0)) then
        tmp = (c * i) + (z * t)
    else if ((c * i) <= 8.5d-300) then
        tmp = t_1
    else if ((c * i) <= 1.05d-220) then
        tmp = (a * b) + (z * t)
    else if ((c * i) <= 2.7d+75) then
        tmp = t_1
    else
        tmp = (x * y) + (c * i)
    end if
    code = tmp
end function
public static double code(double x, double y, double z, double t, double a, double b, double c, double i) {
	double t_1 = (x * y) + (a * b);
	double tmp;
	if ((c * i) <= -33000000.0) {
		tmp = (c * i) + (z * t);
	} else if ((c * i) <= 8.5e-300) {
		tmp = t_1;
	} else if ((c * i) <= 1.05e-220) {
		tmp = (a * b) + (z * t);
	} else if ((c * i) <= 2.7e+75) {
		tmp = t_1;
	} else {
		tmp = (x * y) + (c * i);
	}
	return tmp;
}
def code(x, y, z, t, a, b, c, i):
	t_1 = (x * y) + (a * b)
	tmp = 0
	if (c * i) <= -33000000.0:
		tmp = (c * i) + (z * t)
	elif (c * i) <= 8.5e-300:
		tmp = t_1
	elif (c * i) <= 1.05e-220:
		tmp = (a * b) + (z * t)
	elif (c * i) <= 2.7e+75:
		tmp = t_1
	else:
		tmp = (x * y) + (c * i)
	return tmp
function code(x, y, z, t, a, b, c, i)
	t_1 = Float64(Float64(x * y) + Float64(a * b))
	tmp = 0.0
	if (Float64(c * i) <= -33000000.0)
		tmp = Float64(Float64(c * i) + Float64(z * t));
	elseif (Float64(c * i) <= 8.5e-300)
		tmp = t_1;
	elseif (Float64(c * i) <= 1.05e-220)
		tmp = Float64(Float64(a * b) + Float64(z * t));
	elseif (Float64(c * i) <= 2.7e+75)
		tmp = t_1;
	else
		tmp = Float64(Float64(x * y) + Float64(c * i));
	end
	return tmp
end
function tmp_2 = code(x, y, z, t, a, b, c, i)
	t_1 = (x * y) + (a * b);
	tmp = 0.0;
	if ((c * i) <= -33000000.0)
		tmp = (c * i) + (z * t);
	elseif ((c * i) <= 8.5e-300)
		tmp = t_1;
	elseif ((c * i) <= 1.05e-220)
		tmp = (a * b) + (z * t);
	elseif ((c * i) <= 2.7e+75)
		tmp = t_1;
	else
		tmp = (x * y) + (c * i);
	end
	tmp_2 = tmp;
end
code[x_, y_, z_, t_, a_, b_, c_, i_] := Block[{t$95$1 = N[(N[(x * y), $MachinePrecision] + N[(a * b), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(c * i), $MachinePrecision], -33000000.0], N[(N[(c * i), $MachinePrecision] + N[(z * t), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(c * i), $MachinePrecision], 8.5e-300], t$95$1, If[LessEqual[N[(c * i), $MachinePrecision], 1.05e-220], N[(N[(a * b), $MachinePrecision] + N[(z * t), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(c * i), $MachinePrecision], 2.7e+75], t$95$1, N[(N[(x * y), $MachinePrecision] + N[(c * i), $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}

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

\mathbf{elif}\;c \cdot i \leq 8.5 \cdot 10^{-300}:\\
\;\;\;\;t_1\\

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

\mathbf{elif}\;c \cdot i \leq 2.7 \cdot 10^{+75}:\\
\;\;\;\;t_1\\

\mathbf{else}:\\
\;\;\;\;x \cdot y + c \cdot i\\


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if (*.f64 c i) < -3.3e7

    1. Initial program 96.9%

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

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

    if -3.3e7 < (*.f64 c i) < 8.4999999999999995e-300 or 1.04999999999999996e-220 < (*.f64 c i) < 2.69999999999999998e75

    1. Initial program 97.1%

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

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

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

    if 8.4999999999999995e-300 < (*.f64 c i) < 1.04999999999999996e-220

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

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

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

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

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

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

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

    if 2.69999999999999998e75 < (*.f64 c i)

    1. Initial program 93.5%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;c \cdot i \leq -33000000:\\ \;\;\;\;c \cdot i + z \cdot t\\ \mathbf{elif}\;c \cdot i \leq 8.5 \cdot 10^{-300}:\\ \;\;\;\;x \cdot y + a \cdot b\\ \mathbf{elif}\;c \cdot i \leq 1.05 \cdot 10^{-220}:\\ \;\;\;\;a \cdot b + z \cdot t\\ \mathbf{elif}\;c \cdot i \leq 2.7 \cdot 10^{+75}:\\ \;\;\;\;x \cdot y + a \cdot b\\ \mathbf{else}:\\ \;\;\;\;x \cdot y + c \cdot i\\ \end{array} \]

Alternative 7: 84.9% accurate, 0.8× speedup?

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

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

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

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


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

    1. Initial program 92.7%

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

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

    if -6.8000000000000005e139 < (*.f64 x y) < 2.50000000000000004e140

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

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

    if 2.50000000000000004e140 < (*.f64 x y)

    1. Initial program 92.1%

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \cdot y \leq -6.8 \cdot 10^{+139}:\\ \;\;\;\;x \cdot y + c \cdot i\\ \mathbf{elif}\;x \cdot y \leq 2.5 \cdot 10^{+140}:\\ \;\;\;\;c \cdot i + \left(a \cdot b + z \cdot t\right)\\ \mathbf{else}:\\ \;\;\;\;x \cdot y + a \cdot b\\ \end{array} \]

Alternative 8: 86.0% accurate, 0.8× speedup?

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

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

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

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


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

    1. Initial program 92.7%

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

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

    if -1.74999999999999989e139 < (*.f64 x y) < 7.49999999999999992e139

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

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

    if 7.49999999999999992e139 < (*.f64 x y)

    1. Initial program 92.1%

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

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

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

Alternative 9: 87.4% accurate, 0.8× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;x \cdot y \leq -4.1 \cdot 10^{+138}:\\
\;\;\;\;c \cdot i + \left(x \cdot y + z \cdot t\right)\\

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

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


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

    1. Initial program 92.7%

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

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

    if -4.0999999999999998e138 < (*.f64 x y) < 6.8000000000000005e139

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

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

    if 6.8000000000000005e139 < (*.f64 x y)

    1. Initial program 92.1%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \cdot y \leq -4.1 \cdot 10^{+138}:\\ \;\;\;\;c \cdot i + \left(x \cdot y + z \cdot t\right)\\ \mathbf{elif}\;x \cdot y \leq 6.8 \cdot 10^{+139}:\\ \;\;\;\;c \cdot i + \left(a \cdot b + z \cdot t\right)\\ \mathbf{else}:\\ \;\;\;\;c \cdot i + \left(x \cdot y + a \cdot b\right)\\ \end{array} \]

Alternative 10: 42.2% accurate, 1.0× speedup?

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

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

\mathbf{elif}\;x \cdot y \leq -5.9 \cdot 10^{+46}:\\
\;\;\;\;a \cdot b\\

\mathbf{elif}\;x \cdot y \leq 3.4 \cdot 10^{+131}:\\
\;\;\;\;c \cdot i\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if (*.f64 x y) < -3.80000000000000012e138 or 3.39999999999999986e131 < (*.f64 x y)

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

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

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

    if -3.80000000000000012e138 < (*.f64 x y) < -5.8999999999999999e46

    1. Initial program 93.3%

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

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

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

    if -5.8999999999999999e46 < (*.f64 x y) < 3.39999999999999986e131

    1. Initial program 98.7%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \cdot y \leq -3.8 \cdot 10^{+138}:\\ \;\;\;\;x \cdot y\\ \mathbf{elif}\;x \cdot y \leq -5.9 \cdot 10^{+46}:\\ \;\;\;\;a \cdot b\\ \mathbf{elif}\;x \cdot y \leq 3.4 \cdot 10^{+131}:\\ \;\;\;\;c \cdot i\\ \mathbf{else}:\\ \;\;\;\;x \cdot y\\ \end{array} \]

Alternative 11: 62.8% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \cdot y \leq -1.04 \cdot 10^{+139} \lor \neg \left(x \cdot y \leq 3.6 \cdot 10^{+141}\right):\\ \;\;\;\;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) -1.04e+139) (not (<= (* x y) 3.6e+141)))
   (* 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) <= -1.04e+139) || !((x * y) <= 3.6e+141)) {
		tmp = 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) <= (-1.04d+139)) .or. (.not. ((x * y) <= 3.6d+141))) then
        tmp = 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) <= -1.04e+139) || !((x * y) <= 3.6e+141)) {
		tmp = 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) <= -1.04e+139) or not ((x * y) <= 3.6e+141):
		tmp = 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) <= -1.04e+139) || !(Float64(x * y) <= 3.6e+141))
		tmp = 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) <= -1.04e+139) || ~(((x * y) <= 3.6e+141)))
		tmp = 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], -1.04e+139], N[Not[LessEqual[N[(x * y), $MachinePrecision], 3.6e+141]], $MachinePrecision]], N[(x * y), $MachinePrecision], N[(N[(a * b), $MachinePrecision] + N[(c * i), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;x \cdot y \leq -1.04 \cdot 10^{+139} \lor \neg \left(x \cdot y \leq 3.6 \cdot 10^{+141}\right):\\
\;\;\;\;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) < -1.04e139 or 3.6000000000000001e141 < (*.f64 x y)

    1. Initial program 92.4%

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

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

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

    if -1.04e139 < (*.f64 x y) < 3.6000000000000001e141

    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 a around inf 65.4%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \cdot y \leq -1.04 \cdot 10^{+139} \lor \neg \left(x \cdot y \leq 3.6 \cdot 10^{+141}\right):\\ \;\;\;\;x \cdot y\\ \mathbf{else}:\\ \;\;\;\;a \cdot b + c \cdot i\\ \end{array} \]

Alternative 12: 41.8% accurate, 1.3× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;c \cdot i \leq -950000 \lor \neg \left(c \cdot i \leq 9.5 \cdot 10^{+75}\right):\\ \;\;\;\;c \cdot i\\ \mathbf{else}:\\ \;\;\;\;a \cdot b\\ \end{array} \end{array} \]
(FPCore (x y z t a b c i)
 :precision binary64
 (if (or (<= (* c i) -950000.0) (not (<= (* c i) 9.5e+75))) (* c i) (* a b)))
double code(double x, double y, double z, double t, double a, double b, double c, double i) {
	double tmp;
	if (((c * i) <= -950000.0) || !((c * i) <= 9.5e+75)) {
		tmp = c * i;
	} else {
		tmp = a * b;
	}
	return tmp;
}
real(8) function code(x, y, z, t, a, b, c, i)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8), intent (in) :: t
    real(8), intent (in) :: a
    real(8), intent (in) :: b
    real(8), intent (in) :: c
    real(8), intent (in) :: i
    real(8) :: tmp
    if (((c * i) <= (-950000.0d0)) .or. (.not. ((c * i) <= 9.5d+75))) then
        tmp = c * i
    else
        tmp = a * b
    end if
    code = tmp
end function
public static double code(double x, double y, double z, double t, double a, double b, double c, double i) {
	double tmp;
	if (((c * i) <= -950000.0) || !((c * i) <= 9.5e+75)) {
		tmp = c * i;
	} else {
		tmp = a * b;
	}
	return tmp;
}
def code(x, y, z, t, a, b, c, i):
	tmp = 0
	if ((c * i) <= -950000.0) or not ((c * i) <= 9.5e+75):
		tmp = c * i
	else:
		tmp = a * b
	return tmp
function code(x, y, z, t, a, b, c, i)
	tmp = 0.0
	if ((Float64(c * i) <= -950000.0) || !(Float64(c * i) <= 9.5e+75))
		tmp = Float64(c * i);
	else
		tmp = Float64(a * b);
	end
	return tmp
end
function tmp_2 = code(x, y, z, t, a, b, c, i)
	tmp = 0.0;
	if (((c * i) <= -950000.0) || ~(((c * i) <= 9.5e+75)))
		tmp = c * i;
	else
		tmp = a * b;
	end
	tmp_2 = tmp;
end
code[x_, y_, z_, t_, a_, b_, c_, i_] := If[Or[LessEqual[N[(c * i), $MachinePrecision], -950000.0], N[Not[LessEqual[N[(c * i), $MachinePrecision], 9.5e+75]], $MachinePrecision]], N[(c * i), $MachinePrecision], N[(a * b), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;c \cdot i \leq -950000 \lor \neg \left(c \cdot i \leq 9.5 \cdot 10^{+75}\right):\\
\;\;\;\;c \cdot i\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (*.f64 c i) < -9.5e5 or 9.50000000000000061e75 < (*.f64 c i)

    1. Initial program 95.5%

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

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

    if -9.5e5 < (*.f64 c i) < 9.50000000000000061e75

    1. Initial program 97.2%

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;c \cdot i \leq -950000 \lor \neg \left(c \cdot i \leq 9.5 \cdot 10^{+75}\right):\\ \;\;\;\;c \cdot i\\ \mathbf{else}:\\ \;\;\;\;a \cdot b\\ \end{array} \]

Alternative 13: 27.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.5%

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

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

    \[\leadsto \color{blue}{a \cdot b} \]
  4. Final simplification24.1%

    \[\leadsto a \cdot b \]

Reproduce

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