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

Percentage Accurate: 97.7% → 97.7%
Time: 4.6s
Alternatives: 6
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 6 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: 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}
Derivation
  1. Initial program 98.4%

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

Alternative 2: 85.8% accurate, 0.6× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;z \cdot t \leq -1 \cdot 10^{+68} \lor \neg \left(z \cdot t \leq 2 \cdot 10^{-24}\right):\\ \;\;\;\;\mathsf{fma}\left(b, a, t \cdot z\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(b, a, y \cdot x\right)\\ \end{array} \end{array} \]
(FPCore (x y z t a b)
 :precision binary64
 (if (or (<= (* z t) -1e+68) (not (<= (* z t) 2e-24)))
   (fma b a (* t z))
   (fma b a (* y x))))
double code(double x, double y, double z, double t, double a, double b) {
	double tmp;
	if (((z * t) <= -1e+68) || !((z * t) <= 2e-24)) {
		tmp = fma(b, a, (t * z));
	} else {
		tmp = fma(b, a, (y * x));
	}
	return tmp;
}
function code(x, y, z, t, a, b)
	tmp = 0.0
	if ((Float64(z * t) <= -1e+68) || !(Float64(z * t) <= 2e-24))
		tmp = fma(b, a, Float64(t * z));
	else
		tmp = fma(b, a, Float64(y * x));
	end
	return tmp
end
code[x_, y_, z_, t_, a_, b_] := If[Or[LessEqual[N[(z * t), $MachinePrecision], -1e+68], N[Not[LessEqual[N[(z * t), $MachinePrecision], 2e-24]], $MachinePrecision]], N[(b * a + N[(t * z), $MachinePrecision]), $MachinePrecision], N[(b * a + N[(y * x), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;z \cdot t \leq -1 \cdot 10^{+68} \lor \neg \left(z \cdot t \leq 2 \cdot 10^{-24}\right):\\
\;\;\;\;\mathsf{fma}\left(b, a, t \cdot z\right)\\

\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(b, a, y \cdot x\right)\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (*.f64 z t) < -9.99999999999999953e67 or 1.99999999999999985e-24 < (*.f64 z t)

    1. Initial program 97.5%

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

      \[\leadsto \color{blue}{a \cdot b + t \cdot z} \]
    4. Step-by-step derivation
      1. *-commutativeN/A

        \[\leadsto \color{blue}{b \cdot a} + t \cdot z \]
      2. lower-fma.f64N/A

        \[\leadsto \color{blue}{\mathsf{fma}\left(b, a, t \cdot z\right)} \]
      3. lower-*.f6490.2

        \[\leadsto \mathsf{fma}\left(b, a, \color{blue}{t \cdot z}\right) \]
    5. Applied rewrites90.2%

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

    if -9.99999999999999953e67 < (*.f64 z t) < 1.99999999999999985e-24

    1. Initial program 99.3%

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

      \[\leadsto \color{blue}{a \cdot b + x \cdot y} \]
    4. Step-by-step derivation
      1. *-commutativeN/A

        \[\leadsto \color{blue}{b \cdot a} + x \cdot y \]
      2. lower-fma.f64N/A

        \[\leadsto \color{blue}{\mathsf{fma}\left(b, a, x \cdot y\right)} \]
      3. *-commutativeN/A

        \[\leadsto \mathsf{fma}\left(b, a, \color{blue}{y \cdot x}\right) \]
      4. lower-*.f6488.8

        \[\leadsto \mathsf{fma}\left(b, a, \color{blue}{y \cdot x}\right) \]
    5. Applied rewrites88.8%

      \[\leadsto \color{blue}{\mathsf{fma}\left(b, a, y \cdot x\right)} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification89.5%

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

Alternative 3: 80.3% accurate, 0.6× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \cdot y \leq -5 \cdot 10^{+122} \lor \neg \left(x \cdot y \leq 10^{+47}\right):\\ \;\;\;\;y \cdot x\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(b, a, t \cdot z\right)\\ \end{array} \end{array} \]
(FPCore (x y z t a b)
 :precision binary64
 (if (or (<= (* x y) -5e+122) (not (<= (* x y) 1e+47)))
   (* y x)
   (fma b a (* t z))))
double code(double x, double y, double z, double t, double a, double b) {
	double tmp;
	if (((x * y) <= -5e+122) || !((x * y) <= 1e+47)) {
		tmp = y * x;
	} else {
		tmp = fma(b, a, (t * z));
	}
	return tmp;
}
function code(x, y, z, t, a, b)
	tmp = 0.0
	if ((Float64(x * y) <= -5e+122) || !(Float64(x * y) <= 1e+47))
		tmp = Float64(y * x);
	else
		tmp = fma(b, a, Float64(t * z));
	end
	return tmp
end
code[x_, y_, z_, t_, a_, b_] := If[Or[LessEqual[N[(x * y), $MachinePrecision], -5e+122], N[Not[LessEqual[N[(x * y), $MachinePrecision], 1e+47]], $MachinePrecision]], N[(y * x), $MachinePrecision], N[(b * a + N[(t * z), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

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

\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(b, a, t \cdot z\right)\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (*.f64 x y) < -4.99999999999999989e122 or 1e47 < (*.f64 x y)

    1. Initial program 97.6%

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

      \[\leadsto \color{blue}{a \cdot b + x \cdot y} \]
    4. Step-by-step derivation
      1. *-commutativeN/A

        \[\leadsto \color{blue}{b \cdot a} + x \cdot y \]
      2. lower-fma.f64N/A

        \[\leadsto \color{blue}{\mathsf{fma}\left(b, a, x \cdot y\right)} \]
      3. *-commutativeN/A

        \[\leadsto \mathsf{fma}\left(b, a, \color{blue}{y \cdot x}\right) \]
      4. lower-*.f6483.2

        \[\leadsto \mathsf{fma}\left(b, a, \color{blue}{y \cdot x}\right) \]
    5. Applied rewrites83.2%

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

      \[\leadsto a \cdot \color{blue}{b} \]
    7. Step-by-step derivation
      1. Applied rewrites11.1%

        \[\leadsto b \cdot \color{blue}{a} \]
      2. Taylor expanded in x around inf

        \[\leadsto \color{blue}{x \cdot y} \]
      3. Step-by-step derivation
        1. *-commutativeN/A

          \[\leadsto \color{blue}{y \cdot x} \]
        2. lower-*.f6473.9

          \[\leadsto \color{blue}{y \cdot x} \]
      4. Applied rewrites73.9%

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

      if -4.99999999999999989e122 < (*.f64 x y) < 1e47

      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

        \[\leadsto \color{blue}{a \cdot b + t \cdot z} \]
      4. Step-by-step derivation
        1. *-commutativeN/A

          \[\leadsto \color{blue}{b \cdot a} + t \cdot z \]
        2. lower-fma.f64N/A

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

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

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

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

    Alternative 4: 54.1% accurate, 0.8× speedup?

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

      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 0

        \[\leadsto \color{blue}{a \cdot b + x \cdot y} \]
      4. Step-by-step derivation
        1. *-commutativeN/A

          \[\leadsto \color{blue}{b \cdot a} + x \cdot y \]
        2. lower-fma.f64N/A

          \[\leadsto \color{blue}{\mathsf{fma}\left(b, a, x \cdot y\right)} \]
        3. *-commutativeN/A

          \[\leadsto \mathsf{fma}\left(b, a, \color{blue}{y \cdot x}\right) \]
        4. lower-*.f6428.0

          \[\leadsto \mathsf{fma}\left(b, a, \color{blue}{y \cdot x}\right) \]
      5. Applied rewrites28.0%

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

        \[\leadsto a \cdot \color{blue}{b} \]
      7. Step-by-step derivation
        1. Applied rewrites17.4%

          \[\leadsto b \cdot \color{blue}{a} \]
        2. Taylor expanded in z around inf

          \[\leadsto \color{blue}{t \cdot z} \]
        3. Step-by-step derivation
          1. lower-*.f6474.6

            \[\leadsto \color{blue}{t \cdot z} \]
        4. Applied rewrites74.6%

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

        if -9.99999999999999953e67 < (*.f64 z t) < 1.99999999999999985e-24

        1. Initial program 99.3%

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

          \[\leadsto \color{blue}{a \cdot b + x \cdot y} \]
        4. Step-by-step derivation
          1. *-commutativeN/A

            \[\leadsto \color{blue}{b \cdot a} + x \cdot y \]
          2. lower-fma.f64N/A

            \[\leadsto \color{blue}{\mathsf{fma}\left(b, a, x \cdot y\right)} \]
          3. *-commutativeN/A

            \[\leadsto \mathsf{fma}\left(b, a, \color{blue}{y \cdot x}\right) \]
          4. lower-*.f6488.8

            \[\leadsto \mathsf{fma}\left(b, a, \color{blue}{y \cdot x}\right) \]
        5. Applied rewrites88.8%

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

          \[\leadsto a \cdot \color{blue}{b} \]
        7. Step-by-step derivation
          1. Applied rewrites36.3%

            \[\leadsto b \cdot \color{blue}{a} \]
          2. Taylor expanded in x around inf

            \[\leadsto \color{blue}{x \cdot y} \]
          3. Step-by-step derivation
            1. *-commutativeN/A

              \[\leadsto \color{blue}{y \cdot x} \]
            2. lower-*.f6455.1

              \[\leadsto \color{blue}{y \cdot x} \]
          4. Applied rewrites55.1%

            \[\leadsto \color{blue}{y \cdot x} \]
        8. Recombined 2 regimes into one program.
        9. Final simplification64.3%

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

        Alternative 5: 54.2% accurate, 0.8× speedup?

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

          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 0

            \[\leadsto \color{blue}{a \cdot b + x \cdot y} \]
          4. Step-by-step derivation
            1. *-commutativeN/A

              \[\leadsto \color{blue}{b \cdot a} + x \cdot y \]
            2. lower-fma.f64N/A

              \[\leadsto \color{blue}{\mathsf{fma}\left(b, a, x \cdot y\right)} \]
            3. *-commutativeN/A

              \[\leadsto \mathsf{fma}\left(b, a, \color{blue}{y \cdot x}\right) \]
            4. lower-*.f6430.4

              \[\leadsto \mathsf{fma}\left(b, a, \color{blue}{y \cdot x}\right) \]
          5. Applied rewrites30.4%

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

            \[\leadsto a \cdot \color{blue}{b} \]
          7. Step-by-step derivation
            1. Applied rewrites12.6%

              \[\leadsto b \cdot \color{blue}{a} \]
            2. Taylor expanded in z around inf

              \[\leadsto \color{blue}{t \cdot z} \]
            3. Step-by-step derivation
              1. lower-*.f6472.4

                \[\leadsto \color{blue}{t \cdot z} \]
            4. Applied rewrites72.4%

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

            if -4.9999999999999998e-39 < (*.f64 z t) < 1.00000000000000004e93

            1. Initial program 99.3%

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

              \[\leadsto \color{blue}{a \cdot b + x \cdot y} \]
            4. Step-by-step derivation
              1. *-commutativeN/A

                \[\leadsto \color{blue}{b \cdot a} + x \cdot y \]
              2. lower-fma.f64N/A

                \[\leadsto \color{blue}{\mathsf{fma}\left(b, a, x \cdot y\right)} \]
              3. *-commutativeN/A

                \[\leadsto \mathsf{fma}\left(b, a, \color{blue}{y \cdot x}\right) \]
              4. lower-*.f6486.6

                \[\leadsto \mathsf{fma}\left(b, a, \color{blue}{y \cdot x}\right) \]
            5. Applied rewrites86.6%

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

              \[\leadsto a \cdot \color{blue}{b} \]
            7. Step-by-step derivation
              1. Applied rewrites40.6%

                \[\leadsto b \cdot \color{blue}{a} \]
            8. Recombined 2 regimes into one program.
            9. Final simplification55.6%

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

            Alternative 6: 35.6% accurate, 3.7× speedup?

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

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

              \[\leadsto \color{blue}{a \cdot b + x \cdot y} \]
            4. Step-by-step derivation
              1. *-commutativeN/A

                \[\leadsto \color{blue}{b \cdot a} + x \cdot y \]
              2. lower-fma.f64N/A

                \[\leadsto \color{blue}{\mathsf{fma}\left(b, a, x \cdot y\right)} \]
              3. *-commutativeN/A

                \[\leadsto \mathsf{fma}\left(b, a, \color{blue}{y \cdot x}\right) \]
              4. lower-*.f6460.1

                \[\leadsto \mathsf{fma}\left(b, a, \color{blue}{y \cdot x}\right) \]
            5. Applied rewrites60.1%

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

              \[\leadsto a \cdot \color{blue}{b} \]
            7. Step-by-step derivation
              1. Applied rewrites27.4%

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

              Reproduce

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