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

Percentage Accurate: 95.5% → 97.7%
Time: 8.4s
Alternatives: 12
Speedup: 0.5×

Specification

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

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

Sampling outcomes in binary64 precision:

Local Percentage Accuracy vs ?

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

Accuracy vs Speed?

Herbie found 12 alternatives:

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

Initial Program: 95.5% accurate, 1.0× speedup?

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

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

Alternative 1: 97.7% accurate, 0.0× speedup?

\[\begin{array}{l} \\ \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.1%

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

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

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

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

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

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

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

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

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

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

Alternative 2: 97.3% accurate, 0.1× speedup?

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

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

\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(z, t, c \cdot i\right)\\


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

    1. Initial program 100.0%

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

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

    1. Initial program 0.0%

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{t \cdot z + c \cdot i} \]
      2. *-commutative40.0%

        \[\leadsto \color{blue}{z \cdot t} + c \cdot i \]
      3. fma-udef50.0%

        \[\leadsto \color{blue}{\mathsf{fma}\left(z, t, c \cdot i\right)} \]
    7. Simplified50.0%

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

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

Alternative 3: 65.9% accurate, 0.5× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_1 := x \cdot y + a \cdot b\\ t_2 := z \cdot t + c \cdot i\\ t_3 := a \cdot b + c \cdot i\\ \mathbf{if}\;z \cdot t \leq -1 \cdot 10^{+179}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;z \cdot t \leq -5 \cdot 10^{+40}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \cdot t \leq -1 \cdot 10^{-44}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;z \cdot t \leq -1 \cdot 10^{-108}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;z \cdot t \leq -1 \cdot 10^{-180}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;z \cdot t \leq 2 \cdot 10^{+23}:\\ \;\;\;\;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 (+ (* z t) (* c i)))
        (t_3 (+ (* a b) (* c i))))
   (if (<= (* z t) -1e+179)
     t_2
     (if (<= (* z t) -5e+40)
       t_1
       (if (<= (* z t) -1e-44)
         t_3
         (if (<= (* z t) -1e-108)
           t_1
           (if (<= (* z t) -1e-180) t_3 (if (<= (* z t) 2e+23) 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 = (z * t) + (c * i);
	double t_3 = (a * b) + (c * i);
	double tmp;
	if ((z * t) <= -1e+179) {
		tmp = t_2;
	} else if ((z * t) <= -5e+40) {
		tmp = t_1;
	} else if ((z * t) <= -1e-44) {
		tmp = t_3;
	} else if ((z * t) <= -1e-108) {
		tmp = t_1;
	} else if ((z * t) <= -1e-180) {
		tmp = t_3;
	} else if ((z * t) <= 2e+23) {
		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) :: t_3
    real(8) :: tmp
    t_1 = (x * y) + (a * b)
    t_2 = (z * t) + (c * i)
    t_3 = (a * b) + (c * i)
    if ((z * t) <= (-1d+179)) then
        tmp = t_2
    else if ((z * t) <= (-5d+40)) then
        tmp = t_1
    else if ((z * t) <= (-1d-44)) then
        tmp = t_3
    else if ((z * t) <= (-1d-108)) then
        tmp = t_1
    else if ((z * t) <= (-1d-180)) then
        tmp = t_3
    else if ((z * t) <= 2d+23) 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 = (z * t) + (c * i);
	double t_3 = (a * b) + (c * i);
	double tmp;
	if ((z * t) <= -1e+179) {
		tmp = t_2;
	} else if ((z * t) <= -5e+40) {
		tmp = t_1;
	} else if ((z * t) <= -1e-44) {
		tmp = t_3;
	} else if ((z * t) <= -1e-108) {
		tmp = t_1;
	} else if ((z * t) <= -1e-180) {
		tmp = t_3;
	} else if ((z * t) <= 2e+23) {
		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 = (z * t) + (c * i)
	t_3 = (a * b) + (c * i)
	tmp = 0
	if (z * t) <= -1e+179:
		tmp = t_2
	elif (z * t) <= -5e+40:
		tmp = t_1
	elif (z * t) <= -1e-44:
		tmp = t_3
	elif (z * t) <= -1e-108:
		tmp = t_1
	elif (z * t) <= -1e-180:
		tmp = t_3
	elif (z * t) <= 2e+23:
		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(z * t) + Float64(c * i))
	t_3 = Float64(Float64(a * b) + Float64(c * i))
	tmp = 0.0
	if (Float64(z * t) <= -1e+179)
		tmp = t_2;
	elseif (Float64(z * t) <= -5e+40)
		tmp = t_1;
	elseif (Float64(z * t) <= -1e-44)
		tmp = t_3;
	elseif (Float64(z * t) <= -1e-108)
		tmp = t_1;
	elseif (Float64(z * t) <= -1e-180)
		tmp = t_3;
	elseif (Float64(z * t) <= 2e+23)
		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 = (z * t) + (c * i);
	t_3 = (a * b) + (c * i);
	tmp = 0.0;
	if ((z * t) <= -1e+179)
		tmp = t_2;
	elseif ((z * t) <= -5e+40)
		tmp = t_1;
	elseif ((z * t) <= -1e-44)
		tmp = t_3;
	elseif ((z * t) <= -1e-108)
		tmp = t_1;
	elseif ((z * t) <= -1e-180)
		tmp = t_3;
	elseif ((z * t) <= 2e+23)
		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[(z * t), $MachinePrecision] + N[(c * i), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$3 = N[(N[(a * b), $MachinePrecision] + N[(c * i), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(z * t), $MachinePrecision], -1e+179], t$95$2, If[LessEqual[N[(z * t), $MachinePrecision], -5e+40], t$95$1, If[LessEqual[N[(z * t), $MachinePrecision], -1e-44], t$95$3, If[LessEqual[N[(z * t), $MachinePrecision], -1e-108], t$95$1, If[LessEqual[N[(z * t), $MachinePrecision], -1e-180], t$95$3, If[LessEqual[N[(z * t), $MachinePrecision], 2e+23], t$95$1, t$95$2]]]]]]]]]
\begin{array}{l}

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

\mathbf{elif}\;z \cdot t \leq -5 \cdot 10^{+40}:\\
\;\;\;\;t_1\\

\mathbf{elif}\;z \cdot t \leq -1 \cdot 10^{-44}:\\
\;\;\;\;t_3\\

\mathbf{elif}\;z \cdot t \leq -1 \cdot 10^{-108}:\\
\;\;\;\;t_1\\

\mathbf{elif}\;z \cdot t \leq -1 \cdot 10^{-180}:\\
\;\;\;\;t_3\\

\mathbf{elif}\;z \cdot t \leq 2 \cdot 10^{+23}:\\
\;\;\;\;t_1\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if (*.f64 z t) < -9.9999999999999998e178 or 1.9999999999999998e23 < (*.f64 z t)

    1. Initial program 91.6%

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

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

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

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

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

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

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

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

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

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

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

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

    if -9.9999999999999998e178 < (*.f64 z t) < -5.00000000000000003e40 or -9.99999999999999953e-45 < (*.f64 z t) < -1.00000000000000004e-108 or -1e-180 < (*.f64 z t) < 1.9999999999999998e23

    1. Initial program 98.4%

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

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

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

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

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

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

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

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

      \[\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. Taylor expanded in z around 0 93.2%

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

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

    if -5.00000000000000003e40 < (*.f64 z t) < -9.99999999999999953e-45 or -1.00000000000000004e-108 < (*.f64 z t) < -1e-180

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \cdot t \leq -1 \cdot 10^{+179}:\\ \;\;\;\;z \cdot t + c \cdot i\\ \mathbf{elif}\;z \cdot t \leq -5 \cdot 10^{+40}:\\ \;\;\;\;x \cdot y + a \cdot b\\ \mathbf{elif}\;z \cdot t \leq -1 \cdot 10^{-44}:\\ \;\;\;\;a \cdot b + c \cdot i\\ \mathbf{elif}\;z \cdot t \leq -1 \cdot 10^{-108}:\\ \;\;\;\;x \cdot y + a \cdot b\\ \mathbf{elif}\;z \cdot t \leq -1 \cdot 10^{-180}:\\ \;\;\;\;a \cdot b + c \cdot i\\ \mathbf{elif}\;z \cdot t \leq 2 \cdot 10^{+23}:\\ \;\;\;\;x \cdot y + a \cdot b\\ \mathbf{else}:\\ \;\;\;\;z \cdot t + c \cdot i\\ \end{array} \]

Alternative 4: 96.8% accurate, 0.5× speedup?

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

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

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


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

    1. Initial program 100.0%

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

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

    1. Initial program 0.0%

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

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

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

Alternative 5: 59.8% accurate, 0.6× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \cdot y \leq -7 \cdot 10^{+97}:\\ \;\;\;\;x \cdot y\\ \mathbf{elif}\;x \cdot y \leq -1.7 \cdot 10^{-10}:\\ \;\;\;\;z \cdot t\\ \mathbf{elif}\;x \cdot y \leq -3.1 \cdot 10^{-19} \lor \neg \left(x \cdot y \leq 1.35 \cdot 10^{+138}\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 (<= (* x y) -7e+97)
   (* x y)
   (if (<= (* x y) -1.7e-10)
     (* z t)
     (if (or (<= (* x y) -3.1e-19) (not (<= (* x y) 1.35e+138)))
       (* 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) <= -7e+97) {
		tmp = x * y;
	} else if ((x * y) <= -1.7e-10) {
		tmp = z * t;
	} else if (((x * y) <= -3.1e-19) || !((x * y) <= 1.35e+138)) {
		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) <= (-7d+97)) then
        tmp = x * y
    else if ((x * y) <= (-1.7d-10)) then
        tmp = z * t
    else if (((x * y) <= (-3.1d-19)) .or. (.not. ((x * y) <= 1.35d+138))) 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) <= -7e+97) {
		tmp = x * y;
	} else if ((x * y) <= -1.7e-10) {
		tmp = z * t;
	} else if (((x * y) <= -3.1e-19) || !((x * y) <= 1.35e+138)) {
		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) <= -7e+97:
		tmp = x * y
	elif (x * y) <= -1.7e-10:
		tmp = z * t
	elif ((x * y) <= -3.1e-19) or not ((x * y) <= 1.35e+138):
		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) <= -7e+97)
		tmp = Float64(x * y);
	elseif (Float64(x * y) <= -1.7e-10)
		tmp = Float64(z * t);
	elseif ((Float64(x * y) <= -3.1e-19) || !(Float64(x * y) <= 1.35e+138))
		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) <= -7e+97)
		tmp = x * y;
	elseif ((x * y) <= -1.7e-10)
		tmp = z * t;
	elseif (((x * y) <= -3.1e-19) || ~(((x * y) <= 1.35e+138)))
		tmp = x * y;
	else
		tmp = (a * b) + (c * i);
	end
	tmp_2 = tmp;
end
code[x_, y_, z_, t_, a_, b_, c_, i_] := If[LessEqual[N[(x * y), $MachinePrecision], -7e+97], N[(x * y), $MachinePrecision], If[LessEqual[N[(x * y), $MachinePrecision], -1.7e-10], N[(z * t), $MachinePrecision], If[Or[LessEqual[N[(x * y), $MachinePrecision], -3.1e-19], N[Not[LessEqual[N[(x * y), $MachinePrecision], 1.35e+138]], $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 -7 \cdot 10^{+97}:\\
\;\;\;\;x \cdot y\\

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

\mathbf{elif}\;x \cdot y \leq -3.1 \cdot 10^{-19} \lor \neg \left(x \cdot y \leq 1.35 \cdot 10^{+138}\right):\\
\;\;\;\;x \cdot y\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if (*.f64 x y) < -7.0000000000000001e97 or -1.70000000000000007e-10 < (*.f64 x y) < -3.0999999999999999e-19 or 1.35000000000000004e138 < (*.f64 x y)

    1. Initial program 92.5%

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

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

    if -7.0000000000000001e97 < (*.f64 x y) < -1.70000000000000007e-10

    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 z around inf 61.2%

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

    if -3.0999999999999999e-19 < (*.f64 x y) < 1.35000000000000004e138

    1. Initial program 97.6%

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \cdot y \leq -7 \cdot 10^{+97}:\\ \;\;\;\;x \cdot y\\ \mathbf{elif}\;x \cdot y \leq -1.7 \cdot 10^{-10}:\\ \;\;\;\;z \cdot t\\ \mathbf{elif}\;x \cdot y \leq -3.1 \cdot 10^{-19} \lor \neg \left(x \cdot y \leq 1.35 \cdot 10^{+138}\right):\\ \;\;\;\;x \cdot y\\ \mathbf{else}:\\ \;\;\;\;a \cdot b + c \cdot i\\ \end{array} \]

Alternative 6: 64.7% accurate, 0.6× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_1 := x \cdot y + a \cdot b\\ \mathbf{if}\;x \cdot y \leq -7.1 \cdot 10^{+33}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \cdot y \leq -3.3 \cdot 10^{-9}:\\ \;\;\;\;z \cdot t\\ \mathbf{elif}\;x \cdot y \leq -8 \cdot 10^{-34} \lor \neg \left(x \cdot y \leq 1.9 \cdot 10^{+61}\right):\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;a \cdot b + 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 (<= (* x y) -7.1e+33)
     t_1
     (if (<= (* x y) -3.3e-9)
       (* z t)
       (if (or (<= (* x y) -8e-34) (not (<= (* x y) 1.9e+61)))
         t_1
         (+ (* a b) (* 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 ((x * y) <= -7.1e+33) {
		tmp = t_1;
	} else if ((x * y) <= -3.3e-9) {
		tmp = z * t;
	} else if (((x * y) <= -8e-34) || !((x * y) <= 1.9e+61)) {
		tmp = t_1;
	} 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) :: t_1
    real(8) :: tmp
    t_1 = (x * y) + (a * b)
    if ((x * y) <= (-7.1d+33)) then
        tmp = t_1
    else if ((x * y) <= (-3.3d-9)) then
        tmp = z * t
    else if (((x * y) <= (-8d-34)) .or. (.not. ((x * y) <= 1.9d+61))) then
        tmp = t_1
    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 t_1 = (x * y) + (a * b);
	double tmp;
	if ((x * y) <= -7.1e+33) {
		tmp = t_1;
	} else if ((x * y) <= -3.3e-9) {
		tmp = z * t;
	} else if (((x * y) <= -8e-34) || !((x * y) <= 1.9e+61)) {
		tmp = t_1;
	} else {
		tmp = (a * b) + (c * i);
	}
	return tmp;
}
def code(x, y, z, t, a, b, c, i):
	t_1 = (x * y) + (a * b)
	tmp = 0
	if (x * y) <= -7.1e+33:
		tmp = t_1
	elif (x * y) <= -3.3e-9:
		tmp = z * t
	elif ((x * y) <= -8e-34) or not ((x * y) <= 1.9e+61):
		tmp = t_1
	else:
		tmp = (a * b) + (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(x * y) <= -7.1e+33)
		tmp = t_1;
	elseif (Float64(x * y) <= -3.3e-9)
		tmp = Float64(z * t);
	elseif ((Float64(x * y) <= -8e-34) || !(Float64(x * y) <= 1.9e+61))
		tmp = t_1;
	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)
	t_1 = (x * y) + (a * b);
	tmp = 0.0;
	if ((x * y) <= -7.1e+33)
		tmp = t_1;
	elseif ((x * y) <= -3.3e-9)
		tmp = z * t;
	elseif (((x * y) <= -8e-34) || ~(((x * y) <= 1.9e+61)))
		tmp = t_1;
	else
		tmp = (a * b) + (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[(x * y), $MachinePrecision], -7.1e+33], t$95$1, If[LessEqual[N[(x * y), $MachinePrecision], -3.3e-9], N[(z * t), $MachinePrecision], If[Or[LessEqual[N[(x * y), $MachinePrecision], -8e-34], N[Not[LessEqual[N[(x * y), $MachinePrecision], 1.9e+61]], $MachinePrecision]], t$95$1, N[(N[(a * b), $MachinePrecision] + N[(c * i), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_1 := x \cdot y + a \cdot b\\
\mathbf{if}\;x \cdot y \leq -7.1 \cdot 10^{+33}:\\
\;\;\;\;t_1\\

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

\mathbf{elif}\;x \cdot y \leq -8 \cdot 10^{-34} \lor \neg \left(x \cdot y \leq 1.9 \cdot 10^{+61}\right):\\
\;\;\;\;t_1\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if (*.f64 x y) < -7.09999999999999979e33 or -3.30000000000000018e-9 < (*.f64 x y) < -7.99999999999999942e-34 or 1.89999999999999998e61 < (*.f64 x y)

    1. Initial program 93.3%

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

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

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

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

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

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

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

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

      \[\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. Taylor expanded in z around 0 83.8%

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

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

    if -7.09999999999999979e33 < (*.f64 x y) < -3.30000000000000018e-9

    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 z around inf 75.6%

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

    if -7.99999999999999942e-34 < (*.f64 x y) < 1.89999999999999998e61

    1. Initial program 97.9%

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \cdot y \leq -7.1 \cdot 10^{+33}:\\ \;\;\;\;x \cdot y + a \cdot b\\ \mathbf{elif}\;x \cdot y \leq -3.3 \cdot 10^{-9}:\\ \;\;\;\;z \cdot t\\ \mathbf{elif}\;x \cdot y \leq -8 \cdot 10^{-34} \lor \neg \left(x \cdot y \leq 1.9 \cdot 10^{+61}\right):\\ \;\;\;\;x \cdot y + a \cdot b\\ \mathbf{else}:\\ \;\;\;\;a \cdot b + c \cdot i\\ \end{array} \]

Alternative 7: 44.0% accurate, 0.8× speedup?

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

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

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

\mathbf{elif}\;a \cdot b \leq 95000000000:\\
\;\;\;\;z \cdot t\\

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if (*.f64 a b) < -1.6199999999999999e31 or 8.19999999999999961e138 < (*.f64 a b)

    1. Initial program 92.5%

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

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

    if -1.6199999999999999e31 < (*.f64 a b) < -0.0 or 9.5e10 < (*.f64 a b) < 8.19999999999999961e138

    1. Initial program 98.9%

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

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

    if -0.0 < (*.f64 a b) < 9.5e10

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;a \cdot b \leq -1.62 \cdot 10^{+31}:\\ \;\;\;\;a \cdot b\\ \mathbf{elif}\;a \cdot b \leq 0:\\ \;\;\;\;x \cdot y\\ \mathbf{elif}\;a \cdot b \leq 95000000000:\\ \;\;\;\;z \cdot t\\ \mathbf{elif}\;a \cdot b \leq 8.2 \cdot 10^{+138}:\\ \;\;\;\;x \cdot y\\ \mathbf{else}:\\ \;\;\;\;a \cdot b\\ \end{array} \]

Alternative 8: 84.1% accurate, 0.8× speedup?

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

\mathbf{elif}\;x \cdot y \leq 1.65 \cdot 10^{+123}:\\
\;\;\;\;c \cdot i + \left(z \cdot t + a \cdot b\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) < -2.70000000000000022e96

    1. Initial program 92.5%

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

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

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

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

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

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

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

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

      \[\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. Taylor expanded in z around 0 87.8%

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

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

    if -2.70000000000000022e96 < (*.f64 x y) < 1.65000000000000001e123

    1. Initial program 97.7%

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

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

    if 1.65000000000000001e123 < (*.f64 x y)

    1. Initial program 93.0%

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

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

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

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

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

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

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

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

      \[\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. Taylor expanded in z around 0 86.1%

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

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

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

Alternative 9: 85.4% accurate, 0.8× speedup?

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

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if (*.f64 z t) < -4.99999999999999961e133

    1. Initial program 95.7%

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

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

    if -4.99999999999999961e133 < (*.f64 z t) < 4.00000000000000006e240

    1. Initial program 97.9%

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

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

    if 4.00000000000000006e240 < (*.f64 z t)

    1. Initial program 81.0%

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

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

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

Alternative 10: 44.1% accurate, 1.0× speedup?

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

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

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

\mathbf{elif}\;a \cdot b \leq 80000000000:\\
\;\;\;\;z \cdot t\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if (*.f64 a b) < -4.00000000000000014e62 or 8e10 < (*.f64 a b)

    1. Initial program 93.2%

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

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

    if -4.00000000000000014e62 < (*.f64 a b) < -0.0

    1. Initial program 98.8%

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

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

    if -0.0 < (*.f64 a b) < 8e10

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;a \cdot b \leq -4 \cdot 10^{+62}:\\ \;\;\;\;a \cdot b\\ \mathbf{elif}\;a \cdot b \leq 0:\\ \;\;\;\;c \cdot i\\ \mathbf{elif}\;a \cdot b \leq 80000000000:\\ \;\;\;\;z \cdot t\\ \mathbf{else}:\\ \;\;\;\;a \cdot b\\ \end{array} \]

Alternative 11: 43.8% accurate, 1.3× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;a \cdot b \leq -1.25 \cdot 10^{+63} \lor \neg \left(a \cdot b \leq 1.8 \cdot 10^{+35}\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.25e+63) (not (<= (* a b) 1.8e+35))) (* 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.25e+63) || !((a * b) <= 1.8e+35)) {
		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.25d+63)) .or. (.not. ((a * b) <= 1.8d+35))) 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.25e+63) || !((a * b) <= 1.8e+35)) {
		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.25e+63) or not ((a * b) <= 1.8e+35):
		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.25e+63) || !(Float64(a * b) <= 1.8e+35))
		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.25e+63) || ~(((a * b) <= 1.8e+35)))
		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.25e+63], N[Not[LessEqual[N[(a * b), $MachinePrecision], 1.8e+35]], $MachinePrecision]], N[(a * b), $MachinePrecision], N[(c * i), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;a \cdot b \leq -1.25 \cdot 10^{+63} \lor \neg \left(a \cdot b \leq 1.8 \cdot 10^{+35}\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.25000000000000003e63 or 1.8e35 < (*.f64 a b)

    1. Initial program 93.1%

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

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

    if -1.25000000000000003e63 < (*.f64 a b) < 1.8e35

    1. Initial program 98.0%

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

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

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

Alternative 12: 28.4% accurate, 5.0× speedup?

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

\\
a \cdot b
\end{array}
Derivation
  1. Initial program 96.1%

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

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

    \[\leadsto a \cdot b \]

Reproduce

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