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

Percentage Accurate: 97.8% → 98.5%
Time: 6.3s
Alternatives: 8
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 8 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: 98.5% accurate, 0.4× speedup?

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

\\
\begin{array}{l}
t_1 := x \cdot y + z \cdot t\\
t_2 := a \cdot b + t\_1\\
\mathbf{if}\;t\_2 \leq \infty:\\
\;\;\;\;t\_2\\

\mathbf{else}:\\
\;\;\;\;t\_1\\


\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 55.6%

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

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

Alternative 2: 99.1% accurate, 0.1× speedup?

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

\\
\mathsf{fma}\left(x, y, \mathsf{fma}\left(a, b, 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. associate-+l+96.5%

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

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

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

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

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

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

Alternative 3: 98.2% accurate, 0.1× speedup?

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

\\
\mathsf{fma}\left(x, y, z \cdot t\right) + a \cdot b
\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. 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. Final simplification97.2%

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

Alternative 4: 78.5% accurate, 0.3× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \cdot y \leq -5.2 \cdot 10^{+209} \lor \neg \left(x \cdot y \leq -1.2 \cdot 10^{+88} \lor \neg \left(x \cdot y \leq -9.6 \cdot 10^{+54}\right) \land x \cdot y \leq 2.1 \cdot 10^{+50}\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) -5.2e+209)
         (not
          (or (<= (* x y) -1.2e+88)
              (and (not (<= (* x y) -9.6e+54)) (<= (* x y) 2.1e+50)))))
   (* 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) <= -5.2e+209) || !(((x * y) <= -1.2e+88) || (!((x * y) <= -9.6e+54) && ((x * y) <= 2.1e+50)))) {
		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) <= (-5.2d+209)) .or. (.not. ((x * y) <= (-1.2d+88)) .or. (.not. ((x * y) <= (-9.6d+54))) .and. ((x * y) <= 2.1d+50))) 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) <= -5.2e+209) || !(((x * y) <= -1.2e+88) || (!((x * y) <= -9.6e+54) && ((x * y) <= 2.1e+50)))) {
		tmp = x * y;
	} else {
		tmp = (a * b) + (z * t);
	}
	return tmp;
}
def code(x, y, z, t, a, b):
	tmp = 0
	if ((x * y) <= -5.2e+209) or not (((x * y) <= -1.2e+88) or (not ((x * y) <= -9.6e+54) and ((x * y) <= 2.1e+50))):
		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) <= -5.2e+209) || !((Float64(x * y) <= -1.2e+88) || (!(Float64(x * y) <= -9.6e+54) && (Float64(x * y) <= 2.1e+50))))
		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) <= -5.2e+209) || ~((((x * y) <= -1.2e+88) || (~(((x * y) <= -9.6e+54)) && ((x * y) <= 2.1e+50)))))
		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], -5.2e+209], N[Not[Or[LessEqual[N[(x * y), $MachinePrecision], -1.2e+88], And[N[Not[LessEqual[N[(x * y), $MachinePrecision], -9.6e+54]], $MachinePrecision], LessEqual[N[(x * y), $MachinePrecision], 2.1e+50]]]], $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 -5.2 \cdot 10^{+209} \lor \neg \left(x \cdot y \leq -1.2 \cdot 10^{+88} \lor \neg \left(x \cdot y \leq -9.6 \cdot 10^{+54}\right) \land x \cdot y \leq 2.1 \cdot 10^{+50}\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) < -5.2000000000000001e209 or -1.2e88 < (*.f64 x y) < -9.59999999999999993e54 or 2.1e50 < (*.f64 x y)

    1. Initial program 91.1%

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

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

    if -5.2000000000000001e209 < (*.f64 x y) < -1.2e88 or -9.59999999999999993e54 < (*.f64 x y) < 2.1e50

    1. Initial program 98.9%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \cdot y \leq -5.2 \cdot 10^{+209} \lor \neg \left(x \cdot y \leq -1.2 \cdot 10^{+88} \lor \neg \left(x \cdot y \leq -9.6 \cdot 10^{+54}\right) \land x \cdot y \leq 2.1 \cdot 10^{+50}\right):\\ \;\;\;\;x \cdot y\\ \mathbf{else}:\\ \;\;\;\;a \cdot b + z \cdot t\\ \end{array} \]
  5. Add Preprocessing

Alternative 5: 84.9% accurate, 0.5× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \cdot y \leq -4 \lor \neg \left(x \cdot y \leq 860000000000\right):\\ \;\;\;\;a \cdot b + 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) -4.0) (not (<= (* x y) 860000000000.0)))
   (+ (* a b) (* 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) <= -4.0) || !((x * y) <= 860000000000.0)) {
		tmp = (a * b) + (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) <= (-4.0d0)) .or. (.not. ((x * y) <= 860000000000.0d0))) then
        tmp = (a * b) + (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) <= -4.0) || !((x * y) <= 860000000000.0)) {
		tmp = (a * b) + (x * y);
	} else {
		tmp = (a * b) + (z * t);
	}
	return tmp;
}
def code(x, y, z, t, a, b):
	tmp = 0
	if ((x * y) <= -4.0) or not ((x * y) <= 860000000000.0):
		tmp = (a * b) + (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) <= -4.0) || !(Float64(x * y) <= 860000000000.0))
		tmp = Float64(Float64(a * b) + 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) <= -4.0) || ~(((x * y) <= 860000000000.0)))
		tmp = (a * b) + (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], -4.0], N[Not[LessEqual[N[(x * y), $MachinePrecision], 860000000000.0]], $MachinePrecision]], N[(N[(a * b), $MachinePrecision] + N[(x * y), $MachinePrecision]), $MachinePrecision], N[(N[(a * b), $MachinePrecision] + N[(z * t), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;x \cdot y \leq -4 \lor \neg \left(x \cdot y \leq 860000000000\right):\\
\;\;\;\;a \cdot b + 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) < -4 or 8.6e11 < (*.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 z around 0 81.7%

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

    if -4 < (*.f64 x y) < 8.6e11

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

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

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

Alternative 6: 54.4% accurate, 0.6× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;x \cdot y \leq -3.5 \cdot 10^{+21} \lor \neg \left(x \cdot y \leq 500000000000\right):\\
\;\;\;\;x \cdot y\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (*.f64 x y) < -3.5e21 or 5e11 < (*.f64 x y)

    1. Initial program 93.9%

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

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

    if -3.5e21 < (*.f64 x y) < 5e11

    1. Initial program 98.6%

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

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

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

Alternative 7: 47.1% accurate, 0.8× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;t \leq -6.8 \cdot 10^{-76} \lor \neg \left(t \leq 1.6 \cdot 10^{+143}\right):\\
\;\;\;\;z \cdot t\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if t < -6.7999999999999998e-76 or 1.60000000000000008e143 < t

    1. Initial program 92.5%

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

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

    if -6.7999999999999998e-76 < t < 1.60000000000000008e143

    1. Initial program 99.3%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;t \leq -6.8 \cdot 10^{-76} \lor \neg \left(t \leq 1.6 \cdot 10^{+143}\right):\\ \;\;\;\;z \cdot t\\ \mathbf{else}:\\ \;\;\;\;a \cdot b\\ \end{array} \]
  5. Add Preprocessing

Alternative 8: 35.3% 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 35.6%

    \[\leadsto \color{blue}{a \cdot b} \]
  4. Final simplification35.6%

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

Reproduce

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