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

Percentage Accurate: 95.6% → 97.7%
Time: 4.0s
Alternatives: 14
Speedup: 1.1×

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 14 alternatives:

AlternativeAccuracySpeedup
The accuracy (vertical axis) and speed (horizontal axis) of each alternatives. Up and to the right is better. The red square shows the initial program, and each blue circle shows an alternative.The line shows the best available speed-accuracy tradeoffs.

Initial Program: 95.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.1× 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. Step-by-step derivation
    1. lift-*.f64N/A

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

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

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

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

      \[\leadsto \left(\color{blue}{\left(x \cdot y + z \cdot t\right)} + a \cdot b\right) + 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, \color{blue}{z \cdot t + x \cdot y}\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) \]
  3. 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)} \]
  4. Add Preprocessing

Alternative 2: 89.7% accurate, 0.8× speedup?

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

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

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

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


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

    1. Initial program 92.1%

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

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

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

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

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

        \[\leadsto \left(\color{blue}{\left(x \cdot y + z \cdot t\right)} + a \cdot b\right) + 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, \color{blue}{z \cdot t + x \cdot y}\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.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) \]
    3. Applied rewrites95.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)} \]
    4. Taylor expanded in c around 0

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

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

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

    if -9.99999999999999967e117 < (*.f64 x y) < 6.0000000000000002e23

    1. Initial program 97.7%

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto a \cdot b + \left(c \cdot i + t \cdot z\right) \]
      5. +-commutativeN/A

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

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

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

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

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

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

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

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

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

Alternative 3: 89.6% accurate, 0.8× speedup?

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

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if (*.f64 x y) < -2.00000000000000004e95

    1. Initial program 91.6%

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

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

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

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

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

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

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

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

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

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

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

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

    if -2.00000000000000004e95 < (*.f64 x y) < 6.0000000000000002e23

    1. Initial program 97.7%

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto a \cdot b + \left(c \cdot i + t \cdot z\right) \]
      5. +-commutativeN/A

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

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

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

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

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

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

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

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

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

    if 6.0000000000000002e23 < (*.f64 x y)

    1. Initial program 93.0%

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 4: 89.4% accurate, 0.8× 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}\;x \cdot y \leq -1 \cdot 10^{+118}:\\ \;\;\;\;t\_1\\ \mathbf{elif}\;x \cdot y \leq 6 \cdot 10^{+23}:\\ \;\;\;\;\mathsf{fma}\left(a, b, \mathsf{fma}\left(z, t, c \cdot i\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 (<= (* x y) -1e+118)
     t_1
     (if (<= (* x y) 6e+23) (fma a b (fma z t (* 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(b, a, fma(t, z, (y * x)));
	double tmp;
	if ((x * y) <= -1e+118) {
		tmp = t_1;
	} else if ((x * y) <= 6e+23) {
		tmp = fma(a, b, fma(z, t, (c * i)));
	} 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(x * y) <= -1e+118)
		tmp = t_1;
	elseif (Float64(x * y) <= 6e+23)
		tmp = fma(a, b, fma(z, t, 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[(b * a + N[(t * z + N[(y * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(x * y), $MachinePrecision], -1e+118], t$95$1, If[LessEqual[N[(x * y), $MachinePrecision], 6e+23], N[(a * b + N[(z * t + N[(c * i), $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}\;x \cdot y \leq -1 \cdot 10^{+118}:\\
\;\;\;\;t\_1\\

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

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


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

    1. Initial program 92.1%

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

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

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

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

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

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

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

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

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

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

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

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

    if -9.99999999999999967e117 < (*.f64 x y) < 6.0000000000000002e23

    1. Initial program 97.7%

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto a \cdot b + \left(c \cdot i + t \cdot z\right) \]
      5. +-commutativeN/A

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

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

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

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

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

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

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

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

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

Alternative 5: 85.8% accurate, 0.8× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;x \cdot y \leq -1 \cdot 10^{+118}:\\
\;\;\;\;\mathsf{fma}\left(x, y, b \cdot a\right)\\

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if (*.f64 x y) < -9.99999999999999967e117

    1. Initial program 90.8%

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

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

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

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

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

        \[\leadsto \left(\color{blue}{\left(x \cdot y + z \cdot t\right)} + a \cdot b\right) + 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, \color{blue}{z \cdot t + x \cdot y}\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.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) \]
    3. Applied rewrites95.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)} \]
    4. Taylor expanded in c around 0

      \[\leadsto \color{blue}{a \cdot b + \left(t \cdot z + x \cdot y\right)} \]
    5. 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-*.f6486.9

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

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

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

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

        \[\leadsto \mathsf{fma}\left(x, y, b \cdot a\right) \]
    9. Applied rewrites76.3%

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

    if -9.99999999999999967e117 < (*.f64 x y) < 1.9999999999999999e124

    1. Initial program 97.7%

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

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

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

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

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

        \[\leadsto \left(\color{blue}{\left(x \cdot y + z \cdot t\right)} + a \cdot b\right) + 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, \color{blue}{z \cdot t + x \cdot y}\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) \]
    3. 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)} \]
    4. Taylor expanded in x around 0

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

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

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

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

        \[\leadsto a \cdot b + \left(c \cdot i + t \cdot z\right) \]
      5. +-commutativeN/A

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

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

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

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

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

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

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

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

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

    if 1.9999999999999999e124 < (*.f64 x y)

    1. Initial program 91.0%

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

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

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

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

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

        \[\leadsto \left(\color{blue}{\left(x \cdot y + z \cdot t\right)} + a \cdot b\right) + 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, \color{blue}{z \cdot t + x \cdot y}\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.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) \]
    3. Applied rewrites95.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)} \]
    4. Taylor expanded in c around 0

      \[\leadsto \color{blue}{a \cdot b + \left(t \cdot z + x \cdot y\right)} \]
    5. 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-*.f6486.8

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

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

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

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

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

Alternative 6: 76.1% accurate, 0.6× 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^{+159}:\\ \;\;\;\;t\_1\\ \mathbf{elif}\;t\_2 \leq 5 \cdot 10^{+125}:\\ \;\;\;\;\mathsf{fma}\left(a, b, i \cdot c\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+159) t_1 (if (<= t_2 5e+125) (fma a b (* i c)) 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+159) {
		tmp = t_1;
	} else if (t_2 <= 5e+125) {
		tmp = fma(a, b, (i * c));
	} 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+159)
		tmp = t_1;
	elseif (t_2 <= 5e+125)
		tmp = fma(a, b, Float64(i * c));
	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+159], t$95$1, If[LessEqual[t$95$2, 5e+125], N[(a * b + N[(i * c), $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^{+159}:\\
\;\;\;\;t\_1\\

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (+.f64 (*.f64 x y) (*.f64 z t)) < -9.9999999999999993e158 or 4.99999999999999962e125 < (+.f64 (*.f64 x y) (*.f64 z t))

    1. Initial program 91.9%

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

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

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

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

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

        \[\leadsto \left(\color{blue}{\left(x \cdot y + z \cdot t\right)} + a \cdot b\right) + 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, \color{blue}{z \cdot t + x \cdot y}\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.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) \]
    3. Applied rewrites95.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)} \]
    4. Taylor expanded in c around 0

      \[\leadsto \color{blue}{a \cdot b + \left(t \cdot z + x \cdot y\right)} \]
    5. 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.9

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

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

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

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

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

    if -9.9999999999999993e158 < (+.f64 (*.f64 x y) (*.f64 z t)) < 4.99999999999999962e125

    1. Initial program 99.2%

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

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

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

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

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

        \[\leadsto \left(\color{blue}{\left(x \cdot y + z \cdot t\right)} + a \cdot b\right) + 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, \color{blue}{z \cdot t + x \cdot y}\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.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) \]
    3. Applied rewrites99.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)} \]
    4. Taylor expanded in x around 0

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

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

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

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

        \[\leadsto a \cdot b + \left(c \cdot i + t \cdot z\right) \]
      5. +-commutativeN/A

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 7: 67.1% accurate, 0.7× speedup?

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

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

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

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

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


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

    1. Initial program 92.4%

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

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

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

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

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

        \[\leadsto \left(\color{blue}{\left(x \cdot y + z \cdot t\right)} + a \cdot b\right) + 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, \color{blue}{z \cdot t + x \cdot y}\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.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) \]
    3. Applied rewrites95.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)} \]
    4. Taylor expanded in c around 0

      \[\leadsto \color{blue}{a \cdot b + \left(t \cdot z + x \cdot y\right)} \]
    5. 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-*.f6484.5

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

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

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

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

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

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

    if -1e85 < (*.f64 x y) < 5.00000000000000021e-216

    1. Initial program 97.6%

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{a \cdot b + \left(t \cdot z + x \cdot y\right)} \]
    5. 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.4

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

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

      \[\leadsto a \cdot b + \color{blue}{t \cdot z} \]
    8. Step-by-step derivation
      1. associate-+r+N/A

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

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

        \[\leadsto \mathsf{fma}\left(b, a, t \cdot z\right) \]
      4. lower-*.f6464.7

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

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

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

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

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

        \[\leadsto z \cdot t + b \cdot a \]
      5. *-commutativeN/A

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

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

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

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

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

    if 5.00000000000000021e-216 < (*.f64 x y) < 6.0000000000000002e23

    1. Initial program 98.2%

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto a \cdot b + \left(c \cdot i + t \cdot z\right) \]
      5. +-commutativeN/A

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \mathsf{fma}\left(a, b, i \cdot c\right) \]
      2. lower-*.f6461.4

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

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

Alternative 8: 63.4% accurate, 0.6× speedup?

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

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

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

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if (*.f64 x y) < -9.9999999999999993e158 or 1.9999999999999999e124 < (*.f64 x y)

    1. Initial program 90.3%

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

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

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

        \[\leadsto y \cdot \color{blue}{x} \]
    4. Applied rewrites67.2%

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

    if -9.9999999999999993e158 < (*.f64 x y) < -4.9999999999999998e-281 or 5.00000000000000021e-216 < (*.f64 x y) < 1.9999999999999999e124

    1. Initial program 97.9%

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto a \cdot b + \left(c \cdot i + t \cdot z\right) \]
      5. +-commutativeN/A

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \mathsf{fma}\left(a, b, i \cdot c\right) \]
      2. lower-*.f6459.7

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

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

    if -4.9999999999999998e-281 < (*.f64 x y) < 5.00000000000000021e-216

    1. Initial program 97.3%

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

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

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

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

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

        \[\leadsto \left(\color{blue}{\left(x \cdot y + z \cdot t\right)} + a \cdot b\right) + 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, \color{blue}{z \cdot t + x \cdot y}\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) \]
    3. 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)} \]
    4. Taylor expanded in c around 0

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

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

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

      \[\leadsto a \cdot b + \color{blue}{t \cdot z} \]
    8. Step-by-step derivation
      1. associate-+r+N/A

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

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

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

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

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

Alternative 9: 63.3% accurate, 0.9× speedup?

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

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

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

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


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

    1. Initial program 89.7%

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

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

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

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

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

    if -4.9999999999999998e195 < (*.f64 x y) < 1.9999999999999999e124

    1. Initial program 97.7%

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

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

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

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

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

        \[\leadsto \left(\color{blue}{\left(x \cdot y + z \cdot t\right)} + a \cdot b\right) + 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, \color{blue}{z \cdot t + x \cdot y}\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) \]
    3. 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)} \]
    4. Taylor expanded in c around 0

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

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

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

      \[\leadsto a \cdot b + \color{blue}{t \cdot z} \]
    8. Step-by-step derivation
      1. associate-+r+N/A

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

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

        \[\leadsto \mathsf{fma}\left(b, a, t \cdot z\right) \]
      4. lower-*.f6461.2

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

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

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

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

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

        \[\leadsto z \cdot t + b \cdot a \]
      5. *-commutativeN/A

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

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

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

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

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

Alternative 10: 63.2% accurate, 0.9× speedup?

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

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

\mathbf{elif}\;x \cdot y \leq 2 \cdot 10^{+124}:\\
\;\;\;\;\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) < -4.9999999999999998e195 or 1.9999999999999999e124 < (*.f64 x y)

    1. Initial program 89.7%

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

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

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

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

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

    if -4.9999999999999998e195 < (*.f64 x y) < 1.9999999999999999e124

    1. Initial program 97.7%

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

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

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

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

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

        \[\leadsto \left(\color{blue}{\left(x \cdot y + z \cdot t\right)} + a \cdot b\right) + 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, \color{blue}{z \cdot t + x \cdot y}\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) \]
    3. 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)} \]
    4. Taylor expanded in c around 0

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

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

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

      \[\leadsto a \cdot b + \color{blue}{t \cdot z} \]
    8. Step-by-step derivation
      1. associate-+r+N/A

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

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

        \[\leadsto \mathsf{fma}\left(b, a, t \cdot z\right) \]
      4. lower-*.f6461.2

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

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

Alternative 11: 43.7% accurate, 0.5× speedup?

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

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

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

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

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

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

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

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

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

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


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

    1. Initial program 91.4%

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

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

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

        \[\leadsto y \cdot \color{blue}{x} \]
    4. Applied rewrites62.0%

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

    if -1e85 < (*.f64 x y) < -4.99999999999999962e-25 or -4.9999999999999998e-281 < (*.f64 x y) < 1e-196

    1. Initial program 97.6%

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

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

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

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

    if -4.99999999999999962e-25 < (*.f64 x y) < -5e-177 or 1e-196 < (*.f64 x y) < 1.9999999999999999e124

    1. Initial program 97.9%

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

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

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

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

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

    if -5e-177 < (*.f64 x y) < -4.9999999999999998e-281

    1. Initial program 97.2%

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

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

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

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

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

Alternative 12: 43.0% accurate, 0.7× speedup?

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

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

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

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if (*.f64 a b) < -2e114 or 9.99999999999999983e72 < (*.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. Taylor expanded in a around inf

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

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

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

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

    if -2e114 < (*.f64 a b) < -4.99994e-320 or 2.00000000000000008e-42 < (*.f64 a b) < 9.99999999999999983e72

    1. Initial program 97.7%

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

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

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

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

    if -4.99994e-320 < (*.f64 a b) < 2.00000000000000008e-42

    1. Initial program 97.3%

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

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

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

        \[\leadsto i \cdot \color{blue}{c} \]
    4. Applied rewrites33.7%

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

Alternative 13: 42.4% accurate, 1.2× speedup?

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

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

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

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (*.f64 a b) < -1.00000000000000009e106 or 1e51 < (*.f64 a b)

    1. Initial program 92.4%

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

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

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

        \[\leadsto b \cdot \color{blue}{a} \]
    4. Applied rewrites59.6%

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

    if -1.00000000000000009e106 < (*.f64 a b) < 1e51

    1. Initial program 97.5%

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

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

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

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

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

Alternative 14: 27.7% accurate, 5.3× speedup?

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

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

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

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

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

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

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

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

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

Reproduce

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