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

Percentage Accurate: 95.8% → 98.1%
Time: 9.9s
Alternatives: 11
Speedup: 1.3×

Specification

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

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

Sampling outcomes in binary64 precision:

Local Percentage Accuracy vs ?

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

Accuracy vs Speed?

Herbie found 11 alternatives:

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

Initial Program: 95.8% accurate, 1.0× speedup?

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

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

Alternative 1: 98.1% accurate, 1.3× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 2: 42.5% accurate, 0.6× speedup?

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

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

\mathbf{elif}\;z \cdot t \leq -1 \cdot 10^{-27}:\\
\;\;\;\;c \cdot i\\

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

\mathbf{elif}\;z \cdot t \leq 10^{+58}:\\
\;\;\;\;x \cdot y\\

\mathbf{else}:\\
\;\;\;\;z \cdot t\\


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if (*.f64 z t) < -5e128 or 9.99999999999999944e57 < (*.f64 z t)

    1. Initial program 91.8%

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

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

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

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

    if -5e128 < (*.f64 z t) < -1e-27

    1. Initial program 96.9%

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

      \[\leadsto \color{blue}{c \cdot i} \]
    4. Step-by-step derivation
      1. lower-*.f6444.6

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

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

    if -1e-27 < (*.f64 z t) < -1.99999999999999987e-124

    1. Initial program 100.0%

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

      \[\leadsto \color{blue}{a \cdot b} \]
    4. Step-by-step derivation
      1. lower-*.f6463.8

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

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

    if -1.99999999999999987e-124 < (*.f64 z t) < 9.99999999999999944e57

    1. Initial program 97.2%

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

      \[\leadsto \color{blue}{x \cdot y} \]
    4. Step-by-step derivation
      1. lower-*.f6441.9

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

      \[\leadsto \color{blue}{x \cdot y} \]
  3. Recombined 4 regimes into one program.
  4. Final simplification53.8%

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \cdot t \leq -5 \cdot 10^{+128}:\\ \;\;\;\;z \cdot t\\ \mathbf{elif}\;z \cdot t \leq -1 \cdot 10^{-27}:\\ \;\;\;\;c \cdot i\\ \mathbf{elif}\;z \cdot t \leq -2 \cdot 10^{-124}:\\ \;\;\;\;a \cdot b\\ \mathbf{elif}\;z \cdot t \leq 10^{+58}:\\ \;\;\;\;x \cdot y\\ \mathbf{else}:\\ \;\;\;\;z \cdot t\\ \end{array} \]
  5. Add Preprocessing

Alternative 3: 66.8% accurate, 0.7× speedup?

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

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

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if (*.f64 z t) < -5e112

    1. Initial program 95.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -5e112 < (*.f64 z t) < -5.00000000000000007e-120

    1. Initial program 97.8%

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

      \[\leadsto \color{blue}{a \cdot b} + c \cdot i \]
    4. Step-by-step derivation
      1. lower-*.f6478.7

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

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

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

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

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

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

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

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

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

    if -5.00000000000000007e-120 < (*.f64 z t) < 9.99999999999999944e57

    1. Initial program 97.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \mathsf{fma}\left(a, b, \color{blue}{x \cdot y}\right) \]
    10. Applied rewrites73.6%

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

    if 9.99999999999999944e57 < (*.f64 z t)

    1. Initial program 89.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \mathsf{fma}\left(z, t, \color{blue}{a \cdot b}\right) \]
    6. Step-by-step derivation
      1. lower-*.f6479.2

        \[\leadsto \mathsf{fma}\left(z, t, \color{blue}{a \cdot b}\right) \]
    7. Applied rewrites79.2%

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

Alternative 4: 67.0% accurate, 0.7× speedup?

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

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

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if (*.f64 z t) < -5e128 or 9.99999999999999944e57 < (*.f64 z t)

    1. Initial program 91.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -5e128 < (*.f64 z t) < -5.00000000000000007e-120

    1. Initial program 98.0%

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

      \[\leadsto \color{blue}{a \cdot b} + c \cdot i \]
    4. Step-by-step derivation
      1. lower-*.f6474.5

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

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

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

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

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

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

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

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

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

    if -5.00000000000000007e-120 < (*.f64 z t) < 9.99999999999999944e57

    1. Initial program 97.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \mathsf{fma}\left(a, b, \color{blue}{x \cdot y}\right) \]
    10. Applied rewrites73.6%

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

Alternative 5: 63.3% accurate, 0.7× speedup?

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

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

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

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

\mathbf{else}:\\
\;\;\;\;z \cdot t\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if (*.f64 z t) < -5e128 or 9.9999999999999992e180 < (*.f64 z t)

    1. Initial program 89.6%

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

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

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

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

    if -5e128 < (*.f64 z t) < -5.00000000000000007e-120

    1. Initial program 98.0%

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

      \[\leadsto \color{blue}{a \cdot b} + c \cdot i \]
    4. Step-by-step derivation
      1. lower-*.f6474.5

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

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

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

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

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

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

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

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

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

    if -5.00000000000000007e-120 < (*.f64 z t) < 9.9999999999999992e180

    1. Initial program 97.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\mathsf{fma}\left(a, b, x \cdot y\right)} \]
      2. lower-*.f6468.1

        \[\leadsto \mathsf{fma}\left(a, b, \color{blue}{x \cdot y}\right) \]
    10. Applied rewrites68.1%

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

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

Alternative 6: 85.3% accurate, 0.7× speedup?

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

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (*.f64 c i) < -4.99999999999999973e272 or 9.99999999999999947e182 < (*.f64 c i)

    1. Initial program 88.6%

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

      \[\leadsto \color{blue}{x \cdot y} + c \cdot i \]
    4. Step-by-step derivation
      1. lower-*.f6487.9

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

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

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

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

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

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

    if -4.99999999999999973e272 < (*.f64 c i) < 9.99999999999999947e182

    1. Initial program 96.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \mathsf{fma}\left(z, t, \mathsf{fma}\left(x, y, \color{blue}{a \cdot b}\right)\right) \]
    6. Step-by-step derivation
      1. lower-*.f6488.4

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

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

Alternative 7: 85.1% accurate, 0.7× speedup?

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

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (*.f64 c i) < -4.99999999999999973e272 or 9.99999999999999947e182 < (*.f64 c i)

    1. Initial program 88.6%

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

      \[\leadsto \color{blue}{x \cdot y} + c \cdot i \]
    4. Step-by-step derivation
      1. lower-*.f6487.9

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

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

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

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

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

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

    if -4.99999999999999973e272 < (*.f64 c i) < 9.99999999999999947e182

    1. Initial program 96.7%

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

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

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

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

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

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

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

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

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

Alternative 8: 43.1% accurate, 0.8× speedup?

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

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

\mathbf{elif}\;z \cdot t \leq -1 \cdot 10^{-27}:\\
\;\;\;\;c \cdot i\\

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

\mathbf{else}:\\
\;\;\;\;z \cdot t\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if (*.f64 z t) < -5e128 or 5.0000000000000004e49 < (*.f64 z t)

    1. Initial program 92.0%

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

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

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

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

    if -5e128 < (*.f64 z t) < -1e-27

    1. Initial program 96.9%

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

      \[\leadsto \color{blue}{c \cdot i} \]
    4. Step-by-step derivation
      1. lower-*.f6444.6

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

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

    if -1e-27 < (*.f64 z t) < 5.0000000000000004e49

    1. Initial program 97.6%

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

      \[\leadsto \color{blue}{a \cdot b} \]
    4. Step-by-step derivation
      1. lower-*.f6439.0

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \cdot t \leq -5 \cdot 10^{+128}:\\ \;\;\;\;z \cdot t\\ \mathbf{elif}\;z \cdot t \leq -1 \cdot 10^{-27}:\\ \;\;\;\;c \cdot i\\ \mathbf{elif}\;z \cdot t \leq 5 \cdot 10^{+49}:\\ \;\;\;\;a \cdot b\\ \mathbf{else}:\\ \;\;\;\;z \cdot t\\ \end{array} \]
  5. Add Preprocessing

Alternative 9: 62.6% accurate, 0.9× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;z \cdot t \leq -5 \cdot 10^{+121}:\\
\;\;\;\;z \cdot t\\

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

\mathbf{else}:\\
\;\;\;\;z \cdot t\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (*.f64 z t) < -5.00000000000000007e121 or 9.9999999999999992e180 < (*.f64 z t)

    1. Initial program 90.0%

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

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

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

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

    if -5.00000000000000007e121 < (*.f64 z t) < 9.9999999999999992e180

    1. Initial program 97.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\mathsf{fma}\left(a, b, x \cdot y\right)} \]
      2. lower-*.f6465.0

        \[\leadsto \mathsf{fma}\left(a, b, \color{blue}{x \cdot y}\right) \]
    10. Applied rewrites65.0%

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

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

Alternative 10: 44.0% accurate, 1.1× speedup?

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

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (*.f64 a b) < -1.00000000000000006e140 or 1.05000000000000002e36 < (*.f64 a b)

    1. Initial program 90.9%

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

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

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

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

    if -1.00000000000000006e140 < (*.f64 a b) < 1.05000000000000002e36

    1. Initial program 98.6%

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

      \[\leadsto \color{blue}{c \cdot i} \]
    4. Step-by-step derivation
      1. lower-*.f6430.3

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

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

Alternative 11: 28.3% accurate, 5.0× speedup?

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

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

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

    \[\leadsto \color{blue}{a \cdot b} \]
  4. Step-by-step derivation
    1. lower-*.f6428.3

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

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

Reproduce

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