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

Percentage Accurate: 95.7% → 97.5%
Time: 8.7s
Alternatives: 10
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 10 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.5% 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, a \cdot b\right)\\ \end{array} \end{array} \]
(FPCore (x y z t a b c i)
 :precision binary64
 (let* ((t_1 (+ (+ (+ (* x y) (* z t)) (* a b)) (* c i))))
   (if (<= t_1 INFINITY) t_1 (fma x y (* a b)))))
double code(double x, double y, double z, double t, double a, double b, double c, double i) {
	double t_1 = (((x * y) + (z * t)) + (a * b)) + (c * i);
	double tmp;
	if (t_1 <= ((double) INFINITY)) {
		tmp = t_1;
	} else {
		tmp = fma(x, y, (a * b));
	}
	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, Float64(a * b));
	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), $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, a \cdot b\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. 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-*.f6450.0

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

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

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

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

Alternative 2: 43.1% accurate, 0.6× speedup?

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

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

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

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

\mathbf{elif}\;z \cdot t \leq 1000000000000:\\
\;\;\;\;a \cdot b\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if (*.f64 z t) < -1.99999999999999998e132 or 1e12 < (*.f64 z t)

    1. Initial program 97.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-*.f6468.2

        \[\leadsto \color{blue}{t \cdot z} \]
    5. Simplified68.2%

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

    if -1.99999999999999998e132 < (*.f64 z t) < -1e-176 or 1e-264 < (*.f64 z t) < 1e12

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

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

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

    if -1e-176 < (*.f64 z t) < 1e-264

    1. Initial program 96.3%

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \cdot t \leq -2 \cdot 10^{+132}:\\ \;\;\;\;z \cdot t\\ \mathbf{elif}\;z \cdot t \leq -1 \cdot 10^{-176}:\\ \;\;\;\;a \cdot b\\ \mathbf{elif}\;z \cdot t \leq 10^{-264}:\\ \;\;\;\;x \cdot y\\ \mathbf{elif}\;z \cdot t \leq 1000000000000:\\ \;\;\;\;a \cdot b\\ \mathbf{else}:\\ \;\;\;\;z \cdot t\\ \end{array} \]
  5. Add Preprocessing

Alternative 3: 76.0% accurate, 0.6× speedup?

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

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (+.f64 (*.f64 x y) (*.f64 z t)) < -5.00000000000000009e150 or 5.0000000000000003e129 < (+.f64 (*.f64 x y) (*.f64 z t))

    1. Initial program 96.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. 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-*.f6492.6

        \[\leadsto \mathsf{fma}\left(x, y, \mathsf{fma}\left(a, b, \color{blue}{t \cdot z}\right)\right) \]
    5. Simplified92.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 \mathsf{fma}\left(x, y, \color{blue}{t \cdot z}\right) \]
    7. Step-by-step derivation
      1. lower-*.f6482.2

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

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

    if -5.00000000000000009e150 < (+.f64 (*.f64 x y) (*.f64 z t)) < 5.0000000000000003e129

    1. Initial program 97.5%

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

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

        \[\leadsto \color{blue}{a \cdot b} + c \cdot i \]
    5. Simplified80.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.f6481.6

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

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

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

Alternative 4: 67.2% accurate, 0.7× speedup?

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

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

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

\mathbf{elif}\;x \cdot y \leq 2 \cdot 10^{+110}:\\
\;\;\;\;\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 x y) < -2.00000000000000007e121 or 2e110 < (*.f64 x y)

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

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

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

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

    if -2.00000000000000007e121 < (*.f64 x y) < -1e7

    1. Initial program 95.6%

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

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

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

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

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

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

    if -1e7 < (*.f64 x y) < 2e110

    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. 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-*.f6476.0

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

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

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

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

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

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

Alternative 5: 85.8% accurate, 0.7× speedup?

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

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

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

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


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

    1. Initial program 92.3%

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

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

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

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

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

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

    if -2.00000000000000011e232 < (*.f64 c i) < 5.0000000000000001e215

    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. 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-*.f6489.9

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

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

    if 5.0000000000000001e215 < (*.f64 c i)

    1. Initial program 88.5%

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

        \[\leadsto \color{blue}{t \cdot z} + c \cdot i \]
    5. Simplified96.2%

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

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

        \[\leadsto z \cdot t + \color{blue}{c \cdot i} \]
      3. lower-fma.f6496.2

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

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

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

Alternative 6: 66.9% accurate, 0.9× speedup?

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

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (*.f64 z t) < -1.9999999999999999e82 or 5e13 < (*.f64 z t)

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

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

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

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

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

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

    if -1.9999999999999999e82 < (*.f64 z t) < 5e13

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

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

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

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

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

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

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

Alternative 7: 63.8% accurate, 0.9× speedup?

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

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (*.f64 x y) < -2.95e206 or 5.99999999999999952e217 < (*.f64 x y)

    1. Initial program 90.7%

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

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

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

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

    if -2.95e206 < (*.f64 x y) < 5.99999999999999952e217

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

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

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

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

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

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

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

Alternative 8: 43.3% accurate, 1.1× speedup?

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

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

\mathbf{elif}\;z \cdot t \leq 1000000000000:\\
\;\;\;\;a \cdot b\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (*.f64 z t) < -1.99999999999999998e132 or 1e12 < (*.f64 z t)

    1. Initial program 97.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-*.f6468.2

        \[\leadsto \color{blue}{t \cdot z} \]
    5. Simplified68.2%

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

    if -1.99999999999999998e132 < (*.f64 z t) < 1e12

    1. Initial program 96.8%

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;z \cdot t \leq -2 \cdot 10^{+132}:\\ \;\;\;\;z \cdot t\\ \mathbf{elif}\;z \cdot t \leq 1000000000000:\\ \;\;\;\;a \cdot b\\ \mathbf{else}:\\ \;\;\;\;z \cdot t\\ \end{array} \]
  5. Add Preprocessing

Alternative 9: 42.7% accurate, 1.1× speedup?

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

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (*.f64 a b) < -2.60000000000000011e56 or 8.5999999999999994e90 < (*.f64 a b)

    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} \]
    4. Step-by-step derivation
      1. lower-*.f6470.6

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

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

    if -2.60000000000000011e56 < (*.f64 a b) < 8.5999999999999994e90

    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 inf

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

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

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

Alternative 10: 27.7% 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. lower-*.f6431.2

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

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

Reproduce

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