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

Percentage Accurate: 97.8% → 99.1%
Time: 8.7s
Alternatives: 12
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 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: 97.8% 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.1% accurate, 0.1× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \cdot y + z \cdot t \leq 2 \cdot 10^{+305}:\\ \;\;\;\;\mathsf{fma}\left(x, y, \mathsf{fma}\left(z, t, a \cdot b\right)\right)\\ \mathbf{else}:\\ \;\;\;\;y \cdot \left(x + t \cdot \frac{z}{y}\right)\\ \end{array} \end{array} \]
(FPCore (x y z t a b)
 :precision binary64
 (if (<= (+ (* x y) (* z t)) 2e+305)
   (fma x y (fma z t (* a b)))
   (* y (+ x (* t (/ z y))))))
double code(double x, double y, double z, double t, double a, double b) {
	double tmp;
	if (((x * y) + (z * t)) <= 2e+305) {
		tmp = fma(x, y, fma(z, t, (a * b)));
	} else {
		tmp = y * (x + (t * (z / y)));
	}
	return tmp;
}
function code(x, y, z, t, a, b)
	tmp = 0.0
	if (Float64(Float64(x * y) + Float64(z * t)) <= 2e+305)
		tmp = fma(x, y, fma(z, t, Float64(a * b)));
	else
		tmp = Float64(y * Float64(x + Float64(t * Float64(z / y))));
	end
	return tmp
end
code[x_, y_, z_, t_, a_, b_] := If[LessEqual[N[(N[(x * y), $MachinePrecision] + N[(z * t), $MachinePrecision]), $MachinePrecision], 2e+305], N[(x * y + N[(z * t + N[(a * b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(y * N[(x + N[(t * N[(z / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;x \cdot y + z \cdot t \leq 2 \cdot 10^{+305}:\\
\;\;\;\;\mathsf{fma}\left(x, y, \mathsf{fma}\left(z, t, a \cdot b\right)\right)\\

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


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

    1. Initial program 98.6%

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

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

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

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

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

    if 1.9999999999999999e305 < (+.f64 (*.f64 x y) (*.f64 z t))

    1. Initial program 83.8%

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

      \[\leadsto \color{blue}{t \cdot z + x \cdot y} \]
    4. Taylor expanded in y around inf 91.9%

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

        \[\leadsto y \cdot \left(x + \color{blue}{t \cdot \frac{z}{y}}\right) \]
    6. Simplified100.0%

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

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

Alternative 2: 99.0% accurate, 0.1× speedup?

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

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

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

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

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

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

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

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

Alternative 3: 99.3% accurate, 0.1× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;\left(x \cdot y + z \cdot t\right) + a \cdot b \leq \infty:\\
\;\;\;\;a \cdot b + \mathsf{fma}\left(x, y, z \cdot t\right)\\

\mathbf{else}:\\
\;\;\;\;y \cdot \left(x + t \cdot \frac{z}{y}\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. 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

    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. Add Preprocessing
    3. Taylor expanded in a around 0 33.3%

      \[\leadsto \color{blue}{t \cdot z + x \cdot y} \]
    4. Taylor expanded in y around inf 44.4%

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

        \[\leadsto y \cdot \left(x + \color{blue}{t \cdot \frac{z}{y}}\right) \]
    6. Simplified77.8%

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

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

Alternative 4: 54.3% accurate, 0.3× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \cdot y \leq -2.75 \cdot 10^{+91}:\\ \;\;\;\;x \cdot y\\ \mathbf{elif}\;x \cdot y \leq -1 \cdot 10^{-161}:\\ \;\;\;\;a \cdot b\\ \mathbf{elif}\;x \cdot y \leq -2.2 \cdot 10^{-241}:\\ \;\;\;\;z \cdot t\\ \mathbf{elif}\;x \cdot y \leq 2.3 \cdot 10^{-272}:\\ \;\;\;\;a \cdot b\\ \mathbf{elif}\;x \cdot y \leq 8.5 \cdot 10^{+59}:\\ \;\;\;\;z \cdot t\\ \mathbf{else}:\\ \;\;\;\;x \cdot y\\ \end{array} \end{array} \]
(FPCore (x y z t a b)
 :precision binary64
 (if (<= (* x y) -2.75e+91)
   (* x y)
   (if (<= (* x y) -1e-161)
     (* a b)
     (if (<= (* x y) -2.2e-241)
       (* z t)
       (if (<= (* x y) 2.3e-272)
         (* a b)
         (if (<= (* x y) 8.5e+59) (* z t) (* x y)))))))
double code(double x, double y, double z, double t, double a, double b) {
	double tmp;
	if ((x * y) <= -2.75e+91) {
		tmp = x * y;
	} else if ((x * y) <= -1e-161) {
		tmp = a * b;
	} else if ((x * y) <= -2.2e-241) {
		tmp = z * t;
	} else if ((x * y) <= 2.3e-272) {
		tmp = a * b;
	} else if ((x * y) <= 8.5e+59) {
		tmp = z * t;
	} else {
		tmp = x * y;
	}
	return tmp;
}
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) <= (-2.75d+91)) then
        tmp = x * y
    else if ((x * y) <= (-1d-161)) then
        tmp = a * b
    else if ((x * y) <= (-2.2d-241)) then
        tmp = z * t
    else if ((x * y) <= 2.3d-272) then
        tmp = a * b
    else if ((x * y) <= 8.5d+59) then
        tmp = z * t
    else
        tmp = x * y
    end if
    code = tmp
end function
public static double code(double x, double y, double z, double t, double a, double b) {
	double tmp;
	if ((x * y) <= -2.75e+91) {
		tmp = x * y;
	} else if ((x * y) <= -1e-161) {
		tmp = a * b;
	} else if ((x * y) <= -2.2e-241) {
		tmp = z * t;
	} else if ((x * y) <= 2.3e-272) {
		tmp = a * b;
	} else if ((x * y) <= 8.5e+59) {
		tmp = z * t;
	} else {
		tmp = x * y;
	}
	return tmp;
}
def code(x, y, z, t, a, b):
	tmp = 0
	if (x * y) <= -2.75e+91:
		tmp = x * y
	elif (x * y) <= -1e-161:
		tmp = a * b
	elif (x * y) <= -2.2e-241:
		tmp = z * t
	elif (x * y) <= 2.3e-272:
		tmp = a * b
	elif (x * y) <= 8.5e+59:
		tmp = z * t
	else:
		tmp = x * y
	return tmp
function code(x, y, z, t, a, b)
	tmp = 0.0
	if (Float64(x * y) <= -2.75e+91)
		tmp = Float64(x * y);
	elseif (Float64(x * y) <= -1e-161)
		tmp = Float64(a * b);
	elseif (Float64(x * y) <= -2.2e-241)
		tmp = Float64(z * t);
	elseif (Float64(x * y) <= 2.3e-272)
		tmp = Float64(a * b);
	elseif (Float64(x * y) <= 8.5e+59)
		tmp = Float64(z * t);
	else
		tmp = Float64(x * y);
	end
	return tmp
end
function tmp_2 = code(x, y, z, t, a, b)
	tmp = 0.0;
	if ((x * y) <= -2.75e+91)
		tmp = x * y;
	elseif ((x * y) <= -1e-161)
		tmp = a * b;
	elseif ((x * y) <= -2.2e-241)
		tmp = z * t;
	elseif ((x * y) <= 2.3e-272)
		tmp = a * b;
	elseif ((x * y) <= 8.5e+59)
		tmp = z * t;
	else
		tmp = x * y;
	end
	tmp_2 = tmp;
end
code[x_, y_, z_, t_, a_, b_] := If[LessEqual[N[(x * y), $MachinePrecision], -2.75e+91], N[(x * y), $MachinePrecision], If[LessEqual[N[(x * y), $MachinePrecision], -1e-161], N[(a * b), $MachinePrecision], If[LessEqual[N[(x * y), $MachinePrecision], -2.2e-241], N[(z * t), $MachinePrecision], If[LessEqual[N[(x * y), $MachinePrecision], 2.3e-272], N[(a * b), $MachinePrecision], If[LessEqual[N[(x * y), $MachinePrecision], 8.5e+59], N[(z * t), $MachinePrecision], N[(x * y), $MachinePrecision]]]]]]
\begin{array}{l}

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

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

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

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

\mathbf{elif}\;x \cdot y \leq 8.5 \cdot 10^{+59}:\\
\;\;\;\;z \cdot t\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if (*.f64 x y) < -2.7499999999999999e91 or 8.4999999999999999e59 < (*.f64 x y)

    1. Initial program 94.0%

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

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

    if -2.7499999999999999e91 < (*.f64 x y) < -1.00000000000000003e-161 or -2.1999999999999999e-241 < (*.f64 x y) < 2.29999999999999989e-272

    1. Initial program 98.7%

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

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

    if -1.00000000000000003e-161 < (*.f64 x y) < -2.1999999999999999e-241 or 2.29999999999999989e-272 < (*.f64 x y) < 8.4999999999999999e59

    1. Initial program 97.4%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \cdot y \leq -2.75 \cdot 10^{+91}:\\ \;\;\;\;x \cdot y\\ \mathbf{elif}\;x \cdot y \leq -1 \cdot 10^{-161}:\\ \;\;\;\;a \cdot b\\ \mathbf{elif}\;x \cdot y \leq -2.2 \cdot 10^{-241}:\\ \;\;\;\;z \cdot t\\ \mathbf{elif}\;x \cdot y \leq 2.3 \cdot 10^{-272}:\\ \;\;\;\;a \cdot b\\ \mathbf{elif}\;x \cdot y \leq 8.5 \cdot 10^{+59}:\\ \;\;\;\;z \cdot t\\ \mathbf{else}:\\ \;\;\;\;x \cdot y\\ \end{array} \]
  5. Add Preprocessing

Alternative 5: 51.4% accurate, 0.4× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;a \cdot b \leq -6.2 \cdot 10^{+103} \lor \neg \left(a \cdot b \leq 4.6 \cdot 10^{-13} \lor \neg \left(a \cdot b \leq 4.8 \cdot 10^{+86}\right) \land a \cdot b \leq 2.2 \cdot 10^{+217}\right):\\ \;\;\;\;a \cdot b\\ \mathbf{else}:\\ \;\;\;\;z \cdot t\\ \end{array} \end{array} \]
(FPCore (x y z t a b)
 :precision binary64
 (if (or (<= (* a b) -6.2e+103)
         (not
          (or (<= (* a b) 4.6e-13)
              (and (not (<= (* a b) 4.8e+86)) (<= (* a b) 2.2e+217)))))
   (* a b)
   (* z t)))
double code(double x, double y, double z, double t, double a, double b) {
	double tmp;
	if (((a * b) <= -6.2e+103) || !(((a * b) <= 4.6e-13) || (!((a * b) <= 4.8e+86) && ((a * b) <= 2.2e+217)))) {
		tmp = a * b;
	} else {
		tmp = z * t;
	}
	return tmp;
}
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) <= (-6.2d+103)) .or. (.not. ((a * b) <= 4.6d-13) .or. (.not. ((a * b) <= 4.8d+86)) .and. ((a * b) <= 2.2d+217))) then
        tmp = 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 tmp;
	if (((a * b) <= -6.2e+103) || !(((a * b) <= 4.6e-13) || (!((a * b) <= 4.8e+86) && ((a * b) <= 2.2e+217)))) {
		tmp = a * b;
	} else {
		tmp = z * t;
	}
	return tmp;
}
def code(x, y, z, t, a, b):
	tmp = 0
	if ((a * b) <= -6.2e+103) or not (((a * b) <= 4.6e-13) or (not ((a * b) <= 4.8e+86) and ((a * b) <= 2.2e+217))):
		tmp = a * b
	else:
		tmp = z * t
	return tmp
function code(x, y, z, t, a, b)
	tmp = 0.0
	if ((Float64(a * b) <= -6.2e+103) || !((Float64(a * b) <= 4.6e-13) || (!(Float64(a * b) <= 4.8e+86) && (Float64(a * b) <= 2.2e+217))))
		tmp = Float64(a * b);
	else
		tmp = Float64(z * t);
	end
	return tmp
end
function tmp_2 = code(x, y, z, t, a, b)
	tmp = 0.0;
	if (((a * b) <= -6.2e+103) || ~((((a * b) <= 4.6e-13) || (~(((a * b) <= 4.8e+86)) && ((a * b) <= 2.2e+217)))))
		tmp = a * b;
	else
		tmp = z * t;
	end
	tmp_2 = tmp;
end
code[x_, y_, z_, t_, a_, b_] := If[Or[LessEqual[N[(a * b), $MachinePrecision], -6.2e+103], N[Not[Or[LessEqual[N[(a * b), $MachinePrecision], 4.6e-13], And[N[Not[LessEqual[N[(a * b), $MachinePrecision], 4.8e+86]], $MachinePrecision], LessEqual[N[(a * b), $MachinePrecision], 2.2e+217]]]], $MachinePrecision]], N[(a * b), $MachinePrecision], N[(z * t), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;a \cdot b \leq -6.2 \cdot 10^{+103} \lor \neg \left(a \cdot b \leq 4.6 \cdot 10^{-13} \lor \neg \left(a \cdot b \leq 4.8 \cdot 10^{+86}\right) \land a \cdot b \leq 2.2 \cdot 10^{+217}\right):\\
\;\;\;\;a \cdot b\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (*.f64 a b) < -6.2000000000000003e103 or 4.59999999999999958e-13 < (*.f64 a b) < 4.8000000000000001e86 or 2.2e217 < (*.f64 a b)

    1. Initial program 94.6%

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

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

    if -6.2000000000000003e103 < (*.f64 a b) < 4.59999999999999958e-13 or 4.8000000000000001e86 < (*.f64 a b) < 2.2e217

    1. Initial program 97.5%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;a \cdot b \leq -6.2 \cdot 10^{+103} \lor \neg \left(a \cdot b \leq 4.6 \cdot 10^{-13} \lor \neg \left(a \cdot b \leq 4.8 \cdot 10^{+86}\right) \land a \cdot b \leq 2.2 \cdot 10^{+217}\right):\\ \;\;\;\;a \cdot b\\ \mathbf{else}:\\ \;\;\;\;z \cdot t\\ \end{array} \]
  5. Add Preprocessing

Alternative 6: 99.3% accurate, 0.4× speedup?

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

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

\mathbf{else}:\\
\;\;\;\;y \cdot \left(x + t \cdot \frac{z}{y}\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. Add Preprocessing
    3. Taylor expanded in a around 0 33.3%

      \[\leadsto \color{blue}{t \cdot z + x \cdot y} \]
    4. Taylor expanded in y around inf 44.4%

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

        \[\leadsto y \cdot \left(x + \color{blue}{t \cdot \frac{z}{y}}\right) \]
    6. Simplified77.8%

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

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

Alternative 7: 85.3% accurate, 0.5× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;x \cdot y \leq -1 \cdot 10^{+90} \lor \neg \left(x \cdot y \leq 10^{+58}\right):\\
\;\;\;\;y \cdot \left(x + t \cdot \frac{z}{y}\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (*.f64 x y) < -9.99999999999999966e89 or 9.99999999999999944e57 < (*.f64 x y)

    1. Initial program 94.1%

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

      \[\leadsto \color{blue}{t \cdot z + x \cdot y} \]
    4. Taylor expanded in y around inf 80.2%

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

        \[\leadsto y \cdot \left(x + \color{blue}{t \cdot \frac{z}{y}}\right) \]
    6. Simplified80.3%

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

    if -9.99999999999999966e89 < (*.f64 x y) < 9.99999999999999944e57

    1. Initial program 98.0%

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

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

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

Alternative 8: 80.3% accurate, 0.5× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;x \cdot y \leq -8 \cdot 10^{+201} \lor \neg \left(x \cdot y \leq 1.2 \cdot 10^{+194}\right):\\
\;\;\;\;x \cdot y\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (*.f64 x y) < -8.0000000000000003e201 or 1.2e194 < (*.f64 x y)

    1. Initial program 89.5%

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

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

    if -8.0000000000000003e201 < (*.f64 x y) < 1.2e194

    1. Initial program 98.5%

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

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

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

Alternative 9: 83.6% accurate, 0.5× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;x \cdot y \leq -3.4 \cdot 10^{+192} \lor \neg \left(x \cdot y \leq 2.3 \cdot 10^{+59}\right):\\
\;\;\;\;x \cdot y + a \cdot b\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (*.f64 x y) < -3.39999999999999996e192 or 2.30000000000000008e59 < (*.f64 x y)

    1. Initial program 92.7%

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

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

    if -3.39999999999999996e192 < (*.f64 x y) < 2.30000000000000008e59

    1. Initial program 98.2%

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

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

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

Alternative 10: 83.5% accurate, 0.5× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;x \cdot y \leq -3.4 \cdot 10^{+192}:\\
\;\;\;\;x \cdot y + a \cdot b\\

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

\mathbf{else}:\\
\;\;\;\;x \cdot y + z \cdot t\\


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

    1. Initial program 84.8%

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

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

    if -3.39999999999999996e192 < (*.f64 x y) < 2.19999999999999992e51

    1. Initial program 98.2%

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

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

    if 2.19999999999999992e51 < (*.f64 x y)

    1. Initial program 98.0%

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

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

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

Alternative 11: 83.6% accurate, 0.5× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;x \cdot y \leq -5 \cdot 10^{+198}:\\
\;\;\;\;x \cdot \left(y + \frac{a \cdot b}{x}\right)\\

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

\mathbf{else}:\\
\;\;\;\;x \cdot y + z \cdot t\\


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

    1. Initial program 84.8%

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

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

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

    if -5.00000000000000049e198 < (*.f64 x y) < 1.99999999999999989e49

    1. Initial program 98.2%

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

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

    if 1.99999999999999989e49 < (*.f64 x y)

    1. Initial program 98.0%

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

      \[\leadsto \color{blue}{t \cdot z + x \cdot y} \]
  3. Recombined 3 regimes into one program.
  4. Final simplification88.0%

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

Alternative 12: 35.2% accurate, 3.7× speedup?

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

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

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

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

    \[\leadsto a \cdot b \]
  5. Add Preprocessing

Reproduce

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