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

Percentage Accurate: 95.7% → 97.9%
Time: 8.9s
Alternatives: 12
Speedup: 0.5×

Specification

?
\[\begin{array}{l} \\ \left(\left(x \cdot y + z \cdot t\right) + a \cdot b\right) + c \cdot i \end{array} \]
(FPCore (x y z t a b c i)
 :precision binary64
 (+ (+ (+ (* x y) (* z t)) (* a b)) (* c i)))
double code(double x, double y, double z, double t, double a, double b, double c, double i) {
	return (((x * y) + (z * t)) + (a * b)) + (c * i);
}
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 12 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.7% 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: 97.9% accurate, 0.5× speedup?

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

\\
\begin{array}{l}
t_1 := \left(\left(x \cdot y + z \cdot t\right) + a \cdot b\right) + c \cdot i\\
\mathbf{if}\;t\_1 \leq \infty:\\
\;\;\;\;t\_1\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (+.f64 (+.f64 (+.f64 (*.f64 x y) (*.f64 z t)) (*.f64 a b)) (*.f64 c i)) < +inf.0

    1. Initial program 100.0%

      \[\left(\left(x \cdot y + z \cdot t\right) + a \cdot b\right) + c \cdot i \]
    2. Add Preprocessing

    if +inf.0 < (+.f64 (+.f64 (+.f64 (*.f64 x y) (*.f64 z t)) (*.f64 a b)) (*.f64 c i))

    1. Initial program 0.0%

      \[\left(\left(x \cdot y + z \cdot t\right) + a \cdot b\right) + c \cdot i \]
    2. 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. accelerator-lowering-fma.f64N/A

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

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

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

      \[\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 simplification98.8%

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

Alternative 2: 73.9% accurate, 0.4× speedup?

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

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

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if (+.f64 (*.f64 x y) (*.f64 z t)) < -1.9999999999999999e200

    1. Initial program 93.3%

      \[\left(\left(x \cdot y + z \cdot t\right) + a \cdot b\right) + c \cdot i \]
    2. Add Preprocessing
    3. Taylor expanded in c around 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. accelerator-lowering-fma.f64N/A

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

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

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

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

      \[\leadsto \color{blue}{t \cdot z + x \cdot y} \]
    7. Step-by-step derivation
      1. accelerator-lowering-fma.f64N/A

        \[\leadsto \color{blue}{\mathsf{fma}\left(t, z, x \cdot y\right)} \]
      2. *-lowering-*.f6489.2

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

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

    if -1.9999999999999999e200 < (+.f64 (*.f64 x y) (*.f64 z t)) < 1.99999999999999985e75

    1. Initial program 97.7%

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

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

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

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

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

        \[\leadsto \color{blue}{i \cdot c} + a \cdot b \]
      3. accelerator-lowering-fma.f64N/A

        \[\leadsto \color{blue}{\mathsf{fma}\left(i, c, a \cdot b\right)} \]
      4. *-lowering-*.f6480.2

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

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

    if 1.99999999999999985e75 < (+.f64 (*.f64 x y) (*.f64 z t)) < 1e277

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

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

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

        \[\leadsto \mathsf{fma}\left(c, i, \color{blue}{\mathsf{fma}\left(t, z, x \cdot y\right)}\right) \]
      3. *-lowering-*.f6481.4

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

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

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

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

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

    if 1e277 < (+.f64 (*.f64 x y) (*.f64 z t))

    1. Initial program 95.0%

      \[\left(\left(x \cdot y + z \cdot t\right) + a \cdot b\right) + c \cdot i \]
    2. Add Preprocessing
    3. Taylor expanded in c around 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. accelerator-lowering-fma.f64N/A

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

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

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

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

      \[\leadsto \mathsf{fma}\left(x, y, \color{blue}{t \cdot z}\right) \]
    7. Step-by-step derivation
      1. *-lowering-*.f6495.0

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

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

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

Alternative 3: 73.9% accurate, 0.4× speedup?

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

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

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if (+.f64 (*.f64 x y) (*.f64 z t)) < -1.9999999999999999e200 or 1e277 < (+.f64 (*.f64 x y) (*.f64 z t))

    1. Initial program 94.1%

      \[\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. accelerator-lowering-fma.f64N/A

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

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

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

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

      \[\leadsto \color{blue}{t \cdot z + x \cdot y} \]
    7. Step-by-step derivation
      1. accelerator-lowering-fma.f64N/A

        \[\leadsto \color{blue}{\mathsf{fma}\left(t, z, x \cdot y\right)} \]
      2. *-lowering-*.f6490.7

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

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

    if -1.9999999999999999e200 < (+.f64 (*.f64 x y) (*.f64 z t)) < 1.99999999999999985e75

    1. Initial program 97.7%

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

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

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

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

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

        \[\leadsto \color{blue}{i \cdot c} + a \cdot b \]
      3. accelerator-lowering-fma.f64N/A

        \[\leadsto \color{blue}{\mathsf{fma}\left(i, c, a \cdot b\right)} \]
      4. *-lowering-*.f6480.2

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

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

    if 1.99999999999999985e75 < (+.f64 (*.f64 x y) (*.f64 z t)) < 1e277

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

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

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

        \[\leadsto \mathsf{fma}\left(c, i, \color{blue}{\mathsf{fma}\left(t, z, x \cdot y\right)}\right) \]
      3. *-lowering-*.f6481.4

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

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

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

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

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

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

Alternative 4: 88.4% accurate, 0.6× speedup?

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

\mathbf{elif}\;c \cdot i \leq -1 \cdot 10^{+59}:\\
\;\;\;\;t\_1\\

\mathbf{elif}\;c \cdot i \leq 2 \cdot 10^{+130}:\\
\;\;\;\;\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 3 regimes
  2. if (*.f64 c i) < -1.00000000000000006e136

    1. Initial program 91.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} + c \cdot i \]
    4. Step-by-step derivation
      1. *-lowering-*.f6485.7

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

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

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

        \[\leadsto \color{blue}{i \cdot c} + a \cdot b \]
      3. accelerator-lowering-fma.f64N/A

        \[\leadsto \color{blue}{\mathsf{fma}\left(i, c, a \cdot b\right)} \]
      4. *-lowering-*.f6488.5

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

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

    if -1.00000000000000006e136 < (*.f64 c i) < -9.99999999999999972e58 or 2.0000000000000001e130 < (*.f64 c i)

    1. Initial program 94.7%

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

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

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

        \[\leadsto \mathsf{fma}\left(c, i, \color{blue}{\mathsf{fma}\left(t, z, x \cdot y\right)}\right) \]
      3. *-lowering-*.f6493.1

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

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

    if -9.99999999999999972e58 < (*.f64 c i) < 2.0000000000000001e130

    1. Initial program 98.8%

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

      \[\leadsto \color{blue}{a \cdot b + \left(t \cdot z + x \cdot y\right)} \]
    4. Step-by-step derivation
      1. 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. accelerator-lowering-fma.f64N/A

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

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

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

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

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

Alternative 5: 42.6% accurate, 0.6× speedup?

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

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

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

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if (*.f64 a b) < -3.1e153 or 1.55e15 < (*.f64 a b)

    1. Initial program 94.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. *-lowering-*.f6462.7

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

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

    if -3.1e153 < (*.f64 a b) < -4.99994e-320

    1. Initial program 98.7%

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

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

        \[\leadsto \color{blue}{t \cdot z} \]
    5. Simplified50.0%

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

    if -4.99994e-320 < (*.f64 a b) < 4.8000000000000001e-163

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

      \[\leadsto \color{blue}{c \cdot i} \]
    4. Step-by-step derivation
      1. *-lowering-*.f6445.7

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

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

    if 4.8000000000000001e-163 < (*.f64 a b) < 1.55e15

    1. Initial program 96.4%

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

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

        \[\leadsto \color{blue}{x \cdot y} \]
    5. Simplified50.4%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;a \cdot b \leq -3.1 \cdot 10^{+153}:\\ \;\;\;\;a \cdot b\\ \mathbf{elif}\;a \cdot b \leq -5 \cdot 10^{-320}:\\ \;\;\;\;z \cdot t\\ \mathbf{elif}\;a \cdot b \leq 4.8 \cdot 10^{-163}:\\ \;\;\;\;c \cdot i\\ \mathbf{elif}\;a \cdot b \leq 1.55 \cdot 10^{+15}:\\ \;\;\;\;x \cdot y\\ \mathbf{else}:\\ \;\;\;\;a \cdot b\\ \end{array} \]
  5. Add Preprocessing

Alternative 6: 65.1% accurate, 0.7× speedup?

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

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

\mathbf{elif}\;c \cdot i \leq -50000000:\\
\;\;\;\;\mathsf{fma}\left(c, i, z \cdot t\right)\\

\mathbf{elif}\;c \cdot i \leq 0.0002:\\
\;\;\;\;\mathsf{fma}\left(a, b, z \cdot t\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if (*.f64 c i) < -1.00000000000000006e136 or 2.0000000000000001e-4 < (*.f64 c i)

    1. Initial program 93.8%

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

      \[\leadsto \color{blue}{a \cdot b} + c \cdot i \]
    4. Step-by-step derivation
      1. *-lowering-*.f6475.6

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

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

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

        \[\leadsto \color{blue}{i \cdot c} + a \cdot b \]
      3. accelerator-lowering-fma.f64N/A

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

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

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

    if -1.00000000000000006e136 < (*.f64 c i) < -5e7

    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 0

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

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

        \[\leadsto \mathsf{fma}\left(c, i, \color{blue}{\mathsf{fma}\left(t, z, x \cdot y\right)}\right) \]
      3. *-lowering-*.f6495.5

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

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

      \[\leadsto \mathsf{fma}\left(c, i, \color{blue}{t \cdot z}\right) \]
    7. Step-by-step derivation
      1. *-lowering-*.f6482.3

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

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

    if -5e7 < (*.f64 c i) < 2.0000000000000001e-4

    1. Initial program 98.5%

      \[\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. accelerator-lowering-fma.f64N/A

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

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

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

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

      \[\leadsto \color{blue}{a \cdot b + t \cdot z} \]
    7. Step-by-step derivation
      1. accelerator-lowering-fma.f64N/A

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

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

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

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

Alternative 7: 86.1% accurate, 0.7× speedup?

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

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if (*.f64 a b) < -1.9999999999999999e159

    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 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. accelerator-lowering-fma.f64N/A

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

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

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

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

      \[\leadsto \mathsf{fma}\left(x, y, \color{blue}{a \cdot b}\right) \]
    7. Step-by-step derivation
      1. *-lowering-*.f6489.4

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

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

    if -1.9999999999999999e159 < (*.f64 a b) < 9.9999999999999994e162

    1. Initial program 98.9%

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

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

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

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

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

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

    if 9.9999999999999994e162 < (*.f64 a b)

    1. Initial program 87.1%

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

      \[\leadsto \color{blue}{a \cdot b} + c \cdot i \]
    4. Step-by-step derivation
      1. *-lowering-*.f6479.0

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

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

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

        \[\leadsto \color{blue}{i \cdot c} + a \cdot b \]
      3. accelerator-lowering-fma.f64N/A

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

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

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

Alternative 8: 42.6% accurate, 0.8× speedup?

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

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

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if (*.f64 a b) < -4.6000000000000003e153 or 9.5000000000000008e46 < (*.f64 a b)

    1. Initial program 93.7%

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

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

        \[\leadsto \color{blue}{a \cdot b} \]
    5. Simplified64.9%

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

    if -4.6000000000000003e153 < (*.f64 a b) < -4.99994e-320

    1. Initial program 98.7%

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

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

        \[\leadsto \color{blue}{t \cdot z} \]
    5. Simplified50.0%

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

    if -4.99994e-320 < (*.f64 a b) < 9.5000000000000008e46

    1. Initial program 98.8%

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

      \[\leadsto \color{blue}{c \cdot i} \]
    4. Step-by-step derivation
      1. *-lowering-*.f6439.2

        \[\leadsto \color{blue}{c \cdot i} \]
    5. Simplified39.2%

      \[\leadsto \color{blue}{c \cdot i} \]
  3. Recombined 3 regimes into one program.
  4. Final simplification52.0%

    \[\leadsto \begin{array}{l} \mathbf{if}\;a \cdot b \leq -4.6 \cdot 10^{+153}:\\ \;\;\;\;a \cdot b\\ \mathbf{elif}\;a \cdot b \leq -5 \cdot 10^{-320}:\\ \;\;\;\;z \cdot t\\ \mathbf{elif}\;a \cdot b \leq 9.5 \cdot 10^{+46}:\\ \;\;\;\;c \cdot i\\ \mathbf{else}:\\ \;\;\;\;a \cdot b\\ \end{array} \]
  5. Add Preprocessing

Alternative 9: 65.3% accurate, 0.9× speedup?

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

\\
\begin{array}{l}
t_1 := \mathsf{fma}\left(c, i, z \cdot t\right)\\
\mathbf{if}\;c \cdot i \leq -50000000:\\
\;\;\;\;t\_1\\

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

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


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

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

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

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

        \[\leadsto \mathsf{fma}\left(c, i, \color{blue}{\mathsf{fma}\left(t, z, x \cdot y\right)}\right) \]
      3. *-lowering-*.f6486.1

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

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

      \[\leadsto \mathsf{fma}\left(c, i, \color{blue}{t \cdot z}\right) \]
    7. Step-by-step derivation
      1. *-lowering-*.f6477.4

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

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

    if -5e7 < (*.f64 c i) < 2.0000000000000001e130

    1. Initial program 98.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. accelerator-lowering-fma.f64N/A

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

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

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

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

      \[\leadsto \color{blue}{a \cdot b + t \cdot z} \]
    7. Step-by-step derivation
      1. accelerator-lowering-fma.f64N/A

        \[\leadsto \color{blue}{\mathsf{fma}\left(a, b, t \cdot z\right)} \]
      2. *-lowering-*.f6470.3

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

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

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

Alternative 10: 62.6% accurate, 0.9× speedup?

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

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (*.f64 c i) < -2.75e194 or 1.45999999999999997e143 < (*.f64 c i)

    1. Initial program 91.0%

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

      \[\leadsto \color{blue}{c \cdot i} \]
    4. Step-by-step derivation
      1. *-lowering-*.f6474.2

        \[\leadsto \color{blue}{c \cdot i} \]
    5. Simplified74.2%

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

    if -2.75e194 < (*.f64 c i) < 1.45999999999999997e143

    1. Initial program 98.9%

      \[\left(\left(x \cdot y + z \cdot t\right) + a \cdot b\right) + c \cdot i \]
    2. Add Preprocessing
    3. Taylor expanded in 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. accelerator-lowering-fma.f64N/A

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

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

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

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

      \[\leadsto \color{blue}{a \cdot b + t \cdot z} \]
    7. Step-by-step derivation
      1. accelerator-lowering-fma.f64N/A

        \[\leadsto \color{blue}{\mathsf{fma}\left(a, b, t \cdot z\right)} \]
      2. *-lowering-*.f6467.1

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

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

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

Alternative 11: 42.3% accurate, 1.1× speedup?

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

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (*.f64 c i) < -6.1999999999999998e58 or 4.0000000000000002e130 < (*.f64 c i)

    1. Initial program 93.5%

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

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

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

    if -6.1999999999999998e58 < (*.f64 c i) < 4.0000000000000002e130

    1. Initial program 98.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} \]
    4. Step-by-step derivation
      1. *-lowering-*.f6437.2

        \[\leadsto \color{blue}{a \cdot b} \]
    5. Simplified37.2%

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

Alternative 12: 27.4% 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 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 a around inf

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

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

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

Reproduce

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