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

Percentage Accurate: 96.3% → 97.9%
Time: 10.2s
Alternatives: 12
Speedup: 0.4×

Specification

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

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

Sampling outcomes in binary64 precision:

Local Percentage Accuracy vs ?

The average percentage accuracy by input value. Horizontal axis shows value of an input variable; the variable is choosen in the title. Vertical axis is accuracy; higher is better. Red represent the original program, while blue represents Herbie's suggestion. These can be toggled with buttons below the plot. The line is an average while dots represent individual samples.

Accuracy vs Speed?

Herbie found 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: 96.3% 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.9% accurate, 0.4× speedup?

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

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

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


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

    1. Initial program 100.0%

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

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

    1. Initial program 0.0%

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

      \[\leadsto \color{blue}{a \cdot b + \left(t \cdot z + x \cdot y\right)} \]
    4. Taylor expanded in b around inf 57.1%

      \[\leadsto \color{blue}{b \cdot \left(a + \left(\frac{t \cdot z}{b} + \frac{x \cdot y}{b}\right)\right)} \]
    5. Taylor expanded in t around inf 72.0%

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

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

Alternative 2: 98.3% accurate, 0.0× speedup?

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

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

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

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

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

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

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

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

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

Alternative 3: 88.3% accurate, 0.6× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;x \cdot y \leq -1.75 \cdot 10^{+56} \lor \neg \left(x \cdot y \leq 4.8 \cdot 10^{+36}\right):\\
\;\;\;\;a \cdot b + \left(x \cdot y + z \cdot t\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (*.f64 x y) < -1.75e56 or 4.79999999999999985e36 < (*.f64 x y)

    1. Initial program 97.1%

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

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

    if -1.75e56 < (*.f64 x y) < 4.79999999999999985e36

    1. Initial program 97.3%

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

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

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

Alternative 4: 84.6% accurate, 0.6× speedup?

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

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

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

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


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

    1. Initial program 90.5%

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

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

    if -8.8000000000000001e228 < (*.f64 c i) < 2.9999999999999998e179

    1. Initial program 99.0%

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

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

    if 2.9999999999999998e179 < (*.f64 c i)

    1. Initial program 88.5%

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

      \[\leadsto \left(\color{blue}{z \cdot \left(t + \frac{x \cdot y}{z}\right)} + a \cdot b\right) + c \cdot i \]
    4. Taylor expanded in z around inf 84.6%

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

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

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

Alternative 5: 41.9% accurate, 0.6× speedup?

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

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

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if (*.f64 a b) < -2.2e30 or 7.80000000000000027e214 < (*.f64 a b)

    1. Initial program 93.7%

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

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

    if -2.2e30 < (*.f64 a b) < -0.0

    1. Initial program 100.0%

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

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

    if -0.0 < (*.f64 a b) < 7.80000000000000027e214

    1. Initial program 97.8%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;a \cdot b \leq -2.2 \cdot 10^{+30}:\\ \;\;\;\;a \cdot b\\ \mathbf{elif}\;a \cdot b \leq 0:\\ \;\;\;\;x \cdot y\\ \mathbf{elif}\;a \cdot b \leq 7.8 \cdot 10^{+214}:\\ \;\;\;\;z \cdot t\\ \mathbf{else}:\\ \;\;\;\;a \cdot b\\ \end{array} \]
  5. Add Preprocessing

Alternative 6: 65.2% accurate, 0.7× speedup?

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

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

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

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


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

    1. Initial program 96.3%

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

      \[\leadsto \left(\color{blue}{z \cdot \left(t + \frac{x \cdot y}{z}\right)} + a \cdot b\right) + c \cdot i \]
    4. Taylor expanded in z around inf 87.1%

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

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

    if -2e30 < (*.f64 a b) < 1.0000000000000001e182

    1. Initial program 98.8%

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

      \[\leadsto \color{blue}{a \cdot b + \left(t \cdot z + x \cdot y\right)} \]
    4. Taylor expanded in b around inf 56.0%

      \[\leadsto \color{blue}{b \cdot \left(a + \left(\frac{t \cdot z}{b} + \frac{x \cdot y}{b}\right)\right)} \]
    5. Taylor expanded in b around 0 65.9%

      \[\leadsto \color{blue}{t \cdot z + x \cdot y} \]

    if 1.0000000000000001e182 < (*.f64 a b)

    1. Initial program 90.6%

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

      \[\leadsto \color{blue}{a \cdot b + \left(t \cdot z + x \cdot y\right)} \]
    4. Taylor expanded in b around inf 96.9%

      \[\leadsto \color{blue}{b \cdot \left(a + \left(\frac{t \cdot z}{b} + \frac{x \cdot y}{b}\right)\right)} \]
    5. Taylor expanded in t around inf 100.0%

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

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

Alternative 7: 65.2% accurate, 0.7× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;x \cdot y \leq -1.95 \cdot 10^{+133} \lor \neg \left(x \cdot y \leq 4.4 \cdot 10^{+73}\right):\\
\;\;\;\;x \cdot y + z \cdot t\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (*.f64 x y) < -1.95000000000000007e133 or 4.4e73 < (*.f64 x y)

    1. Initial program 96.2%

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

      \[\leadsto \color{blue}{a \cdot b + \left(t \cdot z + x \cdot y\right)} \]
    4. Taylor expanded in b around inf 69.9%

      \[\leadsto \color{blue}{b \cdot \left(a + \left(\frac{t \cdot z}{b} + \frac{x \cdot y}{b}\right)\right)} \]
    5. Taylor expanded in b around 0 84.0%

      \[\leadsto \color{blue}{t \cdot z + x \cdot y} \]

    if -1.95000000000000007e133 < (*.f64 x y) < 4.4e73

    1. Initial program 97.7%

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

      \[\leadsto \left(\color{blue}{z \cdot \left(t + \frac{x \cdot y}{z}\right)} + a \cdot b\right) + c \cdot i \]
    4. Taylor expanded in z around inf 92.3%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \cdot y \leq -1.95 \cdot 10^{+133} \lor \neg \left(x \cdot y \leq 4.4 \cdot 10^{+73}\right):\\ \;\;\;\;x \cdot y + z \cdot t\\ \mathbf{else}:\\ \;\;\;\;a \cdot b + z \cdot t\\ \end{array} \]
  5. Add Preprocessing

Alternative 8: 62.6% accurate, 0.7× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;x \cdot y \leq -9.2 \cdot 10^{+182} \lor \neg \left(x \cdot y \leq 2.65 \cdot 10^{+191}\right):\\
\;\;\;\;x \cdot y\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (*.f64 x y) < -9.2000000000000001e182 or 2.65000000000000015e191 < (*.f64 x y)

    1. Initial program 94.5%

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

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

    if -9.2000000000000001e182 < (*.f64 x y) < 2.65000000000000015e191

    1. Initial program 98.0%

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

      \[\leadsto \left(\color{blue}{z \cdot \left(t + \frac{x \cdot y}{z}\right)} + a \cdot b\right) + c \cdot i \]
    4. Taylor expanded in z around inf 89.5%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \cdot y \leq -9.2 \cdot 10^{+182} \lor \neg \left(x \cdot y \leq 2.65 \cdot 10^{+191}\right):\\ \;\;\;\;x \cdot y\\ \mathbf{else}:\\ \;\;\;\;a \cdot b + z \cdot t\\ \end{array} \]
  5. Add Preprocessing

Alternative 9: 64.1% accurate, 0.7× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \cdot y \leq -3.1 \cdot 10^{+182} \lor \neg \left(x \cdot y \leq 2 \cdot 10^{+142}\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) -3.1e+182) (not (<= (* x y) 2e+142)))
   (* 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) <= -3.1e+182) || !((x * y) <= 2e+142)) {
		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) <= (-3.1d+182)) .or. (.not. ((x * y) <= 2d+142))) 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) <= -3.1e+182) || !((x * y) <= 2e+142)) {
		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) <= -3.1e+182) or not ((x * y) <= 2e+142):
		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) <= -3.1e+182) || !(Float64(x * y) <= 2e+142))
		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) <= -3.1e+182) || ~(((x * y) <= 2e+142)))
		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], -3.1e+182], N[Not[LessEqual[N[(x * y), $MachinePrecision], 2e+142]], $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 -3.1 \cdot 10^{+182} \lor \neg \left(x \cdot y \leq 2 \cdot 10^{+142}\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) < -3.09999999999999996e182 or 2.0000000000000001e142 < (*.f64 x y)

    1. Initial program 95.1%

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

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

    if -3.09999999999999996e182 < (*.f64 x y) < 2.0000000000000001e142

    1. Initial program 97.9%

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

      \[\leadsto \left(\color{blue}{z \cdot \left(t + \frac{x \cdot y}{z}\right)} + a \cdot b\right) + c \cdot i \]
    4. Taylor expanded in z around inf 90.5%

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

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

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

Alternative 10: 38.1% accurate, 0.8× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;z \leq -2.05 \cdot 10^{+80}:\\
\;\;\;\;z \cdot t\\

\mathbf{elif}\;z \leq -2.1 \cdot 10^{-285}:\\
\;\;\;\;a \cdot b\\

\mathbf{elif}\;z \leq 5.8 \cdot 10^{-10}:\\
\;\;\;\;c \cdot i\\

\mathbf{else}:\\
\;\;\;\;z \cdot t\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if z < -2.05000000000000001e80 or 5.79999999999999962e-10 < z

    1. Initial program 96.0%

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

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

    if -2.05000000000000001e80 < z < -2.09999999999999984e-285

    1. Initial program 98.1%

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

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

    if -2.09999999999999984e-285 < z < 5.79999999999999962e-10

    1. Initial program 98.6%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \leq -2.05 \cdot 10^{+80}:\\ \;\;\;\;z \cdot t\\ \mathbf{elif}\;z \leq -2.1 \cdot 10^{-285}:\\ \;\;\;\;a \cdot b\\ \mathbf{elif}\;z \leq 5.8 \cdot 10^{-10}:\\ \;\;\;\;c \cdot i\\ \mathbf{else}:\\ \;\;\;\;z \cdot t\\ \end{array} \]
  5. Add Preprocessing

Alternative 11: 43.7% accurate, 0.9× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;a \cdot b \leq -1.75 \cdot 10^{+30} \lor \neg \left(a \cdot b \leq 4.9 \cdot 10^{+54}\right):\\
\;\;\;\;a \cdot b\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (*.f64 a b) < -1.75000000000000011e30 or 4.90000000000000001e54 < (*.f64 a b)

    1. Initial program 94.2%

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

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

    if -1.75000000000000011e30 < (*.f64 a b) < 4.90000000000000001e54

    1. Initial program 99.3%

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

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

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

Alternative 12: 28.0% 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 97.2%

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

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

Reproduce

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