Linear.V4:$cdot from linear-1.19.1.3, C

Percentage Accurate: 96.3% → 98.0%
Time: 4.1s
Alternatives: 12
Speedup: 0.5×

Specification

?
\[\begin{array}{l} \\ \left(\left(x \cdot y + z \cdot t\right) + a \cdot b\right) + c \cdot i \end{array} \]
(FPCore (x y z t a b c i)
 :precision binary64
 (+ (+ (+ (* x y) (* z t)) (* a b)) (* c i)))
double code(double x, double y, double z, double t, double a, double b, double c, double i) {
	return (((x * y) + (z * t)) + (a * b)) + (c * i);
}
module fmin_fmax_functions
    implicit none
    private
    public fmax
    public fmin

    interface fmax
        module procedure fmax88
        module procedure fmax44
        module procedure fmax84
        module procedure fmax48
    end interface
    interface fmin
        module procedure fmin88
        module procedure fmin44
        module procedure fmin84
        module procedure fmin48
    end interface
contains
    real(8) function fmax88(x, y) result (res)
        real(8), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
    end function
    real(4) function fmax44(x, y) result (res)
        real(4), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
    end function
    real(8) function fmax84(x, y) result(res)
        real(8), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
    end function
    real(8) function fmax48(x, y) result(res)
        real(4), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
    end function
    real(8) function fmin88(x, y) result (res)
        real(8), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
    end function
    real(4) function fmin44(x, y) result (res)
        real(4), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
    end function
    real(8) function fmin84(x, y) result(res)
        real(8), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
    end function
    real(8) function fmin48(x, y) result(res)
        real(4), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
    end function
end module

real(8) function code(x, y, z, t, a, b, c, i)
use fmin_fmax_functions
    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), intent (in) :: c
    real(8), intent (in) :: i
    code = (((x * y) + (z * t)) + (a * b)) + (c * i)
end function
public static double code(double x, double y, double z, double t, double a, double b, double c, double i) {
	return (((x * y) + (z * t)) + (a * b)) + (c * i);
}
def code(x, y, z, t, a, b, c, i):
	return (((x * y) + (z * t)) + (a * b)) + (c * i)
function code(x, y, z, t, a, b, c, i)
	return Float64(Float64(Float64(Float64(x * y) + Float64(z * t)) + Float64(a * b)) + Float64(c * i))
end
function tmp = code(x, y, z, t, a, b, c, i)
	tmp = (((x * y) + (z * t)) + (a * b)) + (c * i);
end
code[x_, y_, z_, t_, a_, b_, c_, i_] := N[(N[(N[(N[(x * y), $MachinePrecision] + N[(z * t), $MachinePrecision]), $MachinePrecision] + N[(a * b), $MachinePrecision]), $MachinePrecision] + N[(c * i), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
\left(\left(x \cdot y + z \cdot t\right) + a \cdot b\right) + c \cdot i
\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: 96.3% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \left(\left(x \cdot y + z \cdot t\right) + a \cdot b\right) + c \cdot i \end{array} \]
(FPCore (x y z t a b c i)
 :precision binary64
 (+ (+ (+ (* x y) (* z t)) (* a b)) (* c i)))
double code(double x, double y, double z, double t, double a, double b, double c, double i) {
	return (((x * y) + (z * t)) + (a * b)) + (c * i);
}
module fmin_fmax_functions
    implicit none
    private
    public fmax
    public fmin

    interface fmax
        module procedure fmax88
        module procedure fmax44
        module procedure fmax84
        module procedure fmax48
    end interface
    interface fmin
        module procedure fmin88
        module procedure fmin44
        module procedure fmin84
        module procedure fmin48
    end interface
contains
    real(8) function fmax88(x, y) result (res)
        real(8), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
    end function
    real(4) function fmax44(x, y) result (res)
        real(4), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
    end function
    real(8) function fmax84(x, y) result(res)
        real(8), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
    end function
    real(8) function fmax48(x, y) result(res)
        real(4), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
    end function
    real(8) function fmin88(x, y) result (res)
        real(8), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
    end function
    real(4) function fmin44(x, y) result (res)
        real(4), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
    end function
    real(8) function fmin84(x, y) result(res)
        real(8), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
    end function
    real(8) function fmin48(x, y) result(res)
        real(4), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
    end function
end module

real(8) function code(x, y, z, t, a, b, c, i)
use fmin_fmax_functions
    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), intent (in) :: c
    real(8), intent (in) :: i
    code = (((x * y) + (z * t)) + (a * b)) + (c * i)
end function
public static double code(double x, double y, double z, double t, double a, double b, double c, double i) {
	return (((x * y) + (z * t)) + (a * b)) + (c * i);
}
def code(x, y, z, t, a, b, c, i):
	return (((x * y) + (z * t)) + (a * b)) + (c * i)
function code(x, y, z, t, a, b, c, i)
	return Float64(Float64(Float64(Float64(x * y) + Float64(z * t)) + Float64(a * b)) + Float64(c * i))
end
function tmp = code(x, y, z, t, a, b, c, i)
	tmp = (((x * y) + (z * t)) + (a * b)) + (c * i);
end
code[x_, y_, z_, t_, a_, b_, c_, i_] := N[(N[(N[(N[(x * y), $MachinePrecision] + N[(z * t), $MachinePrecision]), $MachinePrecision] + N[(a * b), $MachinePrecision]), $MachinePrecision] + N[(c * i), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
\left(\left(x \cdot y + z \cdot t\right) + a \cdot b\right) + c \cdot i
\end{array}

Alternative 1: 98.0% accurate, 0.5× speedup?

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (+.f64 (+.f64 (+.f64 (*.f64 x y) (*.f64 z t)) (*.f64 a b)) (*.f64 c i)) < +inf.0

    1. Initial program 100.0%

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

    if +inf.0 < (+.f64 (+.f64 (+.f64 (*.f64 x y) (*.f64 z t)) (*.f64 a b)) (*.f64 c i))

    1. Initial program 0.0%

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

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

        \[\leadsto b \cdot a + \left(\color{blue}{c \cdot i} + t \cdot z\right) \]
      2. lower-fma.f64N/A

        \[\leadsto \mathsf{fma}\left(b, \color{blue}{a}, c \cdot i + t \cdot z\right) \]
      3. *-commutativeN/A

        \[\leadsto \mathsf{fma}\left(b, a, i \cdot c + t \cdot z\right) \]
      4. lower-fma.f64N/A

        \[\leadsto \mathsf{fma}\left(b, a, \mathsf{fma}\left(i, c, t \cdot z\right)\right) \]
      5. lower-*.f6475.0

        \[\leadsto \mathsf{fma}\left(b, a, \mathsf{fma}\left(i, c, t \cdot z\right)\right) \]
    5. Applied rewrites75.0%

      \[\leadsto \color{blue}{\mathsf{fma}\left(b, a, \mathsf{fma}\left(i, c, t \cdot z\right)\right)} \]
    6. Step-by-step derivation
      1. lift-*.f64N/A

        \[\leadsto \mathsf{fma}\left(b, a, \mathsf{fma}\left(i, c, t \cdot z\right)\right) \]
      2. lift-fma.f64N/A

        \[\leadsto \mathsf{fma}\left(b, a, i \cdot c + t \cdot z\right) \]
      3. +-commutativeN/A

        \[\leadsto \mathsf{fma}\left(b, a, t \cdot z + i \cdot c\right) \]
      4. *-commutativeN/A

        \[\leadsto \mathsf{fma}\left(b, a, t \cdot z + c \cdot i\right) \]
      5. *-commutativeN/A

        \[\leadsto \mathsf{fma}\left(b, a, z \cdot t + c \cdot i\right) \]
      6. lower-fma.f64N/A

        \[\leadsto \mathsf{fma}\left(b, a, \mathsf{fma}\left(z, t, c \cdot i\right)\right) \]
      7. *-commutativeN/A

        \[\leadsto \mathsf{fma}\left(b, a, \mathsf{fma}\left(z, t, i \cdot c\right)\right) \]
      8. lower-*.f6483.3

        \[\leadsto \mathsf{fma}\left(b, a, \mathsf{fma}\left(z, t, i \cdot c\right)\right) \]
    7. Applied rewrites83.3%

      \[\leadsto \mathsf{fma}\left(b, a, \mathsf{fma}\left(z, t, i \cdot c\right)\right) \]
  3. Recombined 2 regimes into one program.
  4. Add Preprocessing

Alternative 2: 43.3% accurate, 0.6× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \cdot y \leq -5 \cdot 10^{+36}:\\ \;\;\;\;y \cdot x\\ \mathbf{elif}\;x \cdot y \leq 5 \cdot 10^{-133}:\\ \;\;\;\;i \cdot c\\ \mathbf{elif}\;x \cdot y \leq 2 \cdot 10^{-54}:\\ \;\;\;\;t \cdot z\\ \mathbf{elif}\;x \cdot y \leq 10^{+92}:\\ \;\;\;\;b \cdot a\\ \mathbf{else}:\\ \;\;\;\;y \cdot x\\ \end{array} \end{array} \]
(FPCore (x y z t a b c i)
 :precision binary64
 (if (<= (* x y) -5e+36)
   (* y x)
   (if (<= (* x y) 5e-133)
     (* i c)
     (if (<= (* x y) 2e-54) (* t z) (if (<= (* x y) 1e+92) (* b a) (* y x))))))
double code(double x, double y, double z, double t, double a, double b, double c, double i) {
	double tmp;
	if ((x * y) <= -5e+36) {
		tmp = y * x;
	} else if ((x * y) <= 5e-133) {
		tmp = i * c;
	} else if ((x * y) <= 2e-54) {
		tmp = t * z;
	} else if ((x * y) <= 1e+92) {
		tmp = b * a;
	} else {
		tmp = y * x;
	}
	return tmp;
}
module fmin_fmax_functions
    implicit none
    private
    public fmax
    public fmin

    interface fmax
        module procedure fmax88
        module procedure fmax44
        module procedure fmax84
        module procedure fmax48
    end interface
    interface fmin
        module procedure fmin88
        module procedure fmin44
        module procedure fmin84
        module procedure fmin48
    end interface
contains
    real(8) function fmax88(x, y) result (res)
        real(8), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
    end function
    real(4) function fmax44(x, y) result (res)
        real(4), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
    end function
    real(8) function fmax84(x, y) result(res)
        real(8), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
    end function
    real(8) function fmax48(x, y) result(res)
        real(4), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
    end function
    real(8) function fmin88(x, y) result (res)
        real(8), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
    end function
    real(4) function fmin44(x, y) result (res)
        real(4), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
    end function
    real(8) function fmin84(x, y) result(res)
        real(8), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
    end function
    real(8) function fmin48(x, y) result(res)
        real(4), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
    end function
end module

real(8) function code(x, y, z, t, a, b, c, i)
use fmin_fmax_functions
    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), intent (in) :: c
    real(8), intent (in) :: i
    real(8) :: tmp
    if ((x * y) <= (-5d+36)) then
        tmp = y * x
    else if ((x * y) <= 5d-133) then
        tmp = i * c
    else if ((x * y) <= 2d-54) then
        tmp = t * z
    else if ((x * y) <= 1d+92) then
        tmp = b * a
    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 c, double i) {
	double tmp;
	if ((x * y) <= -5e+36) {
		tmp = y * x;
	} else if ((x * y) <= 5e-133) {
		tmp = i * c;
	} else if ((x * y) <= 2e-54) {
		tmp = t * z;
	} else if ((x * y) <= 1e+92) {
		tmp = b * a;
	} else {
		tmp = y * x;
	}
	return tmp;
}
def code(x, y, z, t, a, b, c, i):
	tmp = 0
	if (x * y) <= -5e+36:
		tmp = y * x
	elif (x * y) <= 5e-133:
		tmp = i * c
	elif (x * y) <= 2e-54:
		tmp = t * z
	elif (x * y) <= 1e+92:
		tmp = b * a
	else:
		tmp = y * x
	return tmp
function code(x, y, z, t, a, b, c, i)
	tmp = 0.0
	if (Float64(x * y) <= -5e+36)
		tmp = Float64(y * x);
	elseif (Float64(x * y) <= 5e-133)
		tmp = Float64(i * c);
	elseif (Float64(x * y) <= 2e-54)
		tmp = Float64(t * z);
	elseif (Float64(x * y) <= 1e+92)
		tmp = Float64(b * a);
	else
		tmp = Float64(y * x);
	end
	return tmp
end
function tmp_2 = code(x, y, z, t, a, b, c, i)
	tmp = 0.0;
	if ((x * y) <= -5e+36)
		tmp = y * x;
	elseif ((x * y) <= 5e-133)
		tmp = i * c;
	elseif ((x * y) <= 2e-54)
		tmp = t * z;
	elseif ((x * y) <= 1e+92)
		tmp = b * a;
	else
		tmp = y * x;
	end
	tmp_2 = tmp;
end
code[x_, y_, z_, t_, a_, b_, c_, i_] := If[LessEqual[N[(x * y), $MachinePrecision], -5e+36], N[(y * x), $MachinePrecision], If[LessEqual[N[(x * y), $MachinePrecision], 5e-133], N[(i * c), $MachinePrecision], If[LessEqual[N[(x * y), $MachinePrecision], 2e-54], N[(t * z), $MachinePrecision], If[LessEqual[N[(x * y), $MachinePrecision], 1e+92], N[(b * a), $MachinePrecision], N[(y * x), $MachinePrecision]]]]]
\begin{array}{l}

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

\mathbf{elif}\;x \cdot y \leq 5 \cdot 10^{-133}:\\
\;\;\;\;i \cdot c\\

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if (*.f64 x y) < -4.99999999999999977e36 or 1e92 < (*.f64 x y)

    1. Initial program 93.9%

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

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

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

        \[\leadsto y \cdot \color{blue}{x} \]
    5. Applied rewrites63.4%

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

    if -4.99999999999999977e36 < (*.f64 x y) < 4.9999999999999999e-133

    1. Initial program 96.5%

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

      \[\leadsto \color{blue}{c \cdot i} \]
    4. Step-by-step derivation
      1. *-commutativeN/A

        \[\leadsto i \cdot \color{blue}{c} \]
      2. lower-*.f6442.9

        \[\leadsto i \cdot \color{blue}{c} \]
    5. Applied rewrites42.9%

      \[\leadsto \color{blue}{i \cdot c} \]

    if 4.9999999999999999e-133 < (*.f64 x y) < 2.0000000000000001e-54

    1. Initial program 92.9%

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

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

        \[\leadsto t \cdot \color{blue}{z} \]
    5. Applied rewrites69.0%

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

    if 2.0000000000000001e-54 < (*.f64 x y) < 1e92

    1. Initial program 96.3%

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

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

        \[\leadsto b \cdot \color{blue}{a} \]
      2. lower-*.f6460.4

        \[\leadsto b \cdot \color{blue}{a} \]
    5. Applied rewrites60.4%

      \[\leadsto \color{blue}{b \cdot a} \]
  3. Recombined 4 regimes into one program.
  4. Add Preprocessing

Alternative 3: 75.0% accurate, 0.6× speedup?

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

\\
\begin{array}{l}
t_1 := x \cdot y + z \cdot t\\
\mathbf{if}\;t\_1 \leq -2 \cdot 10^{+54} \lor \neg \left(t\_1 \leq 2 \cdot 10^{+155}\right):\\
\;\;\;\;\mathsf{fma}\left(t, z, y \cdot x\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (+.f64 (*.f64 x y) (*.f64 z t)) < -2.0000000000000002e54 or 2.00000000000000001e155 < (+.f64 (*.f64 x y) (*.f64 z t))

    1. Initial program 92.9%

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

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

        \[\leadsto b \cdot a + \left(\color{blue}{t \cdot z} + x \cdot y\right) \]
      2. +-commutativeN/A

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

        \[\leadsto b \cdot a + \left(x \cdot y + z \cdot \color{blue}{t}\right) \]
      4. lower-fma.f64N/A

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

        \[\leadsto \mathsf{fma}\left(b, a, x \cdot y + t \cdot z\right) \]
      6. +-commutativeN/A

        \[\leadsto \mathsf{fma}\left(b, a, t \cdot z + x \cdot y\right) \]
      7. lower-fma.f64N/A

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

        \[\leadsto \mathsf{fma}\left(b, a, \mathsf{fma}\left(t, z, y \cdot x\right)\right) \]
      9. lower-*.f6486.9

        \[\leadsto \mathsf{fma}\left(b, a, \mathsf{fma}\left(t, z, y \cdot x\right)\right) \]
    5. Applied rewrites86.9%

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

      \[\leadsto t \cdot z + \color{blue}{x \cdot y} \]
    7. Step-by-step derivation
      1. lower-fma.f64N/A

        \[\leadsto \mathsf{fma}\left(t, z, x \cdot y\right) \]
      2. *-commutativeN/A

        \[\leadsto \mathsf{fma}\left(t, z, y \cdot x\right) \]
      3. lift-*.f6477.8

        \[\leadsto \mathsf{fma}\left(t, z, y \cdot x\right) \]
    8. Applied rewrites77.8%

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

    if -2.0000000000000002e54 < (+.f64 (*.f64 x y) (*.f64 z t)) < 2.00000000000000001e155

    1. Initial program 98.2%

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

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

        \[\leadsto b \cdot \color{blue}{a} + c \cdot i \]
      2. lower-*.f6481.7

        \[\leadsto b \cdot \color{blue}{a} + c \cdot i \]
    5. Applied rewrites81.7%

      \[\leadsto \color{blue}{b \cdot a} + c \cdot i \]
    6. Step-by-step derivation
      1. lift-+.f64N/A

        \[\leadsto \color{blue}{b \cdot a + c \cdot i} \]
      2. lift-*.f64N/A

        \[\leadsto b \cdot a + \color{blue}{c \cdot i} \]
      3. +-commutativeN/A

        \[\leadsto \color{blue}{c \cdot i + b \cdot a} \]
      4. *-commutativeN/A

        \[\leadsto \color{blue}{i \cdot c} + b \cdot a \]
      5. lower-fma.f6481.7

        \[\leadsto \color{blue}{\mathsf{fma}\left(i, c, b \cdot a\right)} \]
    7. Applied rewrites81.7%

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

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

Alternative 4: 67.1% accurate, 0.7× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_1 := \mathsf{fma}\left(t, z, y \cdot x\right)\\ \mathbf{if}\;x \cdot y \leq -5 \cdot 10^{+36}:\\ \;\;\;\;t\_1\\ \mathbf{elif}\;x \cdot y \leq 10^{-322}:\\ \;\;\;\;\mathsf{fma}\left(i, c, t \cdot z\right)\\ \mathbf{elif}\;x \cdot y \leq 10^{+92}:\\ \;\;\;\;\mathsf{fma}\left(b, a, t \cdot z\right)\\ \mathbf{else}:\\ \;\;\;\;t\_1\\ \end{array} \end{array} \]
(FPCore (x y z t a b c i)
 :precision binary64
 (let* ((t_1 (fma t z (* y x))))
   (if (<= (* x y) -5e+36)
     t_1
     (if (<= (* x y) 1e-322)
       (fma i c (* t z))
       (if (<= (* x y) 1e+92) (fma b a (* t z)) t_1)))))
double code(double x, double y, double z, double t, double a, double b, double c, double i) {
	double t_1 = fma(t, z, (y * x));
	double tmp;
	if ((x * y) <= -5e+36) {
		tmp = t_1;
	} else if ((x * y) <= 1e-322) {
		tmp = fma(i, c, (t * z));
	} else if ((x * y) <= 1e+92) {
		tmp = fma(b, a, (t * z));
	} else {
		tmp = t_1;
	}
	return tmp;
}
function code(x, y, z, t, a, b, c, i)
	t_1 = fma(t, z, Float64(y * x))
	tmp = 0.0
	if (Float64(x * y) <= -5e+36)
		tmp = t_1;
	elseif (Float64(x * y) <= 1e-322)
		tmp = fma(i, c, Float64(t * z));
	elseif (Float64(x * y) <= 1e+92)
		tmp = fma(b, a, Float64(t * z));
	else
		tmp = t_1;
	end
	return tmp
end
code[x_, y_, z_, t_, a_, b_, c_, i_] := Block[{t$95$1 = N[(t * z + N[(y * x), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(x * y), $MachinePrecision], -5e+36], t$95$1, If[LessEqual[N[(x * y), $MachinePrecision], 1e-322], N[(i * c + N[(t * z), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(x * y), $MachinePrecision], 1e+92], N[(b * a + N[(t * z), $MachinePrecision]), $MachinePrecision], t$95$1]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_1 := \mathsf{fma}\left(t, z, y \cdot x\right)\\
\mathbf{if}\;x \cdot y \leq -5 \cdot 10^{+36}:\\
\;\;\;\;t\_1\\

\mathbf{elif}\;x \cdot y \leq 10^{-322}:\\
\;\;\;\;\mathsf{fma}\left(i, c, t \cdot z\right)\\

\mathbf{elif}\;x \cdot y \leq 10^{+92}:\\
\;\;\;\;\mathsf{fma}\left(b, a, t \cdot z\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if (*.f64 x y) < -4.99999999999999977e36 or 1e92 < (*.f64 x y)

    1. Initial program 93.9%

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

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

        \[\leadsto b \cdot a + \left(\color{blue}{t \cdot z} + x \cdot y\right) \]
      2. +-commutativeN/A

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

        \[\leadsto b \cdot a + \left(x \cdot y + z \cdot \color{blue}{t}\right) \]
      4. lower-fma.f64N/A

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

        \[\leadsto \mathsf{fma}\left(b, a, x \cdot y + t \cdot z\right) \]
      6. +-commutativeN/A

        \[\leadsto \mathsf{fma}\left(b, a, t \cdot z + x \cdot y\right) \]
      7. lower-fma.f64N/A

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

        \[\leadsto \mathsf{fma}\left(b, a, \mathsf{fma}\left(t, z, y \cdot x\right)\right) \]
      9. lower-*.f6487.3

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

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

      \[\leadsto t \cdot z + \color{blue}{x \cdot y} \]
    7. Step-by-step derivation
      1. lower-fma.f64N/A

        \[\leadsto \mathsf{fma}\left(t, z, x \cdot y\right) \]
      2. *-commutativeN/A

        \[\leadsto \mathsf{fma}\left(t, z, y \cdot x\right) \]
      3. lift-*.f6477.8

        \[\leadsto \mathsf{fma}\left(t, z, y \cdot x\right) \]
    8. Applied rewrites77.8%

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

    if -4.99999999999999977e36 < (*.f64 x y) < 9.88131e-323

    1. Initial program 95.8%

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

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

        \[\leadsto b \cdot a + \left(\color{blue}{c \cdot i} + t \cdot z\right) \]
      2. lower-fma.f64N/A

        \[\leadsto \mathsf{fma}\left(b, \color{blue}{a}, c \cdot i + t \cdot z\right) \]
      3. *-commutativeN/A

        \[\leadsto \mathsf{fma}\left(b, a, i \cdot c + t \cdot z\right) \]
      4. lower-fma.f64N/A

        \[\leadsto \mathsf{fma}\left(b, a, \mathsf{fma}\left(i, c, t \cdot z\right)\right) \]
      5. lower-*.f6494.9

        \[\leadsto \mathsf{fma}\left(b, a, \mathsf{fma}\left(i, c, t \cdot z\right)\right) \]
    5. Applied rewrites94.9%

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

      \[\leadsto c \cdot i + \color{blue}{t \cdot z} \]
    7. Step-by-step derivation
      1. *-commutativeN/A

        \[\leadsto i \cdot c + t \cdot z \]
      2. lift-fma.f64N/A

        \[\leadsto \mathsf{fma}\left(i, c, t \cdot z\right) \]
      3. lift-*.f6470.0

        \[\leadsto \mathsf{fma}\left(i, c, t \cdot z\right) \]
    8. Applied rewrites70.0%

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

    if 9.88131e-323 < (*.f64 x y) < 1e92

    1. Initial program 96.7%

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

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

        \[\leadsto b \cdot a + \left(\color{blue}{c \cdot i} + t \cdot z\right) \]
      2. lower-fma.f64N/A

        \[\leadsto \mathsf{fma}\left(b, \color{blue}{a}, c \cdot i + t \cdot z\right) \]
      3. *-commutativeN/A

        \[\leadsto \mathsf{fma}\left(b, a, i \cdot c + t \cdot z\right) \]
      4. lower-fma.f64N/A

        \[\leadsto \mathsf{fma}\left(b, a, \mathsf{fma}\left(i, c, t \cdot z\right)\right) \]
      5. lower-*.f6498.5

        \[\leadsto \mathsf{fma}\left(b, a, \mathsf{fma}\left(i, c, t \cdot z\right)\right) \]
    5. Applied rewrites98.5%

      \[\leadsto \color{blue}{\mathsf{fma}\left(b, a, \mathsf{fma}\left(i, c, t \cdot z\right)\right)} \]
    6. Taylor expanded in z around inf

      \[\leadsto \mathsf{fma}\left(b, a, t \cdot z\right) \]
    7. Step-by-step derivation
      1. lift-*.f6475.4

        \[\leadsto \mathsf{fma}\left(b, a, t \cdot z\right) \]
    8. Applied rewrites75.4%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \cdot y \leq -5 \cdot 10^{+36}:\\ \;\;\;\;\mathsf{fma}\left(t, z, y \cdot x\right)\\ \mathbf{elif}\;x \cdot y \leq 10^{-322}:\\ \;\;\;\;\mathsf{fma}\left(i, c, t \cdot z\right)\\ \mathbf{elif}\;x \cdot y \leq 10^{+92}:\\ \;\;\;\;\mathsf{fma}\left(b, a, t \cdot z\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(t, z, y \cdot x\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 5: 64.6% accurate, 0.7× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_1 := \mathsf{fma}\left(t, z, y \cdot x\right)\\ \mathbf{if}\;x \cdot y \leq -5 \cdot 10^{+36}:\\ \;\;\;\;t\_1\\ \mathbf{elif}\;x \cdot y \leq 5 \cdot 10^{-41}:\\ \;\;\;\;\mathsf{fma}\left(i, c, t \cdot z\right)\\ \mathbf{elif}\;x \cdot y \leq 2 \cdot 10^{+84}:\\ \;\;\;\;b \cdot a\\ \mathbf{else}:\\ \;\;\;\;t\_1\\ \end{array} \end{array} \]
(FPCore (x y z t a b c i)
 :precision binary64
 (let* ((t_1 (fma t z (* y x))))
   (if (<= (* x y) -5e+36)
     t_1
     (if (<= (* x y) 5e-41)
       (fma i c (* t z))
       (if (<= (* x y) 2e+84) (* b a) t_1)))))
double code(double x, double y, double z, double t, double a, double b, double c, double i) {
	double t_1 = fma(t, z, (y * x));
	double tmp;
	if ((x * y) <= -5e+36) {
		tmp = t_1;
	} else if ((x * y) <= 5e-41) {
		tmp = fma(i, c, (t * z));
	} else if ((x * y) <= 2e+84) {
		tmp = b * a;
	} else {
		tmp = t_1;
	}
	return tmp;
}
function code(x, y, z, t, a, b, c, i)
	t_1 = fma(t, z, Float64(y * x))
	tmp = 0.0
	if (Float64(x * y) <= -5e+36)
		tmp = t_1;
	elseif (Float64(x * y) <= 5e-41)
		tmp = fma(i, c, Float64(t * z));
	elseif (Float64(x * y) <= 2e+84)
		tmp = Float64(b * a);
	else
		tmp = t_1;
	end
	return tmp
end
code[x_, y_, z_, t_, a_, b_, c_, i_] := Block[{t$95$1 = N[(t * z + N[(y * x), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(x * y), $MachinePrecision], -5e+36], t$95$1, If[LessEqual[N[(x * y), $MachinePrecision], 5e-41], N[(i * c + N[(t * z), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(x * y), $MachinePrecision], 2e+84], N[(b * a), $MachinePrecision], t$95$1]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_1 := \mathsf{fma}\left(t, z, y \cdot x\right)\\
\mathbf{if}\;x \cdot y \leq -5 \cdot 10^{+36}:\\
\;\;\;\;t\_1\\

\mathbf{elif}\;x \cdot y \leq 5 \cdot 10^{-41}:\\
\;\;\;\;\mathsf{fma}\left(i, c, t \cdot z\right)\\

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if (*.f64 x y) < -4.99999999999999977e36 or 2.00000000000000012e84 < (*.f64 x y)

    1. Initial program 93.1%

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

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

        \[\leadsto b \cdot a + \left(\color{blue}{t \cdot z} + x \cdot y\right) \]
      2. +-commutativeN/A

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

        \[\leadsto b \cdot a + \left(x \cdot y + z \cdot \color{blue}{t}\right) \]
      4. lower-fma.f64N/A

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

        \[\leadsto \mathsf{fma}\left(b, a, x \cdot y + t \cdot z\right) \]
      6. +-commutativeN/A

        \[\leadsto \mathsf{fma}\left(b, a, t \cdot z + x \cdot y\right) \]
      7. lower-fma.f64N/A

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

        \[\leadsto \mathsf{fma}\left(b, a, \mathsf{fma}\left(t, z, y \cdot x\right)\right) \]
      9. lower-*.f6487.6

        \[\leadsto \mathsf{fma}\left(b, a, \mathsf{fma}\left(t, z, y \cdot x\right)\right) \]
    5. Applied rewrites87.6%

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

      \[\leadsto t \cdot z + \color{blue}{x \cdot y} \]
    7. Step-by-step derivation
      1. lower-fma.f64N/A

        \[\leadsto \mathsf{fma}\left(t, z, x \cdot y\right) \]
      2. *-commutativeN/A

        \[\leadsto \mathsf{fma}\left(t, z, y \cdot x\right) \]
      3. lift-*.f6477.3

        \[\leadsto \mathsf{fma}\left(t, z, y \cdot x\right) \]
    8. Applied rewrites77.3%

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

    if -4.99999999999999977e36 < (*.f64 x y) < 4.9999999999999996e-41

    1. Initial program 96.2%

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

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

        \[\leadsto b \cdot a + \left(\color{blue}{c \cdot i} + t \cdot z\right) \]
      2. lower-fma.f64N/A

        \[\leadsto \mathsf{fma}\left(b, \color{blue}{a}, c \cdot i + t \cdot z\right) \]
      3. *-commutativeN/A

        \[\leadsto \mathsf{fma}\left(b, a, i \cdot c + t \cdot z\right) \]
      4. lower-fma.f64N/A

        \[\leadsto \mathsf{fma}\left(b, a, \mathsf{fma}\left(i, c, t \cdot z\right)\right) \]
      5. lower-*.f6496.4

        \[\leadsto \mathsf{fma}\left(b, a, \mathsf{fma}\left(i, c, t \cdot z\right)\right) \]
    5. Applied rewrites96.4%

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

      \[\leadsto c \cdot i + \color{blue}{t \cdot z} \]
    7. Step-by-step derivation
      1. *-commutativeN/A

        \[\leadsto i \cdot c + t \cdot z \]
      2. lift-fma.f64N/A

        \[\leadsto \mathsf{fma}\left(i, c, t \cdot z\right) \]
      3. lift-*.f6468.7

        \[\leadsto \mathsf{fma}\left(i, c, t \cdot z\right) \]
    8. Applied rewrites68.7%

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

    if 4.9999999999999996e-41 < (*.f64 x y) < 2.00000000000000012e84

    1. Initial program 100.0%

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

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

        \[\leadsto b \cdot \color{blue}{a} \]
      2. lower-*.f6464.8

        \[\leadsto b \cdot \color{blue}{a} \]
    5. Applied rewrites64.8%

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

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

Alternative 6: 90.0% accurate, 0.7× speedup?

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (*.f64 x y) < -1.00000000000000004e62 or 1.9999999999999998e23 < (*.f64 x y)

    1. Initial program 93.5%

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

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

        \[\leadsto b \cdot a + \left(\color{blue}{t \cdot z} + x \cdot y\right) \]
      2. +-commutativeN/A

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

        \[\leadsto b \cdot a + \left(x \cdot y + z \cdot \color{blue}{t}\right) \]
      4. lower-fma.f64N/A

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

        \[\leadsto \mathsf{fma}\left(b, a, x \cdot y + t \cdot z\right) \]
      6. +-commutativeN/A

        \[\leadsto \mathsf{fma}\left(b, a, t \cdot z + x \cdot y\right) \]
      7. lower-fma.f64N/A

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

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

        \[\leadsto \mathsf{fma}\left(b, a, \mathsf{fma}\left(t, z, y \cdot x\right)\right) \]
    5. Applied rewrites88.4%

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

    if -1.00000000000000004e62 < (*.f64 x y) < 1.9999999999999998e23

    1. Initial program 96.6%

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

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

        \[\leadsto b \cdot a + \left(\color{blue}{c \cdot i} + t \cdot z\right) \]
      2. lower-fma.f64N/A

        \[\leadsto \mathsf{fma}\left(b, \color{blue}{a}, c \cdot i + t \cdot z\right) \]
      3. *-commutativeN/A

        \[\leadsto \mathsf{fma}\left(b, a, i \cdot c + t \cdot z\right) \]
      4. lower-fma.f64N/A

        \[\leadsto \mathsf{fma}\left(b, a, \mathsf{fma}\left(i, c, t \cdot z\right)\right) \]
      5. lower-*.f6496.1

        \[\leadsto \mathsf{fma}\left(b, a, \mathsf{fma}\left(i, c, t \cdot z\right)\right) \]
    5. Applied rewrites96.1%

      \[\leadsto \color{blue}{\mathsf{fma}\left(b, a, \mathsf{fma}\left(i, c, t \cdot z\right)\right)} \]
    6. Step-by-step derivation
      1. lift-*.f64N/A

        \[\leadsto \mathsf{fma}\left(b, a, \mathsf{fma}\left(i, c, t \cdot z\right)\right) \]
      2. lift-fma.f64N/A

        \[\leadsto \mathsf{fma}\left(b, a, i \cdot c + t \cdot z\right) \]
      3. +-commutativeN/A

        \[\leadsto \mathsf{fma}\left(b, a, t \cdot z + i \cdot c\right) \]
      4. *-commutativeN/A

        \[\leadsto \mathsf{fma}\left(b, a, t \cdot z + c \cdot i\right) \]
      5. *-commutativeN/A

        \[\leadsto \mathsf{fma}\left(b, a, z \cdot t + c \cdot i\right) \]
      6. lower-fma.f64N/A

        \[\leadsto \mathsf{fma}\left(b, a, \mathsf{fma}\left(z, t, c \cdot i\right)\right) \]
      7. *-commutativeN/A

        \[\leadsto \mathsf{fma}\left(b, a, \mathsf{fma}\left(z, t, i \cdot c\right)\right) \]
      8. lower-*.f6496.8

        \[\leadsto \mathsf{fma}\left(b, a, \mathsf{fma}\left(z, t, i \cdot c\right)\right) \]
    7. Applied rewrites96.8%

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

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

Alternative 7: 90.0% accurate, 0.7× speedup?

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (*.f64 x y) < -1.00000000000000004e62 or 1.9999999999999998e23 < (*.f64 x y)

    1. Initial program 93.5%

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

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

        \[\leadsto b \cdot a + \left(\color{blue}{t \cdot z} + x \cdot y\right) \]
      2. +-commutativeN/A

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

        \[\leadsto b \cdot a + \left(x \cdot y + z \cdot \color{blue}{t}\right) \]
      4. lower-fma.f64N/A

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

        \[\leadsto \mathsf{fma}\left(b, a, x \cdot y + t \cdot z\right) \]
      6. +-commutativeN/A

        \[\leadsto \mathsf{fma}\left(b, a, t \cdot z + x \cdot y\right) \]
      7. lower-fma.f64N/A

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

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

        \[\leadsto \mathsf{fma}\left(b, a, \mathsf{fma}\left(t, z, y \cdot x\right)\right) \]
    5. Applied rewrites88.4%

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

    if -1.00000000000000004e62 < (*.f64 x y) < 1.9999999999999998e23

    1. Initial program 96.6%

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

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

        \[\leadsto b \cdot a + \left(\color{blue}{c \cdot i} + t \cdot z\right) \]
      2. lower-fma.f64N/A

        \[\leadsto \mathsf{fma}\left(b, \color{blue}{a}, c \cdot i + t \cdot z\right) \]
      3. *-commutativeN/A

        \[\leadsto \mathsf{fma}\left(b, a, i \cdot c + t \cdot z\right) \]
      4. lower-fma.f64N/A

        \[\leadsto \mathsf{fma}\left(b, a, \mathsf{fma}\left(i, c, t \cdot z\right)\right) \]
      5. lower-*.f6496.1

        \[\leadsto \mathsf{fma}\left(b, a, \mathsf{fma}\left(i, c, t \cdot z\right)\right) \]
    5. Applied rewrites96.1%

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

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

Alternative 8: 85.2% accurate, 0.7× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;x \cdot y \leq -1 \cdot 10^{+62} \lor \neg \left(x \cdot y \leq 10^{+92}\right):\\
\;\;\;\;\mathsf{fma}\left(t, z, y \cdot x\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (*.f64 x y) < -1.00000000000000004e62 or 1e92 < (*.f64 x y)

    1. Initial program 93.8%

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

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

        \[\leadsto b \cdot a + \left(\color{blue}{t \cdot z} + x \cdot y\right) \]
      2. +-commutativeN/A

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

        \[\leadsto b \cdot a + \left(x \cdot y + z \cdot \color{blue}{t}\right) \]
      4. lower-fma.f64N/A

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

        \[\leadsto \mathsf{fma}\left(b, a, x \cdot y + t \cdot z\right) \]
      6. +-commutativeN/A

        \[\leadsto \mathsf{fma}\left(b, a, t \cdot z + x \cdot y\right) \]
      7. lower-fma.f64N/A

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

        \[\leadsto \mathsf{fma}\left(b, a, \mathsf{fma}\left(t, z, y \cdot x\right)\right) \]
      9. lower-*.f6486.9

        \[\leadsto \mathsf{fma}\left(b, a, \mathsf{fma}\left(t, z, y \cdot x\right)\right) \]
    5. Applied rewrites86.9%

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

      \[\leadsto t \cdot z + \color{blue}{x \cdot y} \]
    7. Step-by-step derivation
      1. lower-fma.f64N/A

        \[\leadsto \mathsf{fma}\left(t, z, x \cdot y\right) \]
      2. *-commutativeN/A

        \[\leadsto \mathsf{fma}\left(t, z, y \cdot x\right) \]
      3. lift-*.f6479.1

        \[\leadsto \mathsf{fma}\left(t, z, y \cdot x\right) \]
    8. Applied rewrites79.1%

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

    if -1.00000000000000004e62 < (*.f64 x y) < 1e92

    1. Initial program 96.2%

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

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

        \[\leadsto b \cdot a + \left(\color{blue}{c \cdot i} + t \cdot z\right) \]
      2. lower-fma.f64N/A

        \[\leadsto \mathsf{fma}\left(b, \color{blue}{a}, c \cdot i + t \cdot z\right) \]
      3. *-commutativeN/A

        \[\leadsto \mathsf{fma}\left(b, a, i \cdot c + t \cdot z\right) \]
      4. lower-fma.f64N/A

        \[\leadsto \mathsf{fma}\left(b, a, \mathsf{fma}\left(i, c, t \cdot z\right)\right) \]
      5. lower-*.f6496.4

        \[\leadsto \mathsf{fma}\left(b, a, \mathsf{fma}\left(i, c, t \cdot z\right)\right) \]
    5. Applied rewrites96.4%

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

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

Alternative 9: 43.3% accurate, 0.8× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;a \cdot b \leq -1 \cdot 10^{+49}:\\ \;\;\;\;b \cdot a\\ \mathbf{elif}\;a \cdot b \leq 2 \cdot 10^{-184}:\\ \;\;\;\;i \cdot c\\ \mathbf{elif}\;a \cdot b \leq 5 \cdot 10^{+65}:\\ \;\;\;\;t \cdot z\\ \mathbf{else}:\\ \;\;\;\;b \cdot a\\ \end{array} \end{array} \]
(FPCore (x y z t a b c i)
 :precision binary64
 (if (<= (* a b) -1e+49)
   (* b a)
   (if (<= (* a b) 2e-184) (* i c) (if (<= (* a b) 5e+65) (* t z) (* b a)))))
double code(double x, double y, double z, double t, double a, double b, double c, double i) {
	double tmp;
	if ((a * b) <= -1e+49) {
		tmp = b * a;
	} else if ((a * b) <= 2e-184) {
		tmp = i * c;
	} else if ((a * b) <= 5e+65) {
		tmp = t * z;
	} else {
		tmp = b * a;
	}
	return tmp;
}
module fmin_fmax_functions
    implicit none
    private
    public fmax
    public fmin

    interface fmax
        module procedure fmax88
        module procedure fmax44
        module procedure fmax84
        module procedure fmax48
    end interface
    interface fmin
        module procedure fmin88
        module procedure fmin44
        module procedure fmin84
        module procedure fmin48
    end interface
contains
    real(8) function fmax88(x, y) result (res)
        real(8), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
    end function
    real(4) function fmax44(x, y) result (res)
        real(4), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
    end function
    real(8) function fmax84(x, y) result(res)
        real(8), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
    end function
    real(8) function fmax48(x, y) result(res)
        real(4), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
    end function
    real(8) function fmin88(x, y) result (res)
        real(8), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
    end function
    real(4) function fmin44(x, y) result (res)
        real(4), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
    end function
    real(8) function fmin84(x, y) result(res)
        real(8), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
    end function
    real(8) function fmin48(x, y) result(res)
        real(4), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
    end function
end module

real(8) function code(x, y, z, t, a, b, c, i)
use fmin_fmax_functions
    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), intent (in) :: c
    real(8), intent (in) :: i
    real(8) :: tmp
    if ((a * b) <= (-1d+49)) then
        tmp = b * a
    else if ((a * b) <= 2d-184) then
        tmp = i * c
    else if ((a * b) <= 5d+65) 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 c, double i) {
	double tmp;
	if ((a * b) <= -1e+49) {
		tmp = b * a;
	} else if ((a * b) <= 2e-184) {
		tmp = i * c;
	} else if ((a * b) <= 5e+65) {
		tmp = t * z;
	} else {
		tmp = b * a;
	}
	return tmp;
}
def code(x, y, z, t, a, b, c, i):
	tmp = 0
	if (a * b) <= -1e+49:
		tmp = b * a
	elif (a * b) <= 2e-184:
		tmp = i * c
	elif (a * b) <= 5e+65:
		tmp = t * z
	else:
		tmp = b * a
	return tmp
function code(x, y, z, t, a, b, c, i)
	tmp = 0.0
	if (Float64(a * b) <= -1e+49)
		tmp = Float64(b * a);
	elseif (Float64(a * b) <= 2e-184)
		tmp = Float64(i * c);
	elseif (Float64(a * b) <= 5e+65)
		tmp = Float64(t * z);
	else
		tmp = Float64(b * a);
	end
	return tmp
end
function tmp_2 = code(x, y, z, t, a, b, c, i)
	tmp = 0.0;
	if ((a * b) <= -1e+49)
		tmp = b * a;
	elseif ((a * b) <= 2e-184)
		tmp = i * c;
	elseif ((a * b) <= 5e+65)
		tmp = t * z;
	else
		tmp = b * a;
	end
	tmp_2 = tmp;
end
code[x_, y_, z_, t_, a_, b_, c_, i_] := If[LessEqual[N[(a * b), $MachinePrecision], -1e+49], N[(b * a), $MachinePrecision], If[LessEqual[N[(a * b), $MachinePrecision], 2e-184], N[(i * c), $MachinePrecision], If[LessEqual[N[(a * b), $MachinePrecision], 5e+65], N[(t * z), $MachinePrecision], N[(b * a), $MachinePrecision]]]]
\begin{array}{l}

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

\mathbf{elif}\;a \cdot b \leq 2 \cdot 10^{-184}:\\
\;\;\;\;i \cdot c\\

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if (*.f64 a b) < -9.99999999999999946e48 or 4.99999999999999973e65 < (*.f64 a b)

    1. Initial program 91.8%

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

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

        \[\leadsto b \cdot \color{blue}{a} \]
      2. lower-*.f6458.8

        \[\leadsto b \cdot \color{blue}{a} \]
    5. Applied rewrites58.8%

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

    if -9.99999999999999946e48 < (*.f64 a b) < 2.0000000000000001e-184

    1. Initial program 96.5%

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

      \[\leadsto \color{blue}{c \cdot i} \]
    4. Step-by-step derivation
      1. *-commutativeN/A

        \[\leadsto i \cdot \color{blue}{c} \]
      2. lower-*.f6441.0

        \[\leadsto i \cdot \color{blue}{c} \]
    5. Applied rewrites41.0%

      \[\leadsto \color{blue}{i \cdot c} \]

    if 2.0000000000000001e-184 < (*.f64 a b) < 4.99999999999999973e65

    1. Initial program 100.0%

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

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

        \[\leadsto t \cdot \color{blue}{z} \]
    5. Applied rewrites41.3%

      \[\leadsto \color{blue}{t \cdot z} \]
  3. Recombined 3 regimes into one program.
  4. Add Preprocessing

Alternative 10: 63.0% accurate, 0.9× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;x \cdot y \leq -1 \cdot 10^{+70} \lor \neg \left(x \cdot y \leq 2 \cdot 10^{+169}\right):\\
\;\;\;\;y \cdot x\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (*.f64 x y) < -1.00000000000000007e70 or 1.99999999999999987e169 < (*.f64 x y)

    1. Initial program 92.8%

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

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

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

        \[\leadsto y \cdot \color{blue}{x} \]
    5. Applied rewrites69.0%

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

    if -1.00000000000000007e70 < (*.f64 x y) < 1.99999999999999987e169

    1. Initial program 96.5%

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

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

        \[\leadsto b \cdot a + \left(\color{blue}{c \cdot i} + t \cdot z\right) \]
      2. lower-fma.f64N/A

        \[\leadsto \mathsf{fma}\left(b, \color{blue}{a}, c \cdot i + t \cdot z\right) \]
      3. *-commutativeN/A

        \[\leadsto \mathsf{fma}\left(b, a, i \cdot c + t \cdot z\right) \]
      4. lower-fma.f64N/A

        \[\leadsto \mathsf{fma}\left(b, a, \mathsf{fma}\left(i, c, t \cdot z\right)\right) \]
      5. lower-*.f6493.9

        \[\leadsto \mathsf{fma}\left(b, a, \mathsf{fma}\left(i, c, t \cdot z\right)\right) \]
    5. Applied rewrites93.9%

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

      \[\leadsto c \cdot i + \color{blue}{t \cdot z} \]
    7. Step-by-step derivation
      1. *-commutativeN/A

        \[\leadsto i \cdot c + t \cdot z \]
      2. lift-fma.f64N/A

        \[\leadsto \mathsf{fma}\left(i, c, t \cdot z\right) \]
      3. lift-*.f6463.1

        \[\leadsto \mathsf{fma}\left(i, c, t \cdot z\right) \]
    8. Applied rewrites63.1%

      \[\leadsto \mathsf{fma}\left(i, \color{blue}{c}, t \cdot z\right) \]
  3. Recombined 2 regimes into one program.
  4. Final simplification65.0%

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

Alternative 11: 43.0% accurate, 1.1× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;a \cdot b \leq -1 \cdot 10^{+49} \lor \neg \left(a \cdot b \leq 50000000\right):\\ \;\;\;\;b \cdot a\\ \mathbf{else}:\\ \;\;\;\;i \cdot c\\ \end{array} \end{array} \]
(FPCore (x y z t a b c i)
 :precision binary64
 (if (or (<= (* a b) -1e+49) (not (<= (* a b) 50000000.0))) (* b a) (* i c)))
double code(double x, double y, double z, double t, double a, double b, double c, double i) {
	double tmp;
	if (((a * b) <= -1e+49) || !((a * b) <= 50000000.0)) {
		tmp = b * a;
	} else {
		tmp = i * c;
	}
	return tmp;
}
module fmin_fmax_functions
    implicit none
    private
    public fmax
    public fmin

    interface fmax
        module procedure fmax88
        module procedure fmax44
        module procedure fmax84
        module procedure fmax48
    end interface
    interface fmin
        module procedure fmin88
        module procedure fmin44
        module procedure fmin84
        module procedure fmin48
    end interface
contains
    real(8) function fmax88(x, y) result (res)
        real(8), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
    end function
    real(4) function fmax44(x, y) result (res)
        real(4), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
    end function
    real(8) function fmax84(x, y) result(res)
        real(8), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
    end function
    real(8) function fmax48(x, y) result(res)
        real(4), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
    end function
    real(8) function fmin88(x, y) result (res)
        real(8), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
    end function
    real(4) function fmin44(x, y) result (res)
        real(4), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
    end function
    real(8) function fmin84(x, y) result(res)
        real(8), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
    end function
    real(8) function fmin48(x, y) result(res)
        real(4), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
    end function
end module

real(8) function code(x, y, z, t, a, b, c, i)
use fmin_fmax_functions
    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), intent (in) :: c
    real(8), intent (in) :: i
    real(8) :: tmp
    if (((a * b) <= (-1d+49)) .or. (.not. ((a * b) <= 50000000.0d0))) then
        tmp = b * a
    else
        tmp = i * c
    end if
    code = tmp
end function
public static double code(double x, double y, double z, double t, double a, double b, double c, double i) {
	double tmp;
	if (((a * b) <= -1e+49) || !((a * b) <= 50000000.0)) {
		tmp = b * a;
	} else {
		tmp = i * c;
	}
	return tmp;
}
def code(x, y, z, t, a, b, c, i):
	tmp = 0
	if ((a * b) <= -1e+49) or not ((a * b) <= 50000000.0):
		tmp = b * a
	else:
		tmp = i * c
	return tmp
function code(x, y, z, t, a, b, c, i)
	tmp = 0.0
	if ((Float64(a * b) <= -1e+49) || !(Float64(a * b) <= 50000000.0))
		tmp = Float64(b * a);
	else
		tmp = Float64(i * c);
	end
	return tmp
end
function tmp_2 = code(x, y, z, t, a, b, c, i)
	tmp = 0.0;
	if (((a * b) <= -1e+49) || ~(((a * b) <= 50000000.0)))
		tmp = b * a;
	else
		tmp = i * c;
	end
	tmp_2 = tmp;
end
code[x_, y_, z_, t_, a_, b_, c_, i_] := If[Or[LessEqual[N[(a * b), $MachinePrecision], -1e+49], N[Not[LessEqual[N[(a * b), $MachinePrecision], 50000000.0]], $MachinePrecision]], N[(b * a), $MachinePrecision], N[(i * c), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;a \cdot b \leq -1 \cdot 10^{+49} \lor \neg \left(a \cdot b \leq 50000000\right):\\
\;\;\;\;b \cdot a\\

\mathbf{else}:\\
\;\;\;\;i \cdot c\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (*.f64 a b) < -9.99999999999999946e48 or 5e7 < (*.f64 a b)

    1. Initial program 92.9%

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

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

        \[\leadsto b \cdot \color{blue}{a} \]
      2. lower-*.f6454.0

        \[\leadsto b \cdot \color{blue}{a} \]
    5. Applied rewrites54.0%

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

    if -9.99999999999999946e48 < (*.f64 a b) < 5e7

    1. Initial program 97.2%

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

      \[\leadsto \color{blue}{c \cdot i} \]
    4. Step-by-step derivation
      1. *-commutativeN/A

        \[\leadsto i \cdot \color{blue}{c} \]
      2. lower-*.f6438.2

        \[\leadsto i \cdot \color{blue}{c} \]
    5. Applied rewrites38.2%

      \[\leadsto \color{blue}{i \cdot c} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification45.1%

    \[\leadsto \begin{array}{l} \mathbf{if}\;a \cdot b \leq -1 \cdot 10^{+49} \lor \neg \left(a \cdot b \leq 50000000\right):\\ \;\;\;\;b \cdot a\\ \mathbf{else}:\\ \;\;\;\;i \cdot c\\ \end{array} \]
  5. Add Preprocessing

Alternative 12: 27.6% accurate, 5.0× speedup?

\[\begin{array}{l} \\ b \cdot a \end{array} \]
(FPCore (x y z t a b c i) :precision binary64 (* b a))
double code(double x, double y, double z, double t, double a, double b, double c, double i) {
	return b * a;
}
module fmin_fmax_functions
    implicit none
    private
    public fmax
    public fmin

    interface fmax
        module procedure fmax88
        module procedure fmax44
        module procedure fmax84
        module procedure fmax48
    end interface
    interface fmin
        module procedure fmin88
        module procedure fmin44
        module procedure fmin84
        module procedure fmin48
    end interface
contains
    real(8) function fmax88(x, y) result (res)
        real(8), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
    end function
    real(4) function fmax44(x, y) result (res)
        real(4), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
    end function
    real(8) function fmax84(x, y) result(res)
        real(8), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
    end function
    real(8) function fmax48(x, y) result(res)
        real(4), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
    end function
    real(8) function fmin88(x, y) result (res)
        real(8), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
    end function
    real(4) function fmin44(x, y) result (res)
        real(4), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
    end function
    real(8) function fmin84(x, y) result(res)
        real(8), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
    end function
    real(8) function fmin48(x, y) result(res)
        real(4), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
    end function
end module

real(8) function code(x, y, z, t, a, b, c, i)
use fmin_fmax_functions
    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), intent (in) :: c
    real(8), intent (in) :: i
    code = b * a
end function
public static double code(double x, double y, double z, double t, double a, double b, double c, double i) {
	return b * a;
}
def code(x, y, z, t, a, b, c, i):
	return b * a
function code(x, y, z, t, a, b, c, i)
	return Float64(b * a)
end
function tmp = code(x, y, z, t, a, b, c, i)
	tmp = b * a;
end
code[x_, y_, z_, t_, a_, b_, c_, i_] := N[(b * a), $MachinePrecision]
\begin{array}{l}

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

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

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

      \[\leadsto b \cdot \color{blue}{a} \]
    2. lower-*.f6426.6

      \[\leadsto b \cdot \color{blue}{a} \]
  5. Applied rewrites26.6%

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

Reproduce

?
herbie shell --seed 2025064 
(FPCore (x y z t a b c i)
  :name "Linear.V4:$cdot from linear-1.19.1.3, C"
  :precision binary64
  (+ (+ (+ (* x y) (* z t)) (* a b)) (* c i)))