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

Percentage Accurate: 95.8% → 97.0%
Time: 4.6s
Alternatives: 14
Speedup: 1.2×

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 14 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: 95.8% 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.0% accurate, 1.2× speedup?

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

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

    \[\left(\left(x \cdot y + z \cdot t\right) + a \cdot b\right) + c \cdot i \]
  2. Add Preprocessing
  3. Step-by-step derivation
    1. lift-+.f64N/A

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

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

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

      \[\leadsto \left(\left(x \cdot y + z \cdot t\right) + \color{blue}{a \cdot b}\right) + c \cdot i \]
    5. associate-+l+N/A

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

      \[\leadsto \left(\color{blue}{y \cdot x} + \left(z \cdot t + a \cdot b\right)\right) + c \cdot i \]
    7. lift-*.f64N/A

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

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

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

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

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

      \[\leadsto \mathsf{fma}\left(y, x, \color{blue}{\mathsf{fma}\left(b, a, t \cdot z\right)}\right) + c \cdot i \]
    13. lower-*.f6497.7

      \[\leadsto \mathsf{fma}\left(y, x, \mathsf{fma}\left(b, a, \color{blue}{t \cdot z}\right)\right) + c \cdot i \]
  4. Applied rewrites97.7%

    \[\leadsto \color{blue}{\mathsf{fma}\left(y, x, \mathsf{fma}\left(b, a, t \cdot z\right)\right)} + c \cdot i \]
  5. Add Preprocessing

Alternative 2: 75.6% accurate, 0.4× speedup?

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

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

\mathbf{elif}\;t\_2 \leq 2 \cdot 10^{+52}:\\
\;\;\;\;\mathsf{fma}\left(i, c, a \cdot b\right)\\

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if (+.f64 (*.f64 x y) (*.f64 z t)) < -4.99999999999999977e170 or 1.0000000000000001e235 < (+.f64 (*.f64 x y) (*.f64 z t))

    1. Initial program 88.6%

      \[\left(\left(x \cdot y + z \cdot t\right) + a \cdot b\right) + c \cdot i \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. lift-+.f64N/A

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

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

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

        \[\leadsto \left(\left(x \cdot y + z \cdot t\right) + \color{blue}{a \cdot b}\right) + c \cdot i \]
      5. associate-+l+N/A

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

        \[\leadsto \left(\color{blue}{y \cdot x} + \left(z \cdot t + a \cdot b\right)\right) + c \cdot i \]
      7. lift-*.f64N/A

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

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

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

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

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

        \[\leadsto \mathsf{fma}\left(y, x, \color{blue}{\mathsf{fma}\left(b, a, t \cdot z\right)}\right) + c \cdot i \]
      13. lower-*.f6493.8

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

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

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

        \[\leadsto c \cdot i + \left(t \cdot z + x \cdot y\right) \]
      2. *-commutativeN/A

        \[\leadsto c \cdot i + \left(t \cdot z + x \cdot y\right) \]
      3. +-commutativeN/A

        \[\leadsto c \cdot i + \left(t \cdot z + x \cdot y\right) \]
      4. *-commutativeN/A

        \[\leadsto c \cdot i + \left(t \cdot z + x \cdot y\right) \]
      5. associate-+l+N/A

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

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

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

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

        \[\leadsto \mathsf{fma}\left(i, c, \mathsf{fma}\left(z, t, x \cdot y\right)\right) \]
      10. lower-*.f6490.7

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

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

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

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

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

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

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

    if -4.99999999999999977e170 < (+.f64 (*.f64 x y) (*.f64 z t)) < 2e52

    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} + c \cdot i \]
    4. Step-by-step derivation
      1. *-commutativeN/A

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

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

      \[\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.0

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

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

        \[\leadsto \mathsf{fma}\left(i, c, a \cdot \color{blue}{b}\right) \]
      8. lower-*.f6481.0

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

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

    if 2e52 < (+.f64 (*.f64 x y) (*.f64 z t)) < 1.0000000000000001e235

    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 x around inf

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

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

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

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

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

        \[\leadsto y \cdot x + \color{blue}{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.f6476.6

        \[\leadsto \color{blue}{\mathsf{fma}\left(i, c, y \cdot x\right)} \]
      6. lift-*.f64N/A

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

        \[\leadsto \mathsf{fma}\left(i, c, x \cdot \color{blue}{y}\right) \]
      8. lower-*.f6476.6

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

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

Alternative 3: 43.3% accurate, 0.6× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \cdot y \leq -5 \cdot 10^{+128}:\\ \;\;\;\;y \cdot x\\ \mathbf{elif}\;x \cdot y \leq 2 \cdot 10^{-247}:\\ \;\;\;\;i \cdot c\\ \mathbf{elif}\;x \cdot y \leq 5 \cdot 10^{-208}:\\ \;\;\;\;t \cdot z\\ \mathbf{elif}\;x \cdot y \leq 10^{+31}:\\ \;\;\;\;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+128)
   (* y x)
   (if (<= (* x y) 2e-247)
     (* i c)
     (if (<= (* x y) 5e-208)
       (* t z)
       (if (<= (* x y) 1e+31) (* 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+128) {
		tmp = y * x;
	} else if ((x * y) <= 2e-247) {
		tmp = i * c;
	} else if ((x * y) <= 5e-208) {
		tmp = t * z;
	} else if ((x * y) <= 1e+31) {
		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+128)) then
        tmp = y * x
    else if ((x * y) <= 2d-247) then
        tmp = i * c
    else if ((x * y) <= 5d-208) then
        tmp = t * z
    else if ((x * y) <= 1d+31) 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+128) {
		tmp = y * x;
	} else if ((x * y) <= 2e-247) {
		tmp = i * c;
	} else if ((x * y) <= 5e-208) {
		tmp = t * z;
	} else if ((x * y) <= 1e+31) {
		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+128:
		tmp = y * x
	elif (x * y) <= 2e-247:
		tmp = i * c
	elif (x * y) <= 5e-208:
		tmp = t * z
	elif (x * y) <= 1e+31:
		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+128)
		tmp = Float64(y * x);
	elseif (Float64(x * y) <= 2e-247)
		tmp = Float64(i * c);
	elseif (Float64(x * y) <= 5e-208)
		tmp = Float64(t * z);
	elseif (Float64(x * y) <= 1e+31)
		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+128)
		tmp = y * x;
	elseif ((x * y) <= 2e-247)
		tmp = i * c;
	elseif ((x * y) <= 5e-208)
		tmp = t * z;
	elseif ((x * y) <= 1e+31)
		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+128], N[(y * x), $MachinePrecision], If[LessEqual[N[(x * y), $MachinePrecision], 2e-247], N[(i * c), $MachinePrecision], If[LessEqual[N[(x * y), $MachinePrecision], 5e-208], N[(t * z), $MachinePrecision], If[LessEqual[N[(x * y), $MachinePrecision], 1e+31], N[(b * a), $MachinePrecision], N[(y * x), $MachinePrecision]]]]]
\begin{array}{l}

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

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

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if (*.f64 x y) < -5e128 or 9.9999999999999996e30 < (*.f64 x y)

    1. Initial program 91.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-*.f6466.7

        \[\leadsto y \cdot \color{blue}{x} \]
    5. Applied rewrites66.7%

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

    if -5e128 < (*.f64 x y) < 2e-247

    1. Initial program 99.0%

      \[\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.6

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

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

    if 2e-247 < (*.f64 x y) < 4.99999999999999963e-208

    1. Initial program 85.7%

      \[\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-*.f6485.8

        \[\leadsto t \cdot \color{blue}{z} \]
    5. Applied rewrites85.8%

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

    if 4.99999999999999963e-208 < (*.f64 x y) < 9.9999999999999996e30

    1. Initial program 97.7%

      \[\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-*.f6448.0

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

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

Alternative 4: 76.6% accurate, 0.6× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_1 := x \cdot y + z \cdot t\\ \mathbf{if}\;t\_1 \leq -5 \cdot 10^{+170} \lor \neg \left(t\_1 \leq 5 \cdot 10^{+119}\right):\\ \;\;\;\;\mathsf{fma}\left(z, t, x \cdot y\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(i, c, a \cdot b\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 -5e+170) (not (<= t_1 5e+119)))
     (fma z t (* x y))
     (fma i c (* a b)))))
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 <= -5e+170) || !(t_1 <= 5e+119)) {
		tmp = fma(z, t, (x * y));
	} else {
		tmp = fma(i, c, (a * b));
	}
	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 <= -5e+170) || !(t_1 <= 5e+119))
		tmp = fma(z, t, Float64(x * y));
	else
		tmp = fma(i, c, Float64(a * b));
	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, -5e+170], N[Not[LessEqual[t$95$1, 5e+119]], $MachinePrecision]], N[(z * t + N[(x * y), $MachinePrecision]), $MachinePrecision], N[(i * c + N[(a * b), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (+.f64 (*.f64 x y) (*.f64 z t)) < -4.99999999999999977e170 or 4.9999999999999999e119 < (+.f64 (*.f64 x y) (*.f64 z t))

    1. Initial program 90.5%

      \[\left(\left(x \cdot y + z \cdot t\right) + a \cdot b\right) + c \cdot i \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. lift-+.f64N/A

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

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

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

        \[\leadsto \left(\left(x \cdot y + z \cdot t\right) + \color{blue}{a \cdot b}\right) + c \cdot i \]
      5. associate-+l+N/A

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

        \[\leadsto \left(\color{blue}{y \cdot x} + \left(z \cdot t + a \cdot b\right)\right) + c \cdot i \]
      7. lift-*.f64N/A

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

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

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

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

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

        \[\leadsto \mathsf{fma}\left(y, x, \color{blue}{\mathsf{fma}\left(b, a, t \cdot z\right)}\right) + c \cdot i \]
      13. lower-*.f6494.8

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

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

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

        \[\leadsto c \cdot i + \left(t \cdot z + x \cdot y\right) \]
      2. *-commutativeN/A

        \[\leadsto c \cdot i + \left(t \cdot z + x \cdot y\right) \]
      3. +-commutativeN/A

        \[\leadsto c \cdot i + \left(t \cdot z + x \cdot y\right) \]
      4. *-commutativeN/A

        \[\leadsto c \cdot i + \left(t \cdot z + x \cdot y\right) \]
      5. associate-+l+N/A

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

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

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

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

        \[\leadsto \mathsf{fma}\left(i, c, \mathsf{fma}\left(z, t, x \cdot y\right)\right) \]
      10. lower-*.f6491.4

        \[\leadsto \mathsf{fma}\left(i, c, \mathsf{fma}\left(z, t, x \cdot y\right)\right) \]
    7. Applied rewrites91.4%

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

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

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

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

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

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

    if -4.99999999999999977e170 < (+.f64 (*.f64 x y) (*.f64 z t)) < 4.9999999999999999e119

    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} + c \cdot i \]
    4. Step-by-step derivation
      1. *-commutativeN/A

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

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

      \[\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.f6478.9

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

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

        \[\leadsto \mathsf{fma}\left(i, c, a \cdot \color{blue}{b}\right) \]
      8. lower-*.f6478.9

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

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

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

Alternative 5: 63.5% accurate, 0.7× speedup?

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

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

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if (*.f64 c i) < -1.00000000000000002e234 or 9.9999999999999993e158 < (*.f64 c i)

    1. Initial program 93.3%

      \[\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-*.f6484.9

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

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

    if -1.00000000000000002e234 < (*.f64 c i) < 2.00000000000000013e-301

    1. Initial program 97.4%

      \[\left(\left(x \cdot y + z \cdot t\right) + a \cdot b\right) + c \cdot i \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. lift-+.f64N/A

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

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

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

        \[\leadsto \left(\left(x \cdot y + z \cdot t\right) + \color{blue}{a \cdot b}\right) + c \cdot i \]
      5. associate-+l+N/A

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

        \[\leadsto \left(\color{blue}{y \cdot x} + \left(z \cdot t + a \cdot b\right)\right) + c \cdot i \]
      7. lift-*.f64N/A

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

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

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

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

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

        \[\leadsto \mathsf{fma}\left(y, x, \color{blue}{\mathsf{fma}\left(b, a, t \cdot z\right)}\right) + c \cdot i \]
      13. lower-*.f6499.2

        \[\leadsto \mathsf{fma}\left(y, x, \mathsf{fma}\left(b, a, \color{blue}{t \cdot z}\right)\right) + c \cdot i \]
    4. Applied rewrites99.2%

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

      \[\leadsto \mathsf{fma}\left(y, x, \color{blue}{a \cdot b}\right) + c \cdot i \]
    6. Step-by-step derivation
      1. lower-*.f6481.8

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

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

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

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

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

        \[\leadsto a \cdot b + \left(t \cdot z + x \cdot y\right) \]
      4. *-commutativeN/A

        \[\leadsto a \cdot b + \left(t \cdot z + x \cdot y\right) \]
      5. associate-+l+N/A

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

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

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

        \[\leadsto \left(x \cdot y + z \cdot t\right) + a \cdot b \]
      9. associate-+l+N/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 2.00000000000000013e-301 < (*.f64 c i) < 9.9999999999999993e158

    1. Initial program 94.9%

      \[\left(\left(x \cdot y + z \cdot t\right) + a \cdot b\right) + c \cdot i \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. lift-+.f64N/A

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

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

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

        \[\leadsto \left(\left(x \cdot y + z \cdot t\right) + \color{blue}{a \cdot b}\right) + c \cdot i \]
      5. associate-+l+N/A

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

        \[\leadsto \left(\color{blue}{y \cdot x} + \left(z \cdot t + a \cdot b\right)\right) + c \cdot i \]
      7. lift-*.f64N/A

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

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

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

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

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

        \[\leadsto \mathsf{fma}\left(y, x, \color{blue}{\mathsf{fma}\left(b, a, t \cdot z\right)}\right) + c \cdot i \]
      13. lower-*.f6498.7

        \[\leadsto \mathsf{fma}\left(y, x, \mathsf{fma}\left(b, a, \color{blue}{t \cdot z}\right)\right) + c \cdot i \]
    4. Applied rewrites98.7%

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

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

        \[\leadsto c \cdot i + \left(t \cdot z + x \cdot y\right) \]
      2. *-commutativeN/A

        \[\leadsto c \cdot i + \left(t \cdot z + x \cdot y\right) \]
      3. +-commutativeN/A

        \[\leadsto c \cdot i + \left(t \cdot z + x \cdot y\right) \]
      4. *-commutativeN/A

        \[\leadsto c \cdot i + \left(t \cdot z + x \cdot y\right) \]
      5. associate-+l+N/A

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

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

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

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

        \[\leadsto \mathsf{fma}\left(i, c, \mathsf{fma}\left(z, t, x \cdot y\right)\right) \]
      10. lower-*.f6478.8

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

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

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

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

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

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

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

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

Alternative 6: 62.9% accurate, 0.7× speedup?

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

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

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if (*.f64 c i) < -1.00000000000000002e234 or 9.9999999999999993e158 < (*.f64 c i)

    1. Initial program 93.3%

      \[\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-*.f6484.9

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

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

    if -1.00000000000000002e234 < (*.f64 c i) < -1.00000000000000005e-230

    1. Initial program 97.5%

      \[\left(\left(x \cdot y + z \cdot t\right) + a \cdot b\right) + c \cdot i \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. lift-+.f64N/A

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

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

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

        \[\leadsto \left(\left(x \cdot y + z \cdot t\right) + \color{blue}{a \cdot b}\right) + c \cdot i \]
      5. associate-+l+N/A

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

        \[\leadsto \left(\color{blue}{y \cdot x} + \left(z \cdot t + a \cdot b\right)\right) + c \cdot i \]
      7. lift-*.f64N/A

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

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

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

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

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

        \[\leadsto \mathsf{fma}\left(y, x, \color{blue}{\mathsf{fma}\left(b, a, t \cdot z\right)}\right) + c \cdot i \]
      13. lower-*.f64100.0

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

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

      \[\leadsto \mathsf{fma}\left(y, x, \color{blue}{a \cdot b}\right) + c \cdot i \]
    6. Step-by-step derivation
      1. lower-*.f6480.9

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

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

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

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

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

        \[\leadsto a \cdot b + \left(t \cdot z + x \cdot y\right) \]
      4. *-commutativeN/A

        \[\leadsto a \cdot b + \left(t \cdot z + x \cdot y\right) \]
      5. associate-+l+N/A

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

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

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

        \[\leadsto \left(x \cdot y + z \cdot t\right) + a \cdot b \]
      9. associate-+l+N/A

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto a \cdot b + t \cdot z \]
      2. associate-+l+N/A

        \[\leadsto a \cdot b + \color{blue}{t} \cdot z \]
      3. *-commutativeN/A

        \[\leadsto b \cdot a + t \cdot z \]
      4. lower-fma.f64N/A

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

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

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

    if -1.00000000000000005e-230 < (*.f64 c i) < 9.9999999999999993e158

    1. Initial program 95.6%

      \[\left(\left(x \cdot y + z \cdot t\right) + a \cdot b\right) + c \cdot i \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. lift-+.f64N/A

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

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

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

        \[\leadsto \left(\left(x \cdot y + z \cdot t\right) + \color{blue}{a \cdot b}\right) + c \cdot i \]
      5. associate-+l+N/A

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

        \[\leadsto \left(\color{blue}{y \cdot x} + \left(z \cdot t + a \cdot b\right)\right) + c \cdot i \]
      7. lift-*.f64N/A

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

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

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

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

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

        \[\leadsto \mathsf{fma}\left(y, x, \color{blue}{\mathsf{fma}\left(b, a, t \cdot z\right)}\right) + c \cdot i \]
      13. lower-*.f6498.2

        \[\leadsto \mathsf{fma}\left(y, x, \mathsf{fma}\left(b, a, \color{blue}{t \cdot z}\right)\right) + c \cdot i \]
    4. Applied rewrites98.2%

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

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

        \[\leadsto c \cdot i + \left(t \cdot z + x \cdot y\right) \]
      2. *-commutativeN/A

        \[\leadsto c \cdot i + \left(t \cdot z + x \cdot y\right) \]
      3. +-commutativeN/A

        \[\leadsto c \cdot i + \left(t \cdot z + x \cdot y\right) \]
      4. *-commutativeN/A

        \[\leadsto c \cdot i + \left(t \cdot z + x \cdot y\right) \]
      5. associate-+l+N/A

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

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

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

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

        \[\leadsto \mathsf{fma}\left(i, c, \mathsf{fma}\left(z, t, x \cdot y\right)\right) \]
      10. lower-*.f6474.4

        \[\leadsto \mathsf{fma}\left(i, c, \mathsf{fma}\left(z, t, x \cdot y\right)\right) \]
    7. Applied rewrites74.4%

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

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

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

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

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

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

Alternative 7: 87.2% accurate, 0.7× speedup?

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

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if (*.f64 z t) < -2.00000000000000014e174

    1. Initial program 92.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 0

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

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

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

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

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

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

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

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

        \[\leadsto \mathsf{fma}\left(i, c, \mathsf{fma}\left(t, z, y \cdot x\right)\right) \]
      9. lower-*.f6496.2

        \[\leadsto \mathsf{fma}\left(i, c, \mathsf{fma}\left(t, z, y \cdot x\right)\right) \]
    5. Applied rewrites96.2%

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

    if -2.00000000000000014e174 < (*.f64 z t) < 1.0000000000000001e235

    1. Initial program 97.6%

      \[\left(\left(x \cdot y + z \cdot t\right) + a \cdot b\right) + c \cdot i \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. lift-+.f64N/A

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

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

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

        \[\leadsto \left(\left(x \cdot y + z \cdot t\right) + \color{blue}{a \cdot b}\right) + c \cdot i \]
      5. associate-+l+N/A

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

        \[\leadsto \left(\color{blue}{y \cdot x} + \left(z \cdot t + a \cdot b\right)\right) + c \cdot i \]
      7. lift-*.f64N/A

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

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

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

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

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

        \[\leadsto \mathsf{fma}\left(y, x, \color{blue}{\mathsf{fma}\left(b, a, t \cdot z\right)}\right) + c \cdot i \]
      13. lower-*.f6498.6

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

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

      \[\leadsto \mathsf{fma}\left(y, x, \color{blue}{a \cdot b}\right) + c \cdot i \]
    6. Step-by-step derivation
      1. lower-*.f6491.8

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

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

    if 1.0000000000000001e235 < (*.f64 z t)

    1. Initial program 78.9%

      \[\left(\left(x \cdot y + z \cdot t\right) + a \cdot b\right) + c \cdot i \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. lift-+.f64N/A

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

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

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

        \[\leadsto \left(\left(x \cdot y + z \cdot t\right) + \color{blue}{a \cdot b}\right) + c \cdot i \]
      5. associate-+l+N/A

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

        \[\leadsto \left(\color{blue}{y \cdot x} + \left(z \cdot t + a \cdot b\right)\right) + c \cdot i \]
      7. lift-*.f64N/A

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

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

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

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

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

        \[\leadsto \mathsf{fma}\left(y, x, \color{blue}{\mathsf{fma}\left(b, a, t \cdot z\right)}\right) + c \cdot i \]
      13. lower-*.f6489.5

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

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

      \[\leadsto \mathsf{fma}\left(y, x, \color{blue}{a \cdot b}\right) + c \cdot i \]
    6. Step-by-step derivation
      1. lower-*.f6416.5

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

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

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

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

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

        \[\leadsto a \cdot b + \left(t \cdot z + x \cdot y\right) \]
      4. *-commutativeN/A

        \[\leadsto a \cdot b + \left(t \cdot z + x \cdot y\right) \]
      5. associate-+l+N/A

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

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

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

        \[\leadsto \left(x \cdot y + z \cdot t\right) + a \cdot b \]
      9. associate-+l+N/A

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

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

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

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

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

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

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

        \[\leadsto \mathsf{fma}\left(x, y, \mathsf{fma}\left(a, b, z \cdot t\right)\right) \]
      17. lift-*.f6494.7

        \[\leadsto \mathsf{fma}\left(x, y, \mathsf{fma}\left(a, b, z \cdot t\right)\right) \]
    10. Applied rewrites94.7%

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

Alternative 8: 89.2% accurate, 0.7× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;c \cdot i \leq -5 \cdot 10^{+99} \lor \neg \left(c \cdot i \leq 2 \cdot 10^{+93}\right):\\
\;\;\;\;\mathsf{fma}\left(i, c, \mathsf{fma}\left(t, z, y \cdot x\right)\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (*.f64 c i) < -5.00000000000000008e99 or 2.00000000000000009e93 < (*.f64 c i)

    1. Initial program 93.7%

      \[\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 0

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

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

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

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

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

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

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

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

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

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

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

    if -5.00000000000000008e99 < (*.f64 c i) < 2.00000000000000009e93

    1. Initial program 96.9%

      \[\left(\left(x \cdot y + z \cdot t\right) + a \cdot b\right) + c \cdot i \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. lift-+.f64N/A

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

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

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

        \[\leadsto \left(\left(x \cdot y + z \cdot t\right) + \color{blue}{a \cdot b}\right) + c \cdot i \]
      5. associate-+l+N/A

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

        \[\leadsto \left(\color{blue}{y \cdot x} + \left(z \cdot t + a \cdot b\right)\right) + c \cdot i \]
      7. lift-*.f64N/A

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

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

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

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

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

        \[\leadsto \mathsf{fma}\left(y, x, \color{blue}{\mathsf{fma}\left(b, a, t \cdot z\right)}\right) + c \cdot i \]
      13. lower-*.f6499.4

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

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

      \[\leadsto \mathsf{fma}\left(y, x, \color{blue}{a \cdot b}\right) + c \cdot i \]
    6. Step-by-step derivation
      1. lower-*.f6475.8

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

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

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

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

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

        \[\leadsto a \cdot b + \left(t \cdot z + x \cdot y\right) \]
      4. *-commutativeN/A

        \[\leadsto a \cdot b + \left(t \cdot z + x \cdot y\right) \]
      5. associate-+l+N/A

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

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

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

        \[\leadsto \left(x \cdot y + z \cdot t\right) + a \cdot b \]
      9. associate-+l+N/A

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

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

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

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

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

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

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

        \[\leadsto \mathsf{fma}\left(x, y, \mathsf{fma}\left(a, b, z \cdot t\right)\right) \]
      17. lift-*.f6494.1

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

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

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

Alternative 9: 89.0% accurate, 0.7× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_1 := \mathsf{fma}\left(t, z, y \cdot x\right)\\ \mathbf{if}\;c \cdot i \leq -5 \cdot 10^{+99} \lor \neg \left(c \cdot i \leq 2 \cdot 10^{+17}\right):\\ \;\;\;\;\mathsf{fma}\left(i, c, t\_1\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(b, a, t\_1\right)\\ \end{array} \end{array} \]
(FPCore (x y z t a b c i)
 :precision binary64
 (let* ((t_1 (fma t z (* y x))))
   (if (or (<= (* c i) -5e+99) (not (<= (* c i) 2e+17)))
     (fma i c t_1)
     (fma 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 (((c * i) <= -5e+99) || !((c * i) <= 2e+17)) {
		tmp = fma(i, c, t_1);
	} else {
		tmp = fma(b, a, 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(c * i) <= -5e+99) || !(Float64(c * i) <= 2e+17))
		tmp = fma(i, c, t_1);
	else
		tmp = fma(b, a, 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[Or[LessEqual[N[(c * i), $MachinePrecision], -5e+99], N[Not[LessEqual[N[(c * i), $MachinePrecision], 2e+17]], $MachinePrecision]], N[(i * c + t$95$1), $MachinePrecision], N[(b * a + t$95$1), $MachinePrecision]]]
\begin{array}{l}

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (*.f64 c i) < -5.00000000000000008e99 or 2e17 < (*.f64 c i)

    1. Initial program 92.7%

      \[\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 0

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

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

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

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

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

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

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

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

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

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

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

    if -5.00000000000000008e99 < (*.f64 c i) < 2e17

    1. Initial program 97.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-*.f6494.8

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

      \[\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. Final simplification91.7%

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

Alternative 10: 86.6% accurate, 0.7× speedup?

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

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

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

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


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

    1. Initial program 87.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} + c \cdot i \]
    4. Step-by-step derivation
      1. *-commutativeN/A

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

        \[\leadsto b \cdot \color{blue}{a} + c \cdot i \]
    5. Applied rewrites86.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.f6489.9

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

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

        \[\leadsto \mathsf{fma}\left(i, c, a \cdot \color{blue}{b}\right) \]
      8. lower-*.f6489.9

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

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

    if -4.9999999999999999e207 < (*.f64 c i) < 9.9999999999999998e146

    1. Initial program 97.3%

      \[\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-*.f6489.8

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

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

    if 9.9999999999999998e146 < (*.f64 c i)

    1. Initial program 94.4%

      \[\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} + c \cdot i \]
    4. Step-by-step derivation
      1. *-commutativeN/A

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

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

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

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

        \[\leadsto y \cdot x + \color{blue}{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.f6494.6

        \[\leadsto \color{blue}{\mathsf{fma}\left(i, c, y \cdot x\right)} \]
      6. lift-*.f64N/A

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

        \[\leadsto \mathsf{fma}\left(i, c, x \cdot \color{blue}{y}\right) \]
      8. lower-*.f6494.6

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

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

Alternative 11: 43.3% accurate, 0.8× speedup?

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

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

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

\mathbf{elif}\;c \cdot i \leq 5 \cdot 10^{+105}:\\
\;\;\;\;t \cdot z\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if (*.f64 c i) < -9.9999999999999997e98 or 5.00000000000000046e105 < (*.f64 c i)

    1. Initial program 93.4%

      \[\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-*.f6466.8

        \[\leadsto i \cdot \color{blue}{c} \]
    5. Applied rewrites66.8%

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

    if -9.9999999999999997e98 < (*.f64 c i) < 5.0000000000000001e-290

    1. Initial program 98.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-*.f6444.1

        \[\leadsto b \cdot \color{blue}{a} \]
    5. Applied rewrites44.1%

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

    if 5.0000000000000001e-290 < (*.f64 c i) < 5.00000000000000046e105

    1. Initial program 95.4%

      \[\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-*.f6438.9

        \[\leadsto t \cdot \color{blue}{z} \]
    5. Applied rewrites38.9%

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

Alternative 12: 63.6% accurate, 0.9× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;c \cdot i \leq -5 \cdot 10^{+207} \lor \neg \left(c \cdot i \leq 10^{+159}\right):\\
\;\;\;\;i \cdot c\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (*.f64 c i) < -4.9999999999999999e207 or 9.9999999999999993e158 < (*.f64 c i)

    1. Initial program 92.3%

      \[\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-*.f6481.7

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

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

    if -4.9999999999999999e207 < (*.f64 c i) < 9.9999999999999993e158

    1. Initial program 96.8%

      \[\left(\left(x \cdot y + z \cdot t\right) + a \cdot b\right) + c \cdot i \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. lift-+.f64N/A

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

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

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

        \[\leadsto \left(\left(x \cdot y + z \cdot t\right) + \color{blue}{a \cdot b}\right) + c \cdot i \]
      5. associate-+l+N/A

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

        \[\leadsto \left(\color{blue}{y \cdot x} + \left(z \cdot t + a \cdot b\right)\right) + c \cdot i \]
      7. lift-*.f64N/A

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

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

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

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

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

        \[\leadsto \mathsf{fma}\left(y, x, \color{blue}{\mathsf{fma}\left(b, a, t \cdot z\right)}\right) + c \cdot i \]
      13. lower-*.f6498.9

        \[\leadsto \mathsf{fma}\left(y, x, \mathsf{fma}\left(b, a, \color{blue}{t \cdot z}\right)\right) + c \cdot i \]
    4. Applied rewrites98.9%

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

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

        \[\leadsto c \cdot i + \left(t \cdot z + x \cdot y\right) \]
      2. *-commutativeN/A

        \[\leadsto c \cdot i + \left(t \cdot z + x \cdot y\right) \]
      3. +-commutativeN/A

        \[\leadsto c \cdot i + \left(t \cdot z + x \cdot y\right) \]
      4. *-commutativeN/A

        \[\leadsto c \cdot i + \left(t \cdot z + x \cdot y\right) \]
      5. associate-+l+N/A

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

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

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

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

        \[\leadsto \mathsf{fma}\left(i, c, \mathsf{fma}\left(z, t, x \cdot y\right)\right) \]
      10. lower-*.f6469.5

        \[\leadsto \mathsf{fma}\left(i, c, \mathsf{fma}\left(z, t, x \cdot y\right)\right) \]
    7. Applied rewrites69.5%

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

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

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

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

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

      \[\leadsto \mathsf{fma}\left(z, \color{blue}{t}, x \cdot y\right) \]
  3. Recombined 2 regimes into one program.
  4. Final simplification66.1%

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

Alternative 13: 42.9% accurate, 1.1× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;c \cdot i \leq -1 \cdot 10^{+99} \lor \neg \left(c \cdot i \leq 2 \cdot 10^{+17}\right):\\
\;\;\;\;i \cdot c\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (*.f64 c i) < -9.9999999999999997e98 or 2e17 < (*.f64 c i)

    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 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-*.f6458.7

        \[\leadsto i \cdot \color{blue}{c} \]
    5. Applied rewrites58.7%

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

    if -9.9999999999999997e98 < (*.f64 c i) < 2e17

    1. Initial program 97.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-*.f6436.5

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

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

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

Alternative 14: 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.7%

    \[\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-*.f6427.7

      \[\leadsto b \cdot \color{blue}{a} \]
  5. Applied rewrites27.7%

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

Reproduce

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