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

Percentage Accurate: 96.0% → 97.8%
Time: 5.0s
Alternatives: 10
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}

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 10 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.0% 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: 97.8% 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(t, z, y \cdot x\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 t z (* y x))))))
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(t, z, (y * x)));
	}
	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(t, z, Float64(y * x)));
	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[(t * z + N[(y * x), $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(t, z, y \cdot x\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 \]

    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. Taylor expanded in c around 0

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

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

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

        \[\leadsto b \cdot a + \left(\color{blue}{x \cdot y} + z \cdot 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, z \cdot t + x \cdot y\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-*.f6445.3

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

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

Alternative 2: 85.5% accurate, 0.8× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;c \cdot i \leq -5 \cdot 10^{+79}:\\ \;\;\;\;\mathsf{fma}\left(i, c, y \cdot x\right)\\ \mathbf{elif}\;c \cdot i \leq 10^{+264}:\\ \;\;\;\;\mathsf{fma}\left(b, a, \mathsf{fma}\left(t, z, y \cdot x\right)\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
 (if (<= (* c i) -5e+79)
   (fma i c (* y x))
   (if (<= (* c i) 1e+264) (fma b a (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 tmp;
	if ((c * i) <= -5e+79) {
		tmp = fma(i, c, (y * x));
	} else if ((c * i) <= 1e+264) {
		tmp = fma(b, a, fma(t, z, (y * x)));
	} else {
		tmp = fma(i, c, (b * a));
	}
	return tmp;
}
function code(x, y, z, t, a, b, c, i)
	tmp = 0.0
	if (Float64(c * i) <= -5e+79)
		tmp = fma(i, c, Float64(y * x));
	elseif (Float64(c * i) <= 1e+264)
		tmp = fma(b, a, 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_] := If[LessEqual[N[(c * i), $MachinePrecision], -5e+79], N[(i * c + N[(y * x), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(c * i), $MachinePrecision], 1e+264], N[(b * a + N[(t * z + N[(y * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(i * c + N[(b * a), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;c \cdot i \leq -5 \cdot 10^{+79}:\\
\;\;\;\;\mathsf{fma}\left(i, c, y \cdot x\right)\\

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if (*.f64 c i) < -5e79

    1. Initial program 93.0%

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

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

        \[\leadsto y \cdot \color{blue}{x} + c \cdot i \]
      2. lower-*.f6472.6

        \[\leadsto y \cdot \color{blue}{x} + c \cdot i \]
    4. Applied rewrites72.6%

      \[\leadsto \color{blue}{y \cdot x} + c \cdot i \]
    5. Step-by-step derivation
      1. lift-*.f64N/A

        \[\leadsto y \cdot x + \color{blue}{c \cdot i} \]
      2. lift-+.f64N/A

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

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

        \[\leadsto \color{blue}{i \cdot c} + y \cdot x \]
      5. lower-fma.f6473.5

        \[\leadsto \color{blue}{\mathsf{fma}\left(i, c, y \cdot x\right)} \]
    6. Applied rewrites73.5%

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

    if -5e79 < (*.f64 c i) < 1.00000000000000004e264

    1. Initial program 98.1%

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

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

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

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

        \[\leadsto b \cdot a + \left(\color{blue}{x \cdot y} + z \cdot 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, z \cdot t + x \cdot y\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.2

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

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

    if 1.00000000000000004e264 < (*.f64 c i)

    1. Initial program 84.7%

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

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

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

        \[\leadsto b \cdot \color{blue}{a} + c \cdot i \]
    4. Applied rewrites86.4%

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

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

        \[\leadsto \color{blue}{b \cdot a + 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.f6488.8

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

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

Alternative 3: 67.0% accurate, 0.6× speedup?

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

\\
\begin{array}{l}
t_1 := \mathsf{fma}\left(i, c, b \cdot a\right)\\
t_2 := \mathsf{fma}\left(i, c, y \cdot x\right)\\
\mathbf{if}\;x \cdot y \leq -2.5 \cdot 10^{+100}:\\
\;\;\;\;t\_2\\

\mathbf{elif}\;x \cdot y \leq -1 \cdot 10^{-141}:\\
\;\;\;\;t\_1\\

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

\mathbf{elif}\;x \cdot y \leq 5 \cdot 10^{-13}:\\
\;\;\;\;t\_1\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if (*.f64 x y) < -2.4999999999999999e100 or 4.9999999999999999e-13 < (*.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. Taylor expanded in x around inf

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

        \[\leadsto y \cdot \color{blue}{x} + c \cdot i \]
      2. lower-*.f6468.7

        \[\leadsto y \cdot \color{blue}{x} + c \cdot i \]
    4. Applied rewrites68.7%

      \[\leadsto \color{blue}{y \cdot x} + c \cdot i \]
    5. Step-by-step derivation
      1. lift-*.f64N/A

        \[\leadsto y \cdot x + \color{blue}{c \cdot i} \]
      2. lift-+.f64N/A

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

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

        \[\leadsto \color{blue}{i \cdot c} + y \cdot x \]
      5. lower-fma.f6469.4

        \[\leadsto \color{blue}{\mathsf{fma}\left(i, c, y \cdot x\right)} \]
    6. Applied rewrites69.4%

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

    if -2.4999999999999999e100 < (*.f64 x y) < -1e-141 or 2.0000000000019e-312 < (*.f64 x y) < 4.9999999999999999e-13

    1. Initial program 97.8%

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

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

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

        \[\leadsto b \cdot \color{blue}{a} + c \cdot i \]
    4. Applied rewrites61.8%

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

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

        \[\leadsto \color{blue}{b \cdot a + 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.f6462.2

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

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

    if -1e-141 < (*.f64 x y) < 2.0000000000019e-312

    1. Initial program 97.3%

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

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

        \[\leadsto y \cdot \color{blue}{x} + c \cdot i \]
      2. lower-*.f6435.9

        \[\leadsto y \cdot \color{blue}{x} + c \cdot i \]
    4. Applied rewrites35.9%

      \[\leadsto \color{blue}{y \cdot x} + c \cdot i \]
    5. Step-by-step derivation
      1. lift-*.f64N/A

        \[\leadsto y \cdot x + \color{blue}{c \cdot i} \]
      2. lift-+.f64N/A

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

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

        \[\leadsto \color{blue}{i \cdot c} + y \cdot x \]
      5. lower-fma.f6435.9

        \[\leadsto \color{blue}{\mathsf{fma}\left(i, c, y \cdot x\right)} \]
    6. Applied rewrites35.9%

      \[\leadsto \color{blue}{\mathsf{fma}\left(i, c, y \cdot x\right)} \]
    7. Taylor expanded in z around inf

      \[\leadsto \mathsf{fma}\left(i, c, \color{blue}{t \cdot z}\right) \]
    8. Step-by-step derivation
      1. lift-*.f6468.2

        \[\leadsto \mathsf{fma}\left(i, c, t \cdot \color{blue}{z}\right) \]
    9. Applied rewrites68.2%

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

Alternative 4: 66.6% accurate, 0.6× speedup?

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

\\
\begin{array}{l}
t_1 := \mathsf{fma}\left(i, c, b \cdot a\right)\\
t_2 := \mathsf{fma}\left(b, a, y \cdot x\right)\\
\mathbf{if}\;x \cdot y \leq -5 \cdot 10^{+119}:\\
\;\;\;\;t\_2\\

\mathbf{elif}\;x \cdot y \leq -1 \cdot 10^{-141}:\\
\;\;\;\;t\_1\\

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

\mathbf{elif}\;x \cdot y \leq 2 \cdot 10^{+133}:\\
\;\;\;\;t\_1\\

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


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

    1. Initial program 92.5%

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

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

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

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

        \[\leadsto b \cdot a + \left(\color{blue}{x \cdot y} + z \cdot 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, z \cdot t + x \cdot y\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-*.f6485.2

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

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

      \[\leadsto \mathsf{fma}\left(b, a, x \cdot y\right) \]
    6. Step-by-step derivation
      1. *-commutativeN/A

        \[\leadsto \mathsf{fma}\left(b, a, y \cdot x\right) \]
      2. lift-*.f6475.5

        \[\leadsto \mathsf{fma}\left(b, a, y \cdot x\right) \]
    7. Applied rewrites75.5%

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

    if -4.9999999999999999e119 < (*.f64 x y) < -1e-141 or 2.0000000000019e-312 < (*.f64 x y) < 2e133

    1. Initial program 97.7%

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

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

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

        \[\leadsto b \cdot \color{blue}{a} + c \cdot i \]
    4. Applied rewrites60.1%

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

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

        \[\leadsto \color{blue}{b \cdot a + 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.f6460.5

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

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

    if -1e-141 < (*.f64 x y) < 2.0000000000019e-312

    1. Initial program 97.3%

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

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

        \[\leadsto y \cdot \color{blue}{x} + c \cdot i \]
      2. lower-*.f6435.9

        \[\leadsto y \cdot \color{blue}{x} + c \cdot i \]
    4. Applied rewrites35.9%

      \[\leadsto \color{blue}{y \cdot x} + c \cdot i \]
    5. Step-by-step derivation
      1. lift-*.f64N/A

        \[\leadsto y \cdot x + \color{blue}{c \cdot i} \]
      2. lift-+.f64N/A

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

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

        \[\leadsto \color{blue}{i \cdot c} + y \cdot x \]
      5. lower-fma.f6435.9

        \[\leadsto \color{blue}{\mathsf{fma}\left(i, c, y \cdot x\right)} \]
    6. Applied rewrites35.9%

      \[\leadsto \color{blue}{\mathsf{fma}\left(i, c, y \cdot x\right)} \]
    7. Taylor expanded in z around inf

      \[\leadsto \mathsf{fma}\left(i, c, \color{blue}{t \cdot z}\right) \]
    8. Step-by-step derivation
      1. lift-*.f6468.2

        \[\leadsto \mathsf{fma}\left(i, c, t \cdot \color{blue}{z}\right) \]
    9. Applied rewrites68.2%

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

Alternative 5: 66.5% accurate, 0.6× speedup?

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

\\
\begin{array}{l}
t_1 := \mathsf{fma}\left(i, c, b \cdot a\right)\\
t_2 := \mathsf{fma}\left(b, a, y \cdot x\right)\\
\mathbf{if}\;x \cdot y \leq -5 \cdot 10^{+119}:\\
\;\;\;\;t\_2\\

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

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

\mathbf{elif}\;x \cdot y \leq 2 \cdot 10^{+133}:\\
\;\;\;\;t\_1\\

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


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

    1. Initial program 92.5%

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

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

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

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

        \[\leadsto b \cdot a + \left(\color{blue}{x \cdot y} + z \cdot 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, z \cdot t + x \cdot y\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-*.f6485.2

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

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

      \[\leadsto \mathsf{fma}\left(b, a, x \cdot y\right) \]
    6. Step-by-step derivation
      1. *-commutativeN/A

        \[\leadsto \mathsf{fma}\left(b, a, y \cdot x\right) \]
      2. lift-*.f6475.5

        \[\leadsto \mathsf{fma}\left(b, a, y \cdot x\right) \]
    7. Applied rewrites75.5%

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

    if -4.9999999999999999e119 < (*.f64 x y) < -2.0000000000000002e-208 or 2.0000000000019e-312 < (*.f64 x y) < 2e133

    1. Initial program 97.6%

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

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

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

        \[\leadsto b \cdot \color{blue}{a} + c \cdot i \]
    4. Applied rewrites60.3%

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

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

        \[\leadsto \color{blue}{b \cdot a + 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.f6460.7

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

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

    if -2.0000000000000002e-208 < (*.f64 x y) < 2.0000000000019e-312

    1. Initial program 97.4%

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

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

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

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

        \[\leadsto b \cdot a + \left(\color{blue}{x \cdot y} + z \cdot 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, z \cdot t + x \cdot y\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-*.f6467.1

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

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

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

        \[\leadsto \mathsf{fma}\left(b, a, t \cdot z\right) \]
    7. Applied rewrites66.9%

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

Alternative 6: 63.3% accurate, 0.7× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;c \cdot i \leq -5 \cdot 10^{+79}:\\
\;\;\;\;i \cdot c\\

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

\mathbf{elif}\;c \cdot i \leq 5 \cdot 10^{+151}:\\
\;\;\;\;\mathsf{fma}\left(b, a, y \cdot x\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if (*.f64 c i) < -5e79 or 5.0000000000000002e151 < (*.f64 c i)

    1. Initial program 91.5%

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

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

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

        \[\leadsto i \cdot \color{blue}{c} \]
    4. Applied rewrites65.2%

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

    if -5e79 < (*.f64 c i) < -4.9999999999999999e-161

    1. Initial program 98.2%

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

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

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

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

        \[\leadsto b \cdot a + \left(\color{blue}{x \cdot y} + z \cdot 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, z \cdot t + x \cdot y\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-*.f6490.3

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

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

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

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

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

    if -4.9999999999999999e-161 < (*.f64 c i) < 5.0000000000000002e151

    1. Initial program 98.1%

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

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

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

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

        \[\leadsto b \cdot a + \left(\color{blue}{x \cdot y} + z \cdot 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, z \cdot t + x \cdot y\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-*.f6492.0

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

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

      \[\leadsto \mathsf{fma}\left(b, a, x \cdot y\right) \]
    6. Step-by-step derivation
      1. *-commutativeN/A

        \[\leadsto \mathsf{fma}\left(b, a, y \cdot x\right) \]
      2. lift-*.f6462.8

        \[\leadsto \mathsf{fma}\left(b, a, y \cdot x\right) \]
    7. Applied rewrites62.8%

      \[\leadsto \mathsf{fma}\left(b, a, y \cdot x\right) \]
  3. Recombined 3 regimes into one program.
  4. Add Preprocessing

Alternative 7: 62.8% accurate, 0.9× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \cdot y \leq -2 \cdot 10^{+168}:\\ \;\;\;\;y \cdot x\\ \mathbf{elif}\;x \cdot y \leq 4 \cdot 10^{+118}:\\ \;\;\;\;\mathsf{fma}\left(b, a, t \cdot z\right)\\ \mathbf{else}:\\ \;\;\;\;y \cdot x\\ \end{array} \end{array} \]
(FPCore (x y z t a b c i)
 :precision binary64
 (if (<= (* x y) -2e+168)
   (* y x)
   (if (<= (* x y) 4e+118) (fma b a (* t z)) (* 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) <= -2e+168) {
		tmp = y * x;
	} else if ((x * y) <= 4e+118) {
		tmp = fma(b, a, (t * z));
	} else {
		tmp = y * x;
	}
	return tmp;
}
function code(x, y, z, t, a, b, c, i)
	tmp = 0.0
	if (Float64(x * y) <= -2e+168)
		tmp = Float64(y * x);
	elseif (Float64(x * y) <= 4e+118)
		tmp = fma(b, a, Float64(t * z));
	else
		tmp = Float64(y * x);
	end
	return tmp
end
code[x_, y_, z_, t_, a_, b_, c_, i_] := If[LessEqual[N[(x * y), $MachinePrecision], -2e+168], N[(y * x), $MachinePrecision], If[LessEqual[N[(x * y), $MachinePrecision], 4e+118], N[(b * a + N[(t * z), $MachinePrecision]), $MachinePrecision], N[(y * x), $MachinePrecision]]]
\begin{array}{l}

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (*.f64 x y) < -1.9999999999999999e168 or 3.99999999999999987e118 < (*.f64 x y)

    1. Initial program 92.1%

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

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

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

        \[\leadsto y \cdot \color{blue}{x} \]
    4. Applied rewrites66.3%

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

    if -1.9999999999999999e168 < (*.f64 x y) < 3.99999999999999987e118

    1. Initial program 97.6%

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

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

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

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

        \[\leadsto b \cdot a + \left(\color{blue}{x \cdot y} + z \cdot 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, z \cdot t + x \cdot y\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-*.f6470.0

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

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

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

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

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

Alternative 8: 43.6% accurate, 0.7× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \cdot y \leq -2.5 \cdot 10^{+100}:\\ \;\;\;\;y \cdot x\\ \mathbf{elif}\;x \cdot y \leq -4 \cdot 10^{-130}:\\ \;\;\;\;b \cdot a\\ \mathbf{elif}\;x \cdot y \leq 2 \cdot 10^{-312}:\\ \;\;\;\;t \cdot z\\ \mathbf{elif}\;x \cdot y \leq 2 \cdot 10^{+142}:\\ \;\;\;\;i \cdot c\\ \mathbf{else}:\\ \;\;\;\;y \cdot x\\ \end{array} \end{array} \]
(FPCore (x y z t a b c i)
 :precision binary64
 (if (<= (* x y) -2.5e+100)
   (* y x)
   (if (<= (* x y) -4e-130)
     (* b a)
     (if (<= (* x y) 2e-312)
       (* t z)
       (if (<= (* x y) 2e+142) (* i c) (* 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) <= -2.5e+100) {
		tmp = y * x;
	} else if ((x * y) <= -4e-130) {
		tmp = b * a;
	} else if ((x * y) <= 2e-312) {
		tmp = t * z;
	} else if ((x * y) <= 2e+142) {
		tmp = i * c;
	} 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) <= (-2.5d+100)) then
        tmp = y * x
    else if ((x * y) <= (-4d-130)) then
        tmp = b * a
    else if ((x * y) <= 2d-312) then
        tmp = t * z
    else if ((x * y) <= 2d+142) then
        tmp = i * c
    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) <= -2.5e+100) {
		tmp = y * x;
	} else if ((x * y) <= -4e-130) {
		tmp = b * a;
	} else if ((x * y) <= 2e-312) {
		tmp = t * z;
	} else if ((x * y) <= 2e+142) {
		tmp = i * c;
	} else {
		tmp = y * x;
	}
	return tmp;
}
def code(x, y, z, t, a, b, c, i):
	tmp = 0
	if (x * y) <= -2.5e+100:
		tmp = y * x
	elif (x * y) <= -4e-130:
		tmp = b * a
	elif (x * y) <= 2e-312:
		tmp = t * z
	elif (x * y) <= 2e+142:
		tmp = i * c
	else:
		tmp = y * x
	return tmp
function code(x, y, z, t, a, b, c, i)
	tmp = 0.0
	if (Float64(x * y) <= -2.5e+100)
		tmp = Float64(y * x);
	elseif (Float64(x * y) <= -4e-130)
		tmp = Float64(b * a);
	elseif (Float64(x * y) <= 2e-312)
		tmp = Float64(t * z);
	elseif (Float64(x * y) <= 2e+142)
		tmp = Float64(i * c);
	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) <= -2.5e+100)
		tmp = y * x;
	elseif ((x * y) <= -4e-130)
		tmp = b * a;
	elseif ((x * y) <= 2e-312)
		tmp = t * z;
	elseif ((x * y) <= 2e+142)
		tmp = i * c;
	else
		tmp = y * x;
	end
	tmp_2 = tmp;
end
code[x_, y_, z_, t_, a_, b_, c_, i_] := If[LessEqual[N[(x * y), $MachinePrecision], -2.5e+100], N[(y * x), $MachinePrecision], If[LessEqual[N[(x * y), $MachinePrecision], -4e-130], N[(b * a), $MachinePrecision], If[LessEqual[N[(x * y), $MachinePrecision], 2e-312], N[(t * z), $MachinePrecision], If[LessEqual[N[(x * y), $MachinePrecision], 2e+142], N[(i * c), $MachinePrecision], N[(y * x), $MachinePrecision]]]]]
\begin{array}{l}

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

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

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

\mathbf{elif}\;x \cdot y \leq 2 \cdot 10^{+142}:\\
\;\;\;\;i \cdot c\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if (*.f64 x y) < -2.4999999999999999e100 or 2.0000000000000001e142 < (*.f64 x y)

    1. Initial program 92.5%

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

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

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

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

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

    if -2.4999999999999999e100 < (*.f64 x y) < -4.0000000000000003e-130

    1. Initial program 98.1%

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

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

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

        \[\leadsto b \cdot \color{blue}{a} \]
    4. Applied rewrites30.9%

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

    if -4.0000000000000003e-130 < (*.f64 x y) < 2.0000000000019e-312

    1. Initial program 97.3%

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

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

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

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

    if 2.0000000000019e-312 < (*.f64 x y) < 2.0000000000000001e142

    1. Initial program 97.6%

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

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

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

        \[\leadsto i \cdot \color{blue}{c} \]
    4. Applied rewrites32.6%

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

Alternative 9: 43.3% accurate, 1.2× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;c \cdot i \leq -5 \cdot 10^{+79}:\\ \;\;\;\;i \cdot c\\ \mathbf{elif}\;c \cdot i \leq 5 \cdot 10^{+55}:\\ \;\;\;\;b \cdot a\\ \mathbf{else}:\\ \;\;\;\;i \cdot c\\ \end{array} \end{array} \]
(FPCore (x y z t a b c i)
 :precision binary64
 (if (<= (* c i) -5e+79) (* i c) (if (<= (* c i) 5e+55) (* 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 ((c * i) <= -5e+79) {
		tmp = i * c;
	} else if ((c * i) <= 5e+55) {
		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 ((c * i) <= (-5d+79)) then
        tmp = i * c
    else if ((c * i) <= 5d+55) 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 ((c * i) <= -5e+79) {
		tmp = i * c;
	} else if ((c * i) <= 5e+55) {
		tmp = b * a;
	} else {
		tmp = i * c;
	}
	return tmp;
}
def code(x, y, z, t, a, b, c, i):
	tmp = 0
	if (c * i) <= -5e+79:
		tmp = i * c
	elif (c * i) <= 5e+55:
		tmp = b * a
	else:
		tmp = i * c
	return tmp
function code(x, y, z, t, a, b, c, i)
	tmp = 0.0
	if (Float64(c * i) <= -5e+79)
		tmp = Float64(i * c);
	elseif (Float64(c * i) <= 5e+55)
		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 ((c * i) <= -5e+79)
		tmp = i * c;
	elseif ((c * i) <= 5e+55)
		tmp = b * a;
	else
		tmp = i * c;
	end
	tmp_2 = tmp;
end
code[x_, y_, z_, t_, a_, b_, c_, i_] := If[LessEqual[N[(c * i), $MachinePrecision], -5e+79], N[(i * c), $MachinePrecision], If[LessEqual[N[(c * i), $MachinePrecision], 5e+55], N[(b * a), $MachinePrecision], N[(i * c), $MachinePrecision]]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;c \cdot i \leq -5 \cdot 10^{+79}:\\
\;\;\;\;i \cdot c\\

\mathbf{elif}\;c \cdot i \leq 5 \cdot 10^{+55}:\\
\;\;\;\;b \cdot a\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (*.f64 c i) < -5e79 or 5.00000000000000046e55 < (*.f64 c i)

    1. Initial program 92.6%

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

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

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

        \[\leadsto i \cdot \color{blue}{c} \]
    4. Applied rewrites59.9%

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

    if -5e79 < (*.f64 c i) < 5.00000000000000046e55

    1. Initial program 98.1%

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

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

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

        \[\leadsto b \cdot \color{blue}{a} \]
    4. Applied rewrites33.0%

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

Alternative 10: 27.1% accurate, 5.3× 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 96.0%

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

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

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

      \[\leadsto b \cdot \color{blue}{a} \]
  4. Applied rewrites27.1%

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

Reproduce

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