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

Percentage Accurate: 95.6% → 97.7%
Time: 3.7s
Alternatives: 13
Speedup: 1.3×

Specification

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

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

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

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

Local Percentage Accuracy vs ?

The average percentage accuracy by input value. Horizontal axis shows value of an input variable; the variable is choosen in the title. Vertical axis is accuracy; higher is better. Red represent the original program, while blue represents Herbie's suggestion. These can be toggled with buttons below the plot. The line is an average while dots represent individual samples.

Accuracy vs Speed?

Herbie found 13 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.6% 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.7% accurate, 1.3× speedup?

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

\\
\mathsf{fma}\left(i, c, \mathsf{fma}\left(b, a, \mathsf{fma}\left(t, z, y \cdot x\right)\right)\right)
\end{array}
Derivation
  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 \color{blue}{\left(\left(x \cdot y + z \cdot t\right) + a \cdot b\right)} + c \cdot i \]
    3. lift-+.f64N/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 2: 74.3% accurate, 0.4× speedup?

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

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

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

\mathbf{elif}\;t\_2 \leq 4 \cdot 10^{+113}:\\
\;\;\;\;\mathsf{fma}\left(b, a, c \cdot i\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)) < -9.9999999999999997e266 or 4e113 < (+.f64 (*.f64 x y) (*.f64 z t))

    1. Initial program 91.0%

      \[\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 \color{blue}{\left(\left(x \cdot y + z \cdot t\right) + a \cdot b\right)} + c \cdot i \]
      3. lift-+.f64N/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{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. +-commutativeN/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \mathsf{fma}\left(x, y, t \cdot z\right) \]
    9. Step-by-step derivation
      1. lower-*.f6479.3

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

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

    if -9.9999999999999997e266 < (+.f64 (*.f64 x y) (*.f64 z t)) < -1.00000000000000004e36

    1. Initial program 98.9%

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

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

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

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

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

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

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

        \[\leadsto \mathsf{fma}\left(b, a, \mathsf{fma}\left(i, c, y \cdot x\right)\right) \]
    5. Applied rewrites76.2%

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

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

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

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

    if -1.00000000000000004e36 < (+.f64 (*.f64 x y) (*.f64 z t)) < 4e113

    1. Initial program 99.1%

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

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

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

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

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

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

        \[\leadsto \mathsf{fma}\left(b, a, \mathsf{fma}\left(i, c, y \cdot x\right)\right) \]
      6. lower-*.f6489.7

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

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

      \[\leadsto \mathsf{fma}\left(b, a, c \cdot i\right) \]
    7. Step-by-step derivation
      1. lift-*.f6479.7

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

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

Alternative 3: 63.6% accurate, 0.4× speedup?

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

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

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

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

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

\mathbf{elif}\;x \cdot y \leq 4 \cdot 10^{+106}:\\
\;\;\;\;t\_2\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if (*.f64 x y) < -2.00000000000000007e154 or 4.00000000000000036e106 < (*.f64 x y)

    1. Initial program 91.1%

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

        \[\leadsto y \cdot \color{blue}{x} \]
    5. Applied rewrites65.9%

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

    if -2.00000000000000007e154 < (*.f64 x y) < -1e17 or 2.00000000000000008e-215 < (*.f64 x y) < 9.99999999999999929e-40

    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. 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 \color{blue}{\left(\left(x \cdot y + z \cdot t\right) + a \cdot b\right)} + c \cdot i \]
      3. lift-+.f64N/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{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. +-commutativeN/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -1e17 < (*.f64 x y) < 2.00000000000000008e-215 or 9.99999999999999929e-40 < (*.f64 x y) < 4.00000000000000036e106

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

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

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

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

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

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

        \[\leadsto \mathsf{fma}\left(b, a, \mathsf{fma}\left(i, c, y \cdot x\right)\right) \]
      6. lower-*.f6470.5

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

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

      \[\leadsto \mathsf{fma}\left(b, a, c \cdot i\right) \]
    7. Step-by-step derivation
      1. lift-*.f6464.2

        \[\leadsto \mathsf{fma}\left(b, a, c \cdot i\right) \]
    8. Applied rewrites64.2%

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

Alternative 4: 67.0% accurate, 0.5× speedup?

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

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

\mathbf{elif}\;a \cdot b \leq -2 \cdot 10^{-123}:\\
\;\;\;\;t\_1\\

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

\mathbf{elif}\;a \cdot b \leq 10^{+103}:\\
\;\;\;\;t\_1\\

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


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

    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 z around 0

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

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

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

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

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

        \[\leadsto \mathsf{fma}\left(b, a, \mathsf{fma}\left(i, c, y \cdot x\right)\right) \]
      6. lower-*.f6485.7

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

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

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

        \[\leadsto \mathsf{fma}\left(b, a, c \cdot i\right) \]
    8. Applied rewrites73.4%

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

    if -4.99999999999999973e65 < (*.f64 a b) < -2.0000000000000001e-123 or 1.99999999999999982e-21 < (*.f64 a b) < 1e103

    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 \color{blue}{\left(\left(x \cdot y + z \cdot t\right) + a \cdot b\right)} + c \cdot i \]
      3. lift-+.f64N/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{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. +-commutativeN/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \mathsf{fma}\left(x, y, t \cdot z\right) \]
    9. Step-by-step derivation
      1. lower-*.f6457.4

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

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

    if -2.0000000000000001e-123 < (*.f64 a b) < 1.99999999999999982e-21

    1. Initial program 97.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 \color{blue}{\left(\left(x \cdot y + z \cdot t\right) + a \cdot b\right)} + c \cdot i \]
      3. lift-+.f64N/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 5: 42.8% accurate, 0.6× speedup?

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

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

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

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

\mathbf{elif}\;a \cdot b \leq -2 \cdot 10^{-123}:\\
\;\;\;\;t \cdot z\\

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if (*.f64 a b) < -5.00000000000000021e35 or 1e103 < (*.f64 a b)

    1. Initial program 92.1%

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

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

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

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

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

    if -5.00000000000000021e35 < (*.f64 a b) < -2.0000000000000001e-123 or 1.99999999999999982e-21 < (*.f64 a b) < 1e103

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

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

        \[\leadsto t \cdot \color{blue}{z} \]
    5. Applied rewrites29.7%

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

    if -2.0000000000000001e-123 < (*.f64 a b) < 1.99999999999999982e-21

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

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

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

Alternative 6: 89.6% accurate, 0.7× speedup?

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

\\
\begin{array}{l}
t_1 := \mathsf{fma}\left(b, a, \mathsf{fma}\left(i, c, y \cdot x\right)\right)\\
\mathbf{if}\;c \cdot i \leq -5000000:\\
\;\;\;\;t\_1\\

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

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


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

    1. Initial program 92.9%

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

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

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

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

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

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

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

        \[\leadsto \mathsf{fma}\left(b, a, \mathsf{fma}\left(i, c, y \cdot x\right)\right) \]
    5. Applied rewrites83.4%

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

    if -5e6 < (*.f64 c i) < 1.00000000000000004e42

    1. Initial program 97.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 \color{blue}{\left(\left(x \cdot y + z \cdot t\right) + a \cdot b\right)} + c \cdot i \]
      3. lift-+.f64N/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{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. +-commutativeN/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 7: 88.5% accurate, 0.7× speedup?

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

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (*.f64 z t) < -2e14 or 2.0000000000000002e-15 < (*.f64 z t)

    1. Initial program 93.8%

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

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

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

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

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

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

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

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

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

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

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

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

    if -2e14 < (*.f64 z t) < 2.0000000000000002e-15

    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 z around 0

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

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

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

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

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

        \[\leadsto \mathsf{fma}\left(b, a, \mathsf{fma}\left(i, c, y \cdot x\right)\right) \]
      6. lower-*.f6495.6

        \[\leadsto \mathsf{fma}\left(b, a, \mathsf{fma}\left(i, c, y \cdot x\right)\right) \]
    5. Applied rewrites95.6%

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

Alternative 8: 86.1% accurate, 0.7× speedup?

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

\\
\begin{array}{l}
t_1 := \mathsf{fma}\left(b, a, t \cdot z\right)\\
\mathbf{if}\;z \cdot t \leq -1 \cdot 10^{+267}:\\
\;\;\;\;t\_1\\

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (*.f64 z t) < -9.9999999999999997e266 or 1e173 < (*.f64 z t)

    1. Initial program 88.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 \color{blue}{\left(\left(x \cdot y + z \cdot t\right) + a \cdot b\right)} + c \cdot i \]
      3. lift-+.f64N/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{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. +-commutativeN/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -9.9999999999999997e266 < (*.f64 z t) < 1e173

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

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

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

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

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

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

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

        \[\leadsto \mathsf{fma}\left(b, a, \mathsf{fma}\left(i, c, y \cdot x\right)\right) \]
    5. Applied rewrites86.8%

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

Alternative 9: 43.4% accurate, 0.8× speedup?

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

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

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

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

\mathbf{elif}\;a \cdot b \leq -1 \cdot 10^{-121}:\\
\;\;\;\;t \cdot z\\

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if (*.f64 a b) < -5.00000000000000021e35 or 1e103 < (*.f64 a b)

    1. Initial program 92.1%

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

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

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

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

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

    if -5.00000000000000021e35 < (*.f64 a b) < -9.9999999999999998e-122

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

        \[\leadsto t \cdot \color{blue}{z} \]
    5. Applied rewrites31.6%

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

    if -9.9999999999999998e-122 < (*.f64 a b) < 1e103

    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 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-*.f6434.3

        \[\leadsto y \cdot \color{blue}{x} \]
    5. Applied rewrites34.3%

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

Alternative 10: 67.0% accurate, 0.9× speedup?

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

\\
\begin{array}{l}
t_1 := \mathsf{fma}\left(b, a, c \cdot i\right)\\
\mathbf{if}\;c \cdot i \leq -1 \cdot 10^{+68}:\\
\;\;\;\;t\_1\\

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (*.f64 c i) < -9.99999999999999953e67 or 2.00000000000000004e198 < (*.f64 c i)

    1. Initial program 90.8%

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

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

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

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

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

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

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

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

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

      \[\leadsto \mathsf{fma}\left(b, a, c \cdot i\right) \]
    7. Step-by-step derivation
      1. lift-*.f6476.8

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

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

    if -9.99999999999999953e67 < (*.f64 c i) < 2.00000000000000004e198

    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 z around 0

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

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

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

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

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

        \[\leadsto \mathsf{fma}\left(b, a, \mathsf{fma}\left(i, c, y \cdot x\right)\right) \]
      6. lower-*.f6471.0

        \[\leadsto \mathsf{fma}\left(b, a, \mathsf{fma}\left(i, c, y \cdot x\right)\right) \]
    5. Applied rewrites71.0%

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

      \[\leadsto \mathsf{fma}\left(b, a, x \cdot y\right) \]
    7. Step-by-step derivation
      1. lower-*.f6462.7

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

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

Alternative 11: 62.4% accurate, 0.9× speedup?

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

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (*.f64 x y) < -2.00000000000000007e154 or 4.00000000000000036e106 < (*.f64 x y)

    1. Initial program 91.1%

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

        \[\leadsto y \cdot \color{blue}{x} \]
    5. Applied rewrites65.9%

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

    if -2.00000000000000007e154 < (*.f64 x y) < 4.00000000000000036e106

    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. 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 \color{blue}{\left(\left(x \cdot y + z \cdot t\right) + a \cdot b\right)} + c \cdot i \]
      3. lift-+.f64N/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{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. +-commutativeN/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 12: 43.2% accurate, 1.1× speedup?

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

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

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

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (*.f64 c i) < -1.99999999999999993e90 or 1.00000000000000004e36 < (*.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-*.f6457.8

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

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

    if -1.99999999999999993e90 < (*.f64 c i) < 1.00000000000000004e36

    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-*.f6433.6

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

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

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

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

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

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

Reproduce

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