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

Percentage Accurate: 96.0% → 98.1%
Time: 7.1s
Alternatives: 12
Speedup: 1.3×

Specification

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

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

Sampling outcomes in binary64 precision:

Local Percentage Accuracy vs ?

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

Accuracy vs Speed?

Herbie found 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: 96.0% accurate, 1.0× speedup?

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

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

Alternative 1: 98.1% accurate, 1.3× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 2: 89.6% accurate, 0.7× speedup?

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

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (*.f64 c i) < -1.99999999999999989e49 or 9.9999999999999999e52 < (*.f64 c i)

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

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

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

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

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

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

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

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

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

    if -1.99999999999999989e49 < (*.f64 c i) < 9.9999999999999999e52

    1. Initial program 97.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 3: 89.0% accurate, 0.7× speedup?

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

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (*.f64 x y) < -3.99999999999999974e169 or 1.00000000000000001e55 < (*.f64 x y)

    1. Initial program 94.3%

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

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

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

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

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

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

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

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

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

    if -3.99999999999999974e169 < (*.f64 x y) < 1.00000000000000001e55

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\mathsf{fma}\left(b, a, \mathsf{fma}\left(i, c, t \cdot z\right)\right)} \]
    6. Step-by-step derivation
      1. Applied rewrites96.5%

        \[\leadsto \color{blue}{\mathsf{fma}\left(z, t, \mathsf{fma}\left(c, i, a \cdot b\right)\right)} \]
    7. Recombined 2 regimes into one program.
    8. Final simplification94.0%

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

    Alternative 4: 88.9% accurate, 0.7× speedup?

    \[\begin{array}{l} \\ \begin{array}{l} t_1 := \mathsf{fma}\left(b, a, \mathsf{fma}\left(i, c, x \cdot y\right)\right)\\ \mathbf{if}\;x \cdot y \leq -4 \cdot 10^{+169}:\\ \;\;\;\;t\_1\\ \mathbf{elif}\;x \cdot y \leq 10^{+55}:\\ \;\;\;\;\mathsf{fma}\left(b, a, \mathsf{fma}\left(i, c, 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 b a (fma i c (* x y)))))
       (if (<= (* x y) -4e+169)
         t_1
         (if (<= (* x y) 1e+55) (fma b a (fma i c (* 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(b, a, fma(i, c, (x * y)));
    	double tmp;
    	if ((x * y) <= -4e+169) {
    		tmp = t_1;
    	} else if ((x * y) <= 1e+55) {
    		tmp = fma(b, a, fma(i, c, (z * t)));
    	} else {
    		tmp = t_1;
    	}
    	return tmp;
    }
    
    function code(x, y, z, t, a, b, c, i)
    	t_1 = fma(b, a, fma(i, c, Float64(x * y)))
    	tmp = 0.0
    	if (Float64(x * y) <= -4e+169)
    		tmp = t_1;
    	elseif (Float64(x * y) <= 1e+55)
    		tmp = fma(b, a, fma(i, c, 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[(b * a + N[(i * c + N[(x * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(x * y), $MachinePrecision], -4e+169], t$95$1, If[LessEqual[N[(x * y), $MachinePrecision], 1e+55], N[(b * a + N[(i * c + N[(z * t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$1]]]
    
    \begin{array}{l}
    
    \\
    \begin{array}{l}
    t_1 := \mathsf{fma}\left(b, a, \mathsf{fma}\left(i, c, x \cdot y\right)\right)\\
    \mathbf{if}\;x \cdot y \leq -4 \cdot 10^{+169}:\\
    \;\;\;\;t\_1\\
    
    \mathbf{elif}\;x \cdot y \leq 10^{+55}:\\
    \;\;\;\;\mathsf{fma}\left(b, a, \mathsf{fma}\left(i, c, z \cdot t\right)\right)\\
    
    \mathbf{else}:\\
    \;\;\;\;t\_1\\
    
    
    \end{array}
    \end{array}
    
    Derivation
    1. Split input into 2 regimes
    2. if (*.f64 x y) < -3.99999999999999974e169 or 1.00000000000000001e55 < (*.f64 x y)

      1. Initial program 94.3%

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

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

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

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

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

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

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

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

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

      if -3.99999999999999974e169 < (*.f64 x y) < 1.00000000000000001e55

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

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

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

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

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

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

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

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

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

    Alternative 5: 86.1% accurate, 0.7× speedup?

    \[\begin{array}{l} \\ \begin{array}{l} t_1 := \mathsf{fma}\left(i, c, x \cdot y\right)\\ \mathbf{if}\;x \cdot y \leq -5 \cdot 10^{+203}:\\ \;\;\;\;t\_1\\ \mathbf{elif}\;x \cdot y \leq 4 \cdot 10^{+190}:\\ \;\;\;\;\mathsf{fma}\left(b, a, \mathsf{fma}\left(i, c, 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 i c (* x y))))
       (if (<= (* x y) -5e+203)
         t_1
         (if (<= (* x y) 4e+190) (fma b a (fma i c (* 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, (x * y));
    	double tmp;
    	if ((x * y) <= -5e+203) {
    		tmp = t_1;
    	} else if ((x * y) <= 4e+190) {
    		tmp = fma(b, a, fma(i, c, (z * t)));
    	} else {
    		tmp = t_1;
    	}
    	return tmp;
    }
    
    function code(x, y, z, t, a, b, c, i)
    	t_1 = fma(i, c, Float64(x * y))
    	tmp = 0.0
    	if (Float64(x * y) <= -5e+203)
    		tmp = t_1;
    	elseif (Float64(x * y) <= 4e+190)
    		tmp = fma(b, a, fma(i, c, 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[(x * y), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(x * y), $MachinePrecision], -5e+203], t$95$1, If[LessEqual[N[(x * y), $MachinePrecision], 4e+190], N[(b * a + N[(i * c + N[(z * t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$1]]]
    
    \begin{array}{l}
    
    \\
    \begin{array}{l}
    t_1 := \mathsf{fma}\left(i, c, x \cdot y\right)\\
    \mathbf{if}\;x \cdot y \leq -5 \cdot 10^{+203}:\\
    \;\;\;\;t\_1\\
    
    \mathbf{elif}\;x \cdot y \leq 4 \cdot 10^{+190}:\\
    \;\;\;\;\mathsf{fma}\left(b, a, \mathsf{fma}\left(i, c, z \cdot t\right)\right)\\
    
    \mathbf{else}:\\
    \;\;\;\;t\_1\\
    
    
    \end{array}
    \end{array}
    
    Derivation
    1. Split input into 2 regimes
    2. if (*.f64 x y) < -4.99999999999999994e203 or 4.0000000000000003e190 < (*.f64 x y)

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

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

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

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

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

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

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

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

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

        \[\leadsto a \cdot b + \color{blue}{x \cdot y} \]
      7. Step-by-step derivation
        1. Applied rewrites81.4%

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

          \[\leadsto a \cdot b \]
        3. Step-by-step derivation
          1. Applied rewrites7.4%

            \[\leadsto b \cdot a \]
          2. Taylor expanded in a around 0

            \[\leadsto c \cdot i + \color{blue}{x \cdot y} \]
          3. Step-by-step derivation
            1. Applied rewrites89.2%

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

            if -4.99999999999999994e203 < (*.f64 x y) < 4.0000000000000003e190

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

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

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

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

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

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

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

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

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

          Alternative 6: 42.7% accurate, 0.8× speedup?

          \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;c \cdot i \leq -2 \cdot 10^{+83}:\\ \;\;\;\;c \cdot i\\ \mathbf{elif}\;c \cdot i \leq 2 \cdot 10^{+25}:\\ \;\;\;\;a \cdot b\\ \mathbf{elif}\;c \cdot i \leq 10^{+63}:\\ \;\;\;\;x \cdot y\\ \mathbf{else}:\\ \;\;\;\;c \cdot i\\ \end{array} \end{array} \]
          (FPCore (x y z t a b c i)
           :precision binary64
           (if (<= (* c i) -2e+83)
             (* c i)
             (if (<= (* c i) 2e+25) (* a b) (if (<= (* c i) 1e+63) (* x y) (* 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+83) {
          		tmp = c * i;
          	} else if ((c * i) <= 2e+25) {
          		tmp = a * b;
          	} else if ((c * i) <= 1e+63) {
          		tmp = x * y;
          	} 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) <= (-2d+83)) then
                  tmp = c * i
              else if ((c * i) <= 2d+25) then
                  tmp = a * b
              else if ((c * i) <= 1d+63) then
                  tmp = x * y
              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) <= -2e+83) {
          		tmp = c * i;
          	} else if ((c * i) <= 2e+25) {
          		tmp = a * b;
          	} else if ((c * i) <= 1e+63) {
          		tmp = x * y;
          	} else {
          		tmp = c * i;
          	}
          	return tmp;
          }
          
          def code(x, y, z, t, a, b, c, i):
          	tmp = 0
          	if (c * i) <= -2e+83:
          		tmp = c * i
          	elif (c * i) <= 2e+25:
          		tmp = a * b
          	elif (c * i) <= 1e+63:
          		tmp = x * y
          	else:
          		tmp = c * i
          	return tmp
          
          function code(x, y, z, t, a, b, c, i)
          	tmp = 0.0
          	if (Float64(c * i) <= -2e+83)
          		tmp = Float64(c * i);
          	elseif (Float64(c * i) <= 2e+25)
          		tmp = Float64(a * b);
          	elseif (Float64(c * i) <= 1e+63)
          		tmp = Float64(x * y);
          	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) <= -2e+83)
          		tmp = c * i;
          	elseif ((c * i) <= 2e+25)
          		tmp = a * b;
          	elseif ((c * i) <= 1e+63)
          		tmp = x * y;
          	else
          		tmp = c * i;
          	end
          	tmp_2 = tmp;
          end
          
          code[x_, y_, z_, t_, a_, b_, c_, i_] := If[LessEqual[N[(c * i), $MachinePrecision], -2e+83], N[(c * i), $MachinePrecision], If[LessEqual[N[(c * i), $MachinePrecision], 2e+25], N[(a * b), $MachinePrecision], If[LessEqual[N[(c * i), $MachinePrecision], 1e+63], N[(x * y), $MachinePrecision], N[(c * i), $MachinePrecision]]]]
          
          \begin{array}{l}
          
          \\
          \begin{array}{l}
          \mathbf{if}\;c \cdot i \leq -2 \cdot 10^{+83}:\\
          \;\;\;\;c \cdot i\\
          
          \mathbf{elif}\;c \cdot i \leq 2 \cdot 10^{+25}:\\
          \;\;\;\;a \cdot b\\
          
          \mathbf{elif}\;c \cdot i \leq 10^{+63}:\\
          \;\;\;\;x \cdot y\\
          
          \mathbf{else}:\\
          \;\;\;\;c \cdot i\\
          
          
          \end{array}
          \end{array}
          
          Derivation
          1. Split input into 3 regimes
          2. if (*.f64 c i) < -2.00000000000000006e83 or 1.00000000000000006e63 < (*.f64 c i)

            1. Initial program 96.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 inf

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

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

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

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

            if -2.00000000000000006e83 < (*.f64 c i) < 2.00000000000000018e25

            1. Initial program 97.9%

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

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

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

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

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

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

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

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

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

              \[\leadsto a \cdot b + \color{blue}{x \cdot y} \]
            7. Step-by-step derivation
              1. Applied rewrites68.5%

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

                \[\leadsto a \cdot b \]
              3. Step-by-step derivation
                1. Applied rewrites40.8%

                  \[\leadsto b \cdot a \]

                if 2.00000000000000018e25 < (*.f64 c i) < 1.00000000000000006e63

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

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

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

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

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

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

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

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

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

                  \[\leadsto a \cdot b + \color{blue}{x \cdot y} \]
                7. Step-by-step derivation
                  1. Applied rewrites73.6%

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

                    \[\leadsto a \cdot b \]
                  3. Step-by-step derivation
                    1. Applied rewrites1.6%

                      \[\leadsto b \cdot a \]
                    2. Taylor expanded in x around inf

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

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

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

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

                    \[\leadsto \begin{array}{l} \mathbf{if}\;c \cdot i \leq -2 \cdot 10^{+83}:\\ \;\;\;\;c \cdot i\\ \mathbf{elif}\;c \cdot i \leq 2 \cdot 10^{+25}:\\ \;\;\;\;a \cdot b\\ \mathbf{elif}\;c \cdot i \leq 10^{+63}:\\ \;\;\;\;x \cdot y\\ \mathbf{else}:\\ \;\;\;\;c \cdot i\\ \end{array} \]
                  6. Add Preprocessing

                  Alternative 7: 65.9% accurate, 0.9× speedup?

                  \[\begin{array}{l} \\ \begin{array}{l} t_1 := \mathsf{fma}\left(i, c, x \cdot y\right)\\ \mathbf{if}\;c \cdot i \leq -2 \cdot 10^{+83}:\\ \;\;\;\;t\_1\\ \mathbf{elif}\;c \cdot i \leq 2 \cdot 10^{+33}:\\ \;\;\;\;\mathsf{fma}\left(b, a, 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 (* x y))))
                     (if (<= (* c i) -2e+83) t_1 (if (<= (* c i) 2e+33) (fma b a (* 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, (x * y));
                  	double tmp;
                  	if ((c * i) <= -2e+83) {
                  		tmp = t_1;
                  	} else if ((c * i) <= 2e+33) {
                  		tmp = fma(b, a, (z * t));
                  	} else {
                  		tmp = t_1;
                  	}
                  	return tmp;
                  }
                  
                  function code(x, y, z, t, a, b, c, i)
                  	t_1 = fma(i, c, Float64(x * y))
                  	tmp = 0.0
                  	if (Float64(c * i) <= -2e+83)
                  		tmp = t_1;
                  	elseif (Float64(c * i) <= 2e+33)
                  		tmp = fma(b, a, 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[(x * y), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(c * i), $MachinePrecision], -2e+83], t$95$1, If[LessEqual[N[(c * i), $MachinePrecision], 2e+33], N[(b * a + N[(z * t), $MachinePrecision]), $MachinePrecision], t$95$1]]]
                  
                  \begin{array}{l}
                  
                  \\
                  \begin{array}{l}
                  t_1 := \mathsf{fma}\left(i, c, x \cdot y\right)\\
                  \mathbf{if}\;c \cdot i \leq -2 \cdot 10^{+83}:\\
                  \;\;\;\;t\_1\\
                  
                  \mathbf{elif}\;c \cdot i \leq 2 \cdot 10^{+33}:\\
                  \;\;\;\;\mathsf{fma}\left(b, a, z \cdot t\right)\\
                  
                  \mathbf{else}:\\
                  \;\;\;\;t\_1\\
                  
                  
                  \end{array}
                  \end{array}
                  
                  Derivation
                  1. Split input into 2 regimes
                  2. if (*.f64 c i) < -2.00000000000000006e83 or 1.9999999999999999e33 < (*.f64 c i)

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

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

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

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

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

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

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

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

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

                      \[\leadsto a \cdot b + \color{blue}{x \cdot y} \]
                    7. Step-by-step derivation
                      1. Applied rewrites36.1%

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

                        \[\leadsto a \cdot b \]
                      3. Step-by-step derivation
                        1. Applied rewrites13.0%

                          \[\leadsto b \cdot a \]
                        2. Taylor expanded in a around 0

                          \[\leadsto c \cdot i + \color{blue}{x \cdot y} \]
                        3. Step-by-step derivation
                          1. Applied rewrites84.3%

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

                          if -2.00000000000000006e83 < (*.f64 c i) < 1.9999999999999999e33

                          1. Initial program 97.9%

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

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

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

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

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

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

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

                            \[\leadsto \color{blue}{\mathsf{fma}\left(b, a, \mathsf{fma}\left(i, c, t \cdot z\right)\right)} \]
                          6. Step-by-step derivation
                            1. Applied rewrites73.7%

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

                              \[\leadsto a \cdot b + \color{blue}{t \cdot z} \]
                            3. Step-by-step derivation
                              1. Applied rewrites69.3%

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

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

                            Alternative 8: 66.5% accurate, 0.9× speedup?

                            \[\begin{array}{l} \\ \begin{array}{l} t_1 := \mathsf{fma}\left(i, c, x \cdot y\right)\\ \mathbf{if}\;c \cdot i \leq -2 \cdot 10^{+83}:\\ \;\;\;\;t\_1\\ \mathbf{elif}\;c \cdot i \leq 2 \cdot 10^{+23}:\\ \;\;\;\;\mathsf{fma}\left(y, x, 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 i c (* x y))))
                               (if (<= (* c i) -2e+83) t_1 (if (<= (* c i) 2e+23) (fma y x (* 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(i, c, (x * y));
                            	double tmp;
                            	if ((c * i) <= -2e+83) {
                            		tmp = t_1;
                            	} else if ((c * i) <= 2e+23) {
                            		tmp = fma(y, x, (a * b));
                            	} else {
                            		tmp = t_1;
                            	}
                            	return tmp;
                            }
                            
                            function code(x, y, z, t, a, b, c, i)
                            	t_1 = fma(i, c, Float64(x * y))
                            	tmp = 0.0
                            	if (Float64(c * i) <= -2e+83)
                            		tmp = t_1;
                            	elseif (Float64(c * i) <= 2e+23)
                            		tmp = fma(y, x, 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[(i * c + N[(x * y), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(c * i), $MachinePrecision], -2e+83], t$95$1, If[LessEqual[N[(c * i), $MachinePrecision], 2e+23], N[(y * x + N[(a * b), $MachinePrecision]), $MachinePrecision], t$95$1]]]
                            
                            \begin{array}{l}
                            
                            \\
                            \begin{array}{l}
                            t_1 := \mathsf{fma}\left(i, c, x \cdot y\right)\\
                            \mathbf{if}\;c \cdot i \leq -2 \cdot 10^{+83}:\\
                            \;\;\;\;t\_1\\
                            
                            \mathbf{elif}\;c \cdot i \leq 2 \cdot 10^{+23}:\\
                            \;\;\;\;\mathsf{fma}\left(y, x, a \cdot b\right)\\
                            
                            \mathbf{else}:\\
                            \;\;\;\;t\_1\\
                            
                            
                            \end{array}
                            \end{array}
                            
                            Derivation
                            1. Split input into 2 regimes
                            2. if (*.f64 c i) < -2.00000000000000006e83 or 1.9999999999999998e23 < (*.f64 c i)

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

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

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

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

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

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

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

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

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

                                \[\leadsto a \cdot b + \color{blue}{x \cdot y} \]
                              7. Step-by-step derivation
                                1. Applied rewrites35.7%

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

                                  \[\leadsto a \cdot b \]
                                3. Step-by-step derivation
                                  1. Applied rewrites12.7%

                                    \[\leadsto b \cdot a \]
                                  2. Taylor expanded in a around 0

                                    \[\leadsto c \cdot i + \color{blue}{x \cdot y} \]
                                  3. Step-by-step derivation
                                    1. Applied rewrites83.0%

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

                                    if -2.00000000000000006e83 < (*.f64 c i) < 1.9999999999999998e23

                                    1. Initial program 97.8%

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

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

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

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

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

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

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

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

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

                                      \[\leadsto a \cdot b + \color{blue}{x \cdot y} \]
                                    7. Step-by-step derivation
                                      1. Applied rewrites68.9%

                                        \[\leadsto \mathsf{fma}\left(a, \color{blue}{b}, x \cdot y\right) \]
                                      2. Step-by-step derivation
                                        1. Applied rewrites68.9%

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

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

                                      Alternative 9: 66.6% accurate, 0.9× speedup?

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

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

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

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

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

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

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

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

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

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

                                          \[\leadsto a \cdot b + \color{blue}{x \cdot y} \]
                                        7. Step-by-step derivation
                                          1. Applied rewrites35.7%

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

                                            \[\leadsto a \cdot b \]
                                          3. Step-by-step derivation
                                            1. Applied rewrites12.7%

                                              \[\leadsto b \cdot a \]
                                            2. Taylor expanded in a around 0

                                              \[\leadsto c \cdot i + \color{blue}{x \cdot y} \]
                                            3. Step-by-step derivation
                                              1. Applied rewrites83.0%

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

                                              if -2.00000000000000006e83 < (*.f64 c i) < 1.9999999999999998e23

                                              1. Initial program 97.8%

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

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

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

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

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

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

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

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

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

                                                \[\leadsto a \cdot b + \color{blue}{x \cdot y} \]
                                              7. Step-by-step derivation
                                                1. Applied rewrites68.9%

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

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

                                              Alternative 10: 63.8% accurate, 0.9× speedup?

                                              \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;c \cdot i \leq -1 \cdot 10^{+159}:\\ \;\;\;\;c \cdot i\\ \mathbf{elif}\;c \cdot i \leq 10^{+218}:\\ \;\;\;\;\mathsf{fma}\left(a, b, x \cdot y\right)\\ \mathbf{else}:\\ \;\;\;\;c \cdot i\\ \end{array} \end{array} \]
                                              (FPCore (x y z t a b c i)
                                               :precision binary64
                                               (if (<= (* c i) -1e+159)
                                                 (* c i)
                                                 (if (<= (* c i) 1e+218) (fma a b (* x y)) (* 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) <= -1e+159) {
                                              		tmp = c * i;
                                              	} else if ((c * i) <= 1e+218) {
                                              		tmp = fma(a, b, (x * y));
                                              	} else {
                                              		tmp = c * i;
                                              	}
                                              	return tmp;
                                              }
                                              
                                              function code(x, y, z, t, a, b, c, i)
                                              	tmp = 0.0
                                              	if (Float64(c * i) <= -1e+159)
                                              		tmp = Float64(c * i);
                                              	elseif (Float64(c * i) <= 1e+218)
                                              		tmp = fma(a, b, Float64(x * y));
                                              	else
                                              		tmp = Float64(c * i);
                                              	end
                                              	return tmp
                                              end
                                              
                                              code[x_, y_, z_, t_, a_, b_, c_, i_] := If[LessEqual[N[(c * i), $MachinePrecision], -1e+159], N[(c * i), $MachinePrecision], If[LessEqual[N[(c * i), $MachinePrecision], 1e+218], N[(a * b + N[(x * y), $MachinePrecision]), $MachinePrecision], N[(c * i), $MachinePrecision]]]
                                              
                                              \begin{array}{l}
                                              
                                              \\
                                              \begin{array}{l}
                                              \mathbf{if}\;c \cdot i \leq -1 \cdot 10^{+159}:\\
                                              \;\;\;\;c \cdot i\\
                                              
                                              \mathbf{elif}\;c \cdot i \leq 10^{+218}:\\
                                              \;\;\;\;\mathsf{fma}\left(a, b, x \cdot y\right)\\
                                              
                                              \mathbf{else}:\\
                                              \;\;\;\;c \cdot i\\
                                              
                                              
                                              \end{array}
                                              \end{array}
                                              
                                              Derivation
                                              1. Split input into 2 regimes
                                              2. if (*.f64 c i) < -9.9999999999999993e158 or 1.00000000000000008e218 < (*.f64 c i)

                                                1. Initial program 95.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. *-commutativeN/A

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

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

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

                                                if -9.9999999999999993e158 < (*.f64 c i) < 1.00000000000000008e218

                                                1. Initial program 97.8%

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

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

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

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

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

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

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

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

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

                                                  \[\leadsto a \cdot b + \color{blue}{x \cdot y} \]
                                                7. Step-by-step derivation
                                                  1. Applied rewrites65.1%

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

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

                                                Alternative 11: 42.4% accurate, 1.1× speedup?

                                                \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;c \cdot i \leq -2 \cdot 10^{+83}:\\ \;\;\;\;c \cdot i\\ \mathbf{elif}\;c \cdot i \leq 2 \cdot 10^{+23}:\\ \;\;\;\;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) -2e+83) (* c i) (if (<= (* c i) 2e+23) (* 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) <= -2e+83) {
                                                		tmp = c * i;
                                                	} else if ((c * i) <= 2e+23) {
                                                		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) <= (-2d+83)) then
                                                        tmp = c * i
                                                    else if ((c * i) <= 2d+23) 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) <= -2e+83) {
                                                		tmp = c * i;
                                                	} else if ((c * i) <= 2e+23) {
                                                		tmp = a * b;
                                                	} else {
                                                		tmp = c * i;
                                                	}
                                                	return tmp;
                                                }
                                                
                                                def code(x, y, z, t, a, b, c, i):
                                                	tmp = 0
                                                	if (c * i) <= -2e+83:
                                                		tmp = c * i
                                                	elif (c * i) <= 2e+23:
                                                		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) <= -2e+83)
                                                		tmp = Float64(c * i);
                                                	elseif (Float64(c * i) <= 2e+23)
                                                		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) <= -2e+83)
                                                		tmp = c * i;
                                                	elseif ((c * i) <= 2e+23)
                                                		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], -2e+83], N[(c * i), $MachinePrecision], If[LessEqual[N[(c * i), $MachinePrecision], 2e+23], N[(a * b), $MachinePrecision], N[(c * i), $MachinePrecision]]]
                                                
                                                \begin{array}{l}
                                                
                                                \\
                                                \begin{array}{l}
                                                \mathbf{if}\;c \cdot i \leq -2 \cdot 10^{+83}:\\
                                                \;\;\;\;c \cdot i\\
                                                
                                                \mathbf{elif}\;c \cdot i \leq 2 \cdot 10^{+23}:\\
                                                \;\;\;\;a \cdot b\\
                                                
                                                \mathbf{else}:\\
                                                \;\;\;\;c \cdot i\\
                                                
                                                
                                                \end{array}
                                                \end{array}
                                                
                                                Derivation
                                                1. Split input into 2 regimes
                                                2. if (*.f64 c i) < -2.00000000000000006e83 or 1.9999999999999998e23 < (*.f64 c i)

                                                  1. Initial program 96.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. *-commutativeN/A

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

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

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

                                                  if -2.00000000000000006e83 < (*.f64 c i) < 1.9999999999999998e23

                                                  1. Initial program 97.8%

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

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

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

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

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

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

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

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

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

                                                    \[\leadsto a \cdot b + \color{blue}{x \cdot y} \]
                                                  7. Step-by-step derivation
                                                    1. Applied rewrites68.9%

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

                                                      \[\leadsto a \cdot b \]
                                                    3. Step-by-step derivation
                                                      1. Applied rewrites41.1%

                                                        \[\leadsto b \cdot a \]
                                                    4. Recombined 2 regimes into one program.
                                                    5. Final simplification50.8%

                                                      \[\leadsto \begin{array}{l} \mathbf{if}\;c \cdot i \leq -2 \cdot 10^{+83}:\\ \;\;\;\;c \cdot i\\ \mathbf{elif}\;c \cdot i \leq 2 \cdot 10^{+23}:\\ \;\;\;\;a \cdot b\\ \mathbf{else}:\\ \;\;\;\;c \cdot i\\ \end{array} \]
                                                    6. Add Preprocessing

                                                    Alternative 12: 27.0% 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 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 z around 0

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

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

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

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

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

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

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

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

                                                      \[\leadsto a \cdot b + \color{blue}{x \cdot y} \]
                                                    7. Step-by-step derivation
                                                      1. Applied rewrites53.9%

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

                                                        \[\leadsto a \cdot b \]
                                                      3. Step-by-step derivation
                                                        1. Applied rewrites28.2%

                                                          \[\leadsto b \cdot a \]
                                                        2. Final simplification28.2%

                                                          \[\leadsto a \cdot b \]
                                                        3. Add Preprocessing

                                                        Reproduce

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