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

Percentage Accurate: 97.5% → 99.0%
Time: 6.7s
Alternatives: 12
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 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.5% 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.0% accurate, 0.1× speedup?

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

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

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

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

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

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

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

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

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

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

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

      \[\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 3: 98.7% accurate, 0.1× speedup?

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

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

\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(b, a, z \cdot t\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 \]

    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. Taylor expanded in x around 0 42.9%

      \[\leadsto \color{blue}{t \cdot z} + a \cdot b \]
    3. Step-by-step derivation
      1. +-commutative42.9%

        \[\leadsto \color{blue}{a \cdot b + t \cdot z} \]
      2. *-commutative42.9%

        \[\leadsto \color{blue}{b \cdot a} + t \cdot z \]
      3. fma-def57.1%

        \[\leadsto \color{blue}{\mathsf{fma}\left(b, a, t \cdot z\right)} \]
      4. *-commutative57.1%

        \[\leadsto \mathsf{fma}\left(b, a, \color{blue}{z \cdot t}\right) \]
    4. Applied egg-rr57.1%

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

    \[\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}:\\ \;\;\;\;\mathsf{fma}\left(b, a, z \cdot t\right)\\ \end{array} \]

Alternative 4: 97.9% accurate, 0.1× speedup?

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

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

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

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

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

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

Alternative 5: 98.5% accurate, 0.1× speedup?

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

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

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

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

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

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

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

    \[\leadsto \color{blue}{\mathsf{fma}\left(z, t, \mathsf{fma}\left(x, y, a \cdot b\right)\right)} \]
  4. Step-by-step derivation
    1. fma-udef98.4%

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

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

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

Alternative 6: 54.7% accurate, 0.5× speedup?

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

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

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

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

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if (*.f64 x y) < -1.8500000000000001e83 or 5.80000000000000023e68 < (*.f64 x y)

    1. Initial program 94.8%

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

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

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

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

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

      \[\leadsto \color{blue}{\mathsf{fma}\left(z, t, \mathsf{fma}\left(x, y, a \cdot b\right)\right)} \]
    4. Step-by-step derivation
      1. fma-udef96.5%

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

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

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

    if -1.8500000000000001e83 < (*.f64 x y) < 2.50000000000000017e-302 or 1.34999999999999997e-275 < (*.f64 x y) < 5.7e-84

    1. Initial program 99.1%

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

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

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

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

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

      \[\leadsto \color{blue}{\mathsf{fma}\left(z, t, \mathsf{fma}\left(x, y, a \cdot b\right)\right)} \]
    4. Step-by-step derivation
      1. fma-udef100.0%

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

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

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

    if 2.50000000000000017e-302 < (*.f64 x y) < 1.34999999999999997e-275 or 5.7e-84 < (*.f64 x y) < 5.80000000000000023e68

    1. Initial program 99.9%

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \cdot y \leq -1.85 \cdot 10^{+83}:\\ \;\;\;\;x \cdot y\\ \mathbf{elif}\;x \cdot y \leq 2.5 \cdot 10^{-302}:\\ \;\;\;\;z \cdot t\\ \mathbf{elif}\;x \cdot y \leq 1.35 \cdot 10^{-275}:\\ \;\;\;\;a \cdot b\\ \mathbf{elif}\;x \cdot y \leq 5.7 \cdot 10^{-84}:\\ \;\;\;\;z \cdot t\\ \mathbf{elif}\;x \cdot y \leq 5.8 \cdot 10^{+68}:\\ \;\;\;\;a \cdot b\\ \mathbf{else}:\\ \;\;\;\;x \cdot y\\ \end{array} \]

Alternative 7: 80.7% accurate, 0.7× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \cdot y \leq -4.4 \cdot 10^{+170} \lor \neg \left(x \cdot y \leq 1.4 \cdot 10^{+173}\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) -4.4e+170) (not (<= (* x y) 1.4e+173)))
   (* 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.4e+170) || !((x * y) <= 1.4e+173)) {
		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) <= (-4.4d+170)) .or. (.not. ((x * y) <= 1.4d+173))) 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) <= -4.4e+170) || !((x * y) <= 1.4e+173)) {
		tmp = x * y;
	} else {
		tmp = (a * b) + (z * t);
	}
	return tmp;
}
def code(x, y, z, t, a, b):
	tmp = 0
	if ((x * y) <= -4.4e+170) or not ((x * y) <= 1.4e+173):
		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) <= -4.4e+170) || !(Float64(x * y) <= 1.4e+173))
		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) <= -4.4e+170) || ~(((x * y) <= 1.4e+173)))
		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], -4.4e+170], N[Not[LessEqual[N[(x * y), $MachinePrecision], 1.4e+173]], $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 -4.4 \cdot 10^{+170} \lor \neg \left(x \cdot y \leq 1.4 \cdot 10^{+173}\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) < -4.39999999999999978e170 or 1.39999999999999991e173 < (*.f64 x y)

    1. Initial program 93.6%

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

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

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

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

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

      \[\leadsto \color{blue}{\mathsf{fma}\left(z, t, \mathsf{fma}\left(x, y, a \cdot b\right)\right)} \]
    4. Step-by-step derivation
      1. fma-udef96.2%

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

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

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

    if -4.39999999999999978e170 < (*.f64 x y) < 1.39999999999999991e173

    1. Initial program 98.8%

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

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

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

Alternative 8: 85.1% accurate, 0.7× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;x \cdot y \leq -2.2 \cdot 10^{+48} \lor \neg \left(x \cdot y \leq 4.5 \cdot 10^{+62}\right):\\
\;\;\;\;x \cdot y + z \cdot t\\

\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.1999999999999999e48 or 4.49999999999999999e62 < (*.f64 x y)

    1. Initial program 95.1%

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

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

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

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

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

      \[\leadsto \color{blue}{\mathsf{fma}\left(z, t, \mathsf{fma}\left(x, y, a \cdot b\right)\right)} \]
    4. Step-by-step derivation
      1. fma-udef96.7%

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

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

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

    if -2.1999999999999999e48 < (*.f64 x y) < 4.49999999999999999e62

    1. Initial program 99.2%

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

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

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

Alternative 9: 82.3% accurate, 0.7× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;a \cdot b \leq -1.65 \cdot 10^{+177} \lor \neg \left(a \cdot b \leq 1.12 \cdot 10^{+142}\right):\\
\;\;\;\;a \cdot b + x \cdot y\\

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


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

    1. Initial program 92.6%

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

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

    if -1.6500000000000001e177 < (*.f64 a b) < 1.11999999999999996e142

    1. Initial program 98.9%

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

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

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

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

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

      \[\leadsto \color{blue}{\mathsf{fma}\left(z, t, \mathsf{fma}\left(x, y, a \cdot b\right)\right)} \]
    4. Step-by-step derivation
      1. fma-udef99.5%

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

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

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

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

Alternative 10: 53.0% accurate, 1.0× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;a \cdot b \leq -1.5 \cdot 10^{+154} \lor \neg \left(a \cdot b \leq 3.4 \cdot 10^{+101}\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.50000000000000013e154 or 3.40000000000000017e101 < (*.f64 a b)

    1. Initial program 93.5%

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

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

    if -1.50000000000000013e154 < (*.f64 a b) < 3.40000000000000017e101

    1. Initial program 98.9%

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

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

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

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

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

      \[\leadsto \color{blue}{\mathsf{fma}\left(z, t, \mathsf{fma}\left(x, y, a \cdot b\right)\right)} \]
    4. Step-by-step derivation
      1. fma-udef99.4%

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;a \cdot b \leq -1.5 \cdot 10^{+154} \lor \neg \left(a \cdot b \leq 3.4 \cdot 10^{+101}\right):\\ \;\;\;\;a \cdot b\\ \mathbf{else}:\\ \;\;\;\;z \cdot t\\ \end{array} \]

Alternative 11: 97.5% 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 97.2%

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

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

Alternative 12: 35.9% 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 97.2%

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

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

    \[\leadsto a \cdot b \]

Reproduce

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