Linear.V3:$cdot from linear-1.19.1.3, B

Percentage Accurate: 97.7% → 99.4%
Time: 13.0s
Alternatives: 11
Speedup: 0.4×

Specification

?
\[\begin{array}{l} \\ \left(x \cdot y + z \cdot t\right) + a \cdot b \end{array} \]
(FPCore (x y z t a b) :precision binary64 (+ (+ (* x y) (* z t)) (* a b)))
double code(double x, double y, double z, double t, double a, double b) {
	return ((x * y) + (z * t)) + (a * b);
}
real(8) function code(x, y, z, t, a, b)
    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
    code = ((x * y) + (z * t)) + (a * b)
end function
public static double code(double x, double y, double z, double t, double a, double b) {
	return ((x * y) + (z * t)) + (a * b);
}
def code(x, y, z, t, a, b):
	return ((x * y) + (z * t)) + (a * b)
function code(x, y, z, t, a, b)
	return Float64(Float64(Float64(x * y) + Float64(z * t)) + Float64(a * b))
end
function tmp = code(x, y, z, t, a, b)
	tmp = ((x * y) + (z * t)) + (a * b);
end
code[x_, y_, z_, t_, a_, b_] := N[(N[(N[(x * y), $MachinePrecision] + N[(z * t), $MachinePrecision]), $MachinePrecision] + N[(a * b), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
\left(x \cdot y + z \cdot t\right) + a \cdot b
\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 11 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: 97.7% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \left(x \cdot y + z \cdot t\right) + a \cdot b \end{array} \]
(FPCore (x y z t a b) :precision binary64 (+ (+ (* x y) (* z t)) (* a b)))
double code(double x, double y, double z, double t, double a, double b) {
	return ((x * y) + (z * t)) + (a * b);
}
real(8) function code(x, y, z, t, a, b)
    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
    code = ((x * y) + (z * t)) + (a * b)
end function
public static double code(double x, double y, double z, double t, double a, double b) {
	return ((x * y) + (z * t)) + (a * b);
}
def code(x, y, z, t, a, b):
	return ((x * y) + (z * t)) + (a * b)
function code(x, y, z, t, a, b)
	return Float64(Float64(Float64(x * y) + Float64(z * t)) + Float64(a * b))
end
function tmp = code(x, y, z, t, a, b)
	tmp = ((x * y) + (z * t)) + (a * b);
end
code[x_, y_, z_, t_, a_, b_] := N[(N[(N[(x * y), $MachinePrecision] + N[(z * t), $MachinePrecision]), $MachinePrecision] + N[(a * b), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

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

Alternative 1: 99.4% accurate, 0.4× speedup?

\[\begin{array}{l} [x, y, z, t, a, b] = \mathsf{sort}([x, y, z, t, a, b])\\ \\ \begin{array}{l} t_1 := a \cdot b + \left(z \cdot t + x \cdot y\right)\\ \mathbf{if}\;t\_1 \leq \infty:\\ \;\;\;\;t\_1\\ \mathbf{else}:\\ \;\;\;\;x \cdot \left(\left(y + a \cdot \frac{b}{x}\right) + t \cdot \frac{z}{x}\right)\\ \end{array} \end{array} \]
NOTE: x, y, z, t, a, and b should be sorted in increasing order before calling this function.
(FPCore (x y z t a b)
 :precision binary64
 (let* ((t_1 (+ (* a b) (+ (* z t) (* x y)))))
   (if (<= t_1 INFINITY) t_1 (* x (+ (+ y (* a (/ b x))) (* t (/ z x)))))))
assert(x < y && y < z && z < t && t < a && a < b);
double code(double x, double y, double z, double t, double a, double b) {
	double t_1 = (a * b) + ((z * t) + (x * y));
	double tmp;
	if (t_1 <= ((double) INFINITY)) {
		tmp = t_1;
	} else {
		tmp = x * ((y + (a * (b / x))) + (t * (z / x)));
	}
	return tmp;
}
assert x < y && y < z && z < t && t < a && a < b;
public static double code(double x, double y, double z, double t, double a, double b) {
	double t_1 = (a * b) + ((z * t) + (x * y));
	double tmp;
	if (t_1 <= Double.POSITIVE_INFINITY) {
		tmp = t_1;
	} else {
		tmp = x * ((y + (a * (b / x))) + (t * (z / x)));
	}
	return tmp;
}
[x, y, z, t, a, b] = sort([x, y, z, t, a, b])
def code(x, y, z, t, a, b):
	t_1 = (a * b) + ((z * t) + (x * y))
	tmp = 0
	if t_1 <= math.inf:
		tmp = t_1
	else:
		tmp = x * ((y + (a * (b / x))) + (t * (z / x)))
	return tmp
x, y, z, t, a, b = sort([x, y, z, t, a, b])
function code(x, y, z, t, a, b)
	t_1 = Float64(Float64(a * b) + Float64(Float64(z * t) + Float64(x * y)))
	tmp = 0.0
	if (t_1 <= Inf)
		tmp = t_1;
	else
		tmp = Float64(x * Float64(Float64(y + Float64(a * Float64(b / x))) + Float64(t * Float64(z / x))));
	end
	return tmp
end
x, y, z, t, a, b = num2cell(sort([x, y, z, t, a, b])){:}
function tmp_2 = code(x, y, z, t, a, b)
	t_1 = (a * b) + ((z * t) + (x * y));
	tmp = 0.0;
	if (t_1 <= Inf)
		tmp = t_1;
	else
		tmp = x * ((y + (a * (b / x))) + (t * (z / x)));
	end
	tmp_2 = tmp;
end
NOTE: x, y, z, t, a, and b should be sorted in increasing order before calling this function.
code[x_, y_, z_, t_, a_, b_] := Block[{t$95$1 = N[(N[(a * b), $MachinePrecision] + N[(N[(z * t), $MachinePrecision] + N[(x * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$1, Infinity], t$95$1, N[(x * N[(N[(y + N[(a * N[(b / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(t * N[(z / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
[x, y, z, t, a, b] = \mathsf{sort}([x, y, z, t, a, b])\\
\\
\begin{array}{l}
t_1 := a \cdot b + \left(z \cdot t + x \cdot y\right)\\
\mathbf{if}\;t\_1 \leq \infty:\\
\;\;\;\;t\_1\\

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


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

    1. Initial program 100.0%

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

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

    1. Initial program 0.0%

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

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

      \[\leadsto \color{blue}{\mathsf{fma}\left(x, y, z \cdot t\right) + a \cdot b} \]
    4. Add Preprocessing
    5. Taylor expanded in x around inf 20.0%

      \[\leadsto \color{blue}{x \cdot \left(y + \left(\frac{a \cdot b}{x} + \frac{t \cdot z}{x}\right)\right)} \]
    6. Step-by-step derivation
      1. associate-+r+20.0%

        \[\leadsto x \cdot \color{blue}{\left(\left(y + \frac{a \cdot b}{x}\right) + \frac{t \cdot z}{x}\right)} \]
      2. associate-/l*60.0%

        \[\leadsto x \cdot \left(\left(y + \color{blue}{a \cdot \frac{b}{x}}\right) + \frac{t \cdot z}{x}\right) \]
      3. associate-/l*80.0%

        \[\leadsto x \cdot \left(\left(y + a \cdot \frac{b}{x}\right) + \color{blue}{t \cdot \frac{z}{x}}\right) \]
    7. Simplified80.0%

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

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

Alternative 2: 98.9% accurate, 0.1× speedup?

\[\begin{array}{l} [x, y, z, t, a, b] = \mathsf{sort}([x, y, z, t, a, b])\\ \\ \mathsf{fma}\left(x, y, \mathsf{fma}\left(a, b, z \cdot t\right)\right) \end{array} \]
NOTE: x, y, z, t, a, and b should be sorted in increasing order before calling this function.
(FPCore (x y z t a b) :precision binary64 (fma x y (fma a b (* z t))))
assert(x < y && y < z && z < t && t < a && a < b);
double code(double x, double y, double z, double t, double a, double b) {
	return fma(x, y, fma(a, b, (z * t)));
}
x, y, z, t, a, b = sort([x, y, z, t, a, b])
function code(x, y, z, t, a, b)
	return fma(x, y, fma(a, b, Float64(z * t)))
end
NOTE: x, y, z, t, a, and b should be sorted in increasing order before calling this function.
code[x_, y_, z_, t_, a_, b_] := N[(x * y + N[(a * b + N[(z * t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
[x, y, z, t, a, b] = \mathsf{sort}([x, y, z, t, a, b])\\
\\
\mathsf{fma}\left(x, y, \mathsf{fma}\left(a, b, z \cdot t\right)\right)
\end{array}
Derivation
  1. Initial program 98.0%

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

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

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

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

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

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

Alternative 3: 98.0% accurate, 0.1× speedup?

\[\begin{array}{l} [x, y, z, t, a, b] = \mathsf{sort}([x, y, z, t, a, b])\\ \\ \mathsf{fma}\left(x, y, z \cdot t\right) + a \cdot b \end{array} \]
NOTE: x, y, z, t, a, and b should be sorted in increasing order before calling this function.
(FPCore (x y z t a b) :precision binary64 (+ (fma x y (* z t)) (* a b)))
assert(x < y && y < z && z < t && t < a && a < b);
double code(double x, double y, double z, double t, double a, double b) {
	return fma(x, y, (z * t)) + (a * b);
}
x, y, z, t, a, b = sort([x, y, z, t, a, b])
function code(x, y, z, t, a, b)
	return Float64(fma(x, y, Float64(z * t)) + Float64(a * b))
end
NOTE: x, y, z, t, a, and b should be sorted in increasing order before calling this function.
code[x_, y_, z_, t_, a_, b_] := N[(N[(x * y + N[(z * t), $MachinePrecision]), $MachinePrecision] + N[(a * b), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
[x, y, z, t, a, b] = \mathsf{sort}([x, y, z, t, a, b])\\
\\
\mathsf{fma}\left(x, y, z \cdot t\right) + a \cdot b
\end{array}
Derivation
  1. Initial program 98.0%

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

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

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

Alternative 4: 98.8% accurate, 0.4× speedup?

\[\begin{array}{l} [x, y, z, t, a, b] = \mathsf{sort}([x, y, z, t, a, b])\\ \\ \begin{array}{l} t_1 := a \cdot b + \left(z \cdot t + x \cdot y\right)\\ \mathbf{if}\;t\_1 \leq \infty:\\ \;\;\;\;t\_1\\ \mathbf{else}:\\ \;\;\;\;x \cdot \left(y + \frac{z \cdot t}{x}\right)\\ \end{array} \end{array} \]
NOTE: x, y, z, t, a, and b should be sorted in increasing order before calling this function.
(FPCore (x y z t a b)
 :precision binary64
 (let* ((t_1 (+ (* a b) (+ (* z t) (* x y)))))
   (if (<= t_1 INFINITY) t_1 (* x (+ y (/ (* z t) x))))))
assert(x < y && y < z && z < t && t < a && a < b);
double code(double x, double y, double z, double t, double a, double b) {
	double t_1 = (a * b) + ((z * t) + (x * y));
	double tmp;
	if (t_1 <= ((double) INFINITY)) {
		tmp = t_1;
	} else {
		tmp = x * (y + ((z * t) / x));
	}
	return tmp;
}
assert x < y && y < z && z < t && t < a && a < b;
public static double code(double x, double y, double z, double t, double a, double b) {
	double t_1 = (a * b) + ((z * t) + (x * y));
	double tmp;
	if (t_1 <= Double.POSITIVE_INFINITY) {
		tmp = t_1;
	} else {
		tmp = x * (y + ((z * t) / x));
	}
	return tmp;
}
[x, y, z, t, a, b] = sort([x, y, z, t, a, b])
def code(x, y, z, t, a, b):
	t_1 = (a * b) + ((z * t) + (x * y))
	tmp = 0
	if t_1 <= math.inf:
		tmp = t_1
	else:
		tmp = x * (y + ((z * t) / x))
	return tmp
x, y, z, t, a, b = sort([x, y, z, t, a, b])
function code(x, y, z, t, a, b)
	t_1 = Float64(Float64(a * b) + Float64(Float64(z * t) + Float64(x * y)))
	tmp = 0.0
	if (t_1 <= Inf)
		tmp = t_1;
	else
		tmp = Float64(x * Float64(y + Float64(Float64(z * t) / x)));
	end
	return tmp
end
x, y, z, t, a, b = num2cell(sort([x, y, z, t, a, b])){:}
function tmp_2 = code(x, y, z, t, a, b)
	t_1 = (a * b) + ((z * t) + (x * y));
	tmp = 0.0;
	if (t_1 <= Inf)
		tmp = t_1;
	else
		tmp = x * (y + ((z * t) / x));
	end
	tmp_2 = tmp;
end
NOTE: x, y, z, t, a, and b should be sorted in increasing order before calling this function.
code[x_, y_, z_, t_, a_, b_] := Block[{t$95$1 = N[(N[(a * b), $MachinePrecision] + N[(N[(z * t), $MachinePrecision] + N[(x * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$1, Infinity], t$95$1, N[(x * N[(y + N[(N[(z * t), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
[x, y, z, t, a, b] = \mathsf{sort}([x, y, z, t, a, b])\\
\\
\begin{array}{l}
t_1 := a \cdot b + \left(z \cdot t + x \cdot y\right)\\
\mathbf{if}\;t\_1 \leq \infty:\\
\;\;\;\;t\_1\\

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


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

    1. Initial program 100.0%

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

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

    1. Initial program 0.0%

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

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

      \[\leadsto \color{blue}{\mathsf{fma}\left(x, y, z \cdot t\right) + a \cdot b} \]
    4. Add Preprocessing
    5. Taylor expanded in x around inf 20.0%

      \[\leadsto \color{blue}{x \cdot \left(y + \left(\frac{a \cdot b}{x} + \frac{t \cdot z}{x}\right)\right)} \]
    6. Step-by-step derivation
      1. associate-+r+20.0%

        \[\leadsto x \cdot \color{blue}{\left(\left(y + \frac{a \cdot b}{x}\right) + \frac{t \cdot z}{x}\right)} \]
      2. associate-/l*60.0%

        \[\leadsto x \cdot \left(\left(y + \color{blue}{a \cdot \frac{b}{x}}\right) + \frac{t \cdot z}{x}\right) \]
      3. associate-/l*80.0%

        \[\leadsto x \cdot \left(\left(y + a \cdot \frac{b}{x}\right) + \color{blue}{t \cdot \frac{z}{x}}\right) \]
    7. Simplified80.0%

      \[\leadsto \color{blue}{x \cdot \left(\left(y + a \cdot \frac{b}{x}\right) + t \cdot \frac{z}{x}\right)} \]
    8. Step-by-step derivation
      1. clear-num80.0%

        \[\leadsto x \cdot \left(\left(y + a \cdot \color{blue}{\frac{1}{\frac{x}{b}}}\right) + t \cdot \frac{z}{x}\right) \]
      2. inv-pow80.0%

        \[\leadsto x \cdot \left(\left(y + a \cdot \color{blue}{{\left(\frac{x}{b}\right)}^{-1}}\right) + t \cdot \frac{z}{x}\right) \]
    9. Applied egg-rr80.0%

      \[\leadsto x \cdot \left(\left(y + a \cdot \color{blue}{{\left(\frac{x}{b}\right)}^{-1}}\right) + t \cdot \frac{z}{x}\right) \]
    10. Step-by-step derivation
      1. unpow-180.0%

        \[\leadsto x \cdot \left(\left(y + a \cdot \color{blue}{\frac{1}{\frac{x}{b}}}\right) + t \cdot \frac{z}{x}\right) \]
    11. Simplified80.0%

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

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

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

Alternative 5: 54.3% accurate, 0.5× speedup?

\[\begin{array}{l} [x, y, z, t, a, b] = \mathsf{sort}([x, y, z, t, a, b])\\ \\ \begin{array}{l} \mathbf{if}\;a \cdot b \leq -1 \cdot 10^{-7}:\\ \;\;\;\;a \cdot b\\ \mathbf{elif}\;a \cdot b \leq 8 \cdot 10^{-101}:\\ \;\;\;\;z \cdot t\\ \mathbf{elif}\;a \cdot b \leq 1.95 \cdot 10^{+33}:\\ \;\;\;\;x \cdot y\\ \mathbf{else}:\\ \;\;\;\;a \cdot b\\ \end{array} \end{array} \]
NOTE: x, y, z, t, a, and b should be sorted in increasing order before calling this function.
(FPCore (x y z t a b)
 :precision binary64
 (if (<= (* a b) -1e-7)
   (* a b)
   (if (<= (* a b) 8e-101)
     (* z t)
     (if (<= (* a b) 1.95e+33) (* x y) (* a b)))))
assert(x < y && y < z && z < t && t < a && a < b);
double code(double x, double y, double z, double t, double a, double b) {
	double tmp;
	if ((a * b) <= -1e-7) {
		tmp = a * b;
	} else if ((a * b) <= 8e-101) {
		tmp = z * t;
	} else if ((a * b) <= 1.95e+33) {
		tmp = x * y;
	} else {
		tmp = a * b;
	}
	return tmp;
}
NOTE: x, y, z, t, a, and b should be sorted in increasing order before calling this function.
real(8) function code(x, y, z, t, a, b)
    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) :: tmp
    if ((a * b) <= (-1d-7)) then
        tmp = a * b
    else if ((a * b) <= 8d-101) then
        tmp = z * t
    else if ((a * b) <= 1.95d+33) then
        tmp = x * y
    else
        tmp = a * b
    end if
    code = tmp
end function
assert x < y && y < z && z < t && t < a && a < b;
public static double code(double x, double y, double z, double t, double a, double b) {
	double tmp;
	if ((a * b) <= -1e-7) {
		tmp = a * b;
	} else if ((a * b) <= 8e-101) {
		tmp = z * t;
	} else if ((a * b) <= 1.95e+33) {
		tmp = x * y;
	} else {
		tmp = a * b;
	}
	return tmp;
}
[x, y, z, t, a, b] = sort([x, y, z, t, a, b])
def code(x, y, z, t, a, b):
	tmp = 0
	if (a * b) <= -1e-7:
		tmp = a * b
	elif (a * b) <= 8e-101:
		tmp = z * t
	elif (a * b) <= 1.95e+33:
		tmp = x * y
	else:
		tmp = a * b
	return tmp
x, y, z, t, a, b = sort([x, y, z, t, a, b])
function code(x, y, z, t, a, b)
	tmp = 0.0
	if (Float64(a * b) <= -1e-7)
		tmp = Float64(a * b);
	elseif (Float64(a * b) <= 8e-101)
		tmp = Float64(z * t);
	elseif (Float64(a * b) <= 1.95e+33)
		tmp = Float64(x * y);
	else
		tmp = Float64(a * b);
	end
	return tmp
end
x, y, z, t, a, b = num2cell(sort([x, y, z, t, a, b])){:}
function tmp_2 = code(x, y, z, t, a, b)
	tmp = 0.0;
	if ((a * b) <= -1e-7)
		tmp = a * b;
	elseif ((a * b) <= 8e-101)
		tmp = z * t;
	elseif ((a * b) <= 1.95e+33)
		tmp = x * y;
	else
		tmp = a * b;
	end
	tmp_2 = tmp;
end
NOTE: x, y, z, t, a, and b should be sorted in increasing order before calling this function.
code[x_, y_, z_, t_, a_, b_] := If[LessEqual[N[(a * b), $MachinePrecision], -1e-7], N[(a * b), $MachinePrecision], If[LessEqual[N[(a * b), $MachinePrecision], 8e-101], N[(z * t), $MachinePrecision], If[LessEqual[N[(a * b), $MachinePrecision], 1.95e+33], N[(x * y), $MachinePrecision], N[(a * b), $MachinePrecision]]]]
\begin{array}{l}
[x, y, z, t, a, b] = \mathsf{sort}([x, y, z, t, a, b])\\
\\
\begin{array}{l}
\mathbf{if}\;a \cdot b \leq -1 \cdot 10^{-7}:\\
\;\;\;\;a \cdot b\\

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if (*.f64 a b) < -9.9999999999999995e-8 or 1.9500000000000001e33 < (*.f64 a b)

    1. Initial program 97.7%

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

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

      \[\leadsto \color{blue}{\mathsf{fma}\left(x, y, z \cdot t\right) + a \cdot b} \]
    4. Add Preprocessing
    5. Taylor expanded in a around inf 64.3%

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

    if -9.9999999999999995e-8 < (*.f64 a b) < 8.00000000000000041e-101

    1. Initial program 99.0%

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

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

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

      \[\leadsto \color{blue}{a \cdot b + t \cdot z} \]
    6. Taylor expanded in z around inf 64.7%

      \[\leadsto \color{blue}{z \cdot \left(t + \frac{a \cdot b}{z}\right)} \]
    7. Step-by-step derivation
      1. associate-/l*62.7%

        \[\leadsto z \cdot \left(t + \color{blue}{a \cdot \frac{b}{z}}\right) \]
    8. Simplified62.7%

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

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

    if 8.00000000000000041e-101 < (*.f64 a b) < 1.9500000000000001e33

    1. Initial program 95.8%

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

      \[\leadsto \color{blue}{x \cdot y} + a \cdot b \]
    4. Taylor expanded in y around inf 94.5%

      \[\leadsto \color{blue}{y \cdot \left(x + \frac{a \cdot b}{y}\right)} \]
    5. Step-by-step derivation
      1. associate-/l*90.4%

        \[\leadsto y \cdot \left(x + \color{blue}{a \cdot \frac{b}{y}}\right) \]
    6. Simplified90.4%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;a \cdot b \leq -1 \cdot 10^{-7}:\\ \;\;\;\;a \cdot b\\ \mathbf{elif}\;a \cdot b \leq 8 \cdot 10^{-101}:\\ \;\;\;\;z \cdot t\\ \mathbf{elif}\;a \cdot b \leq 1.95 \cdot 10^{+33}:\\ \;\;\;\;x \cdot y\\ \mathbf{else}:\\ \;\;\;\;a \cdot b\\ \end{array} \]
  5. Add Preprocessing

Alternative 6: 84.6% accurate, 0.5× speedup?

\[\begin{array}{l} [x, y, z, t, a, b] = \mathsf{sort}([x, y, z, t, a, b])\\ \\ \begin{array}{l} \mathbf{if}\;x \cdot y \leq -4 \cdot 10^{+111}:\\ \;\;\;\;z \cdot t + x \cdot y\\ \mathbf{elif}\;x \cdot y \leq 10^{+44}:\\ \;\;\;\;z \cdot t + a \cdot b\\ \mathbf{else}:\\ \;\;\;\;y \cdot \left(x + a \cdot \frac{b}{y}\right)\\ \end{array} \end{array} \]
NOTE: x, y, z, t, a, and b should be sorted in increasing order before calling this function.
(FPCore (x y z t a b)
 :precision binary64
 (if (<= (* x y) -4e+111)
   (+ (* z t) (* x y))
   (if (<= (* x y) 1e+44) (+ (* z t) (* a b)) (* y (+ x (* a (/ b y)))))))
assert(x < y && y < z && z < t && t < a && a < b);
double code(double x, double y, double z, double t, double a, double b) {
	double tmp;
	if ((x * y) <= -4e+111) {
		tmp = (z * t) + (x * y);
	} else if ((x * y) <= 1e+44) {
		tmp = (z * t) + (a * b);
	} else {
		tmp = y * (x + (a * (b / y)));
	}
	return tmp;
}
NOTE: x, y, z, t, a, and b should be sorted in increasing order before calling this function.
real(8) function code(x, y, z, t, a, b)
    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) :: tmp
    if ((x * y) <= (-4d+111)) then
        tmp = (z * t) + (x * y)
    else if ((x * y) <= 1d+44) then
        tmp = (z * t) + (a * b)
    else
        tmp = y * (x + (a * (b / y)))
    end if
    code = tmp
end function
assert x < y && y < z && z < t && t < a && a < b;
public static double code(double x, double y, double z, double t, double a, double b) {
	double tmp;
	if ((x * y) <= -4e+111) {
		tmp = (z * t) + (x * y);
	} else if ((x * y) <= 1e+44) {
		tmp = (z * t) + (a * b);
	} else {
		tmp = y * (x + (a * (b / y)));
	}
	return tmp;
}
[x, y, z, t, a, b] = sort([x, y, z, t, a, b])
def code(x, y, z, t, a, b):
	tmp = 0
	if (x * y) <= -4e+111:
		tmp = (z * t) + (x * y)
	elif (x * y) <= 1e+44:
		tmp = (z * t) + (a * b)
	else:
		tmp = y * (x + (a * (b / y)))
	return tmp
x, y, z, t, a, b = sort([x, y, z, t, a, b])
function code(x, y, z, t, a, b)
	tmp = 0.0
	if (Float64(x * y) <= -4e+111)
		tmp = Float64(Float64(z * t) + Float64(x * y));
	elseif (Float64(x * y) <= 1e+44)
		tmp = Float64(Float64(z * t) + Float64(a * b));
	else
		tmp = Float64(y * Float64(x + Float64(a * Float64(b / y))));
	end
	return tmp
end
x, y, z, t, a, b = num2cell(sort([x, y, z, t, a, b])){:}
function tmp_2 = code(x, y, z, t, a, b)
	tmp = 0.0;
	if ((x * y) <= -4e+111)
		tmp = (z * t) + (x * y);
	elseif ((x * y) <= 1e+44)
		tmp = (z * t) + (a * b);
	else
		tmp = y * (x + (a * (b / y)));
	end
	tmp_2 = tmp;
end
NOTE: x, y, z, t, a, and b should be sorted in increasing order before calling this function.
code[x_, y_, z_, t_, a_, b_] := If[LessEqual[N[(x * y), $MachinePrecision], -4e+111], N[(N[(z * t), $MachinePrecision] + N[(x * y), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(x * y), $MachinePrecision], 1e+44], N[(N[(z * t), $MachinePrecision] + N[(a * b), $MachinePrecision]), $MachinePrecision], N[(y * N[(x + N[(a * N[(b / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
[x, y, z, t, a, b] = \mathsf{sort}([x, y, z, t, a, b])\\
\\
\begin{array}{l}
\mathbf{if}\;x \cdot y \leq -4 \cdot 10^{+111}:\\
\;\;\;\;z \cdot t + x \cdot y\\

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

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


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

    1. Initial program 97.4%

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

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

      \[\leadsto \color{blue}{\mathsf{fma}\left(x, y, z \cdot t\right) + a \cdot b} \]
    4. Add Preprocessing
    5. Taylor expanded in x around inf 97.4%

      \[\leadsto \color{blue}{x \cdot \left(y + \left(\frac{a \cdot b}{x} + \frac{t \cdot z}{x}\right)\right)} \]
    6. Step-by-step derivation
      1. associate-+r+97.4%

        \[\leadsto x \cdot \color{blue}{\left(\left(y + \frac{a \cdot b}{x}\right) + \frac{t \cdot z}{x}\right)} \]
      2. associate-/l*97.3%

        \[\leadsto x \cdot \left(\left(y + \color{blue}{a \cdot \frac{b}{x}}\right) + \frac{t \cdot z}{x}\right) \]
      3. associate-/l*97.3%

        \[\leadsto x \cdot \left(\left(y + a \cdot \frac{b}{x}\right) + \color{blue}{t \cdot \frac{z}{x}}\right) \]
    7. Simplified97.3%

      \[\leadsto \color{blue}{x \cdot \left(\left(y + a \cdot \frac{b}{x}\right) + t \cdot \frac{z}{x}\right)} \]
    8. Step-by-step derivation
      1. clear-num97.3%

        \[\leadsto x \cdot \left(\left(y + a \cdot \color{blue}{\frac{1}{\frac{x}{b}}}\right) + t \cdot \frac{z}{x}\right) \]
      2. inv-pow97.3%

        \[\leadsto x \cdot \left(\left(y + a \cdot \color{blue}{{\left(\frac{x}{b}\right)}^{-1}}\right) + t \cdot \frac{z}{x}\right) \]
    9. Applied egg-rr97.3%

      \[\leadsto x \cdot \left(\left(y + a \cdot \color{blue}{{\left(\frac{x}{b}\right)}^{-1}}\right) + t \cdot \frac{z}{x}\right) \]
    10. Step-by-step derivation
      1. unpow-197.3%

        \[\leadsto x \cdot \left(\left(y + a \cdot \color{blue}{\frac{1}{\frac{x}{b}}}\right) + t \cdot \frac{z}{x}\right) \]
    11. Simplified97.3%

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

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

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

    if -3.99999999999999983e111 < (*.f64 x y) < 1.0000000000000001e44

    1. Initial program 99.3%

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

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

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

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

    if 1.0000000000000001e44 < (*.f64 x y)

    1. Initial program 95.2%

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

      \[\leadsto \color{blue}{x \cdot y} + a \cdot b \]
    4. Taylor expanded in y around inf 87.0%

      \[\leadsto \color{blue}{y \cdot \left(x + \frac{a \cdot b}{y}\right)} \]
    5. Step-by-step derivation
      1. associate-/l*88.6%

        \[\leadsto y \cdot \left(x + \color{blue}{a \cdot \frac{b}{y}}\right) \]
    6. Simplified88.6%

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

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

Alternative 7: 84.7% accurate, 0.5× speedup?

\[\begin{array}{l} [x, y, z, t, a, b] = \mathsf{sort}([x, y, z, t, a, b])\\ \\ \begin{array}{l} \mathbf{if}\;x \cdot y \leq -4 \cdot 10^{+111} \lor \neg \left(x \cdot y \leq 10^{+24}\right):\\ \;\;\;\;z \cdot t + x \cdot y\\ \mathbf{else}:\\ \;\;\;\;z \cdot t + a \cdot b\\ \end{array} \end{array} \]
NOTE: x, y, z, t, a, and b should be sorted in increasing order before calling this function.
(FPCore (x y z t a b)
 :precision binary64
 (if (or (<= (* x y) -4e+111) (not (<= (* x y) 1e+24)))
   (+ (* z t) (* x y))
   (+ (* z t) (* a b))))
assert(x < y && y < z && z < t && t < a && a < b);
double code(double x, double y, double z, double t, double a, double b) {
	double tmp;
	if (((x * y) <= -4e+111) || !((x * y) <= 1e+24)) {
		tmp = (z * t) + (x * y);
	} else {
		tmp = (z * t) + (a * b);
	}
	return tmp;
}
NOTE: x, y, z, t, a, and b should be sorted in increasing order before calling this function.
real(8) function code(x, y, z, t, a, b)
    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) :: tmp
    if (((x * y) <= (-4d+111)) .or. (.not. ((x * y) <= 1d+24))) then
        tmp = (z * t) + (x * y)
    else
        tmp = (z * t) + (a * b)
    end if
    code = tmp
end function
assert x < y && y < z && z < t && t < a && a < b;
public static double code(double x, double y, double z, double t, double a, double b) {
	double tmp;
	if (((x * y) <= -4e+111) || !((x * y) <= 1e+24)) {
		tmp = (z * t) + (x * y);
	} else {
		tmp = (z * t) + (a * b);
	}
	return tmp;
}
[x, y, z, t, a, b] = sort([x, y, z, t, a, b])
def code(x, y, z, t, a, b):
	tmp = 0
	if ((x * y) <= -4e+111) or not ((x * y) <= 1e+24):
		tmp = (z * t) + (x * y)
	else:
		tmp = (z * t) + (a * b)
	return tmp
x, y, z, t, a, b = sort([x, y, z, t, a, b])
function code(x, y, z, t, a, b)
	tmp = 0.0
	if ((Float64(x * y) <= -4e+111) || !(Float64(x * y) <= 1e+24))
		tmp = Float64(Float64(z * t) + Float64(x * y));
	else
		tmp = Float64(Float64(z * t) + Float64(a * b));
	end
	return tmp
end
x, y, z, t, a, b = num2cell(sort([x, y, z, t, a, b])){:}
function tmp_2 = code(x, y, z, t, a, b)
	tmp = 0.0;
	if (((x * y) <= -4e+111) || ~(((x * y) <= 1e+24)))
		tmp = (z * t) + (x * y);
	else
		tmp = (z * t) + (a * b);
	end
	tmp_2 = tmp;
end
NOTE: x, y, z, t, a, and b should be sorted in increasing order before calling this function.
code[x_, y_, z_, t_, a_, b_] := If[Or[LessEqual[N[(x * y), $MachinePrecision], -4e+111], N[Not[LessEqual[N[(x * y), $MachinePrecision], 1e+24]], $MachinePrecision]], N[(N[(z * t), $MachinePrecision] + N[(x * y), $MachinePrecision]), $MachinePrecision], N[(N[(z * t), $MachinePrecision] + N[(a * b), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[x, y, z, t, a, b] = \mathsf{sort}([x, y, z, t, a, b])\\
\\
\begin{array}{l}
\mathbf{if}\;x \cdot y \leq -4 \cdot 10^{+111} \lor \neg \left(x \cdot y \leq 10^{+24}\right):\\
\;\;\;\;z \cdot t + x \cdot y\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (*.f64 x y) < -3.99999999999999983e111 or 9.9999999999999998e23 < (*.f64 x y)

    1. Initial program 95.2%

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

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

      \[\leadsto \color{blue}{\mathsf{fma}\left(x, y, z \cdot t\right) + a \cdot b} \]
    4. Add Preprocessing
    5. Taylor expanded in x around inf 94.4%

      \[\leadsto \color{blue}{x \cdot \left(y + \left(\frac{a \cdot b}{x} + \frac{t \cdot z}{x}\right)\right)} \]
    6. Step-by-step derivation
      1. associate-+r+94.4%

        \[\leadsto x \cdot \color{blue}{\left(\left(y + \frac{a \cdot b}{x}\right) + \frac{t \cdot z}{x}\right)} \]
      2. associate-/l*94.4%

        \[\leadsto x \cdot \left(\left(y + \color{blue}{a \cdot \frac{b}{x}}\right) + \frac{t \cdot z}{x}\right) \]
      3. associate-/l*94.5%

        \[\leadsto x \cdot \left(\left(y + a \cdot \frac{b}{x}\right) + \color{blue}{t \cdot \frac{z}{x}}\right) \]
    7. Simplified94.5%

      \[\leadsto \color{blue}{x \cdot \left(\left(y + a \cdot \frac{b}{x}\right) + t \cdot \frac{z}{x}\right)} \]
    8. Step-by-step derivation
      1. clear-num94.4%

        \[\leadsto x \cdot \left(\left(y + a \cdot \color{blue}{\frac{1}{\frac{x}{b}}}\right) + t \cdot \frac{z}{x}\right) \]
      2. inv-pow94.4%

        \[\leadsto x \cdot \left(\left(y + a \cdot \color{blue}{{\left(\frac{x}{b}\right)}^{-1}}\right) + t \cdot \frac{z}{x}\right) \]
    9. Applied egg-rr94.4%

      \[\leadsto x \cdot \left(\left(y + a \cdot \color{blue}{{\left(\frac{x}{b}\right)}^{-1}}\right) + t \cdot \frac{z}{x}\right) \]
    10. Step-by-step derivation
      1. unpow-194.4%

        \[\leadsto x \cdot \left(\left(y + a \cdot \color{blue}{\frac{1}{\frac{x}{b}}}\right) + t \cdot \frac{z}{x}\right) \]
    11. Simplified94.4%

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

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

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

    if -3.99999999999999983e111 < (*.f64 x y) < 9.9999999999999998e23

    1. Initial program 100.0%

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

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

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

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

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

Alternative 8: 84.6% accurate, 0.5× speedup?

\[\begin{array}{l} [x, y, z, t, a, b] = \mathsf{sort}([x, y, z, t, a, b])\\ \\ \begin{array}{l} \mathbf{if}\;x \cdot y \leq -4 \cdot 10^{+111}:\\ \;\;\;\;z \cdot t + x \cdot y\\ \mathbf{elif}\;x \cdot y \leq 4 \cdot 10^{+42}:\\ \;\;\;\;z \cdot t + a \cdot b\\ \mathbf{else}:\\ \;\;\;\;a \cdot b + x \cdot y\\ \end{array} \end{array} \]
NOTE: x, y, z, t, a, and b should be sorted in increasing order before calling this function.
(FPCore (x y z t a b)
 :precision binary64
 (if (<= (* x y) -4e+111)
   (+ (* z t) (* x y))
   (if (<= (* x y) 4e+42) (+ (* z t) (* a b)) (+ (* a b) (* x y)))))
assert(x < y && y < z && z < t && t < a && a < b);
double code(double x, double y, double z, double t, double a, double b) {
	double tmp;
	if ((x * y) <= -4e+111) {
		tmp = (z * t) + (x * y);
	} else if ((x * y) <= 4e+42) {
		tmp = (z * t) + (a * b);
	} else {
		tmp = (a * b) + (x * y);
	}
	return tmp;
}
NOTE: x, y, z, t, a, and b should be sorted in increasing order before calling this function.
real(8) function code(x, y, z, t, a, b)
    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) :: tmp
    if ((x * y) <= (-4d+111)) then
        tmp = (z * t) + (x * y)
    else if ((x * y) <= 4d+42) then
        tmp = (z * t) + (a * b)
    else
        tmp = (a * b) + (x * y)
    end if
    code = tmp
end function
assert x < y && y < z && z < t && t < a && a < b;
public static double code(double x, double y, double z, double t, double a, double b) {
	double tmp;
	if ((x * y) <= -4e+111) {
		tmp = (z * t) + (x * y);
	} else if ((x * y) <= 4e+42) {
		tmp = (z * t) + (a * b);
	} else {
		tmp = (a * b) + (x * y);
	}
	return tmp;
}
[x, y, z, t, a, b] = sort([x, y, z, t, a, b])
def code(x, y, z, t, a, b):
	tmp = 0
	if (x * y) <= -4e+111:
		tmp = (z * t) + (x * y)
	elif (x * y) <= 4e+42:
		tmp = (z * t) + (a * b)
	else:
		tmp = (a * b) + (x * y)
	return tmp
x, y, z, t, a, b = sort([x, y, z, t, a, b])
function code(x, y, z, t, a, b)
	tmp = 0.0
	if (Float64(x * y) <= -4e+111)
		tmp = Float64(Float64(z * t) + Float64(x * y));
	elseif (Float64(x * y) <= 4e+42)
		tmp = Float64(Float64(z * t) + Float64(a * b));
	else
		tmp = Float64(Float64(a * b) + Float64(x * y));
	end
	return tmp
end
x, y, z, t, a, b = num2cell(sort([x, y, z, t, a, b])){:}
function tmp_2 = code(x, y, z, t, a, b)
	tmp = 0.0;
	if ((x * y) <= -4e+111)
		tmp = (z * t) + (x * y);
	elseif ((x * y) <= 4e+42)
		tmp = (z * t) + (a * b);
	else
		tmp = (a * b) + (x * y);
	end
	tmp_2 = tmp;
end
NOTE: x, y, z, t, a, and b should be sorted in increasing order before calling this function.
code[x_, y_, z_, t_, a_, b_] := If[LessEqual[N[(x * y), $MachinePrecision], -4e+111], N[(N[(z * t), $MachinePrecision] + N[(x * y), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(x * y), $MachinePrecision], 4e+42], N[(N[(z * t), $MachinePrecision] + N[(a * b), $MachinePrecision]), $MachinePrecision], N[(N[(a * b), $MachinePrecision] + N[(x * y), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
[x, y, z, t, a, b] = \mathsf{sort}([x, y, z, t, a, b])\\
\\
\begin{array}{l}
\mathbf{if}\;x \cdot y \leq -4 \cdot 10^{+111}:\\
\;\;\;\;z \cdot t + x \cdot y\\

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

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


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

    1. Initial program 97.4%

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

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

      \[\leadsto \color{blue}{\mathsf{fma}\left(x, y, z \cdot t\right) + a \cdot b} \]
    4. Add Preprocessing
    5. Taylor expanded in x around inf 97.4%

      \[\leadsto \color{blue}{x \cdot \left(y + \left(\frac{a \cdot b}{x} + \frac{t \cdot z}{x}\right)\right)} \]
    6. Step-by-step derivation
      1. associate-+r+97.4%

        \[\leadsto x \cdot \color{blue}{\left(\left(y + \frac{a \cdot b}{x}\right) + \frac{t \cdot z}{x}\right)} \]
      2. associate-/l*97.3%

        \[\leadsto x \cdot \left(\left(y + \color{blue}{a \cdot \frac{b}{x}}\right) + \frac{t \cdot z}{x}\right) \]
      3. associate-/l*97.3%

        \[\leadsto x \cdot \left(\left(y + a \cdot \frac{b}{x}\right) + \color{blue}{t \cdot \frac{z}{x}}\right) \]
    7. Simplified97.3%

      \[\leadsto \color{blue}{x \cdot \left(\left(y + a \cdot \frac{b}{x}\right) + t \cdot \frac{z}{x}\right)} \]
    8. Step-by-step derivation
      1. clear-num97.3%

        \[\leadsto x \cdot \left(\left(y + a \cdot \color{blue}{\frac{1}{\frac{x}{b}}}\right) + t \cdot \frac{z}{x}\right) \]
      2. inv-pow97.3%

        \[\leadsto x \cdot \left(\left(y + a \cdot \color{blue}{{\left(\frac{x}{b}\right)}^{-1}}\right) + t \cdot \frac{z}{x}\right) \]
    9. Applied egg-rr97.3%

      \[\leadsto x \cdot \left(\left(y + a \cdot \color{blue}{{\left(\frac{x}{b}\right)}^{-1}}\right) + t \cdot \frac{z}{x}\right) \]
    10. Step-by-step derivation
      1. unpow-197.3%

        \[\leadsto x \cdot \left(\left(y + a \cdot \color{blue}{\frac{1}{\frac{x}{b}}}\right) + t \cdot \frac{z}{x}\right) \]
    11. Simplified97.3%

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

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

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

    if -3.99999999999999983e111 < (*.f64 x y) < 4.00000000000000018e42

    1. Initial program 99.3%

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

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

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

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

    if 4.00000000000000018e42 < (*.f64 x y)

    1. Initial program 95.2%

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

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

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

Alternative 9: 75.2% accurate, 0.6× speedup?

\[\begin{array}{l} [x, y, z, t, a, b] = \mathsf{sort}([x, y, z, t, a, b])\\ \\ \begin{array}{l} \mathbf{if}\;y \leq -6.2 \cdot 10^{-12} \lor \neg \left(y \leq 8.2 \cdot 10^{+177}\right):\\ \;\;\;\;x \cdot y\\ \mathbf{else}:\\ \;\;\;\;z \cdot t + a \cdot b\\ \end{array} \end{array} \]
NOTE: x, y, z, t, a, and b should be sorted in increasing order before calling this function.
(FPCore (x y z t a b)
 :precision binary64
 (if (or (<= y -6.2e-12) (not (<= y 8.2e+177))) (* x y) (+ (* z t) (* a b))))
assert(x < y && y < z && z < t && t < a && a < b);
double code(double x, double y, double z, double t, double a, double b) {
	double tmp;
	if ((y <= -6.2e-12) || !(y <= 8.2e+177)) {
		tmp = x * y;
	} else {
		tmp = (z * t) + (a * b);
	}
	return tmp;
}
NOTE: x, y, z, t, a, and b should be sorted in increasing order before calling this function.
real(8) function code(x, y, z, t, a, b)
    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) :: tmp
    if ((y <= (-6.2d-12)) .or. (.not. (y <= 8.2d+177))) then
        tmp = x * y
    else
        tmp = (z * t) + (a * b)
    end if
    code = tmp
end function
assert x < y && y < z && z < t && t < a && a < b;
public static double code(double x, double y, double z, double t, double a, double b) {
	double tmp;
	if ((y <= -6.2e-12) || !(y <= 8.2e+177)) {
		tmp = x * y;
	} else {
		tmp = (z * t) + (a * b);
	}
	return tmp;
}
[x, y, z, t, a, b] = sort([x, y, z, t, a, b])
def code(x, y, z, t, a, b):
	tmp = 0
	if (y <= -6.2e-12) or not (y <= 8.2e+177):
		tmp = x * y
	else:
		tmp = (z * t) + (a * b)
	return tmp
x, y, z, t, a, b = sort([x, y, z, t, a, b])
function code(x, y, z, t, a, b)
	tmp = 0.0
	if ((y <= -6.2e-12) || !(y <= 8.2e+177))
		tmp = Float64(x * y);
	else
		tmp = Float64(Float64(z * t) + Float64(a * b));
	end
	return tmp
end
x, y, z, t, a, b = num2cell(sort([x, y, z, t, a, b])){:}
function tmp_2 = code(x, y, z, t, a, b)
	tmp = 0.0;
	if ((y <= -6.2e-12) || ~((y <= 8.2e+177)))
		tmp = x * y;
	else
		tmp = (z * t) + (a * b);
	end
	tmp_2 = tmp;
end
NOTE: x, y, z, t, a, and b should be sorted in increasing order before calling this function.
code[x_, y_, z_, t_, a_, b_] := If[Or[LessEqual[y, -6.2e-12], N[Not[LessEqual[y, 8.2e+177]], $MachinePrecision]], N[(x * y), $MachinePrecision], N[(N[(z * t), $MachinePrecision] + N[(a * b), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[x, y, z, t, a, b] = \mathsf{sort}([x, y, z, t, a, b])\\
\\
\begin{array}{l}
\mathbf{if}\;y \leq -6.2 \cdot 10^{-12} \lor \neg \left(y \leq 8.2 \cdot 10^{+177}\right):\\
\;\;\;\;x \cdot y\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if y < -6.2000000000000002e-12 or 8.20000000000000029e177 < y

    1. Initial program 95.0%

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

      \[\leadsto \color{blue}{x \cdot y} + a \cdot b \]
    4. Taylor expanded in y around inf 77.7%

      \[\leadsto \color{blue}{y \cdot \left(x + \frac{a \cdot b}{y}\right)} \]
    5. Step-by-step derivation
      1. associate-/l*79.6%

        \[\leadsto y \cdot \left(x + \color{blue}{a \cdot \frac{b}{y}}\right) \]
    6. Simplified79.6%

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

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

    if -6.2000000000000002e-12 < y < 8.20000000000000029e177

    1. Initial program 100.0%

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

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

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

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

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

Alternative 10: 52.4% accurate, 0.6× speedup?

\[\begin{array}{l} [x, y, z, t, a, b] = \mathsf{sort}([x, y, z, t, a, b])\\ \\ \begin{array}{l} \mathbf{if}\;a \cdot b \leq -9.5 \cdot 10^{+142} \lor \neg \left(a \cdot b \leq 2 \cdot 10^{+34}\right):\\ \;\;\;\;a \cdot b\\ \mathbf{else}:\\ \;\;\;\;x \cdot y\\ \end{array} \end{array} \]
NOTE: x, y, z, t, a, and b should be sorted in increasing order before calling this function.
(FPCore (x y z t a b)
 :precision binary64
 (if (or (<= (* a b) -9.5e+142) (not (<= (* a b) 2e+34))) (* a b) (* x y)))
assert(x < y && y < z && z < t && t < a && a < b);
double code(double x, double y, double z, double t, double a, double b) {
	double tmp;
	if (((a * b) <= -9.5e+142) || !((a * b) <= 2e+34)) {
		tmp = a * b;
	} else {
		tmp = x * y;
	}
	return tmp;
}
NOTE: x, y, z, t, a, and b should be sorted in increasing order before calling this function.
real(8) function code(x, y, z, t, a, b)
    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) :: tmp
    if (((a * b) <= (-9.5d+142)) .or. (.not. ((a * b) <= 2d+34))) then
        tmp = a * b
    else
        tmp = x * y
    end if
    code = tmp
end function
assert x < y && y < z && z < t && t < a && a < b;
public static double code(double x, double y, double z, double t, double a, double b) {
	double tmp;
	if (((a * b) <= -9.5e+142) || !((a * b) <= 2e+34)) {
		tmp = a * b;
	} else {
		tmp = x * y;
	}
	return tmp;
}
[x, y, z, t, a, b] = sort([x, y, z, t, a, b])
def code(x, y, z, t, a, b):
	tmp = 0
	if ((a * b) <= -9.5e+142) or not ((a * b) <= 2e+34):
		tmp = a * b
	else:
		tmp = x * y
	return tmp
x, y, z, t, a, b = sort([x, y, z, t, a, b])
function code(x, y, z, t, a, b)
	tmp = 0.0
	if ((Float64(a * b) <= -9.5e+142) || !(Float64(a * b) <= 2e+34))
		tmp = Float64(a * b);
	else
		tmp = Float64(x * y);
	end
	return tmp
end
x, y, z, t, a, b = num2cell(sort([x, y, z, t, a, b])){:}
function tmp_2 = code(x, y, z, t, a, b)
	tmp = 0.0;
	if (((a * b) <= -9.5e+142) || ~(((a * b) <= 2e+34)))
		tmp = a * b;
	else
		tmp = x * y;
	end
	tmp_2 = tmp;
end
NOTE: x, y, z, t, a, and b should be sorted in increasing order before calling this function.
code[x_, y_, z_, t_, a_, b_] := If[Or[LessEqual[N[(a * b), $MachinePrecision], -9.5e+142], N[Not[LessEqual[N[(a * b), $MachinePrecision], 2e+34]], $MachinePrecision]], N[(a * b), $MachinePrecision], N[(x * y), $MachinePrecision]]
\begin{array}{l}
[x, y, z, t, a, b] = \mathsf{sort}([x, y, z, t, a, b])\\
\\
\begin{array}{l}
\mathbf{if}\;a \cdot b \leq -9.5 \cdot 10^{+142} \lor \neg \left(a \cdot b \leq 2 \cdot 10^{+34}\right):\\
\;\;\;\;a \cdot b\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (*.f64 a b) < -9.50000000000000001e142 or 1.99999999999999989e34 < (*.f64 a b)

    1. Initial program 97.2%

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

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

      \[\leadsto \color{blue}{\mathsf{fma}\left(x, y, z \cdot t\right) + a \cdot b} \]
    4. Add Preprocessing
    5. Taylor expanded in a around inf 70.6%

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

    if -9.50000000000000001e142 < (*.f64 a b) < 1.99999999999999989e34

    1. Initial program 98.6%

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

      \[\leadsto \color{blue}{x \cdot y} + a \cdot b \]
    4. Taylor expanded in y around inf 58.9%

      \[\leadsto \color{blue}{y \cdot \left(x + \frac{a \cdot b}{y}\right)} \]
    5. Step-by-step derivation
      1. associate-/l*57.0%

        \[\leadsto y \cdot \left(x + \color{blue}{a \cdot \frac{b}{y}}\right) \]
    6. Simplified57.0%

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

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

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

Alternative 11: 35.6% accurate, 3.7× speedup?

\[\begin{array}{l} [x, y, z, t, a, b] = \mathsf{sort}([x, y, z, t, a, b])\\ \\ a \cdot b \end{array} \]
NOTE: x, y, z, t, a, and b should be sorted in increasing order before calling this function.
(FPCore (x y z t a b) :precision binary64 (* a b))
assert(x < y && y < z && z < t && t < a && a < b);
double code(double x, double y, double z, double t, double a, double b) {
	return a * b;
}
NOTE: x, y, z, t, a, and b should be sorted in increasing order before calling this function.
real(8) function code(x, y, z, t, a, b)
    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
    code = a * b
end function
assert x < y && y < z && z < t && t < a && a < b;
public static double code(double x, double y, double z, double t, double a, double b) {
	return a * b;
}
[x, y, z, t, a, b] = sort([x, y, z, t, a, b])
def code(x, y, z, t, a, b):
	return a * b
x, y, z, t, a, b = sort([x, y, z, t, a, b])
function code(x, y, z, t, a, b)
	return Float64(a * b)
end
x, y, z, t, a, b = num2cell(sort([x, y, z, t, a, b])){:}
function tmp = code(x, y, z, t, a, b)
	tmp = a * b;
end
NOTE: x, y, z, t, a, and b should be sorted in increasing order before calling this function.
code[x_, y_, z_, t_, a_, b_] := N[(a * b), $MachinePrecision]
\begin{array}{l}
[x, y, z, t, a, b] = \mathsf{sort}([x, y, z, t, a, b])\\
\\
a \cdot b
\end{array}
Derivation
  1. Initial program 98.0%

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

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

    \[\leadsto \color{blue}{\mathsf{fma}\left(x, y, z \cdot t\right) + a \cdot b} \]
  4. Add Preprocessing
  5. Taylor expanded in a around inf 39.5%

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

Reproduce

?
herbie shell --seed 2024180 
(FPCore (x y z t a b)
  :name "Linear.V3:$cdot from linear-1.19.1.3, B"
  :precision binary64
  (+ (+ (* x y) (* z t)) (* a b)))