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

Percentage Accurate: 97.7% → 98.9%
Time: 4.8s
Alternatives: 8
Speedup: 1.0×

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.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: 98.9% 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 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-def98.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-def98.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. Final simplification98.8%

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

Alternative 2: 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 98.0%

    \[\left(x \cdot y + z \cdot t\right) + a \cdot b \]
  2. Step-by-step derivation
    1. fma-def98.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. Final simplification98.4%

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

Alternative 3: 54.3% accurate, 0.4× speedup?

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

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

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

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

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

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if (*.f64 a b) < -8.19999999999999959e99 or 2.80000000000000015e54 < (*.f64 a b)

    1. Initial program 97.9%

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

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

    if -8.19999999999999959e99 < (*.f64 a b) < -2.2999999999999999e-101 or -9.50000000000000019e-157 < (*.f64 a b) < 1.29999999999999989e-184 or 3.09999999999999987e-149 < (*.f64 a b) < 2.80000000000000015e54

    1. Initial program 98.5%

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

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

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

    if -2.2999999999999999e-101 < (*.f64 a b) < -9.50000000000000019e-157 or 1.29999999999999989e-184 < (*.f64 a b) < 3.09999999999999987e-149

    1. Initial program 95.5%

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;a \cdot b \leq -8.2 \cdot 10^{+99}:\\ \;\;\;\;a \cdot b\\ \mathbf{elif}\;a \cdot b \leq -2.3 \cdot 10^{-101}:\\ \;\;\;\;z \cdot t\\ \mathbf{elif}\;a \cdot b \leq -9.5 \cdot 10^{-157}:\\ \;\;\;\;x \cdot y\\ \mathbf{elif}\;a \cdot b \leq 1.3 \cdot 10^{-184}:\\ \;\;\;\;z \cdot t\\ \mathbf{elif}\;a \cdot b \leq 3.1 \cdot 10^{-149}:\\ \;\;\;\;x \cdot y\\ \mathbf{elif}\;a \cdot b \leq 2.8 \cdot 10^{+54}:\\ \;\;\;\;z \cdot t\\ \mathbf{else}:\\ \;\;\;\;a \cdot b\\ \end{array} \]

Alternative 4: 80.0% accurate, 0.7× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \cdot y \leq -2.05 \cdot 10^{+183} \lor \neg \left(x \cdot y \leq 2.4 \cdot 10^{+147}\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) -2.05e+183) (not (<= (* x y) 2.4e+147)))
   (* 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) <= -2.05e+183) || !((x * y) <= 2.4e+147)) {
		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) <= (-2.05d+183)) .or. (.not. ((x * y) <= 2.4d+147))) 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) <= -2.05e+183) || !((x * y) <= 2.4e+147)) {
		tmp = x * y;
	} else {
		tmp = (a * b) + (z * t);
	}
	return tmp;
}
def code(x, y, z, t, a, b):
	tmp = 0
	if ((x * y) <= -2.05e+183) or not ((x * y) <= 2.4e+147):
		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) <= -2.05e+183) || !(Float64(x * y) <= 2.4e+147))
		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) <= -2.05e+183) || ~(((x * y) <= 2.4e+147)))
		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], -2.05e+183], N[Not[LessEqual[N[(x * y), $MachinePrecision], 2.4e+147]], $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 -2.05 \cdot 10^{+183} \lor \neg \left(x \cdot y \leq 2.4 \cdot 10^{+147}\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) < -2.05000000000000007e183 or 2.40000000000000002e147 < (*.f64 x y)

    1. Initial program 93.0%

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

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

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

    if -2.05000000000000007e183 < (*.f64 x y) < 2.40000000000000002e147

    1. Initial program 99.5%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \cdot y \leq -2.05 \cdot 10^{+183} \lor \neg \left(x \cdot y \leq 2.4 \cdot 10^{+147}\right):\\ \;\;\;\;x \cdot y\\ \mathbf{else}:\\ \;\;\;\;a \cdot b + z \cdot t\\ \end{array} \]

Alternative 5: 84.6% accurate, 0.7× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \cdot y \leq -8 \cdot 10^{+111} \lor \neg \left(x \cdot y \leq 2.9 \cdot 10^{+89}\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) -8e+111) (not (<= (* x y) 2.9e+89)))
   (+ (* 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) <= -8e+111) || !((x * y) <= 2.9e+89)) {
		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) <= (-8d+111)) .or. (.not. ((x * y) <= 2.9d+89))) 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) <= -8e+111) || !((x * y) <= 2.9e+89)) {
		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) <= -8e+111) or not ((x * y) <= 2.9e+89):
		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) <= -8e+111) || !(Float64(x * y) <= 2.9e+89))
		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) <= -8e+111) || ~(((x * y) <= 2.9e+89)))
		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], -8e+111], N[Not[LessEqual[N[(x * y), $MachinePrecision], 2.9e+89]], $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 -8 \cdot 10^{+111} \lor \neg \left(x \cdot y \leq 2.9 \cdot 10^{+89}\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) < -7.99999999999999965e111 or 2.90000000000000025e89 < (*.f64 x y)

    1. Initial program 95.0%

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

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

    if -7.99999999999999965e111 < (*.f64 x y) < 2.90000000000000025e89

    1. Initial program 99.4%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \cdot y \leq -8 \cdot 10^{+111} \lor \neg \left(x \cdot y \leq 2.9 \cdot 10^{+89}\right):\\ \;\;\;\;a \cdot b + x \cdot y\\ \mathbf{else}:\\ \;\;\;\;a \cdot b + z \cdot t\\ \end{array} \]

Alternative 6: 53.8% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;a \cdot b \leq -1.1 \cdot 10^{+100} \lor \neg \left(a \cdot b \leq 3.6 \cdot 10^{+54}\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) -1.1e+100) (not (<= (* a b) 3.6e+54))) (* a b) (* z t)))
double code(double x, double y, double z, double t, double a, double b) {
	double tmp;
	if (((a * b) <= -1.1e+100) || !((a * b) <= 3.6e+54)) {
		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) <= (-1.1d+100)) .or. (.not. ((a * b) <= 3.6d+54))) 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) <= -1.1e+100) || !((a * b) <= 3.6e+54)) {
		tmp = a * b;
	} else {
		tmp = z * t;
	}
	return tmp;
}
def code(x, y, z, t, a, b):
	tmp = 0
	if ((a * b) <= -1.1e+100) or not ((a * b) <= 3.6e+54):
		tmp = a * b
	else:
		tmp = z * t
	return tmp
function code(x, y, z, t, a, b)
	tmp = 0.0
	if ((Float64(a * b) <= -1.1e+100) || !(Float64(a * b) <= 3.6e+54))
		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) <= -1.1e+100) || ~(((a * b) <= 3.6e+54)))
		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], -1.1e+100], N[Not[LessEqual[N[(a * b), $MachinePrecision], 3.6e+54]], $MachinePrecision]], N[(a * b), $MachinePrecision], N[(z * t), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;a \cdot b \leq -1.1 \cdot 10^{+100} \lor \neg \left(a \cdot b \leq 3.6 \cdot 10^{+54}\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) < -1.1e100 or 3.6000000000000001e54 < (*.f64 a b)

    1. Initial program 97.9%

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

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

    if -1.1e100 < (*.f64 a b) < 3.6000000000000001e54

    1. Initial program 98.1%

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;a \cdot b \leq -1.1 \cdot 10^{+100} \lor \neg \left(a \cdot b \leq 3.6 \cdot 10^{+54}\right):\\ \;\;\;\;a \cdot b\\ \mathbf{else}:\\ \;\;\;\;z \cdot t\\ \end{array} \]

Alternative 7: 97.7% accurate, 1.0× speedup?

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

\\
a \cdot b + \left(x \cdot y + z \cdot t\right)
\end{array}
Derivation
  1. Initial program 98.0%

    \[\left(x \cdot y + z \cdot t\right) + a \cdot b \]
  2. Final simplification98.0%

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

Alternative 8: 36.0% 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 98.0%

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

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

    \[\leadsto a \cdot b \]

Reproduce

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