Maksimov and Kolovsky, Equation (32)

Percentage Accurate: 75.9% → 96.1%
Time: 13.8s
Alternatives: 16
Speedup: 1.9×

Specification

?
\[\begin{array}{l} \\ \cos \left(\frac{K \cdot \left(m + n\right)}{2} - M\right) \cdot e^{\left(-{\left(\frac{m + n}{2} - M\right)}^{2}\right) - \left(\ell - \left|m - n\right|\right)} \end{array} \]
(FPCore (K m n M l)
 :precision binary64
 (*
  (cos (- (/ (* K (+ m n)) 2.0) M))
  (exp (- (- (pow (- (/ (+ m n) 2.0) M) 2.0)) (- l (fabs (- m n)))))))
double code(double K, double m, double n, double M, double l) {
	return cos((((K * (m + n)) / 2.0) - M)) * exp((-pow((((m + n) / 2.0) - M), 2.0) - (l - fabs((m - n)))));
}
real(8) function code(k, m, n, m_1, l)
    real(8), intent (in) :: k
    real(8), intent (in) :: m
    real(8), intent (in) :: n
    real(8), intent (in) :: m_1
    real(8), intent (in) :: l
    code = cos((((k * (m + n)) / 2.0d0) - m_1)) * exp((-((((m + n) / 2.0d0) - m_1) ** 2.0d0) - (l - abs((m - n)))))
end function
public static double code(double K, double m, double n, double M, double l) {
	return Math.cos((((K * (m + n)) / 2.0) - M)) * Math.exp((-Math.pow((((m + n) / 2.0) - M), 2.0) - (l - Math.abs((m - n)))));
}
def code(K, m, n, M, l):
	return math.cos((((K * (m + n)) / 2.0) - M)) * math.exp((-math.pow((((m + n) / 2.0) - M), 2.0) - (l - math.fabs((m - n)))))
function code(K, m, n, M, l)
	return Float64(cos(Float64(Float64(Float64(K * Float64(m + n)) / 2.0) - M)) * exp(Float64(Float64(-(Float64(Float64(Float64(m + n) / 2.0) - M) ^ 2.0)) - Float64(l - abs(Float64(m - n))))))
end
function tmp = code(K, m, n, M, l)
	tmp = cos((((K * (m + n)) / 2.0) - M)) * exp((-((((m + n) / 2.0) - M) ^ 2.0) - (l - abs((m - n)))));
end
code[K_, m_, n_, M_, l_] := N[(N[Cos[N[(N[(N[(K * N[(m + n), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision] - M), $MachinePrecision]], $MachinePrecision] * N[Exp[N[((-N[Power[N[(N[(N[(m + n), $MachinePrecision] / 2.0), $MachinePrecision] - M), $MachinePrecision], 2.0], $MachinePrecision]) - N[(l - N[Abs[N[(m - n), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
\cos \left(\frac{K \cdot \left(m + n\right)}{2} - M\right) \cdot e^{\left(-{\left(\frac{m + n}{2} - M\right)}^{2}\right) - \left(\ell - \left|m - n\right|\right)}
\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 16 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: 75.9% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \cos \left(\frac{K \cdot \left(m + n\right)}{2} - M\right) \cdot e^{\left(-{\left(\frac{m + n}{2} - M\right)}^{2}\right) - \left(\ell - \left|m - n\right|\right)} \end{array} \]
(FPCore (K m n M l)
 :precision binary64
 (*
  (cos (- (/ (* K (+ m n)) 2.0) M))
  (exp (- (- (pow (- (/ (+ m n) 2.0) M) 2.0)) (- l (fabs (- m n)))))))
double code(double K, double m, double n, double M, double l) {
	return cos((((K * (m + n)) / 2.0) - M)) * exp((-pow((((m + n) / 2.0) - M), 2.0) - (l - fabs((m - n)))));
}
real(8) function code(k, m, n, m_1, l)
    real(8), intent (in) :: k
    real(8), intent (in) :: m
    real(8), intent (in) :: n
    real(8), intent (in) :: m_1
    real(8), intent (in) :: l
    code = cos((((k * (m + n)) / 2.0d0) - m_1)) * exp((-((((m + n) / 2.0d0) - m_1) ** 2.0d0) - (l - abs((m - n)))))
end function
public static double code(double K, double m, double n, double M, double l) {
	return Math.cos((((K * (m + n)) / 2.0) - M)) * Math.exp((-Math.pow((((m + n) / 2.0) - M), 2.0) - (l - Math.abs((m - n)))));
}
def code(K, m, n, M, l):
	return math.cos((((K * (m + n)) / 2.0) - M)) * math.exp((-math.pow((((m + n) / 2.0) - M), 2.0) - (l - math.fabs((m - n)))))
function code(K, m, n, M, l)
	return Float64(cos(Float64(Float64(Float64(K * Float64(m + n)) / 2.0) - M)) * exp(Float64(Float64(-(Float64(Float64(Float64(m + n) / 2.0) - M) ^ 2.0)) - Float64(l - abs(Float64(m - n))))))
end
function tmp = code(K, m, n, M, l)
	tmp = cos((((K * (m + n)) / 2.0) - M)) * exp((-((((m + n) / 2.0) - M) ^ 2.0) - (l - abs((m - n)))));
end
code[K_, m_, n_, M_, l_] := N[(N[Cos[N[(N[(N[(K * N[(m + n), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision] - M), $MachinePrecision]], $MachinePrecision] * N[Exp[N[((-N[Power[N[(N[(N[(m + n), $MachinePrecision] / 2.0), $MachinePrecision] - M), $MachinePrecision], 2.0], $MachinePrecision]) - N[(l - N[Abs[N[(m - n), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
\cos \left(\frac{K \cdot \left(m + n\right)}{2} - M\right) \cdot e^{\left(-{\left(\frac{m + n}{2} - M\right)}^{2}\right) - \left(\ell - \left|m - n\right|\right)}
\end{array}

Alternative 1: 96.1% accurate, 1.8× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \left|m - n\right|\\ t_1 := \frac{m + n}{2} - M\\ \mathbf{if}\;M \leq -2.3 \cdot 10^{+112}:\\ \;\;\;\;\frac{1}{e^{\left(\ell + M \cdot M\right) - t\_0}}\\ \mathbf{elif}\;M \leq 10^{+95}:\\ \;\;\;\;\frac{1 + \left(M \cdot M\right) \cdot -0.5}{e^{\left(t\_1 \cdot t\_1 + \ell\right) - t\_0}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\cos M}{e^{M \cdot M}}\\ \end{array} \end{array} \]
(FPCore (K m n M l)
 :precision binary64
 (let* ((t_0 (fabs (- m n))) (t_1 (- (/ (+ m n) 2.0) M)))
   (if (<= M -2.3e+112)
     (/ 1.0 (exp (- (+ l (* M M)) t_0)))
     (if (<= M 1e+95)
       (/ (+ 1.0 (* (* M M) -0.5)) (exp (- (+ (* t_1 t_1) l) t_0)))
       (/ (cos M) (exp (* M M)))))))
double code(double K, double m, double n, double M, double l) {
	double t_0 = fabs((m - n));
	double t_1 = ((m + n) / 2.0) - M;
	double tmp;
	if (M <= -2.3e+112) {
		tmp = 1.0 / exp(((l + (M * M)) - t_0));
	} else if (M <= 1e+95) {
		tmp = (1.0 + ((M * M) * -0.5)) / exp((((t_1 * t_1) + l) - t_0));
	} else {
		tmp = cos(M) / exp((M * M));
	}
	return tmp;
}
real(8) function code(k, m, n, m_1, l)
    real(8), intent (in) :: k
    real(8), intent (in) :: m
    real(8), intent (in) :: n
    real(8), intent (in) :: m_1
    real(8), intent (in) :: l
    real(8) :: t_0
    real(8) :: t_1
    real(8) :: tmp
    t_0 = abs((m - n))
    t_1 = ((m + n) / 2.0d0) - m_1
    if (m_1 <= (-2.3d+112)) then
        tmp = 1.0d0 / exp(((l + (m_1 * m_1)) - t_0))
    else if (m_1 <= 1d+95) then
        tmp = (1.0d0 + ((m_1 * m_1) * (-0.5d0))) / exp((((t_1 * t_1) + l) - t_0))
    else
        tmp = cos(m_1) / exp((m_1 * m_1))
    end if
    code = tmp
end function
public static double code(double K, double m, double n, double M, double l) {
	double t_0 = Math.abs((m - n));
	double t_1 = ((m + n) / 2.0) - M;
	double tmp;
	if (M <= -2.3e+112) {
		tmp = 1.0 / Math.exp(((l + (M * M)) - t_0));
	} else if (M <= 1e+95) {
		tmp = (1.0 + ((M * M) * -0.5)) / Math.exp((((t_1 * t_1) + l) - t_0));
	} else {
		tmp = Math.cos(M) / Math.exp((M * M));
	}
	return tmp;
}
def code(K, m, n, M, l):
	t_0 = math.fabs((m - n))
	t_1 = ((m + n) / 2.0) - M
	tmp = 0
	if M <= -2.3e+112:
		tmp = 1.0 / math.exp(((l + (M * M)) - t_0))
	elif M <= 1e+95:
		tmp = (1.0 + ((M * M) * -0.5)) / math.exp((((t_1 * t_1) + l) - t_0))
	else:
		tmp = math.cos(M) / math.exp((M * M))
	return tmp
function code(K, m, n, M, l)
	t_0 = abs(Float64(m - n))
	t_1 = Float64(Float64(Float64(m + n) / 2.0) - M)
	tmp = 0.0
	if (M <= -2.3e+112)
		tmp = Float64(1.0 / exp(Float64(Float64(l + Float64(M * M)) - t_0)));
	elseif (M <= 1e+95)
		tmp = Float64(Float64(1.0 + Float64(Float64(M * M) * -0.5)) / exp(Float64(Float64(Float64(t_1 * t_1) + l) - t_0)));
	else
		tmp = Float64(cos(M) / exp(Float64(M * M)));
	end
	return tmp
end
function tmp_2 = code(K, m, n, M, l)
	t_0 = abs((m - n));
	t_1 = ((m + n) / 2.0) - M;
	tmp = 0.0;
	if (M <= -2.3e+112)
		tmp = 1.0 / exp(((l + (M * M)) - t_0));
	elseif (M <= 1e+95)
		tmp = (1.0 + ((M * M) * -0.5)) / exp((((t_1 * t_1) + l) - t_0));
	else
		tmp = cos(M) / exp((M * M));
	end
	tmp_2 = tmp;
end
code[K_, m_, n_, M_, l_] := Block[{t$95$0 = N[Abs[N[(m - n), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(N[(N[(m + n), $MachinePrecision] / 2.0), $MachinePrecision] - M), $MachinePrecision]}, If[LessEqual[M, -2.3e+112], N[(1.0 / N[Exp[N[(N[(l + N[(M * M), $MachinePrecision]), $MachinePrecision] - t$95$0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[M, 1e+95], N[(N[(1.0 + N[(N[(M * M), $MachinePrecision] * -0.5), $MachinePrecision]), $MachinePrecision] / N[Exp[N[(N[(N[(t$95$1 * t$95$1), $MachinePrecision] + l), $MachinePrecision] - t$95$0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(N[Cos[M], $MachinePrecision] / N[Exp[N[(M * M), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \left|m - n\right|\\
t_1 := \frac{m + n}{2} - M\\
\mathbf{if}\;M \leq -2.3 \cdot 10^{+112}:\\
\;\;\;\;\frac{1}{e^{\left(\ell + M \cdot M\right) - t\_0}}\\

\mathbf{elif}\;M \leq 10^{+95}:\\
\;\;\;\;\frac{1 + \left(M \cdot M\right) \cdot -0.5}{e^{\left(t\_1 \cdot t\_1 + \ell\right) - t\_0}}\\

\mathbf{else}:\\
\;\;\;\;\frac{\cos M}{e^{M \cdot M}}\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if M < -2.3e112

    1. Initial program 87.9%

      \[\cos \left(\frac{K \cdot \left(m + n\right)}{2} - M\right) \cdot e^{\left(-{\left(\frac{m + n}{2} - M\right)}^{2}\right) - \left(\ell - \left|m - n\right|\right)} \]
    2. Step-by-step derivation
      1. neg-sub0N/A

        \[\leadsto \cos \left(\frac{K \cdot \left(m + n\right)}{2} - M\right) \cdot e^{\left(0 - {\left(\frac{m + n}{2} - M\right)}^{2}\right) - \left(\ell - \left|m - n\right|\right)} \]
      2. associate--l-N/A

        \[\leadsto \cos \left(\frac{K \cdot \left(m + n\right)}{2} - M\right) \cdot e^{0 - \left({\left(\frac{m + n}{2} - M\right)}^{2} + \left(\ell - \left|m - n\right|\right)\right)} \]
      3. exp-diffN/A

        \[\leadsto \cos \left(\frac{K \cdot \left(m + n\right)}{2} - M\right) \cdot \frac{e^{0}}{\color{blue}{e^{{\left(\frac{m + n}{2} - M\right)}^{2} + \left(\ell - \left|m - n\right|\right)}}} \]
      4. associate-*r/N/A

        \[\leadsto \frac{\cos \left(\frac{K \cdot \left(m + n\right)}{2} - M\right) \cdot e^{0}}{\color{blue}{e^{{\left(\frac{m + n}{2} - M\right)}^{2} + \left(\ell - \left|m - n\right|\right)}}} \]
      5. exp-0N/A

        \[\leadsto \frac{\cos \left(\frac{K \cdot \left(m + n\right)}{2} - M\right) \cdot 1}{e^{{\left(\frac{m + n}{2} - M\right)}^{2} + \color{blue}{\left(\ell - \left|m - n\right|\right)}}} \]
      6. *-rgt-identityN/A

        \[\leadsto \frac{\cos \left(\frac{K \cdot \left(m + n\right)}{2} - M\right)}{e^{\color{blue}{{\left(\frac{m + n}{2} - M\right)}^{2} + \left(\ell - \left|m - n\right|\right)}}} \]
      7. /-lowering-/.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\cos \left(\frac{K \cdot \left(m + n\right)}{2} - M\right), \color{blue}{\left(e^{{\left(\frac{m + n}{2} - M\right)}^{2} + \left(\ell - \left|m - n\right|\right)}\right)}\right) \]
    3. Simplified87.9%

      \[\leadsto \color{blue}{\frac{\cos \left(\frac{K \cdot \left(m + n\right)}{2} - M\right)}{e^{\left(\left(\frac{m + n}{2} - M\right) \cdot \left(\frac{m + n}{2} - M\right) + \ell\right) - \left|m - n\right|}}} \]
    4. Add Preprocessing
    5. Taylor expanded in M around inf

      \[\leadsto \mathsf{/.f64}\left(\mathsf{cos.f64}\left(\mathsf{\_.f64}\left(\mathsf{/.f64}\left(\mathsf{*.f64}\left(K, \mathsf{+.f64}\left(m, n\right)\right), 2\right), M\right)\right), \mathsf{exp.f64}\left(\mathsf{\_.f64}\left(\mathsf{+.f64}\left(\color{blue}{\left({M}^{2}\right)}, \ell\right), \mathsf{fabs.f64}\left(\mathsf{\_.f64}\left(m, n\right)\right)\right)\right)\right) \]
    6. Step-by-step derivation
      1. unpow2N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{cos.f64}\left(\mathsf{\_.f64}\left(\mathsf{/.f64}\left(\mathsf{*.f64}\left(K, \mathsf{+.f64}\left(m, n\right)\right), 2\right), M\right)\right), \mathsf{exp.f64}\left(\mathsf{\_.f64}\left(\mathsf{+.f64}\left(\left(M \cdot M\right), \ell\right), \mathsf{fabs.f64}\left(\mathsf{\_.f64}\left(m, n\right)\right)\right)\right)\right) \]
      2. *-lowering-*.f6487.9%

        \[\leadsto \mathsf{/.f64}\left(\mathsf{cos.f64}\left(\mathsf{\_.f64}\left(\mathsf{/.f64}\left(\mathsf{*.f64}\left(K, \mathsf{+.f64}\left(m, n\right)\right), 2\right), M\right)\right), \mathsf{exp.f64}\left(\mathsf{\_.f64}\left(\mathsf{+.f64}\left(\mathsf{*.f64}\left(M, M\right), \ell\right), \mathsf{fabs.f64}\left(\mathsf{\_.f64}\left(m, n\right)\right)\right)\right)\right) \]
    7. Simplified87.9%

      \[\leadsto \frac{\cos \left(\frac{K \cdot \left(m + n\right)}{2} - M\right)}{e^{\left(\color{blue}{M \cdot M} + \ell\right) - \left|m - n\right|}} \]
    8. Taylor expanded in n around inf

      \[\leadsto \mathsf{/.f64}\left(\mathsf{cos.f64}\left(\color{blue}{\left(\frac{1}{2} \cdot \left(K \cdot n\right)\right)}\right), \mathsf{exp.f64}\left(\mathsf{\_.f64}\left(\mathsf{+.f64}\left(\mathsf{*.f64}\left(M, M\right), \ell\right), \mathsf{fabs.f64}\left(\mathsf{\_.f64}\left(m, n\right)\right)\right)\right)\right) \]
    9. Step-by-step derivation
      1. associate-*r*N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{cos.f64}\left(\left(\left(\frac{1}{2} \cdot K\right) \cdot n\right)\right), \mathsf{exp.f64}\left(\mathsf{\_.f64}\left(\color{blue}{\mathsf{+.f64}\left(\mathsf{*.f64}\left(M, M\right), \ell\right)}, \mathsf{fabs.f64}\left(\mathsf{\_.f64}\left(m, n\right)\right)\right)\right)\right) \]
      2. *-lowering-*.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(\left(\frac{1}{2} \cdot K\right), n\right)\right), \mathsf{exp.f64}\left(\mathsf{\_.f64}\left(\color{blue}{\mathsf{+.f64}\left(\mathsf{*.f64}\left(M, M\right), \ell\right)}, \mathsf{fabs.f64}\left(\mathsf{\_.f64}\left(m, n\right)\right)\right)\right)\right) \]
      3. *-lowering-*.f6497.0%

        \[\leadsto \mathsf{/.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, K\right), n\right)\right), \mathsf{exp.f64}\left(\mathsf{\_.f64}\left(\mathsf{+.f64}\left(\color{blue}{\mathsf{*.f64}\left(M, M\right)}, \ell\right), \mathsf{fabs.f64}\left(\mathsf{\_.f64}\left(m, n\right)\right)\right)\right)\right) \]
    10. Simplified97.0%

      \[\leadsto \frac{\cos \color{blue}{\left(\left(0.5 \cdot K\right) \cdot n\right)}}{e^{\left(M \cdot M + \ell\right) - \left|m - n\right|}} \]
    11. Taylor expanded in K around 0

      \[\leadsto \mathsf{/.f64}\left(\color{blue}{1}, \mathsf{exp.f64}\left(\mathsf{\_.f64}\left(\mathsf{+.f64}\left(\mathsf{*.f64}\left(M, M\right), \ell\right), \mathsf{fabs.f64}\left(\mathsf{\_.f64}\left(m, n\right)\right)\right)\right)\right) \]
    12. Step-by-step derivation
      1. Simplified100.0%

        \[\leadsto \frac{\color{blue}{1}}{e^{\left(M \cdot M + \ell\right) - \left|m - n\right|}} \]

      if -2.3e112 < M < 1.00000000000000002e95

      1. Initial program 66.6%

        \[\cos \left(\frac{K \cdot \left(m + n\right)}{2} - M\right) \cdot e^{\left(-{\left(\frac{m + n}{2} - M\right)}^{2}\right) - \left(\ell - \left|m - n\right|\right)} \]
      2. Step-by-step derivation
        1. neg-sub0N/A

          \[\leadsto \cos \left(\frac{K \cdot \left(m + n\right)}{2} - M\right) \cdot e^{\left(0 - {\left(\frac{m + n}{2} - M\right)}^{2}\right) - \left(\ell - \left|m - n\right|\right)} \]
        2. associate--l-N/A

          \[\leadsto \cos \left(\frac{K \cdot \left(m + n\right)}{2} - M\right) \cdot e^{0 - \left({\left(\frac{m + n}{2} - M\right)}^{2} + \left(\ell - \left|m - n\right|\right)\right)} \]
        3. exp-diffN/A

          \[\leadsto \cos \left(\frac{K \cdot \left(m + n\right)}{2} - M\right) \cdot \frac{e^{0}}{\color{blue}{e^{{\left(\frac{m + n}{2} - M\right)}^{2} + \left(\ell - \left|m - n\right|\right)}}} \]
        4. associate-*r/N/A

          \[\leadsto \frac{\cos \left(\frac{K \cdot \left(m + n\right)}{2} - M\right) \cdot e^{0}}{\color{blue}{e^{{\left(\frac{m + n}{2} - M\right)}^{2} + \left(\ell - \left|m - n\right|\right)}}} \]
        5. exp-0N/A

          \[\leadsto \frac{\cos \left(\frac{K \cdot \left(m + n\right)}{2} - M\right) \cdot 1}{e^{{\left(\frac{m + n}{2} - M\right)}^{2} + \color{blue}{\left(\ell - \left|m - n\right|\right)}}} \]
        6. *-rgt-identityN/A

          \[\leadsto \frac{\cos \left(\frac{K \cdot \left(m + n\right)}{2} - M\right)}{e^{\color{blue}{{\left(\frac{m + n}{2} - M\right)}^{2} + \left(\ell - \left|m - n\right|\right)}}} \]
        7. /-lowering-/.f64N/A

          \[\leadsto \mathsf{/.f64}\left(\cos \left(\frac{K \cdot \left(m + n\right)}{2} - M\right), \color{blue}{\left(e^{{\left(\frac{m + n}{2} - M\right)}^{2} + \left(\ell - \left|m - n\right|\right)}\right)}\right) \]
      3. Simplified66.6%

        \[\leadsto \color{blue}{\frac{\cos \left(\frac{K \cdot \left(m + n\right)}{2} - M\right)}{e^{\left(\left(\frac{m + n}{2} - M\right) \cdot \left(\frac{m + n}{2} - M\right) + \ell\right) - \left|m - n\right|}}} \]
      4. Add Preprocessing
      5. Taylor expanded in K around 0

        \[\leadsto \mathsf{/.f64}\left(\color{blue}{\cos \left(\mathsf{neg}\left(M\right)\right)}, \mathsf{exp.f64}\left(\mathsf{\_.f64}\left(\mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\mathsf{/.f64}\left(\mathsf{+.f64}\left(m, n\right), 2\right), M\right), \mathsf{\_.f64}\left(\mathsf{/.f64}\left(\mathsf{+.f64}\left(m, n\right), 2\right), M\right)\right), \ell\right), \mathsf{fabs.f64}\left(\mathsf{\_.f64}\left(m, n\right)\right)\right)\right)\right) \]
      6. Step-by-step derivation
        1. cos-negN/A

          \[\leadsto \mathsf{/.f64}\left(\cos M, \mathsf{exp.f64}\left(\color{blue}{\mathsf{\_.f64}\left(\mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\mathsf{/.f64}\left(\mathsf{+.f64}\left(m, n\right), 2\right), M\right), \mathsf{\_.f64}\left(\mathsf{/.f64}\left(\mathsf{+.f64}\left(m, n\right), 2\right), M\right)\right), \ell\right), \mathsf{fabs.f64}\left(\mathsf{\_.f64}\left(m, n\right)\right)\right)}\right)\right) \]
        2. cos-lowering-cos.f6492.1%

          \[\leadsto \mathsf{/.f64}\left(\mathsf{cos.f64}\left(M\right), \mathsf{exp.f64}\left(\color{blue}{\mathsf{\_.f64}\left(\mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\mathsf{/.f64}\left(\mathsf{+.f64}\left(m, n\right), 2\right), M\right), \mathsf{\_.f64}\left(\mathsf{/.f64}\left(\mathsf{+.f64}\left(m, n\right), 2\right), M\right)\right), \ell\right), \mathsf{fabs.f64}\left(\mathsf{\_.f64}\left(m, n\right)\right)\right)}\right)\right) \]
      7. Simplified92.1%

        \[\leadsto \frac{\color{blue}{\cos M}}{e^{\left(\left(\frac{m + n}{2} - M\right) \cdot \left(\frac{m + n}{2} - M\right) + \ell\right) - \left|m - n\right|}} \]
      8. Taylor expanded in M around 0

        \[\leadsto \mathsf{/.f64}\left(\color{blue}{\left(1 + \frac{-1}{2} \cdot {M}^{2}\right)}, \mathsf{exp.f64}\left(\mathsf{\_.f64}\left(\mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\mathsf{/.f64}\left(\mathsf{+.f64}\left(m, n\right), 2\right), M\right), \mathsf{\_.f64}\left(\mathsf{/.f64}\left(\mathsf{+.f64}\left(m, n\right), 2\right), M\right)\right), \ell\right), \mathsf{fabs.f64}\left(\mathsf{\_.f64}\left(m, n\right)\right)\right)\right)\right) \]
      9. Step-by-step derivation
        1. +-lowering-+.f64N/A

          \[\leadsto \mathsf{/.f64}\left(\mathsf{+.f64}\left(1, \left(\frac{-1}{2} \cdot {M}^{2}\right)\right), \mathsf{exp.f64}\left(\color{blue}{\mathsf{\_.f64}\left(\mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\mathsf{/.f64}\left(\mathsf{+.f64}\left(m, n\right), 2\right), M\right), \mathsf{\_.f64}\left(\mathsf{/.f64}\left(\mathsf{+.f64}\left(m, n\right), 2\right), M\right)\right), \ell\right), \mathsf{fabs.f64}\left(\mathsf{\_.f64}\left(m, n\right)\right)\right)}\right)\right) \]
        2. *-lowering-*.f64N/A

          \[\leadsto \mathsf{/.f64}\left(\mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\frac{-1}{2}, \left({M}^{2}\right)\right)\right), \mathsf{exp.f64}\left(\mathsf{\_.f64}\left(\mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\mathsf{/.f64}\left(\mathsf{+.f64}\left(m, n\right), 2\right), M\right), \mathsf{\_.f64}\left(\mathsf{/.f64}\left(\mathsf{+.f64}\left(m, n\right), 2\right), M\right)\right), \ell\right), \color{blue}{\mathsf{fabs.f64}\left(\mathsf{\_.f64}\left(m, n\right)\right)}\right)\right)\right) \]
        3. unpow2N/A

          \[\leadsto \mathsf{/.f64}\left(\mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\frac{-1}{2}, \left(M \cdot M\right)\right)\right), \mathsf{exp.f64}\left(\mathsf{\_.f64}\left(\mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\mathsf{/.f64}\left(\mathsf{+.f64}\left(m, n\right), 2\right), M\right), \mathsf{\_.f64}\left(\mathsf{/.f64}\left(\mathsf{+.f64}\left(m, n\right), 2\right), M\right)\right), \ell\right), \mathsf{fabs.f64}\left(\mathsf{\_.f64}\left(m, n\right)\right)\right)\right)\right) \]
        4. *-lowering-*.f6492.7%

          \[\leadsto \mathsf{/.f64}\left(\mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\frac{-1}{2}, \mathsf{*.f64}\left(M, M\right)\right)\right), \mathsf{exp.f64}\left(\mathsf{\_.f64}\left(\mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\mathsf{/.f64}\left(\mathsf{+.f64}\left(m, n\right), 2\right), M\right), \mathsf{\_.f64}\left(\mathsf{/.f64}\left(\mathsf{+.f64}\left(m, n\right), 2\right), M\right)\right), \ell\right), \mathsf{fabs.f64}\left(\mathsf{\_.f64}\left(m, n\right)\right)\right)\right)\right) \]
      10. Simplified92.7%

        \[\leadsto \frac{\color{blue}{1 + -0.5 \cdot \left(M \cdot M\right)}}{e^{\left(\left(\frac{m + n}{2} - M\right) \cdot \left(\frac{m + n}{2} - M\right) + \ell\right) - \left|m - n\right|}} \]

      if 1.00000000000000002e95 < M

      1. Initial program 80.0%

        \[\cos \left(\frac{K \cdot \left(m + n\right)}{2} - M\right) \cdot e^{\left(-{\left(\frac{m + n}{2} - M\right)}^{2}\right) - \left(\ell - \left|m - n\right|\right)} \]
      2. Step-by-step derivation
        1. neg-sub0N/A

          \[\leadsto \cos \left(\frac{K \cdot \left(m + n\right)}{2} - M\right) \cdot e^{\left(0 - {\left(\frac{m + n}{2} - M\right)}^{2}\right) - \left(\ell - \left|m - n\right|\right)} \]
        2. associate--l-N/A

          \[\leadsto \cos \left(\frac{K \cdot \left(m + n\right)}{2} - M\right) \cdot e^{0 - \left({\left(\frac{m + n}{2} - M\right)}^{2} + \left(\ell - \left|m - n\right|\right)\right)} \]
        3. exp-diffN/A

          \[\leadsto \cos \left(\frac{K \cdot \left(m + n\right)}{2} - M\right) \cdot \frac{e^{0}}{\color{blue}{e^{{\left(\frac{m + n}{2} - M\right)}^{2} + \left(\ell - \left|m - n\right|\right)}}} \]
        4. associate-*r/N/A

          \[\leadsto \frac{\cos \left(\frac{K \cdot \left(m + n\right)}{2} - M\right) \cdot e^{0}}{\color{blue}{e^{{\left(\frac{m + n}{2} - M\right)}^{2} + \left(\ell - \left|m - n\right|\right)}}} \]
        5. exp-0N/A

          \[\leadsto \frac{\cos \left(\frac{K \cdot \left(m + n\right)}{2} - M\right) \cdot 1}{e^{{\left(\frac{m + n}{2} - M\right)}^{2} + \color{blue}{\left(\ell - \left|m - n\right|\right)}}} \]
        6. *-rgt-identityN/A

          \[\leadsto \frac{\cos \left(\frac{K \cdot \left(m + n\right)}{2} - M\right)}{e^{\color{blue}{{\left(\frac{m + n}{2} - M\right)}^{2} + \left(\ell - \left|m - n\right|\right)}}} \]
        7. /-lowering-/.f64N/A

          \[\leadsto \mathsf{/.f64}\left(\cos \left(\frac{K \cdot \left(m + n\right)}{2} - M\right), \color{blue}{\left(e^{{\left(\frac{m + n}{2} - M\right)}^{2} + \left(\ell - \left|m - n\right|\right)}\right)}\right) \]
      3. Simplified80.0%

        \[\leadsto \color{blue}{\frac{\cos \left(\frac{K \cdot \left(m + n\right)}{2} - M\right)}{e^{\left(\left(\frac{m + n}{2} - M\right) \cdot \left(\frac{m + n}{2} - M\right) + \ell\right) - \left|m - n\right|}}} \]
      4. Add Preprocessing
      5. Taylor expanded in K around 0

        \[\leadsto \mathsf{/.f64}\left(\color{blue}{\cos \left(\mathsf{neg}\left(M\right)\right)}, \mathsf{exp.f64}\left(\mathsf{\_.f64}\left(\mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\mathsf{/.f64}\left(\mathsf{+.f64}\left(m, n\right), 2\right), M\right), \mathsf{\_.f64}\left(\mathsf{/.f64}\left(\mathsf{+.f64}\left(m, n\right), 2\right), M\right)\right), \ell\right), \mathsf{fabs.f64}\left(\mathsf{\_.f64}\left(m, n\right)\right)\right)\right)\right) \]
      6. Step-by-step derivation
        1. cos-negN/A

          \[\leadsto \mathsf{/.f64}\left(\cos M, \mathsf{exp.f64}\left(\color{blue}{\mathsf{\_.f64}\left(\mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\mathsf{/.f64}\left(\mathsf{+.f64}\left(m, n\right), 2\right), M\right), \mathsf{\_.f64}\left(\mathsf{/.f64}\left(\mathsf{+.f64}\left(m, n\right), 2\right), M\right)\right), \ell\right), \mathsf{fabs.f64}\left(\mathsf{\_.f64}\left(m, n\right)\right)\right)}\right)\right) \]
        2. cos-lowering-cos.f64100.0%

          \[\leadsto \mathsf{/.f64}\left(\mathsf{cos.f64}\left(M\right), \mathsf{exp.f64}\left(\color{blue}{\mathsf{\_.f64}\left(\mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\mathsf{/.f64}\left(\mathsf{+.f64}\left(m, n\right), 2\right), M\right), \mathsf{\_.f64}\left(\mathsf{/.f64}\left(\mathsf{+.f64}\left(m, n\right), 2\right), M\right)\right), \ell\right), \mathsf{fabs.f64}\left(\mathsf{\_.f64}\left(m, n\right)\right)\right)}\right)\right) \]
      7. Simplified100.0%

        \[\leadsto \frac{\color{blue}{\cos M}}{e^{\left(\left(\frac{m + n}{2} - M\right) \cdot \left(\frac{m + n}{2} - M\right) + \ell\right) - \left|m - n\right|}} \]
      8. Taylor expanded in M around inf

        \[\leadsto \mathsf{/.f64}\left(\mathsf{cos.f64}\left(M\right), \mathsf{exp.f64}\left(\color{blue}{\left({M}^{2}\right)}\right)\right) \]
      9. Step-by-step derivation
        1. unpow2N/A

          \[\leadsto \mathsf{/.f64}\left(\mathsf{cos.f64}\left(M\right), \mathsf{exp.f64}\left(\left(M \cdot M\right)\right)\right) \]
        2. *-lowering-*.f64100.0%

          \[\leadsto \mathsf{/.f64}\left(\mathsf{cos.f64}\left(M\right), \mathsf{exp.f64}\left(\mathsf{*.f64}\left(M, M\right)\right)\right) \]
      10. Simplified100.0%

        \[\leadsto \frac{\cos M}{e^{\color{blue}{M \cdot M}}} \]
    13. Recombined 3 regimes into one program.
    14. Final simplification94.8%

      \[\leadsto \begin{array}{l} \mathbf{if}\;M \leq -2.3 \cdot 10^{+112}:\\ \;\;\;\;\frac{1}{e^{\left(\ell + M \cdot M\right) - \left|m - n\right|}}\\ \mathbf{elif}\;M \leq 10^{+95}:\\ \;\;\;\;\frac{1 + \left(M \cdot M\right) \cdot -0.5}{e^{\left(\left(\frac{m + n}{2} - M\right) \cdot \left(\frac{m + n}{2} - M\right) + \ell\right) - \left|m - n\right|}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\cos M}{e^{M \cdot M}}\\ \end{array} \]
    15. Add Preprocessing

    Alternative 2: 96.9% accurate, 1.3× speedup?

    \[\begin{array}{l} \\ \begin{array}{l} t_0 := \frac{m + n}{2} - M\\ \frac{\cos M}{e^{\left(t\_0 \cdot t\_0 + \ell\right) - \left|m - n\right|}} \end{array} \end{array} \]
    (FPCore (K m n M l)
     :precision binary64
     (let* ((t_0 (- (/ (+ m n) 2.0) M)))
       (/ (cos M) (exp (- (+ (* t_0 t_0) l) (fabs (- m n)))))))
    double code(double K, double m, double n, double M, double l) {
    	double t_0 = ((m + n) / 2.0) - M;
    	return cos(M) / exp((((t_0 * t_0) + l) - fabs((m - n))));
    }
    
    real(8) function code(k, m, n, m_1, l)
        real(8), intent (in) :: k
        real(8), intent (in) :: m
        real(8), intent (in) :: n
        real(8), intent (in) :: m_1
        real(8), intent (in) :: l
        real(8) :: t_0
        t_0 = ((m + n) / 2.0d0) - m_1
        code = cos(m_1) / exp((((t_0 * t_0) + l) - abs((m - n))))
    end function
    
    public static double code(double K, double m, double n, double M, double l) {
    	double t_0 = ((m + n) / 2.0) - M;
    	return Math.cos(M) / Math.exp((((t_0 * t_0) + l) - Math.abs((m - n))));
    }
    
    def code(K, m, n, M, l):
    	t_0 = ((m + n) / 2.0) - M
    	return math.cos(M) / math.exp((((t_0 * t_0) + l) - math.fabs((m - n))))
    
    function code(K, m, n, M, l)
    	t_0 = Float64(Float64(Float64(m + n) / 2.0) - M)
    	return Float64(cos(M) / exp(Float64(Float64(Float64(t_0 * t_0) + l) - abs(Float64(m - n)))))
    end
    
    function tmp = code(K, m, n, M, l)
    	t_0 = ((m + n) / 2.0) - M;
    	tmp = cos(M) / exp((((t_0 * t_0) + l) - abs((m - n))));
    end
    
    code[K_, m_, n_, M_, l_] := Block[{t$95$0 = N[(N[(N[(m + n), $MachinePrecision] / 2.0), $MachinePrecision] - M), $MachinePrecision]}, N[(N[Cos[M], $MachinePrecision] / N[Exp[N[(N[(N[(t$95$0 * t$95$0), $MachinePrecision] + l), $MachinePrecision] - N[Abs[N[(m - n), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
    
    \begin{array}{l}
    
    \\
    \begin{array}{l}
    t_0 := \frac{m + n}{2} - M\\
    \frac{\cos M}{e^{\left(t\_0 \cdot t\_0 + \ell\right) - \left|m - n\right|}}
    \end{array}
    \end{array}
    
    Derivation
    1. Initial program 71.5%

      \[\cos \left(\frac{K \cdot \left(m + n\right)}{2} - M\right) \cdot e^{\left(-{\left(\frac{m + n}{2} - M\right)}^{2}\right) - \left(\ell - \left|m - n\right|\right)} \]
    2. Step-by-step derivation
      1. neg-sub0N/A

        \[\leadsto \cos \left(\frac{K \cdot \left(m + n\right)}{2} - M\right) \cdot e^{\left(0 - {\left(\frac{m + n}{2} - M\right)}^{2}\right) - \left(\ell - \left|m - n\right|\right)} \]
      2. associate--l-N/A

        \[\leadsto \cos \left(\frac{K \cdot \left(m + n\right)}{2} - M\right) \cdot e^{0 - \left({\left(\frac{m + n}{2} - M\right)}^{2} + \left(\ell - \left|m - n\right|\right)\right)} \]
      3. exp-diffN/A

        \[\leadsto \cos \left(\frac{K \cdot \left(m + n\right)}{2} - M\right) \cdot \frac{e^{0}}{\color{blue}{e^{{\left(\frac{m + n}{2} - M\right)}^{2} + \left(\ell - \left|m - n\right|\right)}}} \]
      4. associate-*r/N/A

        \[\leadsto \frac{\cos \left(\frac{K \cdot \left(m + n\right)}{2} - M\right) \cdot e^{0}}{\color{blue}{e^{{\left(\frac{m + n}{2} - M\right)}^{2} + \left(\ell - \left|m - n\right|\right)}}} \]
      5. exp-0N/A

        \[\leadsto \frac{\cos \left(\frac{K \cdot \left(m + n\right)}{2} - M\right) \cdot 1}{e^{{\left(\frac{m + n}{2} - M\right)}^{2} + \color{blue}{\left(\ell - \left|m - n\right|\right)}}} \]
      6. *-rgt-identityN/A

        \[\leadsto \frac{\cos \left(\frac{K \cdot \left(m + n\right)}{2} - M\right)}{e^{\color{blue}{{\left(\frac{m + n}{2} - M\right)}^{2} + \left(\ell - \left|m - n\right|\right)}}} \]
      7. /-lowering-/.f64N/A

        \[\leadsto \mathsf{/.f64}\left(\cos \left(\frac{K \cdot \left(m + n\right)}{2} - M\right), \color{blue}{\left(e^{{\left(\frac{m + n}{2} - M\right)}^{2} + \left(\ell - \left|m - n\right|\right)}\right)}\right) \]
    3. Simplified71.5%

      \[\leadsto \color{blue}{\frac{\cos \left(\frac{K \cdot \left(m + n\right)}{2} - M\right)}{e^{\left(\left(\frac{m + n}{2} - M\right) \cdot \left(\frac{m + n}{2} - M\right) + \ell\right) - \left|m - n\right|}}} \]
    4. Add Preprocessing
    5. Taylor expanded in K around 0

      \[\leadsto \mathsf{/.f64}\left(\color{blue}{\cos \left(\mathsf{neg}\left(M\right)\right)}, \mathsf{exp.f64}\left(\mathsf{\_.f64}\left(\mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\mathsf{/.f64}\left(\mathsf{+.f64}\left(m, n\right), 2\right), M\right), \mathsf{\_.f64}\left(\mathsf{/.f64}\left(\mathsf{+.f64}\left(m, n\right), 2\right), M\right)\right), \ell\right), \mathsf{fabs.f64}\left(\mathsf{\_.f64}\left(m, n\right)\right)\right)\right)\right) \]
    6. Step-by-step derivation
      1. cos-negN/A

        \[\leadsto \mathsf{/.f64}\left(\cos M, \mathsf{exp.f64}\left(\color{blue}{\mathsf{\_.f64}\left(\mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\mathsf{/.f64}\left(\mathsf{+.f64}\left(m, n\right), 2\right), M\right), \mathsf{\_.f64}\left(\mathsf{/.f64}\left(\mathsf{+.f64}\left(m, n\right), 2\right), M\right)\right), \ell\right), \mathsf{fabs.f64}\left(\mathsf{\_.f64}\left(m, n\right)\right)\right)}\right)\right) \]
      2. cos-lowering-cos.f6494.4%

        \[\leadsto \mathsf{/.f64}\left(\mathsf{cos.f64}\left(M\right), \mathsf{exp.f64}\left(\color{blue}{\mathsf{\_.f64}\left(\mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\mathsf{/.f64}\left(\mathsf{+.f64}\left(m, n\right), 2\right), M\right), \mathsf{\_.f64}\left(\mathsf{/.f64}\left(\mathsf{+.f64}\left(m, n\right), 2\right), M\right)\right), \ell\right), \mathsf{fabs.f64}\left(\mathsf{\_.f64}\left(m, n\right)\right)\right)}\right)\right) \]
    7. Simplified94.4%

      \[\leadsto \frac{\color{blue}{\cos M}}{e^{\left(\left(\frac{m + n}{2} - M\right) \cdot \left(\frac{m + n}{2} - M\right) + \ell\right) - \left|m - n\right|}} \]
    8. Add Preprocessing

    Alternative 3: 95.7% accurate, 1.9× speedup?

    \[\begin{array}{l} \\ \begin{array}{l} t_0 := \frac{\cos M}{e^{M \cdot M}}\\ \mathbf{if}\;M \leq -1 \cdot 10^{+18}:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;M \leq 2.5 \cdot 10^{+16}:\\ \;\;\;\;\frac{1}{e^{\ell + \left(0.25 \cdot \left(\left(m + n\right) \cdot \left(m + n\right)\right) - \left|m - n\right|\right)}}\\ \mathbf{else}:\\ \;\;\;\;t\_0\\ \end{array} \end{array} \]
    (FPCore (K m n M l)
     :precision binary64
     (let* ((t_0 (/ (cos M) (exp (* M M)))))
       (if (<= M -1e+18)
         t_0
         (if (<= M 2.5e+16)
           (/ 1.0 (exp (+ l (- (* 0.25 (* (+ m n) (+ m n))) (fabs (- m n))))))
           t_0))))
    double code(double K, double m, double n, double M, double l) {
    	double t_0 = cos(M) / exp((M * M));
    	double tmp;
    	if (M <= -1e+18) {
    		tmp = t_0;
    	} else if (M <= 2.5e+16) {
    		tmp = 1.0 / exp((l + ((0.25 * ((m + n) * (m + n))) - fabs((m - n)))));
    	} else {
    		tmp = t_0;
    	}
    	return tmp;
    }
    
    real(8) function code(k, m, n, m_1, l)
        real(8), intent (in) :: k
        real(8), intent (in) :: m
        real(8), intent (in) :: n
        real(8), intent (in) :: m_1
        real(8), intent (in) :: l
        real(8) :: t_0
        real(8) :: tmp
        t_0 = cos(m_1) / exp((m_1 * m_1))
        if (m_1 <= (-1d+18)) then
            tmp = t_0
        else if (m_1 <= 2.5d+16) then
            tmp = 1.0d0 / exp((l + ((0.25d0 * ((m + n) * (m + n))) - abs((m - n)))))
        else
            tmp = t_0
        end if
        code = tmp
    end function
    
    public static double code(double K, double m, double n, double M, double l) {
    	double t_0 = Math.cos(M) / Math.exp((M * M));
    	double tmp;
    	if (M <= -1e+18) {
    		tmp = t_0;
    	} else if (M <= 2.5e+16) {
    		tmp = 1.0 / Math.exp((l + ((0.25 * ((m + n) * (m + n))) - Math.abs((m - n)))));
    	} else {
    		tmp = t_0;
    	}
    	return tmp;
    }
    
    def code(K, m, n, M, l):
    	t_0 = math.cos(M) / math.exp((M * M))
    	tmp = 0
    	if M <= -1e+18:
    		tmp = t_0
    	elif M <= 2.5e+16:
    		tmp = 1.0 / math.exp((l + ((0.25 * ((m + n) * (m + n))) - math.fabs((m - n)))))
    	else:
    		tmp = t_0
    	return tmp
    
    function code(K, m, n, M, l)
    	t_0 = Float64(cos(M) / exp(Float64(M * M)))
    	tmp = 0.0
    	if (M <= -1e+18)
    		tmp = t_0;
    	elseif (M <= 2.5e+16)
    		tmp = Float64(1.0 / exp(Float64(l + Float64(Float64(0.25 * Float64(Float64(m + n) * Float64(m + n))) - abs(Float64(m - n))))));
    	else
    		tmp = t_0;
    	end
    	return tmp
    end
    
    function tmp_2 = code(K, m, n, M, l)
    	t_0 = cos(M) / exp((M * M));
    	tmp = 0.0;
    	if (M <= -1e+18)
    		tmp = t_0;
    	elseif (M <= 2.5e+16)
    		tmp = 1.0 / exp((l + ((0.25 * ((m + n) * (m + n))) - abs((m - n)))));
    	else
    		tmp = t_0;
    	end
    	tmp_2 = tmp;
    end
    
    code[K_, m_, n_, M_, l_] := Block[{t$95$0 = N[(N[Cos[M], $MachinePrecision] / N[Exp[N[(M * M), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[M, -1e+18], t$95$0, If[LessEqual[M, 2.5e+16], N[(1.0 / N[Exp[N[(l + N[(N[(0.25 * N[(N[(m + n), $MachinePrecision] * N[(m + n), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[Abs[N[(m - n), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], t$95$0]]]
    
    \begin{array}{l}
    
    \\
    \begin{array}{l}
    t_0 := \frac{\cos M}{e^{M \cdot M}}\\
    \mathbf{if}\;M \leq -1 \cdot 10^{+18}:\\
    \;\;\;\;t\_0\\
    
    \mathbf{elif}\;M \leq 2.5 \cdot 10^{+16}:\\
    \;\;\;\;\frac{1}{e^{\ell + \left(0.25 \cdot \left(\left(m + n\right) \cdot \left(m + n\right)\right) - \left|m - n\right|\right)}}\\
    
    \mathbf{else}:\\
    \;\;\;\;t\_0\\
    
    
    \end{array}
    \end{array}
    
    Derivation
    1. Split input into 2 regimes
    2. if M < -1e18 or 2.5e16 < M

      1. Initial program 77.5%

        \[\cos \left(\frac{K \cdot \left(m + n\right)}{2} - M\right) \cdot e^{\left(-{\left(\frac{m + n}{2} - M\right)}^{2}\right) - \left(\ell - \left|m - n\right|\right)} \]
      2. Step-by-step derivation
        1. neg-sub0N/A

          \[\leadsto \cos \left(\frac{K \cdot \left(m + n\right)}{2} - M\right) \cdot e^{\left(0 - {\left(\frac{m + n}{2} - M\right)}^{2}\right) - \left(\ell - \left|m - n\right|\right)} \]
        2. associate--l-N/A

          \[\leadsto \cos \left(\frac{K \cdot \left(m + n\right)}{2} - M\right) \cdot e^{0 - \left({\left(\frac{m + n}{2} - M\right)}^{2} + \left(\ell - \left|m - n\right|\right)\right)} \]
        3. exp-diffN/A

          \[\leadsto \cos \left(\frac{K \cdot \left(m + n\right)}{2} - M\right) \cdot \frac{e^{0}}{\color{blue}{e^{{\left(\frac{m + n}{2} - M\right)}^{2} + \left(\ell - \left|m - n\right|\right)}}} \]
        4. associate-*r/N/A

          \[\leadsto \frac{\cos \left(\frac{K \cdot \left(m + n\right)}{2} - M\right) \cdot e^{0}}{\color{blue}{e^{{\left(\frac{m + n}{2} - M\right)}^{2} + \left(\ell - \left|m - n\right|\right)}}} \]
        5. exp-0N/A

          \[\leadsto \frac{\cos \left(\frac{K \cdot \left(m + n\right)}{2} - M\right) \cdot 1}{e^{{\left(\frac{m + n}{2} - M\right)}^{2} + \color{blue}{\left(\ell - \left|m - n\right|\right)}}} \]
        6. *-rgt-identityN/A

          \[\leadsto \frac{\cos \left(\frac{K \cdot \left(m + n\right)}{2} - M\right)}{e^{\color{blue}{{\left(\frac{m + n}{2} - M\right)}^{2} + \left(\ell - \left|m - n\right|\right)}}} \]
        7. /-lowering-/.f64N/A

          \[\leadsto \mathsf{/.f64}\left(\cos \left(\frac{K \cdot \left(m + n\right)}{2} - M\right), \color{blue}{\left(e^{{\left(\frac{m + n}{2} - M\right)}^{2} + \left(\ell - \left|m - n\right|\right)}\right)}\right) \]
      3. Simplified77.5%

        \[\leadsto \color{blue}{\frac{\cos \left(\frac{K \cdot \left(m + n\right)}{2} - M\right)}{e^{\left(\left(\frac{m + n}{2} - M\right) \cdot \left(\frac{m + n}{2} - M\right) + \ell\right) - \left|m - n\right|}}} \]
      4. Add Preprocessing
      5. Taylor expanded in K around 0

        \[\leadsto \mathsf{/.f64}\left(\color{blue}{\cos \left(\mathsf{neg}\left(M\right)\right)}, \mathsf{exp.f64}\left(\mathsf{\_.f64}\left(\mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\mathsf{/.f64}\left(\mathsf{+.f64}\left(m, n\right), 2\right), M\right), \mathsf{\_.f64}\left(\mathsf{/.f64}\left(\mathsf{+.f64}\left(m, n\right), 2\right), M\right)\right), \ell\right), \mathsf{fabs.f64}\left(\mathsf{\_.f64}\left(m, n\right)\right)\right)\right)\right) \]
      6. Step-by-step derivation
        1. cos-negN/A

          \[\leadsto \mathsf{/.f64}\left(\cos M, \mathsf{exp.f64}\left(\color{blue}{\mathsf{\_.f64}\left(\mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\mathsf{/.f64}\left(\mathsf{+.f64}\left(m, n\right), 2\right), M\right), \mathsf{\_.f64}\left(\mathsf{/.f64}\left(\mathsf{+.f64}\left(m, n\right), 2\right), M\right)\right), \ell\right), \mathsf{fabs.f64}\left(\mathsf{\_.f64}\left(m, n\right)\right)\right)}\right)\right) \]
        2. cos-lowering-cos.f6499.1%

          \[\leadsto \mathsf{/.f64}\left(\mathsf{cos.f64}\left(M\right), \mathsf{exp.f64}\left(\color{blue}{\mathsf{\_.f64}\left(\mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\mathsf{/.f64}\left(\mathsf{+.f64}\left(m, n\right), 2\right), M\right), \mathsf{\_.f64}\left(\mathsf{/.f64}\left(\mathsf{+.f64}\left(m, n\right), 2\right), M\right)\right), \ell\right), \mathsf{fabs.f64}\left(\mathsf{\_.f64}\left(m, n\right)\right)\right)}\right)\right) \]
      7. Simplified99.1%

        \[\leadsto \frac{\color{blue}{\cos M}}{e^{\left(\left(\frac{m + n}{2} - M\right) \cdot \left(\frac{m + n}{2} - M\right) + \ell\right) - \left|m - n\right|}} \]
      8. Taylor expanded in M around inf

        \[\leadsto \mathsf{/.f64}\left(\mathsf{cos.f64}\left(M\right), \mathsf{exp.f64}\left(\color{blue}{\left({M}^{2}\right)}\right)\right) \]
      9. Step-by-step derivation
        1. unpow2N/A

          \[\leadsto \mathsf{/.f64}\left(\mathsf{cos.f64}\left(M\right), \mathsf{exp.f64}\left(\left(M \cdot M\right)\right)\right) \]
        2. *-lowering-*.f6497.3%

          \[\leadsto \mathsf{/.f64}\left(\mathsf{cos.f64}\left(M\right), \mathsf{exp.f64}\left(\mathsf{*.f64}\left(M, M\right)\right)\right) \]
      10. Simplified97.3%

        \[\leadsto \frac{\cos M}{e^{\color{blue}{M \cdot M}}} \]

      if -1e18 < M < 2.5e16

      1. Initial program 66.9%

        \[\cos \left(\frac{K \cdot \left(m + n\right)}{2} - M\right) \cdot e^{\left(-{\left(\frac{m + n}{2} - M\right)}^{2}\right) - \left(\ell - \left|m - n\right|\right)} \]
      2. Step-by-step derivation
        1. neg-sub0N/A

          \[\leadsto \cos \left(\frac{K \cdot \left(m + n\right)}{2} - M\right) \cdot e^{\left(0 - {\left(\frac{m + n}{2} - M\right)}^{2}\right) - \left(\ell - \left|m - n\right|\right)} \]
        2. associate--l-N/A

          \[\leadsto \cos \left(\frac{K \cdot \left(m + n\right)}{2} - M\right) \cdot e^{0 - \left({\left(\frac{m + n}{2} - M\right)}^{2} + \left(\ell - \left|m - n\right|\right)\right)} \]
        3. exp-diffN/A

          \[\leadsto \cos \left(\frac{K \cdot \left(m + n\right)}{2} - M\right) \cdot \frac{e^{0}}{\color{blue}{e^{{\left(\frac{m + n}{2} - M\right)}^{2} + \left(\ell - \left|m - n\right|\right)}}} \]
        4. associate-*r/N/A

          \[\leadsto \frac{\cos \left(\frac{K \cdot \left(m + n\right)}{2} - M\right) \cdot e^{0}}{\color{blue}{e^{{\left(\frac{m + n}{2} - M\right)}^{2} + \left(\ell - \left|m - n\right|\right)}}} \]
        5. exp-0N/A

          \[\leadsto \frac{\cos \left(\frac{K \cdot \left(m + n\right)}{2} - M\right) \cdot 1}{e^{{\left(\frac{m + n}{2} - M\right)}^{2} + \color{blue}{\left(\ell - \left|m - n\right|\right)}}} \]
        6. *-rgt-identityN/A

          \[\leadsto \frac{\cos \left(\frac{K \cdot \left(m + n\right)}{2} - M\right)}{e^{\color{blue}{{\left(\frac{m + n}{2} - M\right)}^{2} + \left(\ell - \left|m - n\right|\right)}}} \]
        7. /-lowering-/.f64N/A

          \[\leadsto \mathsf{/.f64}\left(\cos \left(\frac{K \cdot \left(m + n\right)}{2} - M\right), \color{blue}{\left(e^{{\left(\frac{m + n}{2} - M\right)}^{2} + \left(\ell - \left|m - n\right|\right)}\right)}\right) \]
      3. Simplified66.9%

        \[\leadsto \color{blue}{\frac{\cos \left(\frac{K \cdot \left(m + n\right)}{2} - M\right)}{e^{\left(\left(\frac{m + n}{2} - M\right) \cdot \left(\frac{m + n}{2} - M\right) + \ell\right) - \left|m - n\right|}}} \]
      4. Add Preprocessing
      5. Taylor expanded in K around 0

        \[\leadsto \mathsf{/.f64}\left(\color{blue}{\cos \left(\mathsf{neg}\left(M\right)\right)}, \mathsf{exp.f64}\left(\mathsf{\_.f64}\left(\mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\mathsf{/.f64}\left(\mathsf{+.f64}\left(m, n\right), 2\right), M\right), \mathsf{\_.f64}\left(\mathsf{/.f64}\left(\mathsf{+.f64}\left(m, n\right), 2\right), M\right)\right), \ell\right), \mathsf{fabs.f64}\left(\mathsf{\_.f64}\left(m, n\right)\right)\right)\right)\right) \]
      6. Step-by-step derivation
        1. cos-negN/A

          \[\leadsto \mathsf{/.f64}\left(\cos M, \mathsf{exp.f64}\left(\color{blue}{\mathsf{\_.f64}\left(\mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\mathsf{/.f64}\left(\mathsf{+.f64}\left(m, n\right), 2\right), M\right), \mathsf{\_.f64}\left(\mathsf{/.f64}\left(\mathsf{+.f64}\left(m, n\right), 2\right), M\right)\right), \ell\right), \mathsf{fabs.f64}\left(\mathsf{\_.f64}\left(m, n\right)\right)\right)}\right)\right) \]
        2. cos-lowering-cos.f6490.7%

          \[\leadsto \mathsf{/.f64}\left(\mathsf{cos.f64}\left(M\right), \mathsf{exp.f64}\left(\color{blue}{\mathsf{\_.f64}\left(\mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\mathsf{/.f64}\left(\mathsf{+.f64}\left(m, n\right), 2\right), M\right), \mathsf{\_.f64}\left(\mathsf{/.f64}\left(\mathsf{+.f64}\left(m, n\right), 2\right), M\right)\right), \ell\right), \mathsf{fabs.f64}\left(\mathsf{\_.f64}\left(m, n\right)\right)\right)}\right)\right) \]
      7. Simplified90.7%

        \[\leadsto \frac{\color{blue}{\cos M}}{e^{\left(\left(\frac{m + n}{2} - M\right) \cdot \left(\frac{m + n}{2} - M\right) + \ell\right) - \left|m - n\right|}} \]
      8. Taylor expanded in M around 0

        \[\leadsto \color{blue}{\frac{1}{e^{\left(\ell + \frac{1}{4} \cdot {\left(m + n\right)}^{2}\right) - \left|m - n\right|}}} \]
      9. Step-by-step derivation
        1. /-lowering-/.f64N/A

          \[\leadsto \mathsf{/.f64}\left(1, \color{blue}{\left(e^{\left(\ell + \frac{1}{4} \cdot {\left(m + n\right)}^{2}\right) - \left|m - n\right|}\right)}\right) \]
        2. exp-lowering-exp.f64N/A

          \[\leadsto \mathsf{/.f64}\left(1, \mathsf{exp.f64}\left(\left(\left(\ell + \frac{1}{4} \cdot {\left(m + n\right)}^{2}\right) - \left|m - n\right|\right)\right)\right) \]
        3. fabs-subN/A

          \[\leadsto \mathsf{/.f64}\left(1, \mathsf{exp.f64}\left(\left(\left(\ell + \frac{1}{4} \cdot {\left(m + n\right)}^{2}\right) - \left|n - m\right|\right)\right)\right) \]
        4. associate--l+N/A

          \[\leadsto \mathsf{/.f64}\left(1, \mathsf{exp.f64}\left(\left(\ell + \left(\frac{1}{4} \cdot {\left(m + n\right)}^{2} - \left|n - m\right|\right)\right)\right)\right) \]
        5. +-lowering-+.f64N/A

          \[\leadsto \mathsf{/.f64}\left(1, \mathsf{exp.f64}\left(\mathsf{+.f64}\left(\ell, \left(\frac{1}{4} \cdot {\left(m + n\right)}^{2} - \left|n - m\right|\right)\right)\right)\right) \]
        6. --lowering--.f64N/A

          \[\leadsto \mathsf{/.f64}\left(1, \mathsf{exp.f64}\left(\mathsf{+.f64}\left(\ell, \mathsf{\_.f64}\left(\left(\frac{1}{4} \cdot {\left(m + n\right)}^{2}\right), \left(\left|n - m\right|\right)\right)\right)\right)\right) \]
        7. *-lowering-*.f64N/A

          \[\leadsto \mathsf{/.f64}\left(1, \mathsf{exp.f64}\left(\mathsf{+.f64}\left(\ell, \mathsf{\_.f64}\left(\mathsf{*.f64}\left(\frac{1}{4}, \left({\left(m + n\right)}^{2}\right)\right), \left(\left|n - m\right|\right)\right)\right)\right)\right) \]
        8. unpow2N/A

          \[\leadsto \mathsf{/.f64}\left(1, \mathsf{exp.f64}\left(\mathsf{+.f64}\left(\ell, \mathsf{\_.f64}\left(\mathsf{*.f64}\left(\frac{1}{4}, \left(\left(m + n\right) \cdot \left(m + n\right)\right)\right), \left(\left|n - m\right|\right)\right)\right)\right)\right) \]
        9. *-lowering-*.f64N/A

          \[\leadsto \mathsf{/.f64}\left(1, \mathsf{exp.f64}\left(\mathsf{+.f64}\left(\ell, \mathsf{\_.f64}\left(\mathsf{*.f64}\left(\frac{1}{4}, \mathsf{*.f64}\left(\left(m + n\right), \left(m + n\right)\right)\right), \left(\left|n - m\right|\right)\right)\right)\right)\right) \]
        10. +-lowering-+.f64N/A

          \[\leadsto \mathsf{/.f64}\left(1, \mathsf{exp.f64}\left(\mathsf{+.f64}\left(\ell, \mathsf{\_.f64}\left(\mathsf{*.f64}\left(\frac{1}{4}, \mathsf{*.f64}\left(\mathsf{+.f64}\left(m, n\right), \left(m + n\right)\right)\right), \left(\left|n - m\right|\right)\right)\right)\right)\right) \]
        11. +-lowering-+.f64N/A

          \[\leadsto \mathsf{/.f64}\left(1, \mathsf{exp.f64}\left(\mathsf{+.f64}\left(\ell, \mathsf{\_.f64}\left(\mathsf{*.f64}\left(\frac{1}{4}, \mathsf{*.f64}\left(\mathsf{+.f64}\left(m, n\right), \mathsf{+.f64}\left(m, n\right)\right)\right), \left(\left|n - m\right|\right)\right)\right)\right)\right) \]
        12. sub-negN/A

          \[\leadsto \mathsf{/.f64}\left(1, \mathsf{exp.f64}\left(\mathsf{+.f64}\left(\ell, \mathsf{\_.f64}\left(\mathsf{*.f64}\left(\frac{1}{4}, \mathsf{*.f64}\left(\mathsf{+.f64}\left(m, n\right), \mathsf{+.f64}\left(m, n\right)\right)\right), \left(\left|n + \left(\mathsf{neg}\left(m\right)\right)\right|\right)\right)\right)\right)\right) \]
        13. mul-1-negN/A

          \[\leadsto \mathsf{/.f64}\left(1, \mathsf{exp.f64}\left(\mathsf{+.f64}\left(\ell, \mathsf{\_.f64}\left(\mathsf{*.f64}\left(\frac{1}{4}, \mathsf{*.f64}\left(\mathsf{+.f64}\left(m, n\right), \mathsf{+.f64}\left(m, n\right)\right)\right), \left(\left|n + -1 \cdot m\right|\right)\right)\right)\right)\right) \]
        14. fabs-lowering-fabs.f64N/A

          \[\leadsto \mathsf{/.f64}\left(1, \mathsf{exp.f64}\left(\mathsf{+.f64}\left(\ell, \mathsf{\_.f64}\left(\mathsf{*.f64}\left(\frac{1}{4}, \mathsf{*.f64}\left(\mathsf{+.f64}\left(m, n\right), \mathsf{+.f64}\left(m, n\right)\right)\right), \mathsf{fabs.f64}\left(\left(n + -1 \cdot m\right)\right)\right)\right)\right)\right) \]
        15. mul-1-negN/A

          \[\leadsto \mathsf{/.f64}\left(1, \mathsf{exp.f64}\left(\mathsf{+.f64}\left(\ell, \mathsf{\_.f64}\left(\mathsf{*.f64}\left(\frac{1}{4}, \mathsf{*.f64}\left(\mathsf{+.f64}\left(m, n\right), \mathsf{+.f64}\left(m, n\right)\right)\right), \mathsf{fabs.f64}\left(\left(n + \left(\mathsf{neg}\left(m\right)\right)\right)\right)\right)\right)\right)\right) \]
        16. sub-negN/A

          \[\leadsto \mathsf{/.f64}\left(1, \mathsf{exp.f64}\left(\mathsf{+.f64}\left(\ell, \mathsf{\_.f64}\left(\mathsf{*.f64}\left(\frac{1}{4}, \mathsf{*.f64}\left(\mathsf{+.f64}\left(m, n\right), \mathsf{+.f64}\left(m, n\right)\right)\right), \mathsf{fabs.f64}\left(\left(n - m\right)\right)\right)\right)\right)\right) \]
        17. --lowering--.f6490.7%

          \[\leadsto \mathsf{/.f64}\left(1, \mathsf{exp.f64}\left(\mathsf{+.f64}\left(\ell, \mathsf{\_.f64}\left(\mathsf{*.f64}\left(\frac{1}{4}, \mathsf{*.f64}\left(\mathsf{+.f64}\left(m, n\right), \mathsf{+.f64}\left(m, n\right)\right)\right), \mathsf{fabs.f64}\left(\mathsf{\_.f64}\left(n, m\right)\right)\right)\right)\right)\right) \]
      10. Simplified90.7%

        \[\leadsto \color{blue}{\frac{1}{e^{\ell + \left(0.25 \cdot \left(\left(m + n\right) \cdot \left(m + n\right)\right) - \left|n - m\right|\right)}}} \]
    3. Recombined 2 regimes into one program.
    4. Final simplification93.6%

      \[\leadsto \begin{array}{l} \mathbf{if}\;M \leq -1 \cdot 10^{+18}:\\ \;\;\;\;\frac{\cos M}{e^{M \cdot M}}\\ \mathbf{elif}\;M \leq 2.5 \cdot 10^{+16}:\\ \;\;\;\;\frac{1}{e^{\ell + \left(0.25 \cdot \left(\left(m + n\right) \cdot \left(m + n\right)\right) - \left|m - n\right|\right)}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\cos M}{e^{M \cdot M}}\\ \end{array} \]
    5. Add Preprocessing

    Alternative 4: 73.5% accurate, 1.9× speedup?

    \[\begin{array}{l} \\ \begin{array}{l} t_0 := \left|m - n\right|\\ \mathbf{if}\;n \leq 4.9 \cdot 10^{-104}:\\ \;\;\;\;\frac{1}{e^{\left(\ell + 0.25 \cdot \left(m \cdot m\right)\right) - t\_0}}\\ \mathbf{elif}\;n \leq 1900000:\\ \;\;\;\;\frac{1}{e^{\left(\ell + M \cdot M\right) - t\_0}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\cos M}{e^{0.25 \cdot \left(n \cdot n\right)}}\\ \end{array} \end{array} \]
    (FPCore (K m n M l)
     :precision binary64
     (let* ((t_0 (fabs (- m n))))
       (if (<= n 4.9e-104)
         (/ 1.0 (exp (- (+ l (* 0.25 (* m m))) t_0)))
         (if (<= n 1900000.0)
           (/ 1.0 (exp (- (+ l (* M M)) t_0)))
           (/ (cos M) (exp (* 0.25 (* n n))))))))
    double code(double K, double m, double n, double M, double l) {
    	double t_0 = fabs((m - n));
    	double tmp;
    	if (n <= 4.9e-104) {
    		tmp = 1.0 / exp(((l + (0.25 * (m * m))) - t_0));
    	} else if (n <= 1900000.0) {
    		tmp = 1.0 / exp(((l + (M * M)) - t_0));
    	} else {
    		tmp = cos(M) / exp((0.25 * (n * n)));
    	}
    	return tmp;
    }
    
    real(8) function code(k, m, n, m_1, l)
        real(8), intent (in) :: k
        real(8), intent (in) :: m
        real(8), intent (in) :: n
        real(8), intent (in) :: m_1
        real(8), intent (in) :: l
        real(8) :: t_0
        real(8) :: tmp
        t_0 = abs((m - n))
        if (n <= 4.9d-104) then
            tmp = 1.0d0 / exp(((l + (0.25d0 * (m * m))) - t_0))
        else if (n <= 1900000.0d0) then
            tmp = 1.0d0 / exp(((l + (m_1 * m_1)) - t_0))
        else
            tmp = cos(m_1) / exp((0.25d0 * (n * n)))
        end if
        code = tmp
    end function
    
    public static double code(double K, double m, double n, double M, double l) {
    	double t_0 = Math.abs((m - n));
    	double tmp;
    	if (n <= 4.9e-104) {
    		tmp = 1.0 / Math.exp(((l + (0.25 * (m * m))) - t_0));
    	} else if (n <= 1900000.0) {
    		tmp = 1.0 / Math.exp(((l + (M * M)) - t_0));
    	} else {
    		tmp = Math.cos(M) / Math.exp((0.25 * (n * n)));
    	}
    	return tmp;
    }
    
    def code(K, m, n, M, l):
    	t_0 = math.fabs((m - n))
    	tmp = 0
    	if n <= 4.9e-104:
    		tmp = 1.0 / math.exp(((l + (0.25 * (m * m))) - t_0))
    	elif n <= 1900000.0:
    		tmp = 1.0 / math.exp(((l + (M * M)) - t_0))
    	else:
    		tmp = math.cos(M) / math.exp((0.25 * (n * n)))
    	return tmp
    
    function code(K, m, n, M, l)
    	t_0 = abs(Float64(m - n))
    	tmp = 0.0
    	if (n <= 4.9e-104)
    		tmp = Float64(1.0 / exp(Float64(Float64(l + Float64(0.25 * Float64(m * m))) - t_0)));
    	elseif (n <= 1900000.0)
    		tmp = Float64(1.0 / exp(Float64(Float64(l + Float64(M * M)) - t_0)));
    	else
    		tmp = Float64(cos(M) / exp(Float64(0.25 * Float64(n * n))));
    	end
    	return tmp
    end
    
    function tmp_2 = code(K, m, n, M, l)
    	t_0 = abs((m - n));
    	tmp = 0.0;
    	if (n <= 4.9e-104)
    		tmp = 1.0 / exp(((l + (0.25 * (m * m))) - t_0));
    	elseif (n <= 1900000.0)
    		tmp = 1.0 / exp(((l + (M * M)) - t_0));
    	else
    		tmp = cos(M) / exp((0.25 * (n * n)));
    	end
    	tmp_2 = tmp;
    end
    
    code[K_, m_, n_, M_, l_] := Block[{t$95$0 = N[Abs[N[(m - n), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[n, 4.9e-104], N[(1.0 / N[Exp[N[(N[(l + N[(0.25 * N[(m * m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - t$95$0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[n, 1900000.0], N[(1.0 / N[Exp[N[(N[(l + N[(M * M), $MachinePrecision]), $MachinePrecision] - t$95$0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(N[Cos[M], $MachinePrecision] / N[Exp[N[(0.25 * N[(n * n), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]]
    
    \begin{array}{l}
    
    \\
    \begin{array}{l}
    t_0 := \left|m - n\right|\\
    \mathbf{if}\;n \leq 4.9 \cdot 10^{-104}:\\
    \;\;\;\;\frac{1}{e^{\left(\ell + 0.25 \cdot \left(m \cdot m\right)\right) - t\_0}}\\
    
    \mathbf{elif}\;n \leq 1900000:\\
    \;\;\;\;\frac{1}{e^{\left(\ell + M \cdot M\right) - t\_0}}\\
    
    \mathbf{else}:\\
    \;\;\;\;\frac{\cos M}{e^{0.25 \cdot \left(n \cdot n\right)}}\\
    
    
    \end{array}
    \end{array}
    
    Derivation
    1. Split input into 3 regimes
    2. if n < 4.9000000000000003e-104

      1. Initial program 74.2%

        \[\cos \left(\frac{K \cdot \left(m + n\right)}{2} - M\right) \cdot e^{\left(-{\left(\frac{m + n}{2} - M\right)}^{2}\right) - \left(\ell - \left|m - n\right|\right)} \]
      2. Step-by-step derivation
        1. neg-sub0N/A

          \[\leadsto \cos \left(\frac{K \cdot \left(m + n\right)}{2} - M\right) \cdot e^{\left(0 - {\left(\frac{m + n}{2} - M\right)}^{2}\right) - \left(\ell - \left|m - n\right|\right)} \]
        2. associate--l-N/A

          \[\leadsto \cos \left(\frac{K \cdot \left(m + n\right)}{2} - M\right) \cdot e^{0 - \left({\left(\frac{m + n}{2} - M\right)}^{2} + \left(\ell - \left|m - n\right|\right)\right)} \]
        3. exp-diffN/A

          \[\leadsto \cos \left(\frac{K \cdot \left(m + n\right)}{2} - M\right) \cdot \frac{e^{0}}{\color{blue}{e^{{\left(\frac{m + n}{2} - M\right)}^{2} + \left(\ell - \left|m - n\right|\right)}}} \]
        4. associate-*r/N/A

          \[\leadsto \frac{\cos \left(\frac{K \cdot \left(m + n\right)}{2} - M\right) \cdot e^{0}}{\color{blue}{e^{{\left(\frac{m + n}{2} - M\right)}^{2} + \left(\ell - \left|m - n\right|\right)}}} \]
        5. exp-0N/A

          \[\leadsto \frac{\cos \left(\frac{K \cdot \left(m + n\right)}{2} - M\right) \cdot 1}{e^{{\left(\frac{m + n}{2} - M\right)}^{2} + \color{blue}{\left(\ell - \left|m - n\right|\right)}}} \]
        6. *-rgt-identityN/A

          \[\leadsto \frac{\cos \left(\frac{K \cdot \left(m + n\right)}{2} - M\right)}{e^{\color{blue}{{\left(\frac{m + n}{2} - M\right)}^{2} + \left(\ell - \left|m - n\right|\right)}}} \]
        7. /-lowering-/.f64N/A

          \[\leadsto \mathsf{/.f64}\left(\cos \left(\frac{K \cdot \left(m + n\right)}{2} - M\right), \color{blue}{\left(e^{{\left(\frac{m + n}{2} - M\right)}^{2} + \left(\ell - \left|m - n\right|\right)}\right)}\right) \]
      3. Simplified74.2%

        \[\leadsto \color{blue}{\frac{\cos \left(\frac{K \cdot \left(m + n\right)}{2} - M\right)}{e^{\left(\left(\frac{m + n}{2} - M\right) \cdot \left(\frac{m + n}{2} - M\right) + \ell\right) - \left|m - n\right|}}} \]
      4. Add Preprocessing
      5. Taylor expanded in K around 0

        \[\leadsto \mathsf{/.f64}\left(\color{blue}{\cos \left(\mathsf{neg}\left(M\right)\right)}, \mathsf{exp.f64}\left(\mathsf{\_.f64}\left(\mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\mathsf{/.f64}\left(\mathsf{+.f64}\left(m, n\right), 2\right), M\right), \mathsf{\_.f64}\left(\mathsf{/.f64}\left(\mathsf{+.f64}\left(m, n\right), 2\right), M\right)\right), \ell\right), \mathsf{fabs.f64}\left(\mathsf{\_.f64}\left(m, n\right)\right)\right)\right)\right) \]
      6. Step-by-step derivation
        1. cos-negN/A

          \[\leadsto \mathsf{/.f64}\left(\cos M, \mathsf{exp.f64}\left(\color{blue}{\mathsf{\_.f64}\left(\mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\mathsf{/.f64}\left(\mathsf{+.f64}\left(m, n\right), 2\right), M\right), \mathsf{\_.f64}\left(\mathsf{/.f64}\left(\mathsf{+.f64}\left(m, n\right), 2\right), M\right)\right), \ell\right), \mathsf{fabs.f64}\left(\mathsf{\_.f64}\left(m, n\right)\right)\right)}\right)\right) \]
        2. cos-lowering-cos.f6493.6%

          \[\leadsto \mathsf{/.f64}\left(\mathsf{cos.f64}\left(M\right), \mathsf{exp.f64}\left(\color{blue}{\mathsf{\_.f64}\left(\mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\mathsf{/.f64}\left(\mathsf{+.f64}\left(m, n\right), 2\right), M\right), \mathsf{\_.f64}\left(\mathsf{/.f64}\left(\mathsf{+.f64}\left(m, n\right), 2\right), M\right)\right), \ell\right), \mathsf{fabs.f64}\left(\mathsf{\_.f64}\left(m, n\right)\right)\right)}\right)\right) \]
      7. Simplified93.6%

        \[\leadsto \frac{\color{blue}{\cos M}}{e^{\left(\left(\frac{m + n}{2} - M\right) \cdot \left(\frac{m + n}{2} - M\right) + \ell\right) - \left|m - n\right|}} \]
      8. Taylor expanded in M around 0

        \[\leadsto \color{blue}{\frac{1}{e^{\left(\ell + \frac{1}{4} \cdot {\left(m + n\right)}^{2}\right) - \left|m - n\right|}}} \]
      9. Step-by-step derivation
        1. /-lowering-/.f64N/A

          \[\leadsto \mathsf{/.f64}\left(1, \color{blue}{\left(e^{\left(\ell + \frac{1}{4} \cdot {\left(m + n\right)}^{2}\right) - \left|m - n\right|}\right)}\right) \]
        2. exp-lowering-exp.f64N/A

          \[\leadsto \mathsf{/.f64}\left(1, \mathsf{exp.f64}\left(\left(\left(\ell + \frac{1}{4} \cdot {\left(m + n\right)}^{2}\right) - \left|m - n\right|\right)\right)\right) \]
        3. fabs-subN/A

          \[\leadsto \mathsf{/.f64}\left(1, \mathsf{exp.f64}\left(\left(\left(\ell + \frac{1}{4} \cdot {\left(m + n\right)}^{2}\right) - \left|n - m\right|\right)\right)\right) \]
        4. associate--l+N/A

          \[\leadsto \mathsf{/.f64}\left(1, \mathsf{exp.f64}\left(\left(\ell + \left(\frac{1}{4} \cdot {\left(m + n\right)}^{2} - \left|n - m\right|\right)\right)\right)\right) \]
        5. +-lowering-+.f64N/A

          \[\leadsto \mathsf{/.f64}\left(1, \mathsf{exp.f64}\left(\mathsf{+.f64}\left(\ell, \left(\frac{1}{4} \cdot {\left(m + n\right)}^{2} - \left|n - m\right|\right)\right)\right)\right) \]
        6. --lowering--.f64N/A

          \[\leadsto \mathsf{/.f64}\left(1, \mathsf{exp.f64}\left(\mathsf{+.f64}\left(\ell, \mathsf{\_.f64}\left(\left(\frac{1}{4} \cdot {\left(m + n\right)}^{2}\right), \left(\left|n - m\right|\right)\right)\right)\right)\right) \]
        7. *-lowering-*.f64N/A

          \[\leadsto \mathsf{/.f64}\left(1, \mathsf{exp.f64}\left(\mathsf{+.f64}\left(\ell, \mathsf{\_.f64}\left(\mathsf{*.f64}\left(\frac{1}{4}, \left({\left(m + n\right)}^{2}\right)\right), \left(\left|n - m\right|\right)\right)\right)\right)\right) \]
        8. unpow2N/A

          \[\leadsto \mathsf{/.f64}\left(1, \mathsf{exp.f64}\left(\mathsf{+.f64}\left(\ell, \mathsf{\_.f64}\left(\mathsf{*.f64}\left(\frac{1}{4}, \left(\left(m + n\right) \cdot \left(m + n\right)\right)\right), \left(\left|n - m\right|\right)\right)\right)\right)\right) \]
        9. *-lowering-*.f64N/A

          \[\leadsto \mathsf{/.f64}\left(1, \mathsf{exp.f64}\left(\mathsf{+.f64}\left(\ell, \mathsf{\_.f64}\left(\mathsf{*.f64}\left(\frac{1}{4}, \mathsf{*.f64}\left(\left(m + n\right), \left(m + n\right)\right)\right), \left(\left|n - m\right|\right)\right)\right)\right)\right) \]
        10. +-lowering-+.f64N/A

          \[\leadsto \mathsf{/.f64}\left(1, \mathsf{exp.f64}\left(\mathsf{+.f64}\left(\ell, \mathsf{\_.f64}\left(\mathsf{*.f64}\left(\frac{1}{4}, \mathsf{*.f64}\left(\mathsf{+.f64}\left(m, n\right), \left(m + n\right)\right)\right), \left(\left|n - m\right|\right)\right)\right)\right)\right) \]
        11. +-lowering-+.f64N/A

          \[\leadsto \mathsf{/.f64}\left(1, \mathsf{exp.f64}\left(\mathsf{+.f64}\left(\ell, \mathsf{\_.f64}\left(\mathsf{*.f64}\left(\frac{1}{4}, \mathsf{*.f64}\left(\mathsf{+.f64}\left(m, n\right), \mathsf{+.f64}\left(m, n\right)\right)\right), \left(\left|n - m\right|\right)\right)\right)\right)\right) \]
        12. sub-negN/A

          \[\leadsto \mathsf{/.f64}\left(1, \mathsf{exp.f64}\left(\mathsf{+.f64}\left(\ell, \mathsf{\_.f64}\left(\mathsf{*.f64}\left(\frac{1}{4}, \mathsf{*.f64}\left(\mathsf{+.f64}\left(m, n\right), \mathsf{+.f64}\left(m, n\right)\right)\right), \left(\left|n + \left(\mathsf{neg}\left(m\right)\right)\right|\right)\right)\right)\right)\right) \]
        13. mul-1-negN/A

          \[\leadsto \mathsf{/.f64}\left(1, \mathsf{exp.f64}\left(\mathsf{+.f64}\left(\ell, \mathsf{\_.f64}\left(\mathsf{*.f64}\left(\frac{1}{4}, \mathsf{*.f64}\left(\mathsf{+.f64}\left(m, n\right), \mathsf{+.f64}\left(m, n\right)\right)\right), \left(\left|n + -1 \cdot m\right|\right)\right)\right)\right)\right) \]
        14. fabs-lowering-fabs.f64N/A

          \[\leadsto \mathsf{/.f64}\left(1, \mathsf{exp.f64}\left(\mathsf{+.f64}\left(\ell, \mathsf{\_.f64}\left(\mathsf{*.f64}\left(\frac{1}{4}, \mathsf{*.f64}\left(\mathsf{+.f64}\left(m, n\right), \mathsf{+.f64}\left(m, n\right)\right)\right), \mathsf{fabs.f64}\left(\left(n + -1 \cdot m\right)\right)\right)\right)\right)\right) \]
        15. mul-1-negN/A

          \[\leadsto \mathsf{/.f64}\left(1, \mathsf{exp.f64}\left(\mathsf{+.f64}\left(\ell, \mathsf{\_.f64}\left(\mathsf{*.f64}\left(\frac{1}{4}, \mathsf{*.f64}\left(\mathsf{+.f64}\left(m, n\right), \mathsf{+.f64}\left(m, n\right)\right)\right), \mathsf{fabs.f64}\left(\left(n + \left(\mathsf{neg}\left(m\right)\right)\right)\right)\right)\right)\right)\right) \]
        16. sub-negN/A

          \[\leadsto \mathsf{/.f64}\left(1, \mathsf{exp.f64}\left(\mathsf{+.f64}\left(\ell, \mathsf{\_.f64}\left(\mathsf{*.f64}\left(\frac{1}{4}, \mathsf{*.f64}\left(\mathsf{+.f64}\left(m, n\right), \mathsf{+.f64}\left(m, n\right)\right)\right), \mathsf{fabs.f64}\left(\left(n - m\right)\right)\right)\right)\right)\right) \]
        17. --lowering--.f6481.0%

          \[\leadsto \mathsf{/.f64}\left(1, \mathsf{exp.f64}\left(\mathsf{+.f64}\left(\ell, \mathsf{\_.f64}\left(\mathsf{*.f64}\left(\frac{1}{4}, \mathsf{*.f64}\left(\mathsf{+.f64}\left(m, n\right), \mathsf{+.f64}\left(m, n\right)\right)\right), \mathsf{fabs.f64}\left(\mathsf{\_.f64}\left(n, m\right)\right)\right)\right)\right)\right) \]
      10. Simplified81.0%

        \[\leadsto \color{blue}{\frac{1}{e^{\ell + \left(0.25 \cdot \left(\left(m + n\right) \cdot \left(m + n\right)\right) - \left|n - m\right|\right)}}} \]
      11. Taylor expanded in n around 0

        \[\leadsto \mathsf{/.f64}\left(1, \color{blue}{\left(e^{\left(\ell + \frac{1}{4} \cdot {m}^{2}\right) - \left|n - m\right|}\right)}\right) \]
      12. Step-by-step derivation
        1. fabs-subN/A

          \[\leadsto \mathsf{/.f64}\left(1, \left(e^{\left(\ell + \frac{1}{4} \cdot {m}^{2}\right) - \left|m - n\right|}\right)\right) \]
        2. sub-negN/A

          \[\leadsto \mathsf{/.f64}\left(1, \left(e^{\left(\ell + \frac{1}{4} \cdot {m}^{2}\right) - \left|m + \left(\mathsf{neg}\left(n\right)\right)\right|}\right)\right) \]
        3. mul-1-negN/A

          \[\leadsto \mathsf{/.f64}\left(1, \left(e^{\left(\ell + \frac{1}{4} \cdot {m}^{2}\right) - \left|m + -1 \cdot n\right|}\right)\right) \]
        4. fabs-negN/A

          \[\leadsto \mathsf{/.f64}\left(1, \left(e^{\left(\ell + \frac{1}{4} \cdot {m}^{2}\right) - \left|\mathsf{neg}\left(\left(m + -1 \cdot n\right)\right)\right|}\right)\right) \]
        5. exp-lowering-exp.f64N/A

          \[\leadsto \mathsf{/.f64}\left(1, \mathsf{exp.f64}\left(\left(\left(\ell + \frac{1}{4} \cdot {m}^{2}\right) - \left|\mathsf{neg}\left(\left(m + -1 \cdot n\right)\right)\right|\right)\right)\right) \]
        6. fabs-negN/A

          \[\leadsto \mathsf{/.f64}\left(1, \mathsf{exp.f64}\left(\left(\left(\ell + \frac{1}{4} \cdot {m}^{2}\right) - \left|m + -1 \cdot n\right|\right)\right)\right) \]
        7. mul-1-negN/A

          \[\leadsto \mathsf{/.f64}\left(1, \mathsf{exp.f64}\left(\left(\left(\ell + \frac{1}{4} \cdot {m}^{2}\right) - \left|m + \left(\mathsf{neg}\left(n\right)\right)\right|\right)\right)\right) \]
        8. sub-negN/A

          \[\leadsto \mathsf{/.f64}\left(1, \mathsf{exp.f64}\left(\left(\left(\ell + \frac{1}{4} \cdot {m}^{2}\right) - \left|m - n\right|\right)\right)\right) \]
        9. fabs-subN/A

          \[\leadsto \mathsf{/.f64}\left(1, \mathsf{exp.f64}\left(\left(\left(\ell + \frac{1}{4} \cdot {m}^{2}\right) - \left|n - m\right|\right)\right)\right) \]
        10. --lowering--.f64N/A

          \[\leadsto \mathsf{/.f64}\left(1, \mathsf{exp.f64}\left(\mathsf{\_.f64}\left(\left(\ell + \frac{1}{4} \cdot {m}^{2}\right), \left(\left|n - m\right|\right)\right)\right)\right) \]
        11. +-lowering-+.f64N/A

          \[\leadsto \mathsf{/.f64}\left(1, \mathsf{exp.f64}\left(\mathsf{\_.f64}\left(\mathsf{+.f64}\left(\ell, \left(\frac{1}{4} \cdot {m}^{2}\right)\right), \left(\left|n - m\right|\right)\right)\right)\right) \]
        12. *-lowering-*.f64N/A

          \[\leadsto \mathsf{/.f64}\left(1, \mathsf{exp.f64}\left(\mathsf{\_.f64}\left(\mathsf{+.f64}\left(\ell, \mathsf{*.f64}\left(\frac{1}{4}, \left({m}^{2}\right)\right)\right), \left(\left|n - m\right|\right)\right)\right)\right) \]
        13. unpow2N/A

          \[\leadsto \mathsf{/.f64}\left(1, \mathsf{exp.f64}\left(\mathsf{\_.f64}\left(\mathsf{+.f64}\left(\ell, \mathsf{*.f64}\left(\frac{1}{4}, \left(m \cdot m\right)\right)\right), \left(\left|n - m\right|\right)\right)\right)\right) \]
        14. *-lowering-*.f64N/A

          \[\leadsto \mathsf{/.f64}\left(1, \mathsf{exp.f64}\left(\mathsf{\_.f64}\left(\mathsf{+.f64}\left(\ell, \mathsf{*.f64}\left(\frac{1}{4}, \mathsf{*.f64}\left(m, m\right)\right)\right), \left(\left|n - m\right|\right)\right)\right)\right) \]
        15. sub-negN/A

          \[\leadsto \mathsf{/.f64}\left(1, \mathsf{exp.f64}\left(\mathsf{\_.f64}\left(\mathsf{+.f64}\left(\ell, \mathsf{*.f64}\left(\frac{1}{4}, \mathsf{*.f64}\left(m, m\right)\right)\right), \left(\left|n + \left(\mathsf{neg}\left(m\right)\right)\right|\right)\right)\right)\right) \]
        16. mul-1-negN/A

          \[\leadsto \mathsf{/.f64}\left(1, \mathsf{exp.f64}\left(\mathsf{\_.f64}\left(\mathsf{+.f64}\left(\ell, \mathsf{*.f64}\left(\frac{1}{4}, \mathsf{*.f64}\left(m, m\right)\right)\right), \left(\left|n + -1 \cdot m\right|\right)\right)\right)\right) \]
        17. fabs-lowering-fabs.f64N/A

          \[\leadsto \mathsf{/.f64}\left(1, \mathsf{exp.f64}\left(\mathsf{\_.f64}\left(\mathsf{+.f64}\left(\ell, \mathsf{*.f64}\left(\frac{1}{4}, \mathsf{*.f64}\left(m, m\right)\right)\right), \mathsf{fabs.f64}\left(\left(n + -1 \cdot m\right)\right)\right)\right)\right) \]
        18. mul-1-negN/A

          \[\leadsto \mathsf{/.f64}\left(1, \mathsf{exp.f64}\left(\mathsf{\_.f64}\left(\mathsf{+.f64}\left(\ell, \mathsf{*.f64}\left(\frac{1}{4}, \mathsf{*.f64}\left(m, m\right)\right)\right), \mathsf{fabs.f64}\left(\left(n + \left(\mathsf{neg}\left(m\right)\right)\right)\right)\right)\right)\right) \]
        19. sub-negN/A

          \[\leadsto \mathsf{/.f64}\left(1, \mathsf{exp.f64}\left(\mathsf{\_.f64}\left(\mathsf{+.f64}\left(\ell, \mathsf{*.f64}\left(\frac{1}{4}, \mathsf{*.f64}\left(m, m\right)\right)\right), \mathsf{fabs.f64}\left(\left(n - m\right)\right)\right)\right)\right) \]
        20. --lowering--.f6459.6%

          \[\leadsto \mathsf{/.f64}\left(1, \mathsf{exp.f64}\left(\mathsf{\_.f64}\left(\mathsf{+.f64}\left(\ell, \mathsf{*.f64}\left(\frac{1}{4}, \mathsf{*.f64}\left(m, m\right)\right)\right), \mathsf{fabs.f64}\left(\mathsf{\_.f64}\left(n, m\right)\right)\right)\right)\right) \]
      13. Simplified59.6%

        \[\leadsto \frac{1}{\color{blue}{e^{\left(\ell + 0.25 \cdot \left(m \cdot m\right)\right) - \left|n - m\right|}}} \]

      if 4.9000000000000003e-104 < n < 1.9e6

      1. Initial program 66.9%

        \[\cos \left(\frac{K \cdot \left(m + n\right)}{2} - M\right) \cdot e^{\left(-{\left(\frac{m + n}{2} - M\right)}^{2}\right) - \left(\ell - \left|m - n\right|\right)} \]
      2. Step-by-step derivation
        1. neg-sub0N/A

          \[\leadsto \cos \left(\frac{K \cdot \left(m + n\right)}{2} - M\right) \cdot e^{\left(0 - {\left(\frac{m + n}{2} - M\right)}^{2}\right) - \left(\ell - \left|m - n\right|\right)} \]
        2. associate--l-N/A

          \[\leadsto \cos \left(\frac{K \cdot \left(m + n\right)}{2} - M\right) \cdot e^{0 - \left({\left(\frac{m + n}{2} - M\right)}^{2} + \left(\ell - \left|m - n\right|\right)\right)} \]
        3. exp-diffN/A

          \[\leadsto \cos \left(\frac{K \cdot \left(m + n\right)}{2} - M\right) \cdot \frac{e^{0}}{\color{blue}{e^{{\left(\frac{m + n}{2} - M\right)}^{2} + \left(\ell - \left|m - n\right|\right)}}} \]
        4. associate-*r/N/A

          \[\leadsto \frac{\cos \left(\frac{K \cdot \left(m + n\right)}{2} - M\right) \cdot e^{0}}{\color{blue}{e^{{\left(\frac{m + n}{2} - M\right)}^{2} + \left(\ell - \left|m - n\right|\right)}}} \]
        5. exp-0N/A

          \[\leadsto \frac{\cos \left(\frac{K \cdot \left(m + n\right)}{2} - M\right) \cdot 1}{e^{{\left(\frac{m + n}{2} - M\right)}^{2} + \color{blue}{\left(\ell - \left|m - n\right|\right)}}} \]
        6. *-rgt-identityN/A

          \[\leadsto \frac{\cos \left(\frac{K \cdot \left(m + n\right)}{2} - M\right)}{e^{\color{blue}{{\left(\frac{m + n}{2} - M\right)}^{2} + \left(\ell - \left|m - n\right|\right)}}} \]
        7. /-lowering-/.f64N/A

          \[\leadsto \mathsf{/.f64}\left(\cos \left(\frac{K \cdot \left(m + n\right)}{2} - M\right), \color{blue}{\left(e^{{\left(\frac{m + n}{2} - M\right)}^{2} + \left(\ell - \left|m - n\right|\right)}\right)}\right) \]
      3. Simplified66.9%

        \[\leadsto \color{blue}{\frac{\cos \left(\frac{K \cdot \left(m + n\right)}{2} - M\right)}{e^{\left(\left(\frac{m + n}{2} - M\right) \cdot \left(\frac{m + n}{2} - M\right) + \ell\right) - \left|m - n\right|}}} \]
      4. Add Preprocessing
      5. Taylor expanded in M around inf

        \[\leadsto \mathsf{/.f64}\left(\mathsf{cos.f64}\left(\mathsf{\_.f64}\left(\mathsf{/.f64}\left(\mathsf{*.f64}\left(K, \mathsf{+.f64}\left(m, n\right)\right), 2\right), M\right)\right), \mathsf{exp.f64}\left(\mathsf{\_.f64}\left(\mathsf{+.f64}\left(\color{blue}{\left({M}^{2}\right)}, \ell\right), \mathsf{fabs.f64}\left(\mathsf{\_.f64}\left(m, n\right)\right)\right)\right)\right) \]
      6. Step-by-step derivation
        1. unpow2N/A

          \[\leadsto \mathsf{/.f64}\left(\mathsf{cos.f64}\left(\mathsf{\_.f64}\left(\mathsf{/.f64}\left(\mathsf{*.f64}\left(K, \mathsf{+.f64}\left(m, n\right)\right), 2\right), M\right)\right), \mathsf{exp.f64}\left(\mathsf{\_.f64}\left(\mathsf{+.f64}\left(\left(M \cdot M\right), \ell\right), \mathsf{fabs.f64}\left(\mathsf{\_.f64}\left(m, n\right)\right)\right)\right)\right) \]
        2. *-lowering-*.f6459.4%

          \[\leadsto \mathsf{/.f64}\left(\mathsf{cos.f64}\left(\mathsf{\_.f64}\left(\mathsf{/.f64}\left(\mathsf{*.f64}\left(K, \mathsf{+.f64}\left(m, n\right)\right), 2\right), M\right)\right), \mathsf{exp.f64}\left(\mathsf{\_.f64}\left(\mathsf{+.f64}\left(\mathsf{*.f64}\left(M, M\right), \ell\right), \mathsf{fabs.f64}\left(\mathsf{\_.f64}\left(m, n\right)\right)\right)\right)\right) \]
      7. Simplified59.4%

        \[\leadsto \frac{\cos \left(\frac{K \cdot \left(m + n\right)}{2} - M\right)}{e^{\left(\color{blue}{M \cdot M} + \ell\right) - \left|m - n\right|}} \]
      8. Taylor expanded in n around inf

        \[\leadsto \mathsf{/.f64}\left(\mathsf{cos.f64}\left(\color{blue}{\left(\frac{1}{2} \cdot \left(K \cdot n\right)\right)}\right), \mathsf{exp.f64}\left(\mathsf{\_.f64}\left(\mathsf{+.f64}\left(\mathsf{*.f64}\left(M, M\right), \ell\right), \mathsf{fabs.f64}\left(\mathsf{\_.f64}\left(m, n\right)\right)\right)\right)\right) \]
      9. Step-by-step derivation
        1. associate-*r*N/A

          \[\leadsto \mathsf{/.f64}\left(\mathsf{cos.f64}\left(\left(\left(\frac{1}{2} \cdot K\right) \cdot n\right)\right), \mathsf{exp.f64}\left(\mathsf{\_.f64}\left(\color{blue}{\mathsf{+.f64}\left(\mathsf{*.f64}\left(M, M\right), \ell\right)}, \mathsf{fabs.f64}\left(\mathsf{\_.f64}\left(m, n\right)\right)\right)\right)\right) \]
        2. *-lowering-*.f64N/A

          \[\leadsto \mathsf{/.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(\left(\frac{1}{2} \cdot K\right), n\right)\right), \mathsf{exp.f64}\left(\mathsf{\_.f64}\left(\color{blue}{\mathsf{+.f64}\left(\mathsf{*.f64}\left(M, M\right), \ell\right)}, \mathsf{fabs.f64}\left(\mathsf{\_.f64}\left(m, n\right)\right)\right)\right)\right) \]
        3. *-lowering-*.f6469.6%

          \[\leadsto \mathsf{/.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, K\right), n\right)\right), \mathsf{exp.f64}\left(\mathsf{\_.f64}\left(\mathsf{+.f64}\left(\color{blue}{\mathsf{*.f64}\left(M, M\right)}, \ell\right), \mathsf{fabs.f64}\left(\mathsf{\_.f64}\left(m, n\right)\right)\right)\right)\right) \]
      10. Simplified69.6%

        \[\leadsto \frac{\cos \color{blue}{\left(\left(0.5 \cdot K\right) \cdot n\right)}}{e^{\left(M \cdot M + \ell\right) - \left|m - n\right|}} \]
      11. Taylor expanded in K around 0

        \[\leadsto \mathsf{/.f64}\left(\color{blue}{1}, \mathsf{exp.f64}\left(\mathsf{\_.f64}\left(\mathsf{+.f64}\left(\mathsf{*.f64}\left(M, M\right), \ell\right), \mathsf{fabs.f64}\left(\mathsf{\_.f64}\left(m, n\right)\right)\right)\right)\right) \]
      12. Step-by-step derivation
        1. Simplified69.6%

          \[\leadsto \frac{\color{blue}{1}}{e^{\left(M \cdot M + \ell\right) - \left|m - n\right|}} \]

        if 1.9e6 < n

        1. Initial program 63.8%

          \[\cos \left(\frac{K \cdot \left(m + n\right)}{2} - M\right) \cdot e^{\left(-{\left(\frac{m + n}{2} - M\right)}^{2}\right) - \left(\ell - \left|m - n\right|\right)} \]
        2. Step-by-step derivation
          1. neg-sub0N/A

            \[\leadsto \cos \left(\frac{K \cdot \left(m + n\right)}{2} - M\right) \cdot e^{\left(0 - {\left(\frac{m + n}{2} - M\right)}^{2}\right) - \left(\ell - \left|m - n\right|\right)} \]
          2. associate--l-N/A

            \[\leadsto \cos \left(\frac{K \cdot \left(m + n\right)}{2} - M\right) \cdot e^{0 - \left({\left(\frac{m + n}{2} - M\right)}^{2} + \left(\ell - \left|m - n\right|\right)\right)} \]
          3. exp-diffN/A

            \[\leadsto \cos \left(\frac{K \cdot \left(m + n\right)}{2} - M\right) \cdot \frac{e^{0}}{\color{blue}{e^{{\left(\frac{m + n}{2} - M\right)}^{2} + \left(\ell - \left|m - n\right|\right)}}} \]
          4. associate-*r/N/A

            \[\leadsto \frac{\cos \left(\frac{K \cdot \left(m + n\right)}{2} - M\right) \cdot e^{0}}{\color{blue}{e^{{\left(\frac{m + n}{2} - M\right)}^{2} + \left(\ell - \left|m - n\right|\right)}}} \]
          5. exp-0N/A

            \[\leadsto \frac{\cos \left(\frac{K \cdot \left(m + n\right)}{2} - M\right) \cdot 1}{e^{{\left(\frac{m + n}{2} - M\right)}^{2} + \color{blue}{\left(\ell - \left|m - n\right|\right)}}} \]
          6. *-rgt-identityN/A

            \[\leadsto \frac{\cos \left(\frac{K \cdot \left(m + n\right)}{2} - M\right)}{e^{\color{blue}{{\left(\frac{m + n}{2} - M\right)}^{2} + \left(\ell - \left|m - n\right|\right)}}} \]
          7. /-lowering-/.f64N/A

            \[\leadsto \mathsf{/.f64}\left(\cos \left(\frac{K \cdot \left(m + n\right)}{2} - M\right), \color{blue}{\left(e^{{\left(\frac{m + n}{2} - M\right)}^{2} + \left(\ell - \left|m - n\right|\right)}\right)}\right) \]
        3. Simplified63.8%

          \[\leadsto \color{blue}{\frac{\cos \left(\frac{K \cdot \left(m + n\right)}{2} - M\right)}{e^{\left(\left(\frac{m + n}{2} - M\right) \cdot \left(\frac{m + n}{2} - M\right) + \ell\right) - \left|m - n\right|}}} \]
        4. Add Preprocessing
        5. Taylor expanded in K around 0

          \[\leadsto \mathsf{/.f64}\left(\color{blue}{\cos \left(\mathsf{neg}\left(M\right)\right)}, \mathsf{exp.f64}\left(\mathsf{\_.f64}\left(\mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\mathsf{/.f64}\left(\mathsf{+.f64}\left(m, n\right), 2\right), M\right), \mathsf{\_.f64}\left(\mathsf{/.f64}\left(\mathsf{+.f64}\left(m, n\right), 2\right), M\right)\right), \ell\right), \mathsf{fabs.f64}\left(\mathsf{\_.f64}\left(m, n\right)\right)\right)\right)\right) \]
        6. Step-by-step derivation
          1. cos-negN/A

            \[\leadsto \mathsf{/.f64}\left(\cos M, \mathsf{exp.f64}\left(\color{blue}{\mathsf{\_.f64}\left(\mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\mathsf{/.f64}\left(\mathsf{+.f64}\left(m, n\right), 2\right), M\right), \mathsf{\_.f64}\left(\mathsf{/.f64}\left(\mathsf{+.f64}\left(m, n\right), 2\right), M\right)\right), \ell\right), \mathsf{fabs.f64}\left(\mathsf{\_.f64}\left(m, n\right)\right)\right)}\right)\right) \]
          2. cos-lowering-cos.f64100.0%

            \[\leadsto \mathsf{/.f64}\left(\mathsf{cos.f64}\left(M\right), \mathsf{exp.f64}\left(\color{blue}{\mathsf{\_.f64}\left(\mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\mathsf{/.f64}\left(\mathsf{+.f64}\left(m, n\right), 2\right), M\right), \mathsf{\_.f64}\left(\mathsf{/.f64}\left(\mathsf{+.f64}\left(m, n\right), 2\right), M\right)\right), \ell\right), \mathsf{fabs.f64}\left(\mathsf{\_.f64}\left(m, n\right)\right)\right)}\right)\right) \]
        7. Simplified100.0%

          \[\leadsto \frac{\color{blue}{\cos M}}{e^{\left(\left(\frac{m + n}{2} - M\right) \cdot \left(\frac{m + n}{2} - M\right) + \ell\right) - \left|m - n\right|}} \]
        8. Taylor expanded in n around inf

          \[\leadsto \mathsf{/.f64}\left(\mathsf{cos.f64}\left(M\right), \mathsf{exp.f64}\left(\color{blue}{\left(\frac{1}{4} \cdot {n}^{2}\right)}\right)\right) \]
        9. Step-by-step derivation
          1. *-lowering-*.f64N/A

            \[\leadsto \mathsf{/.f64}\left(\mathsf{cos.f64}\left(M\right), \mathsf{exp.f64}\left(\mathsf{*.f64}\left(\frac{1}{4}, \left({n}^{2}\right)\right)\right)\right) \]
          2. unpow2N/A

            \[\leadsto \mathsf{/.f64}\left(\mathsf{cos.f64}\left(M\right), \mathsf{exp.f64}\left(\mathsf{*.f64}\left(\frac{1}{4}, \left(n \cdot n\right)\right)\right)\right) \]
          3. *-lowering-*.f64100.0%

            \[\leadsto \mathsf{/.f64}\left(\mathsf{cos.f64}\left(M\right), \mathsf{exp.f64}\left(\mathsf{*.f64}\left(\frac{1}{4}, \mathsf{*.f64}\left(n, n\right)\right)\right)\right) \]
        10. Simplified100.0%

          \[\leadsto \frac{\cos M}{e^{\color{blue}{0.25 \cdot \left(n \cdot n\right)}}} \]
      13. Recombined 3 regimes into one program.
      14. Final simplification68.2%

        \[\leadsto \begin{array}{l} \mathbf{if}\;n \leq 4.9 \cdot 10^{-104}:\\ \;\;\;\;\frac{1}{e^{\left(\ell + 0.25 \cdot \left(m \cdot m\right)\right) - \left|m - n\right|}}\\ \mathbf{elif}\;n \leq 1900000:\\ \;\;\;\;\frac{1}{e^{\left(\ell + M \cdot M\right) - \left|m - n\right|}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\cos M}{e^{0.25 \cdot \left(n \cdot n\right)}}\\ \end{array} \]
      15. Add Preprocessing

      Alternative 5: 67.7% accurate, 1.9× speedup?

      \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;n \leq 4.2 \cdot 10^{-213}:\\ \;\;\;\;\frac{\cos M}{e^{0.25 \cdot \left(m \cdot m\right)}}\\ \mathbf{elif}\;n \leq 1900000:\\ \;\;\;\;\frac{1}{e^{\left(\ell + M \cdot M\right) - \left|m - n\right|}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\cos M}{e^{0.25 \cdot \left(n \cdot n\right)}}\\ \end{array} \end{array} \]
      (FPCore (K m n M l)
       :precision binary64
       (if (<= n 4.2e-213)
         (/ (cos M) (exp (* 0.25 (* m m))))
         (if (<= n 1900000.0)
           (/ 1.0 (exp (- (+ l (* M M)) (fabs (- m n)))))
           (/ (cos M) (exp (* 0.25 (* n n)))))))
      double code(double K, double m, double n, double M, double l) {
      	double tmp;
      	if (n <= 4.2e-213) {
      		tmp = cos(M) / exp((0.25 * (m * m)));
      	} else if (n <= 1900000.0) {
      		tmp = 1.0 / exp(((l + (M * M)) - fabs((m - n))));
      	} else {
      		tmp = cos(M) / exp((0.25 * (n * n)));
      	}
      	return tmp;
      }
      
      real(8) function code(k, m, n, m_1, l)
          real(8), intent (in) :: k
          real(8), intent (in) :: m
          real(8), intent (in) :: n
          real(8), intent (in) :: m_1
          real(8), intent (in) :: l
          real(8) :: tmp
          if (n <= 4.2d-213) then
              tmp = cos(m_1) / exp((0.25d0 * (m * m)))
          else if (n <= 1900000.0d0) then
              tmp = 1.0d0 / exp(((l + (m_1 * m_1)) - abs((m - n))))
          else
              tmp = cos(m_1) / exp((0.25d0 * (n * n)))
          end if
          code = tmp
      end function
      
      public static double code(double K, double m, double n, double M, double l) {
      	double tmp;
      	if (n <= 4.2e-213) {
      		tmp = Math.cos(M) / Math.exp((0.25 * (m * m)));
      	} else if (n <= 1900000.0) {
      		tmp = 1.0 / Math.exp(((l + (M * M)) - Math.abs((m - n))));
      	} else {
      		tmp = Math.cos(M) / Math.exp((0.25 * (n * n)));
      	}
      	return tmp;
      }
      
      def code(K, m, n, M, l):
      	tmp = 0
      	if n <= 4.2e-213:
      		tmp = math.cos(M) / math.exp((0.25 * (m * m)))
      	elif n <= 1900000.0:
      		tmp = 1.0 / math.exp(((l + (M * M)) - math.fabs((m - n))))
      	else:
      		tmp = math.cos(M) / math.exp((0.25 * (n * n)))
      	return tmp
      
      function code(K, m, n, M, l)
      	tmp = 0.0
      	if (n <= 4.2e-213)
      		tmp = Float64(cos(M) / exp(Float64(0.25 * Float64(m * m))));
      	elseif (n <= 1900000.0)
      		tmp = Float64(1.0 / exp(Float64(Float64(l + Float64(M * M)) - abs(Float64(m - n)))));
      	else
      		tmp = Float64(cos(M) / exp(Float64(0.25 * Float64(n * n))));
      	end
      	return tmp
      end
      
      function tmp_2 = code(K, m, n, M, l)
      	tmp = 0.0;
      	if (n <= 4.2e-213)
      		tmp = cos(M) / exp((0.25 * (m * m)));
      	elseif (n <= 1900000.0)
      		tmp = 1.0 / exp(((l + (M * M)) - abs((m - n))));
      	else
      		tmp = cos(M) / exp((0.25 * (n * n)));
      	end
      	tmp_2 = tmp;
      end
      
      code[K_, m_, n_, M_, l_] := If[LessEqual[n, 4.2e-213], N[(N[Cos[M], $MachinePrecision] / N[Exp[N[(0.25 * N[(m * m), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[n, 1900000.0], N[(1.0 / N[Exp[N[(N[(l + N[(M * M), $MachinePrecision]), $MachinePrecision] - N[Abs[N[(m - n), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(N[Cos[M], $MachinePrecision] / N[Exp[N[(0.25 * N[(n * n), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]
      
      \begin{array}{l}
      
      \\
      \begin{array}{l}
      \mathbf{if}\;n \leq 4.2 \cdot 10^{-213}:\\
      \;\;\;\;\frac{\cos M}{e^{0.25 \cdot \left(m \cdot m\right)}}\\
      
      \mathbf{elif}\;n \leq 1900000:\\
      \;\;\;\;\frac{1}{e^{\left(\ell + M \cdot M\right) - \left|m - n\right|}}\\
      
      \mathbf{else}:\\
      \;\;\;\;\frac{\cos M}{e^{0.25 \cdot \left(n \cdot n\right)}}\\
      
      
      \end{array}
      \end{array}
      
      Derivation
      1. Split input into 3 regimes
      2. if n < 4.1999999999999997e-213

        1. Initial program 72.8%

          \[\cos \left(\frac{K \cdot \left(m + n\right)}{2} - M\right) \cdot e^{\left(-{\left(\frac{m + n}{2} - M\right)}^{2}\right) - \left(\ell - \left|m - n\right|\right)} \]
        2. Step-by-step derivation
          1. neg-sub0N/A

            \[\leadsto \cos \left(\frac{K \cdot \left(m + n\right)}{2} - M\right) \cdot e^{\left(0 - {\left(\frac{m + n}{2} - M\right)}^{2}\right) - \left(\ell - \left|m - n\right|\right)} \]
          2. associate--l-N/A

            \[\leadsto \cos \left(\frac{K \cdot \left(m + n\right)}{2} - M\right) \cdot e^{0 - \left({\left(\frac{m + n}{2} - M\right)}^{2} + \left(\ell - \left|m - n\right|\right)\right)} \]
          3. exp-diffN/A

            \[\leadsto \cos \left(\frac{K \cdot \left(m + n\right)}{2} - M\right) \cdot \frac{e^{0}}{\color{blue}{e^{{\left(\frac{m + n}{2} - M\right)}^{2} + \left(\ell - \left|m - n\right|\right)}}} \]
          4. associate-*r/N/A

            \[\leadsto \frac{\cos \left(\frac{K \cdot \left(m + n\right)}{2} - M\right) \cdot e^{0}}{\color{blue}{e^{{\left(\frac{m + n}{2} - M\right)}^{2} + \left(\ell - \left|m - n\right|\right)}}} \]
          5. exp-0N/A

            \[\leadsto \frac{\cos \left(\frac{K \cdot \left(m + n\right)}{2} - M\right) \cdot 1}{e^{{\left(\frac{m + n}{2} - M\right)}^{2} + \color{blue}{\left(\ell - \left|m - n\right|\right)}}} \]
          6. *-rgt-identityN/A

            \[\leadsto \frac{\cos \left(\frac{K \cdot \left(m + n\right)}{2} - M\right)}{e^{\color{blue}{{\left(\frac{m + n}{2} - M\right)}^{2} + \left(\ell - \left|m - n\right|\right)}}} \]
          7. /-lowering-/.f64N/A

            \[\leadsto \mathsf{/.f64}\left(\cos \left(\frac{K \cdot \left(m + n\right)}{2} - M\right), \color{blue}{\left(e^{{\left(\frac{m + n}{2} - M\right)}^{2} + \left(\ell - \left|m - n\right|\right)}\right)}\right) \]
        3. Simplified72.8%

          \[\leadsto \color{blue}{\frac{\cos \left(\frac{K \cdot \left(m + n\right)}{2} - M\right)}{e^{\left(\left(\frac{m + n}{2} - M\right) \cdot \left(\frac{m + n}{2} - M\right) + \ell\right) - \left|m - n\right|}}} \]
        4. Add Preprocessing
        5. Taylor expanded in K around 0

          \[\leadsto \mathsf{/.f64}\left(\color{blue}{\cos \left(\mathsf{neg}\left(M\right)\right)}, \mathsf{exp.f64}\left(\mathsf{\_.f64}\left(\mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\mathsf{/.f64}\left(\mathsf{+.f64}\left(m, n\right), 2\right), M\right), \mathsf{\_.f64}\left(\mathsf{/.f64}\left(\mathsf{+.f64}\left(m, n\right), 2\right), M\right)\right), \ell\right), \mathsf{fabs.f64}\left(\mathsf{\_.f64}\left(m, n\right)\right)\right)\right)\right) \]
        6. Step-by-step derivation
          1. cos-negN/A

            \[\leadsto \mathsf{/.f64}\left(\cos M, \mathsf{exp.f64}\left(\color{blue}{\mathsf{\_.f64}\left(\mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\mathsf{/.f64}\left(\mathsf{+.f64}\left(m, n\right), 2\right), M\right), \mathsf{\_.f64}\left(\mathsf{/.f64}\left(\mathsf{+.f64}\left(m, n\right), 2\right), M\right)\right), \ell\right), \mathsf{fabs.f64}\left(\mathsf{\_.f64}\left(m, n\right)\right)\right)}\right)\right) \]
          2. cos-lowering-cos.f6492.6%

            \[\leadsto \mathsf{/.f64}\left(\mathsf{cos.f64}\left(M\right), \mathsf{exp.f64}\left(\color{blue}{\mathsf{\_.f64}\left(\mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\mathsf{/.f64}\left(\mathsf{+.f64}\left(m, n\right), 2\right), M\right), \mathsf{\_.f64}\left(\mathsf{/.f64}\left(\mathsf{+.f64}\left(m, n\right), 2\right), M\right)\right), \ell\right), \mathsf{fabs.f64}\left(\mathsf{\_.f64}\left(m, n\right)\right)\right)}\right)\right) \]
        7. Simplified92.6%

          \[\leadsto \frac{\color{blue}{\cos M}}{e^{\left(\left(\frac{m + n}{2} - M\right) \cdot \left(\frac{m + n}{2} - M\right) + \ell\right) - \left|m - n\right|}} \]
        8. Taylor expanded in m around inf

          \[\leadsto \mathsf{/.f64}\left(\mathsf{cos.f64}\left(M\right), \mathsf{exp.f64}\left(\color{blue}{\left(\frac{1}{4} \cdot {m}^{2}\right)}\right)\right) \]
        9. Step-by-step derivation
          1. *-lowering-*.f64N/A

            \[\leadsto \mathsf{/.f64}\left(\mathsf{cos.f64}\left(M\right), \mathsf{exp.f64}\left(\mathsf{*.f64}\left(\frac{1}{4}, \left({m}^{2}\right)\right)\right)\right) \]
          2. unpow2N/A

            \[\leadsto \mathsf{/.f64}\left(\mathsf{cos.f64}\left(M\right), \mathsf{exp.f64}\left(\mathsf{*.f64}\left(\frac{1}{4}, \left(m \cdot m\right)\right)\right)\right) \]
          3. *-lowering-*.f6452.6%

            \[\leadsto \mathsf{/.f64}\left(\mathsf{cos.f64}\left(M\right), \mathsf{exp.f64}\left(\mathsf{*.f64}\left(\frac{1}{4}, \mathsf{*.f64}\left(m, m\right)\right)\right)\right) \]
        10. Simplified52.6%

          \[\leadsto \frac{\cos M}{e^{\color{blue}{0.25 \cdot \left(m \cdot m\right)}}} \]

        if 4.1999999999999997e-213 < n < 1.9e6

        1. Initial program 74.2%

          \[\cos \left(\frac{K \cdot \left(m + n\right)}{2} - M\right) \cdot e^{\left(-{\left(\frac{m + n}{2} - M\right)}^{2}\right) - \left(\ell - \left|m - n\right|\right)} \]
        2. Step-by-step derivation
          1. neg-sub0N/A

            \[\leadsto \cos \left(\frac{K \cdot \left(m + n\right)}{2} - M\right) \cdot e^{\left(0 - {\left(\frac{m + n}{2} - M\right)}^{2}\right) - \left(\ell - \left|m - n\right|\right)} \]
          2. associate--l-N/A

            \[\leadsto \cos \left(\frac{K \cdot \left(m + n\right)}{2} - M\right) \cdot e^{0 - \left({\left(\frac{m + n}{2} - M\right)}^{2} + \left(\ell - \left|m - n\right|\right)\right)} \]
          3. exp-diffN/A

            \[\leadsto \cos \left(\frac{K \cdot \left(m + n\right)}{2} - M\right) \cdot \frac{e^{0}}{\color{blue}{e^{{\left(\frac{m + n}{2} - M\right)}^{2} + \left(\ell - \left|m - n\right|\right)}}} \]
          4. associate-*r/N/A

            \[\leadsto \frac{\cos \left(\frac{K \cdot \left(m + n\right)}{2} - M\right) \cdot e^{0}}{\color{blue}{e^{{\left(\frac{m + n}{2} - M\right)}^{2} + \left(\ell - \left|m - n\right|\right)}}} \]
          5. exp-0N/A

            \[\leadsto \frac{\cos \left(\frac{K \cdot \left(m + n\right)}{2} - M\right) \cdot 1}{e^{{\left(\frac{m + n}{2} - M\right)}^{2} + \color{blue}{\left(\ell - \left|m - n\right|\right)}}} \]
          6. *-rgt-identityN/A

            \[\leadsto \frac{\cos \left(\frac{K \cdot \left(m + n\right)}{2} - M\right)}{e^{\color{blue}{{\left(\frac{m + n}{2} - M\right)}^{2} + \left(\ell - \left|m - n\right|\right)}}} \]
          7. /-lowering-/.f64N/A

            \[\leadsto \mathsf{/.f64}\left(\cos \left(\frac{K \cdot \left(m + n\right)}{2} - M\right), \color{blue}{\left(e^{{\left(\frac{m + n}{2} - M\right)}^{2} + \left(\ell - \left|m - n\right|\right)}\right)}\right) \]
        3. Simplified74.2%

          \[\leadsto \color{blue}{\frac{\cos \left(\frac{K \cdot \left(m + n\right)}{2} - M\right)}{e^{\left(\left(\frac{m + n}{2} - M\right) \cdot \left(\frac{m + n}{2} - M\right) + \ell\right) - \left|m - n\right|}}} \]
        4. Add Preprocessing
        5. Taylor expanded in M around inf

          \[\leadsto \mathsf{/.f64}\left(\mathsf{cos.f64}\left(\mathsf{\_.f64}\left(\mathsf{/.f64}\left(\mathsf{*.f64}\left(K, \mathsf{+.f64}\left(m, n\right)\right), 2\right), M\right)\right), \mathsf{exp.f64}\left(\mathsf{\_.f64}\left(\mathsf{+.f64}\left(\color{blue}{\left({M}^{2}\right)}, \ell\right), \mathsf{fabs.f64}\left(\mathsf{\_.f64}\left(m, n\right)\right)\right)\right)\right) \]
        6. Step-by-step derivation
          1. unpow2N/A

            \[\leadsto \mathsf{/.f64}\left(\mathsf{cos.f64}\left(\mathsf{\_.f64}\left(\mathsf{/.f64}\left(\mathsf{*.f64}\left(K, \mathsf{+.f64}\left(m, n\right)\right), 2\right), M\right)\right), \mathsf{exp.f64}\left(\mathsf{\_.f64}\left(\mathsf{+.f64}\left(\left(M \cdot M\right), \ell\right), \mathsf{fabs.f64}\left(\mathsf{\_.f64}\left(m, n\right)\right)\right)\right)\right) \]
          2. *-lowering-*.f6460.5%

            \[\leadsto \mathsf{/.f64}\left(\mathsf{cos.f64}\left(\mathsf{\_.f64}\left(\mathsf{/.f64}\left(\mathsf{*.f64}\left(K, \mathsf{+.f64}\left(m, n\right)\right), 2\right), M\right)\right), \mathsf{exp.f64}\left(\mathsf{\_.f64}\left(\mathsf{+.f64}\left(\mathsf{*.f64}\left(M, M\right), \ell\right), \mathsf{fabs.f64}\left(\mathsf{\_.f64}\left(m, n\right)\right)\right)\right)\right) \]
        7. Simplified60.5%

          \[\leadsto \frac{\cos \left(\frac{K \cdot \left(m + n\right)}{2} - M\right)}{e^{\left(\color{blue}{M \cdot M} + \ell\right) - \left|m - n\right|}} \]
        8. Taylor expanded in n around inf

          \[\leadsto \mathsf{/.f64}\left(\mathsf{cos.f64}\left(\color{blue}{\left(\frac{1}{2} \cdot \left(K \cdot n\right)\right)}\right), \mathsf{exp.f64}\left(\mathsf{\_.f64}\left(\mathsf{+.f64}\left(\mathsf{*.f64}\left(M, M\right), \ell\right), \mathsf{fabs.f64}\left(\mathsf{\_.f64}\left(m, n\right)\right)\right)\right)\right) \]
        9. Step-by-step derivation
          1. associate-*r*N/A

            \[\leadsto \mathsf{/.f64}\left(\mathsf{cos.f64}\left(\left(\left(\frac{1}{2} \cdot K\right) \cdot n\right)\right), \mathsf{exp.f64}\left(\mathsf{\_.f64}\left(\color{blue}{\mathsf{+.f64}\left(\mathsf{*.f64}\left(M, M\right), \ell\right)}, \mathsf{fabs.f64}\left(\mathsf{\_.f64}\left(m, n\right)\right)\right)\right)\right) \]
          2. *-lowering-*.f64N/A

            \[\leadsto \mathsf{/.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(\left(\frac{1}{2} \cdot K\right), n\right)\right), \mathsf{exp.f64}\left(\mathsf{\_.f64}\left(\color{blue}{\mathsf{+.f64}\left(\mathsf{*.f64}\left(M, M\right), \ell\right)}, \mathsf{fabs.f64}\left(\mathsf{\_.f64}\left(m, n\right)\right)\right)\right)\right) \]
          3. *-lowering-*.f6470.0%

            \[\leadsto \mathsf{/.f64}\left(\mathsf{cos.f64}\left(\mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, K\right), n\right)\right), \mathsf{exp.f64}\left(\mathsf{\_.f64}\left(\mathsf{+.f64}\left(\color{blue}{\mathsf{*.f64}\left(M, M\right)}, \ell\right), \mathsf{fabs.f64}\left(\mathsf{\_.f64}\left(m, n\right)\right)\right)\right)\right) \]
        10. Simplified70.0%

          \[\leadsto \frac{\cos \color{blue}{\left(\left(0.5 \cdot K\right) \cdot n\right)}}{e^{\left(M \cdot M + \ell\right) - \left|m - n\right|}} \]
        11. Taylor expanded in K around 0

          \[\leadsto \mathsf{/.f64}\left(\color{blue}{1}, \mathsf{exp.f64}\left(\mathsf{\_.f64}\left(\mathsf{+.f64}\left(\mathsf{*.f64}\left(M, M\right), \ell\right), \mathsf{fabs.f64}\left(\mathsf{\_.f64}\left(m, n\right)\right)\right)\right)\right) \]
        12. Step-by-step derivation
          1. Simplified70.0%

            \[\leadsto \frac{\color{blue}{1}}{e^{\left(M \cdot M + \ell\right) - \left|m - n\right|}} \]

          if 1.9e6 < n

          1. Initial program 63.8%

            \[\cos \left(\frac{K \cdot \left(m + n\right)}{2} - M\right) \cdot e^{\left(-{\left(\frac{m + n}{2} - M\right)}^{2}\right) - \left(\ell - \left|m - n\right|\right)} \]
          2. Step-by-step derivation
            1. neg-sub0N/A

              \[\leadsto \cos \left(\frac{K \cdot \left(m + n\right)}{2} - M\right) \cdot e^{\left(0 - {\left(\frac{m + n}{2} - M\right)}^{2}\right) - \left(\ell - \left|m - n\right|\right)} \]
            2. associate--l-N/A

              \[\leadsto \cos \left(\frac{K \cdot \left(m + n\right)}{2} - M\right) \cdot e^{0 - \left({\left(\frac{m + n}{2} - M\right)}^{2} + \left(\ell - \left|m - n\right|\right)\right)} \]
            3. exp-diffN/A

              \[\leadsto \cos \left(\frac{K \cdot \left(m + n\right)}{2} - M\right) \cdot \frac{e^{0}}{\color{blue}{e^{{\left(\frac{m + n}{2} - M\right)}^{2} + \left(\ell - \left|m - n\right|\right)}}} \]
            4. associate-*r/N/A

              \[\leadsto \frac{\cos \left(\frac{K \cdot \left(m + n\right)}{2} - M\right) \cdot e^{0}}{\color{blue}{e^{{\left(\frac{m + n}{2} - M\right)}^{2} + \left(\ell - \left|m - n\right|\right)}}} \]
            5. exp-0N/A

              \[\leadsto \frac{\cos \left(\frac{K \cdot \left(m + n\right)}{2} - M\right) \cdot 1}{e^{{\left(\frac{m + n}{2} - M\right)}^{2} + \color{blue}{\left(\ell - \left|m - n\right|\right)}}} \]
            6. *-rgt-identityN/A

              \[\leadsto \frac{\cos \left(\frac{K \cdot \left(m + n\right)}{2} - M\right)}{e^{\color{blue}{{\left(\frac{m + n}{2} - M\right)}^{2} + \left(\ell - \left|m - n\right|\right)}}} \]
            7. /-lowering-/.f64N/A

              \[\leadsto \mathsf{/.f64}\left(\cos \left(\frac{K \cdot \left(m + n\right)}{2} - M\right), \color{blue}{\left(e^{{\left(\frac{m + n}{2} - M\right)}^{2} + \left(\ell - \left|m - n\right|\right)}\right)}\right) \]
          3. Simplified63.8%

            \[\leadsto \color{blue}{\frac{\cos \left(\frac{K \cdot \left(m + n\right)}{2} - M\right)}{e^{\left(\left(\frac{m + n}{2} - M\right) \cdot \left(\frac{m + n}{2} - M\right) + \ell\right) - \left|m - n\right|}}} \]
          4. Add Preprocessing
          5. Taylor expanded in K around 0

            \[\leadsto \mathsf{/.f64}\left(\color{blue}{\cos \left(\mathsf{neg}\left(M\right)\right)}, \mathsf{exp.f64}\left(\mathsf{\_.f64}\left(\mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\mathsf{/.f64}\left(\mathsf{+.f64}\left(m, n\right), 2\right), M\right), \mathsf{\_.f64}\left(\mathsf{/.f64}\left(\mathsf{+.f64}\left(m, n\right), 2\right), M\right)\right), \ell\right), \mathsf{fabs.f64}\left(\mathsf{\_.f64}\left(m, n\right)\right)\right)\right)\right) \]
          6. Step-by-step derivation
            1. cos-negN/A

              \[\leadsto \mathsf{/.f64}\left(\cos M, \mathsf{exp.f64}\left(\color{blue}{\mathsf{\_.f64}\left(\mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\mathsf{/.f64}\left(\mathsf{+.f64}\left(m, n\right), 2\right), M\right), \mathsf{\_.f64}\left(\mathsf{/.f64}\left(\mathsf{+.f64}\left(m, n\right), 2\right), M\right)\right), \ell\right), \mathsf{fabs.f64}\left(\mathsf{\_.f64}\left(m, n\right)\right)\right)}\right)\right) \]
            2. cos-lowering-cos.f64100.0%

              \[\leadsto \mathsf{/.f64}\left(\mathsf{cos.f64}\left(M\right), \mathsf{exp.f64}\left(\color{blue}{\mathsf{\_.f64}\left(\mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\mathsf{/.f64}\left(\mathsf{+.f64}\left(m, n\right), 2\right), M\right), \mathsf{\_.f64}\left(\mathsf{/.f64}\left(\mathsf{+.f64}\left(m, n\right), 2\right), M\right)\right), \ell\right), \mathsf{fabs.f64}\left(\mathsf{\_.f64}\left(m, n\right)\right)\right)}\right)\right) \]
          7. Simplified100.0%

            \[\leadsto \frac{\color{blue}{\cos M}}{e^{\left(\left(\frac{m + n}{2} - M\right) \cdot \left(\frac{m + n}{2} - M\right) + \ell\right) - \left|m - n\right|}} \]
          8. Taylor expanded in n around inf

            \[\leadsto \mathsf{/.f64}\left(\mathsf{cos.f64}\left(M\right), \mathsf{exp.f64}\left(\color{blue}{\left(\frac{1}{4} \cdot {n}^{2}\right)}\right)\right) \]
          9. Step-by-step derivation
            1. *-lowering-*.f64N/A

              \[\leadsto \mathsf{/.f64}\left(\mathsf{cos.f64}\left(M\right), \mathsf{exp.f64}\left(\mathsf{*.f64}\left(\frac{1}{4}, \left({n}^{2}\right)\right)\right)\right) \]
            2. unpow2N/A

              \[\leadsto \mathsf{/.f64}\left(\mathsf{cos.f64}\left(M\right), \mathsf{exp.f64}\left(\mathsf{*.f64}\left(\frac{1}{4}, \left(n \cdot n\right)\right)\right)\right) \]
            3. *-lowering-*.f64100.0%

              \[\leadsto \mathsf{/.f64}\left(\mathsf{cos.f64}\left(M\right), \mathsf{exp.f64}\left(\mathsf{*.f64}\left(\frac{1}{4}, \mathsf{*.f64}\left(n, n\right)\right)\right)\right) \]
          10. Simplified100.0%

            \[\leadsto \frac{\cos M}{e^{\color{blue}{0.25 \cdot \left(n \cdot n\right)}}} \]
        13. Recombined 3 regimes into one program.
        14. Final simplification64.9%

          \[\leadsto \begin{array}{l} \mathbf{if}\;n \leq 4.2 \cdot 10^{-213}:\\ \;\;\;\;\frac{\cos M}{e^{0.25 \cdot \left(m \cdot m\right)}}\\ \mathbf{elif}\;n \leq 1900000:\\ \;\;\;\;\frac{1}{e^{\left(\ell + M \cdot M\right) - \left|m - n\right|}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\cos M}{e^{0.25 \cdot \left(n \cdot n\right)}}\\ \end{array} \]
        15. Add Preprocessing

        Alternative 6: 73.7% accurate, 1.9× speedup?

        \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;m \leq -54:\\ \;\;\;\;\frac{1}{e^{0.25 \cdot \left(m \cdot m\right)}}\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{e^{\ell + \left(0.25 \cdot \left(n \cdot n\right) - \left|m - n\right|\right)}}\\ \end{array} \end{array} \]
        (FPCore (K m n M l)
         :precision binary64
         (if (<= m -54.0)
           (/ 1.0 (exp (* 0.25 (* m m))))
           (/ 1.0 (exp (+ l (- (* 0.25 (* n n)) (fabs (- m n))))))))
        double code(double K, double m, double n, double M, double l) {
        	double tmp;
        	if (m <= -54.0) {
        		tmp = 1.0 / exp((0.25 * (m * m)));
        	} else {
        		tmp = 1.0 / exp((l + ((0.25 * (n * n)) - fabs((m - n)))));
        	}
        	return tmp;
        }
        
        real(8) function code(k, m, n, m_1, l)
            real(8), intent (in) :: k
            real(8), intent (in) :: m
            real(8), intent (in) :: n
            real(8), intent (in) :: m_1
            real(8), intent (in) :: l
            real(8) :: tmp
            if (m <= (-54.0d0)) then
                tmp = 1.0d0 / exp((0.25d0 * (m * m)))
            else
                tmp = 1.0d0 / exp((l + ((0.25d0 * (n * n)) - abs((m - n)))))
            end if
            code = tmp
        end function
        
        public static double code(double K, double m, double n, double M, double l) {
        	double tmp;
        	if (m <= -54.0) {
        		tmp = 1.0 / Math.exp((0.25 * (m * m)));
        	} else {
        		tmp = 1.0 / Math.exp((l + ((0.25 * (n * n)) - Math.abs((m - n)))));
        	}
        	return tmp;
        }
        
        def code(K, m, n, M, l):
        	tmp = 0
        	if m <= -54.0:
        		tmp = 1.0 / math.exp((0.25 * (m * m)))
        	else:
        		tmp = 1.0 / math.exp((l + ((0.25 * (n * n)) - math.fabs((m - n)))))
        	return tmp
        
        function code(K, m, n, M, l)
        	tmp = 0.0
        	if (m <= -54.0)
        		tmp = Float64(1.0 / exp(Float64(0.25 * Float64(m * m))));
        	else
        		tmp = Float64(1.0 / exp(Float64(l + Float64(Float64(0.25 * Float64(n * n)) - abs(Float64(m - n))))));
        	end
        	return tmp
        end
        
        function tmp_2 = code(K, m, n, M, l)
        	tmp = 0.0;
        	if (m <= -54.0)
        		tmp = 1.0 / exp((0.25 * (m * m)));
        	else
        		tmp = 1.0 / exp((l + ((0.25 * (n * n)) - abs((m - n)))));
        	end
        	tmp_2 = tmp;
        end
        
        code[K_, m_, n_, M_, l_] := If[LessEqual[m, -54.0], N[(1.0 / N[Exp[N[(0.25 * N[(m * m), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(1.0 / N[Exp[N[(l + N[(N[(0.25 * N[(n * n), $MachinePrecision]), $MachinePrecision] - N[Abs[N[(m - n), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
        
        \begin{array}{l}
        
        \\
        \begin{array}{l}
        \mathbf{if}\;m \leq -54:\\
        \;\;\;\;\frac{1}{e^{0.25 \cdot \left(m \cdot m\right)}}\\
        
        \mathbf{else}:\\
        \;\;\;\;\frac{1}{e^{\ell + \left(0.25 \cdot \left(n \cdot n\right) - \left|m - n\right|\right)}}\\
        
        
        \end{array}
        \end{array}
        
        Derivation
        1. Split input into 2 regimes
        2. if m < -54

          1. Initial program 66.2%

            \[\cos \left(\frac{K \cdot \left(m + n\right)}{2} - M\right) \cdot e^{\left(-{\left(\frac{m + n}{2} - M\right)}^{2}\right) - \left(\ell - \left|m - n\right|\right)} \]
          2. Step-by-step derivation
            1. neg-sub0N/A

              \[\leadsto \cos \left(\frac{K \cdot \left(m + n\right)}{2} - M\right) \cdot e^{\left(0 - {\left(\frac{m + n}{2} - M\right)}^{2}\right) - \left(\ell - \left|m - n\right|\right)} \]
            2. associate--l-N/A

              \[\leadsto \cos \left(\frac{K \cdot \left(m + n\right)}{2} - M\right) \cdot e^{0 - \left({\left(\frac{m + n}{2} - M\right)}^{2} + \left(\ell - \left|m - n\right|\right)\right)} \]
            3. exp-diffN/A

              \[\leadsto \cos \left(\frac{K \cdot \left(m + n\right)}{2} - M\right) \cdot \frac{e^{0}}{\color{blue}{e^{{\left(\frac{m + n}{2} - M\right)}^{2} + \left(\ell - \left|m - n\right|\right)}}} \]
            4. associate-*r/N/A

              \[\leadsto \frac{\cos \left(\frac{K \cdot \left(m + n\right)}{2} - M\right) \cdot e^{0}}{\color{blue}{e^{{\left(\frac{m + n}{2} - M\right)}^{2} + \left(\ell - \left|m - n\right|\right)}}} \]
            5. exp-0N/A

              \[\leadsto \frac{\cos \left(\frac{K \cdot \left(m + n\right)}{2} - M\right) \cdot 1}{e^{{\left(\frac{m + n}{2} - M\right)}^{2} + \color{blue}{\left(\ell - \left|m - n\right|\right)}}} \]
            6. *-rgt-identityN/A

              \[\leadsto \frac{\cos \left(\frac{K \cdot \left(m + n\right)}{2} - M\right)}{e^{\color{blue}{{\left(\frac{m + n}{2} - M\right)}^{2} + \left(\ell - \left|m - n\right|\right)}}} \]
            7. /-lowering-/.f64N/A

              \[\leadsto \mathsf{/.f64}\left(\cos \left(\frac{K \cdot \left(m + n\right)}{2} - M\right), \color{blue}{\left(e^{{\left(\frac{m + n}{2} - M\right)}^{2} + \left(\ell - \left|m - n\right|\right)}\right)}\right) \]
          3. Simplified66.2%

            \[\leadsto \color{blue}{\frac{\cos \left(\frac{K \cdot \left(m + n\right)}{2} - M\right)}{e^{\left(\left(\frac{m + n}{2} - M\right) \cdot \left(\frac{m + n}{2} - M\right) + \ell\right) - \left|m - n\right|}}} \]
          4. Add Preprocessing
          5. Taylor expanded in K around 0

            \[\leadsto \mathsf{/.f64}\left(\color{blue}{\cos \left(\mathsf{neg}\left(M\right)\right)}, \mathsf{exp.f64}\left(\mathsf{\_.f64}\left(\mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\mathsf{/.f64}\left(\mathsf{+.f64}\left(m, n\right), 2\right), M\right), \mathsf{\_.f64}\left(\mathsf{/.f64}\left(\mathsf{+.f64}\left(m, n\right), 2\right), M\right)\right), \ell\right), \mathsf{fabs.f64}\left(\mathsf{\_.f64}\left(m, n\right)\right)\right)\right)\right) \]
          6. Step-by-step derivation
            1. cos-negN/A

              \[\leadsto \mathsf{/.f64}\left(\cos M, \mathsf{exp.f64}\left(\color{blue}{\mathsf{\_.f64}\left(\mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\mathsf{/.f64}\left(\mathsf{+.f64}\left(m, n\right), 2\right), M\right), \mathsf{\_.f64}\left(\mathsf{/.f64}\left(\mathsf{+.f64}\left(m, n\right), 2\right), M\right)\right), \ell\right), \mathsf{fabs.f64}\left(\mathsf{\_.f64}\left(m, n\right)\right)\right)}\right)\right) \]
            2. cos-lowering-cos.f6498.5%

              \[\leadsto \mathsf{/.f64}\left(\mathsf{cos.f64}\left(M\right), \mathsf{exp.f64}\left(\color{blue}{\mathsf{\_.f64}\left(\mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\mathsf{/.f64}\left(\mathsf{+.f64}\left(m, n\right), 2\right), M\right), \mathsf{\_.f64}\left(\mathsf{/.f64}\left(\mathsf{+.f64}\left(m, n\right), 2\right), M\right)\right), \ell\right), \mathsf{fabs.f64}\left(\mathsf{\_.f64}\left(m, n\right)\right)\right)}\right)\right) \]
          7. Simplified98.5%

            \[\leadsto \frac{\color{blue}{\cos M}}{e^{\left(\left(\frac{m + n}{2} - M\right) \cdot \left(\frac{m + n}{2} - M\right) + \ell\right) - \left|m - n\right|}} \]
          8. Taylor expanded in M around 0

            \[\leadsto \color{blue}{\frac{1}{e^{\left(\ell + \frac{1}{4} \cdot {\left(m + n\right)}^{2}\right) - \left|m - n\right|}}} \]
          9. Step-by-step derivation
            1. /-lowering-/.f64N/A

              \[\leadsto \mathsf{/.f64}\left(1, \color{blue}{\left(e^{\left(\ell + \frac{1}{4} \cdot {\left(m + n\right)}^{2}\right) - \left|m - n\right|}\right)}\right) \]
            2. exp-lowering-exp.f64N/A

              \[\leadsto \mathsf{/.f64}\left(1, \mathsf{exp.f64}\left(\left(\left(\ell + \frac{1}{4} \cdot {\left(m + n\right)}^{2}\right) - \left|m - n\right|\right)\right)\right) \]
            3. fabs-subN/A

              \[\leadsto \mathsf{/.f64}\left(1, \mathsf{exp.f64}\left(\left(\left(\ell + \frac{1}{4} \cdot {\left(m + n\right)}^{2}\right) - \left|n - m\right|\right)\right)\right) \]
            4. associate--l+N/A

              \[\leadsto \mathsf{/.f64}\left(1, \mathsf{exp.f64}\left(\left(\ell + \left(\frac{1}{4} \cdot {\left(m + n\right)}^{2} - \left|n - m\right|\right)\right)\right)\right) \]
            5. +-lowering-+.f64N/A

              \[\leadsto \mathsf{/.f64}\left(1, \mathsf{exp.f64}\left(\mathsf{+.f64}\left(\ell, \left(\frac{1}{4} \cdot {\left(m + n\right)}^{2} - \left|n - m\right|\right)\right)\right)\right) \]
            6. --lowering--.f64N/A

              \[\leadsto \mathsf{/.f64}\left(1, \mathsf{exp.f64}\left(\mathsf{+.f64}\left(\ell, \mathsf{\_.f64}\left(\left(\frac{1}{4} \cdot {\left(m + n\right)}^{2}\right), \left(\left|n - m\right|\right)\right)\right)\right)\right) \]
            7. *-lowering-*.f64N/A

              \[\leadsto \mathsf{/.f64}\left(1, \mathsf{exp.f64}\left(\mathsf{+.f64}\left(\ell, \mathsf{\_.f64}\left(\mathsf{*.f64}\left(\frac{1}{4}, \left({\left(m + n\right)}^{2}\right)\right), \left(\left|n - m\right|\right)\right)\right)\right)\right) \]
            8. unpow2N/A

              \[\leadsto \mathsf{/.f64}\left(1, \mathsf{exp.f64}\left(\mathsf{+.f64}\left(\ell, \mathsf{\_.f64}\left(\mathsf{*.f64}\left(\frac{1}{4}, \left(\left(m + n\right) \cdot \left(m + n\right)\right)\right), \left(\left|n - m\right|\right)\right)\right)\right)\right) \]
            9. *-lowering-*.f64N/A

              \[\leadsto \mathsf{/.f64}\left(1, \mathsf{exp.f64}\left(\mathsf{+.f64}\left(\ell, \mathsf{\_.f64}\left(\mathsf{*.f64}\left(\frac{1}{4}, \mathsf{*.f64}\left(\left(m + n\right), \left(m + n\right)\right)\right), \left(\left|n - m\right|\right)\right)\right)\right)\right) \]
            10. +-lowering-+.f64N/A

              \[\leadsto \mathsf{/.f64}\left(1, \mathsf{exp.f64}\left(\mathsf{+.f64}\left(\ell, \mathsf{\_.f64}\left(\mathsf{*.f64}\left(\frac{1}{4}, \mathsf{*.f64}\left(\mathsf{+.f64}\left(m, n\right), \left(m + n\right)\right)\right), \left(\left|n - m\right|\right)\right)\right)\right)\right) \]
            11. +-lowering-+.f64N/A

              \[\leadsto \mathsf{/.f64}\left(1, \mathsf{exp.f64}\left(\mathsf{+.f64}\left(\ell, \mathsf{\_.f64}\left(\mathsf{*.f64}\left(\frac{1}{4}, \mathsf{*.f64}\left(\mathsf{+.f64}\left(m, n\right), \mathsf{+.f64}\left(m, n\right)\right)\right), \left(\left|n - m\right|\right)\right)\right)\right)\right) \]
            12. sub-negN/A

              \[\leadsto \mathsf{/.f64}\left(1, \mathsf{exp.f64}\left(\mathsf{+.f64}\left(\ell, \mathsf{\_.f64}\left(\mathsf{*.f64}\left(\frac{1}{4}, \mathsf{*.f64}\left(\mathsf{+.f64}\left(m, n\right), \mathsf{+.f64}\left(m, n\right)\right)\right), \left(\left|n + \left(\mathsf{neg}\left(m\right)\right)\right|\right)\right)\right)\right)\right) \]
            13. mul-1-negN/A

              \[\leadsto \mathsf{/.f64}\left(1, \mathsf{exp.f64}\left(\mathsf{+.f64}\left(\ell, \mathsf{\_.f64}\left(\mathsf{*.f64}\left(\frac{1}{4}, \mathsf{*.f64}\left(\mathsf{+.f64}\left(m, n\right), \mathsf{+.f64}\left(m, n\right)\right)\right), \left(\left|n + -1 \cdot m\right|\right)\right)\right)\right)\right) \]
            14. fabs-lowering-fabs.f64N/A

              \[\leadsto \mathsf{/.f64}\left(1, \mathsf{exp.f64}\left(\mathsf{+.f64}\left(\ell, \mathsf{\_.f64}\left(\mathsf{*.f64}\left(\frac{1}{4}, \mathsf{*.f64}\left(\mathsf{+.f64}\left(m, n\right), \mathsf{+.f64}\left(m, n\right)\right)\right), \mathsf{fabs.f64}\left(\left(n + -1 \cdot m\right)\right)\right)\right)\right)\right) \]
            15. mul-1-negN/A

              \[\leadsto \mathsf{/.f64}\left(1, \mathsf{exp.f64}\left(\mathsf{+.f64}\left(\ell, \mathsf{\_.f64}\left(\mathsf{*.f64}\left(\frac{1}{4}, \mathsf{*.f64}\left(\mathsf{+.f64}\left(m, n\right), \mathsf{+.f64}\left(m, n\right)\right)\right), \mathsf{fabs.f64}\left(\left(n + \left(\mathsf{neg}\left(m\right)\right)\right)\right)\right)\right)\right)\right) \]
            16. sub-negN/A

              \[\leadsto \mathsf{/.f64}\left(1, \mathsf{exp.f64}\left(\mathsf{+.f64}\left(\ell, \mathsf{\_.f64}\left(\mathsf{*.f64}\left(\frac{1}{4}, \mathsf{*.f64}\left(\mathsf{+.f64}\left(m, n\right), \mathsf{+.f64}\left(m, n\right)\right)\right), \mathsf{fabs.f64}\left(\left(n - m\right)\right)\right)\right)\right)\right) \]
            17. --lowering--.f6493.9%

              \[\leadsto \mathsf{/.f64}\left(1, \mathsf{exp.f64}\left(\mathsf{+.f64}\left(\ell, \mathsf{\_.f64}\left(\mathsf{*.f64}\left(\frac{1}{4}, \mathsf{*.f64}\left(\mathsf{+.f64}\left(m, n\right), \mathsf{+.f64}\left(m, n\right)\right)\right), \mathsf{fabs.f64}\left(\mathsf{\_.f64}\left(n, m\right)\right)\right)\right)\right)\right) \]
          10. Simplified93.9%

            \[\leadsto \color{blue}{\frac{1}{e^{\ell + \left(0.25 \cdot \left(\left(m + n\right) \cdot \left(m + n\right)\right) - \left|n - m\right|\right)}}} \]
          11. Taylor expanded in m around inf

            \[\leadsto \mathsf{/.f64}\left(1, \mathsf{exp.f64}\left(\color{blue}{\left(\frac{1}{4} \cdot {m}^{2}\right)}\right)\right) \]
          12. Step-by-step derivation
            1. *-lowering-*.f64N/A

              \[\leadsto \mathsf{/.f64}\left(1, \mathsf{exp.f64}\left(\mathsf{*.f64}\left(\frac{1}{4}, \left({m}^{2}\right)\right)\right)\right) \]
            2. unpow2N/A

              \[\leadsto \mathsf{/.f64}\left(1, \mathsf{exp.f64}\left(\mathsf{*.f64}\left(\frac{1}{4}, \left(m \cdot m\right)\right)\right)\right) \]
            3. *-lowering-*.f6495.5%

              \[\leadsto \mathsf{/.f64}\left(1, \mathsf{exp.f64}\left(\mathsf{*.f64}\left(\frac{1}{4}, \mathsf{*.f64}\left(m, m\right)\right)\right)\right) \]
          13. Simplified95.5%

            \[\leadsto \frac{1}{e^{\color{blue}{0.25 \cdot \left(m \cdot m\right)}}} \]

          if -54 < m

          1. Initial program 73.3%

            \[\cos \left(\frac{K \cdot \left(m + n\right)}{2} - M\right) \cdot e^{\left(-{\left(\frac{m + n}{2} - M\right)}^{2}\right) - \left(\ell - \left|m - n\right|\right)} \]
          2. Step-by-step derivation
            1. neg-sub0N/A

              \[\leadsto \cos \left(\frac{K \cdot \left(m + n\right)}{2} - M\right) \cdot e^{\left(0 - {\left(\frac{m + n}{2} - M\right)}^{2}\right) - \left(\ell - \left|m - n\right|\right)} \]
            2. associate--l-N/A

              \[\leadsto \cos \left(\frac{K \cdot \left(m + n\right)}{2} - M\right) \cdot e^{0 - \left({\left(\frac{m + n}{2} - M\right)}^{2} + \left(\ell - \left|m - n\right|\right)\right)} \]
            3. exp-diffN/A

              \[\leadsto \cos \left(\frac{K \cdot \left(m + n\right)}{2} - M\right) \cdot \frac{e^{0}}{\color{blue}{e^{{\left(\frac{m + n}{2} - M\right)}^{2} + \left(\ell - \left|m - n\right|\right)}}} \]
            4. associate-*r/N/A

              \[\leadsto \frac{\cos \left(\frac{K \cdot \left(m + n\right)}{2} - M\right) \cdot e^{0}}{\color{blue}{e^{{\left(\frac{m + n}{2} - M\right)}^{2} + \left(\ell - \left|m - n\right|\right)}}} \]
            5. exp-0N/A

              \[\leadsto \frac{\cos \left(\frac{K \cdot \left(m + n\right)}{2} - M\right) \cdot 1}{e^{{\left(\frac{m + n}{2} - M\right)}^{2} + \color{blue}{\left(\ell - \left|m - n\right|\right)}}} \]
            6. *-rgt-identityN/A

              \[\leadsto \frac{\cos \left(\frac{K \cdot \left(m + n\right)}{2} - M\right)}{e^{\color{blue}{{\left(\frac{m + n}{2} - M\right)}^{2} + \left(\ell - \left|m - n\right|\right)}}} \]
            7. /-lowering-/.f64N/A

              \[\leadsto \mathsf{/.f64}\left(\cos \left(\frac{K \cdot \left(m + n\right)}{2} - M\right), \color{blue}{\left(e^{{\left(\frac{m + n}{2} - M\right)}^{2} + \left(\ell - \left|m - n\right|\right)}\right)}\right) \]
          3. Simplified73.3%

            \[\leadsto \color{blue}{\frac{\cos \left(\frac{K \cdot \left(m + n\right)}{2} - M\right)}{e^{\left(\left(\frac{m + n}{2} - M\right) \cdot \left(\frac{m + n}{2} - M\right) + \ell\right) - \left|m - n\right|}}} \]
          4. Add Preprocessing
          5. Taylor expanded in K around 0

            \[\leadsto \mathsf{/.f64}\left(\color{blue}{\cos \left(\mathsf{neg}\left(M\right)\right)}, \mathsf{exp.f64}\left(\mathsf{\_.f64}\left(\mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\mathsf{/.f64}\left(\mathsf{+.f64}\left(m, n\right), 2\right), M\right), \mathsf{\_.f64}\left(\mathsf{/.f64}\left(\mathsf{+.f64}\left(m, n\right), 2\right), M\right)\right), \ell\right), \mathsf{fabs.f64}\left(\mathsf{\_.f64}\left(m, n\right)\right)\right)\right)\right) \]
          6. Step-by-step derivation
            1. cos-negN/A

              \[\leadsto \mathsf{/.f64}\left(\cos M, \mathsf{exp.f64}\left(\color{blue}{\mathsf{\_.f64}\left(\mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\mathsf{/.f64}\left(\mathsf{+.f64}\left(m, n\right), 2\right), M\right), \mathsf{\_.f64}\left(\mathsf{/.f64}\left(\mathsf{+.f64}\left(m, n\right), 2\right), M\right)\right), \ell\right), \mathsf{fabs.f64}\left(\mathsf{\_.f64}\left(m, n\right)\right)\right)}\right)\right) \]
            2. cos-lowering-cos.f6493.0%

              \[\leadsto \mathsf{/.f64}\left(\mathsf{cos.f64}\left(M\right), \mathsf{exp.f64}\left(\color{blue}{\mathsf{\_.f64}\left(\mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\mathsf{/.f64}\left(\mathsf{+.f64}\left(m, n\right), 2\right), M\right), \mathsf{\_.f64}\left(\mathsf{/.f64}\left(\mathsf{+.f64}\left(m, n\right), 2\right), M\right)\right), \ell\right), \mathsf{fabs.f64}\left(\mathsf{\_.f64}\left(m, n\right)\right)\right)}\right)\right) \]
          7. Simplified93.0%

            \[\leadsto \frac{\color{blue}{\cos M}}{e^{\left(\left(\frac{m + n}{2} - M\right) \cdot \left(\frac{m + n}{2} - M\right) + \ell\right) - \left|m - n\right|}} \]
          8. Taylor expanded in M around 0

            \[\leadsto \color{blue}{\frac{1}{e^{\left(\ell + \frac{1}{4} \cdot {\left(m + n\right)}^{2}\right) - \left|m - n\right|}}} \]
          9. Step-by-step derivation
            1. /-lowering-/.f64N/A

              \[\leadsto \mathsf{/.f64}\left(1, \color{blue}{\left(e^{\left(\ell + \frac{1}{4} \cdot {\left(m + n\right)}^{2}\right) - \left|m - n\right|}\right)}\right) \]
            2. exp-lowering-exp.f64N/A

              \[\leadsto \mathsf{/.f64}\left(1, \mathsf{exp.f64}\left(\left(\left(\ell + \frac{1}{4} \cdot {\left(m + n\right)}^{2}\right) - \left|m - n\right|\right)\right)\right) \]
            3. fabs-subN/A

              \[\leadsto \mathsf{/.f64}\left(1, \mathsf{exp.f64}\left(\left(\left(\ell + \frac{1}{4} \cdot {\left(m + n\right)}^{2}\right) - \left|n - m\right|\right)\right)\right) \]
            4. associate--l+N/A

              \[\leadsto \mathsf{/.f64}\left(1, \mathsf{exp.f64}\left(\left(\ell + \left(\frac{1}{4} \cdot {\left(m + n\right)}^{2} - \left|n - m\right|\right)\right)\right)\right) \]
            5. +-lowering-+.f64N/A

              \[\leadsto \mathsf{/.f64}\left(1, \mathsf{exp.f64}\left(\mathsf{+.f64}\left(\ell, \left(\frac{1}{4} \cdot {\left(m + n\right)}^{2} - \left|n - m\right|\right)\right)\right)\right) \]
            6. --lowering--.f64N/A

              \[\leadsto \mathsf{/.f64}\left(1, \mathsf{exp.f64}\left(\mathsf{+.f64}\left(\ell, \mathsf{\_.f64}\left(\left(\frac{1}{4} \cdot {\left(m + n\right)}^{2}\right), \left(\left|n - m\right|\right)\right)\right)\right)\right) \]
            7. *-lowering-*.f64N/A

              \[\leadsto \mathsf{/.f64}\left(1, \mathsf{exp.f64}\left(\mathsf{+.f64}\left(\ell, \mathsf{\_.f64}\left(\mathsf{*.f64}\left(\frac{1}{4}, \left({\left(m + n\right)}^{2}\right)\right), \left(\left|n - m\right|\right)\right)\right)\right)\right) \]
            8. unpow2N/A

              \[\leadsto \mathsf{/.f64}\left(1, \mathsf{exp.f64}\left(\mathsf{+.f64}\left(\ell, \mathsf{\_.f64}\left(\mathsf{*.f64}\left(\frac{1}{4}, \left(\left(m + n\right) \cdot \left(m + n\right)\right)\right), \left(\left|n - m\right|\right)\right)\right)\right)\right) \]
            9. *-lowering-*.f64N/A

              \[\leadsto \mathsf{/.f64}\left(1, \mathsf{exp.f64}\left(\mathsf{+.f64}\left(\ell, \mathsf{\_.f64}\left(\mathsf{*.f64}\left(\frac{1}{4}, \mathsf{*.f64}\left(\left(m + n\right), \left(m + n\right)\right)\right), \left(\left|n - m\right|\right)\right)\right)\right)\right) \]
            10. +-lowering-+.f64N/A

              \[\leadsto \mathsf{/.f64}\left(1, \mathsf{exp.f64}\left(\mathsf{+.f64}\left(\ell, \mathsf{\_.f64}\left(\mathsf{*.f64}\left(\frac{1}{4}, \mathsf{*.f64}\left(\mathsf{+.f64}\left(m, n\right), \left(m + n\right)\right)\right), \left(\left|n - m\right|\right)\right)\right)\right)\right) \]
            11. +-lowering-+.f64N/A

              \[\leadsto \mathsf{/.f64}\left(1, \mathsf{exp.f64}\left(\mathsf{+.f64}\left(\ell, \mathsf{\_.f64}\left(\mathsf{*.f64}\left(\frac{1}{4}, \mathsf{*.f64}\left(\mathsf{+.f64}\left(m, n\right), \mathsf{+.f64}\left(m, n\right)\right)\right), \left(\left|n - m\right|\right)\right)\right)\right)\right) \]
            12. sub-negN/A

              \[\leadsto \mathsf{/.f64}\left(1, \mathsf{exp.f64}\left(\mathsf{+.f64}\left(\ell, \mathsf{\_.f64}\left(\mathsf{*.f64}\left(\frac{1}{4}, \mathsf{*.f64}\left(\mathsf{+.f64}\left(m, n\right), \mathsf{+.f64}\left(m, n\right)\right)\right), \left(\left|n + \left(\mathsf{neg}\left(m\right)\right)\right|\right)\right)\right)\right)\right) \]
            13. mul-1-negN/A

              \[\leadsto \mathsf{/.f64}\left(1, \mathsf{exp.f64}\left(\mathsf{+.f64}\left(\ell, \mathsf{\_.f64}\left(\mathsf{*.f64}\left(\frac{1}{4}, \mathsf{*.f64}\left(\mathsf{+.f64}\left(m, n\right), \mathsf{+.f64}\left(m, n\right)\right)\right), \left(\left|n + -1 \cdot m\right|\right)\right)\right)\right)\right) \]
            14. fabs-lowering-fabs.f64N/A

              \[\leadsto \mathsf{/.f64}\left(1, \mathsf{exp.f64}\left(\mathsf{+.f64}\left(\ell, \mathsf{\_.f64}\left(\mathsf{*.f64}\left(\frac{1}{4}, \mathsf{*.f64}\left(\mathsf{+.f64}\left(m, n\right), \mathsf{+.f64}\left(m, n\right)\right)\right), \mathsf{fabs.f64}\left(\left(n + -1 \cdot m\right)\right)\right)\right)\right)\right) \]
            15. mul-1-negN/A

              \[\leadsto \mathsf{/.f64}\left(1, \mathsf{exp.f64}\left(\mathsf{+.f64}\left(\ell, \mathsf{\_.f64}\left(\mathsf{*.f64}\left(\frac{1}{4}, \mathsf{*.f64}\left(\mathsf{+.f64}\left(m, n\right), \mathsf{+.f64}\left(m, n\right)\right)\right), \mathsf{fabs.f64}\left(\left(n + \left(\mathsf{neg}\left(m\right)\right)\right)\right)\right)\right)\right)\right) \]
            16. sub-negN/A

              \[\leadsto \mathsf{/.f64}\left(1, \mathsf{exp.f64}\left(\mathsf{+.f64}\left(\ell, \mathsf{\_.f64}\left(\mathsf{*.f64}\left(\frac{1}{4}, \mathsf{*.f64}\left(\mathsf{+.f64}\left(m, n\right), \mathsf{+.f64}\left(m, n\right)\right)\right), \mathsf{fabs.f64}\left(\left(n - m\right)\right)\right)\right)\right)\right) \]
            17. --lowering--.f6479.2%

              \[\leadsto \mathsf{/.f64}\left(1, \mathsf{exp.f64}\left(\mathsf{+.f64}\left(\ell, \mathsf{\_.f64}\left(\mathsf{*.f64}\left(\frac{1}{4}, \mathsf{*.f64}\left(\mathsf{+.f64}\left(m, n\right), \mathsf{+.f64}\left(m, n\right)\right)\right), \mathsf{fabs.f64}\left(\mathsf{\_.f64}\left(n, m\right)\right)\right)\right)\right)\right) \]
          10. Simplified79.2%

            \[\leadsto \color{blue}{\frac{1}{e^{\ell + \left(0.25 \cdot \left(\left(m + n\right) \cdot \left(m + n\right)\right) - \left|n - m\right|\right)}}} \]
          11. Taylor expanded in m around 0

            \[\leadsto \mathsf{/.f64}\left(1, \color{blue}{\left(e^{\left(\ell + \frac{1}{4} \cdot {n}^{2}\right) - \left|n - m\right|}\right)}\right) \]
          12. Step-by-step derivation
            1. sub-negN/A

              \[\leadsto \mathsf{/.f64}\left(1, \left(e^{\left(\ell + \frac{1}{4} \cdot {n}^{2}\right) - \left|n + \left(\mathsf{neg}\left(m\right)\right)\right|}\right)\right) \]
            2. mul-1-negN/A

              \[\leadsto \mathsf{/.f64}\left(1, \left(e^{\left(\ell + \frac{1}{4} \cdot {n}^{2}\right) - \left|n + -1 \cdot m\right|}\right)\right) \]
            3. exp-lowering-exp.f64N/A

              \[\leadsto \mathsf{/.f64}\left(1, \mathsf{exp.f64}\left(\left(\left(\ell + \frac{1}{4} \cdot {n}^{2}\right) - \left|n + -1 \cdot m\right|\right)\right)\right) \]
            4. associate--l+N/A

              \[\leadsto \mathsf{/.f64}\left(1, \mathsf{exp.f64}\left(\left(\ell + \left(\frac{1}{4} \cdot {n}^{2} - \left|n + -1 \cdot m\right|\right)\right)\right)\right) \]
            5. +-lowering-+.f64N/A

              \[\leadsto \mathsf{/.f64}\left(1, \mathsf{exp.f64}\left(\mathsf{+.f64}\left(\ell, \left(\frac{1}{4} \cdot {n}^{2} - \left|n + -1 \cdot m\right|\right)\right)\right)\right) \]
            6. mul-1-negN/A

              \[\leadsto \mathsf{/.f64}\left(1, \mathsf{exp.f64}\left(\mathsf{+.f64}\left(\ell, \left(\frac{1}{4} \cdot {n}^{2} - \left|n + \left(\mathsf{neg}\left(m\right)\right)\right|\right)\right)\right)\right) \]
            7. sub-negN/A

              \[\leadsto \mathsf{/.f64}\left(1, \mathsf{exp.f64}\left(\mathsf{+.f64}\left(\ell, \left(\frac{1}{4} \cdot {n}^{2} - \left|n - m\right|\right)\right)\right)\right) \]
            8. --lowering--.f64N/A

              \[\leadsto \mathsf{/.f64}\left(1, \mathsf{exp.f64}\left(\mathsf{+.f64}\left(\ell, \mathsf{\_.f64}\left(\left(\frac{1}{4} \cdot {n}^{2}\right), \left(\left|n - m\right|\right)\right)\right)\right)\right) \]
            9. *-lowering-*.f64N/A

              \[\leadsto \mathsf{/.f64}\left(1, \mathsf{exp.f64}\left(\mathsf{+.f64}\left(\ell, \mathsf{\_.f64}\left(\mathsf{*.f64}\left(\frac{1}{4}, \left({n}^{2}\right)\right), \left(\left|n - m\right|\right)\right)\right)\right)\right) \]
            10. unpow2N/A

              \[\leadsto \mathsf{/.f64}\left(1, \mathsf{exp.f64}\left(\mathsf{+.f64}\left(\ell, \mathsf{\_.f64}\left(\mathsf{*.f64}\left(\frac{1}{4}, \left(n \cdot n\right)\right), \left(\left|n - m\right|\right)\right)\right)\right)\right) \]
            11. *-lowering-*.f64N/A

              \[\leadsto \mathsf{/.f64}\left(1, \mathsf{exp.f64}\left(\mathsf{+.f64}\left(\ell, \mathsf{\_.f64}\left(\mathsf{*.f64}\left(\frac{1}{4}, \mathsf{*.f64}\left(n, n\right)\right), \left(\left|n - m\right|\right)\right)\right)\right)\right) \]
            12. sub-negN/A

              \[\leadsto \mathsf{/.f64}\left(1, \mathsf{exp.f64}\left(\mathsf{+.f64}\left(\ell, \mathsf{\_.f64}\left(\mathsf{*.f64}\left(\frac{1}{4}, \mathsf{*.f64}\left(n, n\right)\right), \left(\left|n + \left(\mathsf{neg}\left(m\right)\right)\right|\right)\right)\right)\right)\right) \]
            13. mul-1-negN/A

              \[\leadsto \mathsf{/.f64}\left(1, \mathsf{exp.f64}\left(\mathsf{+.f64}\left(\ell, \mathsf{\_.f64}\left(\mathsf{*.f64}\left(\frac{1}{4}, \mathsf{*.f64}\left(n, n\right)\right), \left(\left|n + -1 \cdot m\right|\right)\right)\right)\right)\right) \]
            14. fabs-lowering-fabs.f64N/A

              \[\leadsto \mathsf{/.f64}\left(1, \mathsf{exp.f64}\left(\mathsf{+.f64}\left(\ell, \mathsf{\_.f64}\left(\mathsf{*.f64}\left(\frac{1}{4}, \mathsf{*.f64}\left(n, n\right)\right), \mathsf{fabs.f64}\left(\left(n + -1 \cdot m\right)\right)\right)\right)\right)\right) \]
            15. mul-1-negN/A

              \[\leadsto \mathsf{/.f64}\left(1, \mathsf{exp.f64}\left(\mathsf{+.f64}\left(\ell, \mathsf{\_.f64}\left(\mathsf{*.f64}\left(\frac{1}{4}, \mathsf{*.f64}\left(n, n\right)\right), \mathsf{fabs.f64}\left(\left(n + \left(\mathsf{neg}\left(m\right)\right)\right)\right)\right)\right)\right)\right) \]
            16. sub-negN/A

              \[\leadsto \mathsf{/.f64}\left(1, \mathsf{exp.f64}\left(\mathsf{+.f64}\left(\ell, \mathsf{\_.f64}\left(\mathsf{*.f64}\left(\frac{1}{4}, \mathsf{*.f64}\left(n, n\right)\right), \mathsf{fabs.f64}\left(\left(n - m\right)\right)\right)\right)\right)\right) \]
            17. --lowering--.f6460.5%

              \[\leadsto \mathsf{/.f64}\left(1, \mathsf{exp.f64}\left(\mathsf{+.f64}\left(\ell, \mathsf{\_.f64}\left(\mathsf{*.f64}\left(\frac{1}{4}, \mathsf{*.f64}\left(n, n\right)\right), \mathsf{fabs.f64}\left(\mathsf{\_.f64}\left(n, m\right)\right)\right)\right)\right)\right) \]
          13. Simplified60.5%

            \[\leadsto \frac{1}{\color{blue}{e^{\ell + \left(0.25 \cdot \left(n \cdot n\right) - \left|n - m\right|\right)}}} \]
        3. Recombined 2 regimes into one program.
        4. Final simplification69.4%

          \[\leadsto \begin{array}{l} \mathbf{if}\;m \leq -54:\\ \;\;\;\;\frac{1}{e^{0.25 \cdot \left(m \cdot m\right)}}\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{e^{\ell + \left(0.25 \cdot \left(n \cdot n\right) - \left|m - n\right|\right)}}\\ \end{array} \]
        5. Add Preprocessing

        Alternative 7: 63.0% accurate, 2.0× speedup?

        \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;n \leq 5.6 \cdot 10^{-102}:\\ \;\;\;\;\frac{1}{e^{0.25 \cdot \left(m \cdot m\right) - \left|m - n\right|}}\\ \mathbf{elif}\;n \leq 94000000000000:\\ \;\;\;\;\frac{\cos M}{e^{M \cdot M}}\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{e^{0.25 \cdot \left(n \cdot n\right)}}\\ \end{array} \end{array} \]
        (FPCore (K m n M l)
         :precision binary64
         (if (<= n 5.6e-102)
           (/ 1.0 (exp (- (* 0.25 (* m m)) (fabs (- m n)))))
           (if (<= n 94000000000000.0)
             (/ (cos M) (exp (* M M)))
             (/ 1.0 (exp (* 0.25 (* n n)))))))
        double code(double K, double m, double n, double M, double l) {
        	double tmp;
        	if (n <= 5.6e-102) {
        		tmp = 1.0 / exp(((0.25 * (m * m)) - fabs((m - n))));
        	} else if (n <= 94000000000000.0) {
        		tmp = cos(M) / exp((M * M));
        	} else {
        		tmp = 1.0 / exp((0.25 * (n * n)));
        	}
        	return tmp;
        }
        
        real(8) function code(k, m, n, m_1, l)
            real(8), intent (in) :: k
            real(8), intent (in) :: m
            real(8), intent (in) :: n
            real(8), intent (in) :: m_1
            real(8), intent (in) :: l
            real(8) :: tmp
            if (n <= 5.6d-102) then
                tmp = 1.0d0 / exp(((0.25d0 * (m * m)) - abs((m - n))))
            else if (n <= 94000000000000.0d0) then
                tmp = cos(m_1) / exp((m_1 * m_1))
            else
                tmp = 1.0d0 / exp((0.25d0 * (n * n)))
            end if
            code = tmp
        end function
        
        public static double code(double K, double m, double n, double M, double l) {
        	double tmp;
        	if (n <= 5.6e-102) {
        		tmp = 1.0 / Math.exp(((0.25 * (m * m)) - Math.abs((m - n))));
        	} else if (n <= 94000000000000.0) {
        		tmp = Math.cos(M) / Math.exp((M * M));
        	} else {
        		tmp = 1.0 / Math.exp((0.25 * (n * n)));
        	}
        	return tmp;
        }
        
        def code(K, m, n, M, l):
        	tmp = 0
        	if n <= 5.6e-102:
        		tmp = 1.0 / math.exp(((0.25 * (m * m)) - math.fabs((m - n))))
        	elif n <= 94000000000000.0:
        		tmp = math.cos(M) / math.exp((M * M))
        	else:
        		tmp = 1.0 / math.exp((0.25 * (n * n)))
        	return tmp
        
        function code(K, m, n, M, l)
        	tmp = 0.0
        	if (n <= 5.6e-102)
        		tmp = Float64(1.0 / exp(Float64(Float64(0.25 * Float64(m * m)) - abs(Float64(m - n)))));
        	elseif (n <= 94000000000000.0)
        		tmp = Float64(cos(M) / exp(Float64(M * M)));
        	else
        		tmp = Float64(1.0 / exp(Float64(0.25 * Float64(n * n))));
        	end
        	return tmp
        end
        
        function tmp_2 = code(K, m, n, M, l)
        	tmp = 0.0;
        	if (n <= 5.6e-102)
        		tmp = 1.0 / exp(((0.25 * (m * m)) - abs((m - n))));
        	elseif (n <= 94000000000000.0)
        		tmp = cos(M) / exp((M * M));
        	else
        		tmp = 1.0 / exp((0.25 * (n * n)));
        	end
        	tmp_2 = tmp;
        end
        
        code[K_, m_, n_, M_, l_] := If[LessEqual[n, 5.6e-102], N[(1.0 / N[Exp[N[(N[(0.25 * N[(m * m), $MachinePrecision]), $MachinePrecision] - N[Abs[N[(m - n), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[n, 94000000000000.0], N[(N[Cos[M], $MachinePrecision] / N[Exp[N[(M * M), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(1.0 / N[Exp[N[(0.25 * N[(n * n), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]
        
        \begin{array}{l}
        
        \\
        \begin{array}{l}
        \mathbf{if}\;n \leq 5.6 \cdot 10^{-102}:\\
        \;\;\;\;\frac{1}{e^{0.25 \cdot \left(m \cdot m\right) - \left|m - n\right|}}\\
        
        \mathbf{elif}\;n \leq 94000000000000:\\
        \;\;\;\;\frac{\cos M}{e^{M \cdot M}}\\
        
        \mathbf{else}:\\
        \;\;\;\;\frac{1}{e^{0.25 \cdot \left(n \cdot n\right)}}\\
        
        
        \end{array}
        \end{array}
        
        Derivation
        1. Split input into 3 regimes
        2. if n < 5.60000000000000026e-102

          1. Initial program 74.2%

            \[\cos \left(\frac{K \cdot \left(m + n\right)}{2} - M\right) \cdot e^{\left(-{\left(\frac{m + n}{2} - M\right)}^{2}\right) - \left(\ell - \left|m - n\right|\right)} \]
          2. Step-by-step derivation
            1. neg-sub0N/A

              \[\leadsto \cos \left(\frac{K \cdot \left(m + n\right)}{2} - M\right) \cdot e^{\left(0 - {\left(\frac{m + n}{2} - M\right)}^{2}\right) - \left(\ell - \left|m - n\right|\right)} \]
            2. associate--l-N/A

              \[\leadsto \cos \left(\frac{K \cdot \left(m + n\right)}{2} - M\right) \cdot e^{0 - \left({\left(\frac{m + n}{2} - M\right)}^{2} + \left(\ell - \left|m - n\right|\right)\right)} \]
            3. exp-diffN/A

              \[\leadsto \cos \left(\frac{K \cdot \left(m + n\right)}{2} - M\right) \cdot \frac{e^{0}}{\color{blue}{e^{{\left(\frac{m + n}{2} - M\right)}^{2} + \left(\ell - \left|m - n\right|\right)}}} \]
            4. associate-*r/N/A

              \[\leadsto \frac{\cos \left(\frac{K \cdot \left(m + n\right)}{2} - M\right) \cdot e^{0}}{\color{blue}{e^{{\left(\frac{m + n}{2} - M\right)}^{2} + \left(\ell - \left|m - n\right|\right)}}} \]
            5. exp-0N/A

              \[\leadsto \frac{\cos \left(\frac{K \cdot \left(m + n\right)}{2} - M\right) \cdot 1}{e^{{\left(\frac{m + n}{2} - M\right)}^{2} + \color{blue}{\left(\ell - \left|m - n\right|\right)}}} \]
            6. *-rgt-identityN/A

              \[\leadsto \frac{\cos \left(\frac{K \cdot \left(m + n\right)}{2} - M\right)}{e^{\color{blue}{{\left(\frac{m + n}{2} - M\right)}^{2} + \left(\ell - \left|m - n\right|\right)}}} \]
            7. /-lowering-/.f64N/A

              \[\leadsto \mathsf{/.f64}\left(\cos \left(\frac{K \cdot \left(m + n\right)}{2} - M\right), \color{blue}{\left(e^{{\left(\frac{m + n}{2} - M\right)}^{2} + \left(\ell - \left|m - n\right|\right)}\right)}\right) \]
          3. Simplified74.2%

            \[\leadsto \color{blue}{\frac{\cos \left(\frac{K \cdot \left(m + n\right)}{2} - M\right)}{e^{\left(\left(\frac{m + n}{2} - M\right) \cdot \left(\frac{m + n}{2} - M\right) + \ell\right) - \left|m - n\right|}}} \]
          4. Add Preprocessing
          5. Taylor expanded in K around 0

            \[\leadsto \mathsf{/.f64}\left(\color{blue}{\cos \left(\mathsf{neg}\left(M\right)\right)}, \mathsf{exp.f64}\left(\mathsf{\_.f64}\left(\mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\mathsf{/.f64}\left(\mathsf{+.f64}\left(m, n\right), 2\right), M\right), \mathsf{\_.f64}\left(\mathsf{/.f64}\left(\mathsf{+.f64}\left(m, n\right), 2\right), M\right)\right), \ell\right), \mathsf{fabs.f64}\left(\mathsf{\_.f64}\left(m, n\right)\right)\right)\right)\right) \]
          6. Step-by-step derivation
            1. cos-negN/A

              \[\leadsto \mathsf{/.f64}\left(\cos M, \mathsf{exp.f64}\left(\color{blue}{\mathsf{\_.f64}\left(\mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\mathsf{/.f64}\left(\mathsf{+.f64}\left(m, n\right), 2\right), M\right), \mathsf{\_.f64}\left(\mathsf{/.f64}\left(\mathsf{+.f64}\left(m, n\right), 2\right), M\right)\right), \ell\right), \mathsf{fabs.f64}\left(\mathsf{\_.f64}\left(m, n\right)\right)\right)}\right)\right) \]
            2. cos-lowering-cos.f6493.6%

              \[\leadsto \mathsf{/.f64}\left(\mathsf{cos.f64}\left(M\right), \mathsf{exp.f64}\left(\color{blue}{\mathsf{\_.f64}\left(\mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\mathsf{/.f64}\left(\mathsf{+.f64}\left(m, n\right), 2\right), M\right), \mathsf{\_.f64}\left(\mathsf{/.f64}\left(\mathsf{+.f64}\left(m, n\right), 2\right), M\right)\right), \ell\right), \mathsf{fabs.f64}\left(\mathsf{\_.f64}\left(m, n\right)\right)\right)}\right)\right) \]
          7. Simplified93.6%

            \[\leadsto \frac{\color{blue}{\cos M}}{e^{\left(\left(\frac{m + n}{2} - M\right) \cdot \left(\frac{m + n}{2} - M\right) + \ell\right) - \left|m - n\right|}} \]
          8. Taylor expanded in M around 0

            \[\leadsto \color{blue}{\frac{1}{e^{\left(\ell + \frac{1}{4} \cdot {\left(m + n\right)}^{2}\right) - \left|m - n\right|}}} \]
          9. Step-by-step derivation
            1. /-lowering-/.f64N/A

              \[\leadsto \mathsf{/.f64}\left(1, \color{blue}{\left(e^{\left(\ell + \frac{1}{4} \cdot {\left(m + n\right)}^{2}\right) - \left|m - n\right|}\right)}\right) \]
            2. exp-lowering-exp.f64N/A

              \[\leadsto \mathsf{/.f64}\left(1, \mathsf{exp.f64}\left(\left(\left(\ell + \frac{1}{4} \cdot {\left(m + n\right)}^{2}\right) - \left|m - n\right|\right)\right)\right) \]
            3. fabs-subN/A

              \[\leadsto \mathsf{/.f64}\left(1, \mathsf{exp.f64}\left(\left(\left(\ell + \frac{1}{4} \cdot {\left(m + n\right)}^{2}\right) - \left|n - m\right|\right)\right)\right) \]
            4. associate--l+N/A

              \[\leadsto \mathsf{/.f64}\left(1, \mathsf{exp.f64}\left(\left(\ell + \left(\frac{1}{4} \cdot {\left(m + n\right)}^{2} - \left|n - m\right|\right)\right)\right)\right) \]
            5. +-lowering-+.f64N/A

              \[\leadsto \mathsf{/.f64}\left(1, \mathsf{exp.f64}\left(\mathsf{+.f64}\left(\ell, \left(\frac{1}{4} \cdot {\left(m + n\right)}^{2} - \left|n - m\right|\right)\right)\right)\right) \]
            6. --lowering--.f64N/A

              \[\leadsto \mathsf{/.f64}\left(1, \mathsf{exp.f64}\left(\mathsf{+.f64}\left(\ell, \mathsf{\_.f64}\left(\left(\frac{1}{4} \cdot {\left(m + n\right)}^{2}\right), \left(\left|n - m\right|\right)\right)\right)\right)\right) \]
            7. *-lowering-*.f64N/A

              \[\leadsto \mathsf{/.f64}\left(1, \mathsf{exp.f64}\left(\mathsf{+.f64}\left(\ell, \mathsf{\_.f64}\left(\mathsf{*.f64}\left(\frac{1}{4}, \left({\left(m + n\right)}^{2}\right)\right), \left(\left|n - m\right|\right)\right)\right)\right)\right) \]
            8. unpow2N/A

              \[\leadsto \mathsf{/.f64}\left(1, \mathsf{exp.f64}\left(\mathsf{+.f64}\left(\ell, \mathsf{\_.f64}\left(\mathsf{*.f64}\left(\frac{1}{4}, \left(\left(m + n\right) \cdot \left(m + n\right)\right)\right), \left(\left|n - m\right|\right)\right)\right)\right)\right) \]
            9. *-lowering-*.f64N/A

              \[\leadsto \mathsf{/.f64}\left(1, \mathsf{exp.f64}\left(\mathsf{+.f64}\left(\ell, \mathsf{\_.f64}\left(\mathsf{*.f64}\left(\frac{1}{4}, \mathsf{*.f64}\left(\left(m + n\right), \left(m + n\right)\right)\right), \left(\left|n - m\right|\right)\right)\right)\right)\right) \]
            10. +-lowering-+.f64N/A

              \[\leadsto \mathsf{/.f64}\left(1, \mathsf{exp.f64}\left(\mathsf{+.f64}\left(\ell, \mathsf{\_.f64}\left(\mathsf{*.f64}\left(\frac{1}{4}, \mathsf{*.f64}\left(\mathsf{+.f64}\left(m, n\right), \left(m + n\right)\right)\right), \left(\left|n - m\right|\right)\right)\right)\right)\right) \]
            11. +-lowering-+.f64N/A

              \[\leadsto \mathsf{/.f64}\left(1, \mathsf{exp.f64}\left(\mathsf{+.f64}\left(\ell, \mathsf{\_.f64}\left(\mathsf{*.f64}\left(\frac{1}{4}, \mathsf{*.f64}\left(\mathsf{+.f64}\left(m, n\right), \mathsf{+.f64}\left(m, n\right)\right)\right), \left(\left|n - m\right|\right)\right)\right)\right)\right) \]
            12. sub-negN/A

              \[\leadsto \mathsf{/.f64}\left(1, \mathsf{exp.f64}\left(\mathsf{+.f64}\left(\ell, \mathsf{\_.f64}\left(\mathsf{*.f64}\left(\frac{1}{4}, \mathsf{*.f64}\left(\mathsf{+.f64}\left(m, n\right), \mathsf{+.f64}\left(m, n\right)\right)\right), \left(\left|n + \left(\mathsf{neg}\left(m\right)\right)\right|\right)\right)\right)\right)\right) \]
            13. mul-1-negN/A

              \[\leadsto \mathsf{/.f64}\left(1, \mathsf{exp.f64}\left(\mathsf{+.f64}\left(\ell, \mathsf{\_.f64}\left(\mathsf{*.f64}\left(\frac{1}{4}, \mathsf{*.f64}\left(\mathsf{+.f64}\left(m, n\right), \mathsf{+.f64}\left(m, n\right)\right)\right), \left(\left|n + -1 \cdot m\right|\right)\right)\right)\right)\right) \]
            14. fabs-lowering-fabs.f64N/A

              \[\leadsto \mathsf{/.f64}\left(1, \mathsf{exp.f64}\left(\mathsf{+.f64}\left(\ell, \mathsf{\_.f64}\left(\mathsf{*.f64}\left(\frac{1}{4}, \mathsf{*.f64}\left(\mathsf{+.f64}\left(m, n\right), \mathsf{+.f64}\left(m, n\right)\right)\right), \mathsf{fabs.f64}\left(\left(n + -1 \cdot m\right)\right)\right)\right)\right)\right) \]
            15. mul-1-negN/A

              \[\leadsto \mathsf{/.f64}\left(1, \mathsf{exp.f64}\left(\mathsf{+.f64}\left(\ell, \mathsf{\_.f64}\left(\mathsf{*.f64}\left(\frac{1}{4}, \mathsf{*.f64}\left(\mathsf{+.f64}\left(m, n\right), \mathsf{+.f64}\left(m, n\right)\right)\right), \mathsf{fabs.f64}\left(\left(n + \left(\mathsf{neg}\left(m\right)\right)\right)\right)\right)\right)\right)\right) \]
            16. sub-negN/A

              \[\leadsto \mathsf{/.f64}\left(1, \mathsf{exp.f64}\left(\mathsf{+.f64}\left(\ell, \mathsf{\_.f64}\left(\mathsf{*.f64}\left(\frac{1}{4}, \mathsf{*.f64}\left(\mathsf{+.f64}\left(m, n\right), \mathsf{+.f64}\left(m, n\right)\right)\right), \mathsf{fabs.f64}\left(\left(n - m\right)\right)\right)\right)\right)\right) \]
            17. --lowering--.f6481.0%

              \[\leadsto \mathsf{/.f64}\left(1, \mathsf{exp.f64}\left(\mathsf{+.f64}\left(\ell, \mathsf{\_.f64}\left(\mathsf{*.f64}\left(\frac{1}{4}, \mathsf{*.f64}\left(\mathsf{+.f64}\left(m, n\right), \mathsf{+.f64}\left(m, n\right)\right)\right), \mathsf{fabs.f64}\left(\mathsf{\_.f64}\left(n, m\right)\right)\right)\right)\right)\right) \]
          10. Simplified81.0%

            \[\leadsto \color{blue}{\frac{1}{e^{\ell + \left(0.25 \cdot \left(\left(m + n\right) \cdot \left(m + n\right)\right) - \left|n - m\right|\right)}}} \]
          11. Taylor expanded in n around 0

            \[\leadsto \mathsf{/.f64}\left(1, \color{blue}{\left(e^{\left(\ell + \frac{1}{4} \cdot {m}^{2}\right) - \left|n - m\right|}\right)}\right) \]
          12. Step-by-step derivation
            1. fabs-subN/A

              \[\leadsto \mathsf{/.f64}\left(1, \left(e^{\left(\ell + \frac{1}{4} \cdot {m}^{2}\right) - \left|m - n\right|}\right)\right) \]
            2. sub-negN/A

              \[\leadsto \mathsf{/.f64}\left(1, \left(e^{\left(\ell + \frac{1}{4} \cdot {m}^{2}\right) - \left|m + \left(\mathsf{neg}\left(n\right)\right)\right|}\right)\right) \]
            3. mul-1-negN/A

              \[\leadsto \mathsf{/.f64}\left(1, \left(e^{\left(\ell + \frac{1}{4} \cdot {m}^{2}\right) - \left|m + -1 \cdot n\right|}\right)\right) \]
            4. fabs-negN/A

              \[\leadsto \mathsf{/.f64}\left(1, \left(e^{\left(\ell + \frac{1}{4} \cdot {m}^{2}\right) - \left|\mathsf{neg}\left(\left(m + -1 \cdot n\right)\right)\right|}\right)\right) \]
            5. exp-lowering-exp.f64N/A

              \[\leadsto \mathsf{/.f64}\left(1, \mathsf{exp.f64}\left(\left(\left(\ell + \frac{1}{4} \cdot {m}^{2}\right) - \left|\mathsf{neg}\left(\left(m + -1 \cdot n\right)\right)\right|\right)\right)\right) \]
            6. fabs-negN/A

              \[\leadsto \mathsf{/.f64}\left(1, \mathsf{exp.f64}\left(\left(\left(\ell + \frac{1}{4} \cdot {m}^{2}\right) - \left|m + -1 \cdot n\right|\right)\right)\right) \]
            7. mul-1-negN/A

              \[\leadsto \mathsf{/.f64}\left(1, \mathsf{exp.f64}\left(\left(\left(\ell + \frac{1}{4} \cdot {m}^{2}\right) - \left|m + \left(\mathsf{neg}\left(n\right)\right)\right|\right)\right)\right) \]
            8. sub-negN/A

              \[\leadsto \mathsf{/.f64}\left(1, \mathsf{exp.f64}\left(\left(\left(\ell + \frac{1}{4} \cdot {m}^{2}\right) - \left|m - n\right|\right)\right)\right) \]
            9. fabs-subN/A

              \[\leadsto \mathsf{/.f64}\left(1, \mathsf{exp.f64}\left(\left(\left(\ell + \frac{1}{4} \cdot {m}^{2}\right) - \left|n - m\right|\right)\right)\right) \]
            10. --lowering--.f64N/A

              \[\leadsto \mathsf{/.f64}\left(1, \mathsf{exp.f64}\left(\mathsf{\_.f64}\left(\left(\ell + \frac{1}{4} \cdot {m}^{2}\right), \left(\left|n - m\right|\right)\right)\right)\right) \]
            11. +-lowering-+.f64N/A

              \[\leadsto \mathsf{/.f64}\left(1, \mathsf{exp.f64}\left(\mathsf{\_.f64}\left(\mathsf{+.f64}\left(\ell, \left(\frac{1}{4} \cdot {m}^{2}\right)\right), \left(\left|n - m\right|\right)\right)\right)\right) \]
            12. *-lowering-*.f64N/A

              \[\leadsto \mathsf{/.f64}\left(1, \mathsf{exp.f64}\left(\mathsf{\_.f64}\left(\mathsf{+.f64}\left(\ell, \mathsf{*.f64}\left(\frac{1}{4}, \left({m}^{2}\right)\right)\right), \left(\left|n - m\right|\right)\right)\right)\right) \]
            13. unpow2N/A

              \[\leadsto \mathsf{/.f64}\left(1, \mathsf{exp.f64}\left(\mathsf{\_.f64}\left(\mathsf{+.f64}\left(\ell, \mathsf{*.f64}\left(\frac{1}{4}, \left(m \cdot m\right)\right)\right), \left(\left|n - m\right|\right)\right)\right)\right) \]
            14. *-lowering-*.f64N/A

              \[\leadsto \mathsf{/.f64}\left(1, \mathsf{exp.f64}\left(\mathsf{\_.f64}\left(\mathsf{+.f64}\left(\ell, \mathsf{*.f64}\left(\frac{1}{4}, \mathsf{*.f64}\left(m, m\right)\right)\right), \left(\left|n - m\right|\right)\right)\right)\right) \]
            15. sub-negN/A

              \[\leadsto \mathsf{/.f64}\left(1, \mathsf{exp.f64}\left(\mathsf{\_.f64}\left(\mathsf{+.f64}\left(\ell, \mathsf{*.f64}\left(\frac{1}{4}, \mathsf{*.f64}\left(m, m\right)\right)\right), \left(\left|n + \left(\mathsf{neg}\left(m\right)\right)\right|\right)\right)\right)\right) \]
            16. mul-1-negN/A

              \[\leadsto \mathsf{/.f64}\left(1, \mathsf{exp.f64}\left(\mathsf{\_.f64}\left(\mathsf{+.f64}\left(\ell, \mathsf{*.f64}\left(\frac{1}{4}, \mathsf{*.f64}\left(m, m\right)\right)\right), \left(\left|n + -1 \cdot m\right|\right)\right)\right)\right) \]
            17. fabs-lowering-fabs.f64N/A

              \[\leadsto \mathsf{/.f64}\left(1, \mathsf{exp.f64}\left(\mathsf{\_.f64}\left(\mathsf{+.f64}\left(\ell, \mathsf{*.f64}\left(\frac{1}{4}, \mathsf{*.f64}\left(m, m\right)\right)\right), \mathsf{fabs.f64}\left(\left(n + -1 \cdot m\right)\right)\right)\right)\right) \]
            18. mul-1-negN/A

              \[\leadsto \mathsf{/.f64}\left(1, \mathsf{exp.f64}\left(\mathsf{\_.f64}\left(\mathsf{+.f64}\left(\ell, \mathsf{*.f64}\left(\frac{1}{4}, \mathsf{*.f64}\left(m, m\right)\right)\right), \mathsf{fabs.f64}\left(\left(n + \left(\mathsf{neg}\left(m\right)\right)\right)\right)\right)\right)\right) \]
            19. sub-negN/A

              \[\leadsto \mathsf{/.f64}\left(1, \mathsf{exp.f64}\left(\mathsf{\_.f64}\left(\mathsf{+.f64}\left(\ell, \mathsf{*.f64}\left(\frac{1}{4}, \mathsf{*.f64}\left(m, m\right)\right)\right), \mathsf{fabs.f64}\left(\left(n - m\right)\right)\right)\right)\right) \]
            20. --lowering--.f6459.6%

              \[\leadsto \mathsf{/.f64}\left(1, \mathsf{exp.f64}\left(\mathsf{\_.f64}\left(\mathsf{+.f64}\left(\ell, \mathsf{*.f64}\left(\frac{1}{4}, \mathsf{*.f64}\left(m, m\right)\right)\right), \mathsf{fabs.f64}\left(\mathsf{\_.f64}\left(n, m\right)\right)\right)\right)\right) \]
          13. Simplified59.6%

            \[\leadsto \frac{1}{\color{blue}{e^{\left(\ell + 0.25 \cdot \left(m \cdot m\right)\right) - \left|n - m\right|}}} \]
          14. Taylor expanded in l around 0

            \[\leadsto \mathsf{/.f64}\left(1, \mathsf{exp.f64}\left(\mathsf{\_.f64}\left(\color{blue}{\left(\frac{1}{4} \cdot {m}^{2}\right)}, \mathsf{fabs.f64}\left(\mathsf{\_.f64}\left(n, m\right)\right)\right)\right)\right) \]
          15. Step-by-step derivation
            1. *-lowering-*.f64N/A

              \[\leadsto \mathsf{/.f64}\left(1, \mathsf{exp.f64}\left(\mathsf{\_.f64}\left(\mathsf{*.f64}\left(\frac{1}{4}, \left({m}^{2}\right)\right), \mathsf{fabs.f64}\left(\mathsf{\_.f64}\left(n, m\right)\right)\right)\right)\right) \]
            2. unpow2N/A

              \[\leadsto \mathsf{/.f64}\left(1, \mathsf{exp.f64}\left(\mathsf{\_.f64}\left(\mathsf{*.f64}\left(\frac{1}{4}, \left(m \cdot m\right)\right), \mathsf{fabs.f64}\left(\mathsf{\_.f64}\left(n, m\right)\right)\right)\right)\right) \]
            3. *-lowering-*.f6448.8%

              \[\leadsto \mathsf{/.f64}\left(1, \mathsf{exp.f64}\left(\mathsf{\_.f64}\left(\mathsf{*.f64}\left(\frac{1}{4}, \mathsf{*.f64}\left(m, m\right)\right), \mathsf{fabs.f64}\left(\mathsf{\_.f64}\left(n, m\right)\right)\right)\right)\right) \]
          16. Simplified48.8%

            \[\leadsto \frac{1}{e^{\color{blue}{0.25 \cdot \left(m \cdot m\right)} - \left|n - m\right|}} \]

          if 5.60000000000000026e-102 < n < 9.4e13

          1. Initial program 66.9%

            \[\cos \left(\frac{K \cdot \left(m + n\right)}{2} - M\right) \cdot e^{\left(-{\left(\frac{m + n}{2} - M\right)}^{2}\right) - \left(\ell - \left|m - n\right|\right)} \]
          2. Step-by-step derivation
            1. neg-sub0N/A

              \[\leadsto \cos \left(\frac{K \cdot \left(m + n\right)}{2} - M\right) \cdot e^{\left(0 - {\left(\frac{m + n}{2} - M\right)}^{2}\right) - \left(\ell - \left|m - n\right|\right)} \]
            2. associate--l-N/A

              \[\leadsto \cos \left(\frac{K \cdot \left(m + n\right)}{2} - M\right) \cdot e^{0 - \left({\left(\frac{m + n}{2} - M\right)}^{2} + \left(\ell - \left|m - n\right|\right)\right)} \]
            3. exp-diffN/A

              \[\leadsto \cos \left(\frac{K \cdot \left(m + n\right)}{2} - M\right) \cdot \frac{e^{0}}{\color{blue}{e^{{\left(\frac{m + n}{2} - M\right)}^{2} + \left(\ell - \left|m - n\right|\right)}}} \]
            4. associate-*r/N/A

              \[\leadsto \frac{\cos \left(\frac{K \cdot \left(m + n\right)}{2} - M\right) \cdot e^{0}}{\color{blue}{e^{{\left(\frac{m + n}{2} - M\right)}^{2} + \left(\ell - \left|m - n\right|\right)}}} \]
            5. exp-0N/A

              \[\leadsto \frac{\cos \left(\frac{K \cdot \left(m + n\right)}{2} - M\right) \cdot 1}{e^{{\left(\frac{m + n}{2} - M\right)}^{2} + \color{blue}{\left(\ell - \left|m - n\right|\right)}}} \]
            6. *-rgt-identityN/A

              \[\leadsto \frac{\cos \left(\frac{K \cdot \left(m + n\right)}{2} - M\right)}{e^{\color{blue}{{\left(\frac{m + n}{2} - M\right)}^{2} + \left(\ell - \left|m - n\right|\right)}}} \]
            7. /-lowering-/.f64N/A

              \[\leadsto \mathsf{/.f64}\left(\cos \left(\frac{K \cdot \left(m + n\right)}{2} - M\right), \color{blue}{\left(e^{{\left(\frac{m + n}{2} - M\right)}^{2} + \left(\ell - \left|m - n\right|\right)}\right)}\right) \]
          3. Simplified66.9%

            \[\leadsto \color{blue}{\frac{\cos \left(\frac{K \cdot \left(m + n\right)}{2} - M\right)}{e^{\left(\left(\frac{m + n}{2} - M\right) \cdot \left(\frac{m + n}{2} - M\right) + \ell\right) - \left|m - n\right|}}} \]
          4. Add Preprocessing
          5. Taylor expanded in K around 0

            \[\leadsto \mathsf{/.f64}\left(\color{blue}{\cos \left(\mathsf{neg}\left(M\right)\right)}, \mathsf{exp.f64}\left(\mathsf{\_.f64}\left(\mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\mathsf{/.f64}\left(\mathsf{+.f64}\left(m, n\right), 2\right), M\right), \mathsf{\_.f64}\left(\mathsf{/.f64}\left(\mathsf{+.f64}\left(m, n\right), 2\right), M\right)\right), \ell\right), \mathsf{fabs.f64}\left(\mathsf{\_.f64}\left(m, n\right)\right)\right)\right)\right) \]
          6. Step-by-step derivation
            1. cos-negN/A

              \[\leadsto \mathsf{/.f64}\left(\cos M, \mathsf{exp.f64}\left(\color{blue}{\mathsf{\_.f64}\left(\mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\mathsf{/.f64}\left(\mathsf{+.f64}\left(m, n\right), 2\right), M\right), \mathsf{\_.f64}\left(\mathsf{/.f64}\left(\mathsf{+.f64}\left(m, n\right), 2\right), M\right)\right), \ell\right), \mathsf{fabs.f64}\left(\mathsf{\_.f64}\left(m, n\right)\right)\right)}\right)\right) \]
            2. cos-lowering-cos.f6491.1%

              \[\leadsto \mathsf{/.f64}\left(\mathsf{cos.f64}\left(M\right), \mathsf{exp.f64}\left(\color{blue}{\mathsf{\_.f64}\left(\mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\mathsf{/.f64}\left(\mathsf{+.f64}\left(m, n\right), 2\right), M\right), \mathsf{\_.f64}\left(\mathsf{/.f64}\left(\mathsf{+.f64}\left(m, n\right), 2\right), M\right)\right), \ell\right), \mathsf{fabs.f64}\left(\mathsf{\_.f64}\left(m, n\right)\right)\right)}\right)\right) \]
          7. Simplified91.1%

            \[\leadsto \frac{\color{blue}{\cos M}}{e^{\left(\left(\frac{m + n}{2} - M\right) \cdot \left(\frac{m + n}{2} - M\right) + \ell\right) - \left|m - n\right|}} \]
          8. Taylor expanded in M around inf

            \[\leadsto \mathsf{/.f64}\left(\mathsf{cos.f64}\left(M\right), \mathsf{exp.f64}\left(\color{blue}{\left({M}^{2}\right)}\right)\right) \]
          9. Step-by-step derivation
            1. unpow2N/A

              \[\leadsto \mathsf{/.f64}\left(\mathsf{cos.f64}\left(M\right), \mathsf{exp.f64}\left(\left(M \cdot M\right)\right)\right) \]
            2. *-lowering-*.f6460.0%

              \[\leadsto \mathsf{/.f64}\left(\mathsf{cos.f64}\left(M\right), \mathsf{exp.f64}\left(\mathsf{*.f64}\left(M, M\right)\right)\right) \]
          10. Simplified60.0%

            \[\leadsto \frac{\cos M}{e^{\color{blue}{M \cdot M}}} \]

          if 9.4e13 < n

          1. Initial program 63.6%

            \[\cos \left(\frac{K \cdot \left(m + n\right)}{2} - M\right) \cdot e^{\left(-{\left(\frac{m + n}{2} - M\right)}^{2}\right) - \left(\ell - \left|m - n\right|\right)} \]
          2. Step-by-step derivation
            1. neg-sub0N/A

              \[\leadsto \cos \left(\frac{K \cdot \left(m + n\right)}{2} - M\right) \cdot e^{\left(0 - {\left(\frac{m + n}{2} - M\right)}^{2}\right) - \left(\ell - \left|m - n\right|\right)} \]
            2. associate--l-N/A

              \[\leadsto \cos \left(\frac{K \cdot \left(m + n\right)}{2} - M\right) \cdot e^{0 - \left({\left(\frac{m + n}{2} - M\right)}^{2} + \left(\ell - \left|m - n\right|\right)\right)} \]
            3. exp-diffN/A

              \[\leadsto \cos \left(\frac{K \cdot \left(m + n\right)}{2} - M\right) \cdot \frac{e^{0}}{\color{blue}{e^{{\left(\frac{m + n}{2} - M\right)}^{2} + \left(\ell - \left|m - n\right|\right)}}} \]
            4. associate-*r/N/A

              \[\leadsto \frac{\cos \left(\frac{K \cdot \left(m + n\right)}{2} - M\right) \cdot e^{0}}{\color{blue}{e^{{\left(\frac{m + n}{2} - M\right)}^{2} + \left(\ell - \left|m - n\right|\right)}}} \]
            5. exp-0N/A

              \[\leadsto \frac{\cos \left(\frac{K \cdot \left(m + n\right)}{2} - M\right) \cdot 1}{e^{{\left(\frac{m + n}{2} - M\right)}^{2} + \color{blue}{\left(\ell - \left|m - n\right|\right)}}} \]
            6. *-rgt-identityN/A

              \[\leadsto \frac{\cos \left(\frac{K \cdot \left(m + n\right)}{2} - M\right)}{e^{\color{blue}{{\left(\frac{m + n}{2} - M\right)}^{2} + \left(\ell - \left|m - n\right|\right)}}} \]
            7. /-lowering-/.f64N/A

              \[\leadsto \mathsf{/.f64}\left(\cos \left(\frac{K \cdot \left(m + n\right)}{2} - M\right), \color{blue}{\left(e^{{\left(\frac{m + n}{2} - M\right)}^{2} + \left(\ell - \left|m - n\right|\right)}\right)}\right) \]
          3. Simplified63.6%

            \[\leadsto \color{blue}{\frac{\cos \left(\frac{K \cdot \left(m + n\right)}{2} - M\right)}{e^{\left(\left(\frac{m + n}{2} - M\right) \cdot \left(\frac{m + n}{2} - M\right) + \ell\right) - \left|m - n\right|}}} \]
          4. Add Preprocessing
          5. Taylor expanded in K around 0

            \[\leadsto \mathsf{/.f64}\left(\color{blue}{\cos \left(\mathsf{neg}\left(M\right)\right)}, \mathsf{exp.f64}\left(\mathsf{\_.f64}\left(\mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\mathsf{/.f64}\left(\mathsf{+.f64}\left(m, n\right), 2\right), M\right), \mathsf{\_.f64}\left(\mathsf{/.f64}\left(\mathsf{+.f64}\left(m, n\right), 2\right), M\right)\right), \ell\right), \mathsf{fabs.f64}\left(\mathsf{\_.f64}\left(m, n\right)\right)\right)\right)\right) \]
          6. Step-by-step derivation
            1. cos-negN/A

              \[\leadsto \mathsf{/.f64}\left(\cos M, \mathsf{exp.f64}\left(\color{blue}{\mathsf{\_.f64}\left(\mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\mathsf{/.f64}\left(\mathsf{+.f64}\left(m, n\right), 2\right), M\right), \mathsf{\_.f64}\left(\mathsf{/.f64}\left(\mathsf{+.f64}\left(m, n\right), 2\right), M\right)\right), \ell\right), \mathsf{fabs.f64}\left(\mathsf{\_.f64}\left(m, n\right)\right)\right)}\right)\right) \]
            2. cos-lowering-cos.f64100.0%

              \[\leadsto \mathsf{/.f64}\left(\mathsf{cos.f64}\left(M\right), \mathsf{exp.f64}\left(\color{blue}{\mathsf{\_.f64}\left(\mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\mathsf{/.f64}\left(\mathsf{+.f64}\left(m, n\right), 2\right), M\right), \mathsf{\_.f64}\left(\mathsf{/.f64}\left(\mathsf{+.f64}\left(m, n\right), 2\right), M\right)\right), \ell\right), \mathsf{fabs.f64}\left(\mathsf{\_.f64}\left(m, n\right)\right)\right)}\right)\right) \]
          7. Simplified100.0%

            \[\leadsto \frac{\color{blue}{\cos M}}{e^{\left(\left(\frac{m + n}{2} - M\right) \cdot \left(\frac{m + n}{2} - M\right) + \ell\right) - \left|m - n\right|}} \]
          8. Taylor expanded in M around 0

            \[\leadsto \color{blue}{\frac{1}{e^{\left(\ell + \frac{1}{4} \cdot {\left(m + n\right)}^{2}\right) - \left|m - n\right|}}} \]
          9. Step-by-step derivation
            1. /-lowering-/.f64N/A

              \[\leadsto \mathsf{/.f64}\left(1, \color{blue}{\left(e^{\left(\ell + \frac{1}{4} \cdot {\left(m + n\right)}^{2}\right) - \left|m - n\right|}\right)}\right) \]
            2. exp-lowering-exp.f64N/A

              \[\leadsto \mathsf{/.f64}\left(1, \mathsf{exp.f64}\left(\left(\left(\ell + \frac{1}{4} \cdot {\left(m + n\right)}^{2}\right) - \left|m - n\right|\right)\right)\right) \]
            3. fabs-subN/A

              \[\leadsto \mathsf{/.f64}\left(1, \mathsf{exp.f64}\left(\left(\left(\ell + \frac{1}{4} \cdot {\left(m + n\right)}^{2}\right) - \left|n - m\right|\right)\right)\right) \]
            4. associate--l+N/A

              \[\leadsto \mathsf{/.f64}\left(1, \mathsf{exp.f64}\left(\left(\ell + \left(\frac{1}{4} \cdot {\left(m + n\right)}^{2} - \left|n - m\right|\right)\right)\right)\right) \]
            5. +-lowering-+.f64N/A

              \[\leadsto \mathsf{/.f64}\left(1, \mathsf{exp.f64}\left(\mathsf{+.f64}\left(\ell, \left(\frac{1}{4} \cdot {\left(m + n\right)}^{2} - \left|n - m\right|\right)\right)\right)\right) \]
            6. --lowering--.f64N/A

              \[\leadsto \mathsf{/.f64}\left(1, \mathsf{exp.f64}\left(\mathsf{+.f64}\left(\ell, \mathsf{\_.f64}\left(\left(\frac{1}{4} \cdot {\left(m + n\right)}^{2}\right), \left(\left|n - m\right|\right)\right)\right)\right)\right) \]
            7. *-lowering-*.f64N/A

              \[\leadsto \mathsf{/.f64}\left(1, \mathsf{exp.f64}\left(\mathsf{+.f64}\left(\ell, \mathsf{\_.f64}\left(\mathsf{*.f64}\left(\frac{1}{4}, \left({\left(m + n\right)}^{2}\right)\right), \left(\left|n - m\right|\right)\right)\right)\right)\right) \]
            8. unpow2N/A

              \[\leadsto \mathsf{/.f64}\left(1, \mathsf{exp.f64}\left(\mathsf{+.f64}\left(\ell, \mathsf{\_.f64}\left(\mathsf{*.f64}\left(\frac{1}{4}, \left(\left(m + n\right) \cdot \left(m + n\right)\right)\right), \left(\left|n - m\right|\right)\right)\right)\right)\right) \]
            9. *-lowering-*.f64N/A

              \[\leadsto \mathsf{/.f64}\left(1, \mathsf{exp.f64}\left(\mathsf{+.f64}\left(\ell, \mathsf{\_.f64}\left(\mathsf{*.f64}\left(\frac{1}{4}, \mathsf{*.f64}\left(\left(m + n\right), \left(m + n\right)\right)\right), \left(\left|n - m\right|\right)\right)\right)\right)\right) \]
            10. +-lowering-+.f64N/A

              \[\leadsto \mathsf{/.f64}\left(1, \mathsf{exp.f64}\left(\mathsf{+.f64}\left(\ell, \mathsf{\_.f64}\left(\mathsf{*.f64}\left(\frac{1}{4}, \mathsf{*.f64}\left(\mathsf{+.f64}\left(m, n\right), \left(m + n\right)\right)\right), \left(\left|n - m\right|\right)\right)\right)\right)\right) \]
            11. +-lowering-+.f64N/A

              \[\leadsto \mathsf{/.f64}\left(1, \mathsf{exp.f64}\left(\mathsf{+.f64}\left(\ell, \mathsf{\_.f64}\left(\mathsf{*.f64}\left(\frac{1}{4}, \mathsf{*.f64}\left(\mathsf{+.f64}\left(m, n\right), \mathsf{+.f64}\left(m, n\right)\right)\right), \left(\left|n - m\right|\right)\right)\right)\right)\right) \]
            12. sub-negN/A

              \[\leadsto \mathsf{/.f64}\left(1, \mathsf{exp.f64}\left(\mathsf{+.f64}\left(\ell, \mathsf{\_.f64}\left(\mathsf{*.f64}\left(\frac{1}{4}, \mathsf{*.f64}\left(\mathsf{+.f64}\left(m, n\right), \mathsf{+.f64}\left(m, n\right)\right)\right), \left(\left|n + \left(\mathsf{neg}\left(m\right)\right)\right|\right)\right)\right)\right)\right) \]
            13. mul-1-negN/A

              \[\leadsto \mathsf{/.f64}\left(1, \mathsf{exp.f64}\left(\mathsf{+.f64}\left(\ell, \mathsf{\_.f64}\left(\mathsf{*.f64}\left(\frac{1}{4}, \mathsf{*.f64}\left(\mathsf{+.f64}\left(m, n\right), \mathsf{+.f64}\left(m, n\right)\right)\right), \left(\left|n + -1 \cdot m\right|\right)\right)\right)\right)\right) \]
            14. fabs-lowering-fabs.f64N/A

              \[\leadsto \mathsf{/.f64}\left(1, \mathsf{exp.f64}\left(\mathsf{+.f64}\left(\ell, \mathsf{\_.f64}\left(\mathsf{*.f64}\left(\frac{1}{4}, \mathsf{*.f64}\left(\mathsf{+.f64}\left(m, n\right), \mathsf{+.f64}\left(m, n\right)\right)\right), \mathsf{fabs.f64}\left(\left(n + -1 \cdot m\right)\right)\right)\right)\right)\right) \]
            15. mul-1-negN/A

              \[\leadsto \mathsf{/.f64}\left(1, \mathsf{exp.f64}\left(\mathsf{+.f64}\left(\ell, \mathsf{\_.f64}\left(\mathsf{*.f64}\left(\frac{1}{4}, \mathsf{*.f64}\left(\mathsf{+.f64}\left(m, n\right), \mathsf{+.f64}\left(m, n\right)\right)\right), \mathsf{fabs.f64}\left(\left(n + \left(\mathsf{neg}\left(m\right)\right)\right)\right)\right)\right)\right)\right) \]
            16. sub-negN/A

              \[\leadsto \mathsf{/.f64}\left(1, \mathsf{exp.f64}\left(\mathsf{+.f64}\left(\ell, \mathsf{\_.f64}\left(\mathsf{*.f64}\left(\frac{1}{4}, \mathsf{*.f64}\left(\mathsf{+.f64}\left(m, n\right), \mathsf{+.f64}\left(m, n\right)\right)\right), \mathsf{fabs.f64}\left(\left(n - m\right)\right)\right)\right)\right)\right) \]
            17. --lowering--.f64100.0%

              \[\leadsto \mathsf{/.f64}\left(1, \mathsf{exp.f64}\left(\mathsf{+.f64}\left(\ell, \mathsf{\_.f64}\left(\mathsf{*.f64}\left(\frac{1}{4}, \mathsf{*.f64}\left(\mathsf{+.f64}\left(m, n\right), \mathsf{+.f64}\left(m, n\right)\right)\right), \mathsf{fabs.f64}\left(\mathsf{\_.f64}\left(n, m\right)\right)\right)\right)\right)\right) \]
          10. Simplified100.0%

            \[\leadsto \color{blue}{\frac{1}{e^{\ell + \left(0.25 \cdot \left(\left(m + n\right) \cdot \left(m + n\right)\right) - \left|n - m\right|\right)}}} \]
          11. Taylor expanded in n around inf

            \[\leadsto \mathsf{/.f64}\left(1, \mathsf{exp.f64}\left(\color{blue}{\left(\frac{1}{4} \cdot {n}^{2}\right)}\right)\right) \]
          12. Step-by-step derivation
            1. *-lowering-*.f64N/A

              \[\leadsto \mathsf{/.f64}\left(1, \mathsf{exp.f64}\left(\mathsf{*.f64}\left(\frac{1}{4}, \left({n}^{2}\right)\right)\right)\right) \]
            2. unpow2N/A

              \[\leadsto \mathsf{/.f64}\left(1, \mathsf{exp.f64}\left(\mathsf{*.f64}\left(\frac{1}{4}, \left(n \cdot n\right)\right)\right)\right) \]
            3. *-lowering-*.f64100.0%

              \[\leadsto \mathsf{/.f64}\left(1, \mathsf{exp.f64}\left(\mathsf{*.f64}\left(\frac{1}{4}, \mathsf{*.f64}\left(n, n\right)\right)\right)\right) \]
          13. Simplified100.0%

            \[\leadsto \frac{1}{e^{\color{blue}{0.25 \cdot \left(n \cdot n\right)}}} \]
        3. Recombined 3 regimes into one program.
        4. Final simplification59.0%

          \[\leadsto \begin{array}{l} \mathbf{if}\;n \leq 5.6 \cdot 10^{-102}:\\ \;\;\;\;\frac{1}{e^{0.25 \cdot \left(m \cdot m\right) - \left|m - n\right|}}\\ \mathbf{elif}\;n \leq 94000000000000:\\ \;\;\;\;\frac{\cos M}{e^{M \cdot M}}\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{e^{0.25 \cdot \left(n \cdot n\right)}}\\ \end{array} \]
        5. Add Preprocessing

        Alternative 8: 65.6% accurate, 2.0× speedup?

        \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;n \leq 5.2 \cdot 10^{-210}:\\ \;\;\;\;\frac{\cos M}{e^{0.25 \cdot \left(m \cdot m\right)}}\\ \mathbf{elif}\;n \leq 94000000000000:\\ \;\;\;\;\frac{\cos M}{e^{M \cdot M}}\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{e^{0.25 \cdot \left(n \cdot n\right)}}\\ \end{array} \end{array} \]
        (FPCore (K m n M l)
         :precision binary64
         (if (<= n 5.2e-210)
           (/ (cos M) (exp (* 0.25 (* m m))))
           (if (<= n 94000000000000.0)
             (/ (cos M) (exp (* M M)))
             (/ 1.0 (exp (* 0.25 (* n n)))))))
        double code(double K, double m, double n, double M, double l) {
        	double tmp;
        	if (n <= 5.2e-210) {
        		tmp = cos(M) / exp((0.25 * (m * m)));
        	} else if (n <= 94000000000000.0) {
        		tmp = cos(M) / exp((M * M));
        	} else {
        		tmp = 1.0 / exp((0.25 * (n * n)));
        	}
        	return tmp;
        }
        
        real(8) function code(k, m, n, m_1, l)
            real(8), intent (in) :: k
            real(8), intent (in) :: m
            real(8), intent (in) :: n
            real(8), intent (in) :: m_1
            real(8), intent (in) :: l
            real(8) :: tmp
            if (n <= 5.2d-210) then
                tmp = cos(m_1) / exp((0.25d0 * (m * m)))
            else if (n <= 94000000000000.0d0) then
                tmp = cos(m_1) / exp((m_1 * m_1))
            else
                tmp = 1.0d0 / exp((0.25d0 * (n * n)))
            end if
            code = tmp
        end function
        
        public static double code(double K, double m, double n, double M, double l) {
        	double tmp;
        	if (n <= 5.2e-210) {
        		tmp = Math.cos(M) / Math.exp((0.25 * (m * m)));
        	} else if (n <= 94000000000000.0) {
        		tmp = Math.cos(M) / Math.exp((M * M));
        	} else {
        		tmp = 1.0 / Math.exp((0.25 * (n * n)));
        	}
        	return tmp;
        }
        
        def code(K, m, n, M, l):
        	tmp = 0
        	if n <= 5.2e-210:
        		tmp = math.cos(M) / math.exp((0.25 * (m * m)))
        	elif n <= 94000000000000.0:
        		tmp = math.cos(M) / math.exp((M * M))
        	else:
        		tmp = 1.0 / math.exp((0.25 * (n * n)))
        	return tmp
        
        function code(K, m, n, M, l)
        	tmp = 0.0
        	if (n <= 5.2e-210)
        		tmp = Float64(cos(M) / exp(Float64(0.25 * Float64(m * m))));
        	elseif (n <= 94000000000000.0)
        		tmp = Float64(cos(M) / exp(Float64(M * M)));
        	else
        		tmp = Float64(1.0 / exp(Float64(0.25 * Float64(n * n))));
        	end
        	return tmp
        end
        
        function tmp_2 = code(K, m, n, M, l)
        	tmp = 0.0;
        	if (n <= 5.2e-210)
        		tmp = cos(M) / exp((0.25 * (m * m)));
        	elseif (n <= 94000000000000.0)
        		tmp = cos(M) / exp((M * M));
        	else
        		tmp = 1.0 / exp((0.25 * (n * n)));
        	end
        	tmp_2 = tmp;
        end
        
        code[K_, m_, n_, M_, l_] := If[LessEqual[n, 5.2e-210], N[(N[Cos[M], $MachinePrecision] / N[Exp[N[(0.25 * N[(m * m), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[n, 94000000000000.0], N[(N[Cos[M], $MachinePrecision] / N[Exp[N[(M * M), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(1.0 / N[Exp[N[(0.25 * N[(n * n), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]
        
        \begin{array}{l}
        
        \\
        \begin{array}{l}
        \mathbf{if}\;n \leq 5.2 \cdot 10^{-210}:\\
        \;\;\;\;\frac{\cos M}{e^{0.25 \cdot \left(m \cdot m\right)}}\\
        
        \mathbf{elif}\;n \leq 94000000000000:\\
        \;\;\;\;\frac{\cos M}{e^{M \cdot M}}\\
        
        \mathbf{else}:\\
        \;\;\;\;\frac{1}{e^{0.25 \cdot \left(n \cdot n\right)}}\\
        
        
        \end{array}
        \end{array}
        
        Derivation
        1. Split input into 3 regimes
        2. if n < 5.1999999999999997e-210

          1. Initial program 72.8%

            \[\cos \left(\frac{K \cdot \left(m + n\right)}{2} - M\right) \cdot e^{\left(-{\left(\frac{m + n}{2} - M\right)}^{2}\right) - \left(\ell - \left|m - n\right|\right)} \]
          2. Step-by-step derivation
            1. neg-sub0N/A

              \[\leadsto \cos \left(\frac{K \cdot \left(m + n\right)}{2} - M\right) \cdot e^{\left(0 - {\left(\frac{m + n}{2} - M\right)}^{2}\right) - \left(\ell - \left|m - n\right|\right)} \]
            2. associate--l-N/A

              \[\leadsto \cos \left(\frac{K \cdot \left(m + n\right)}{2} - M\right) \cdot e^{0 - \left({\left(\frac{m + n}{2} - M\right)}^{2} + \left(\ell - \left|m - n\right|\right)\right)} \]
            3. exp-diffN/A

              \[\leadsto \cos \left(\frac{K \cdot \left(m + n\right)}{2} - M\right) \cdot \frac{e^{0}}{\color{blue}{e^{{\left(\frac{m + n}{2} - M\right)}^{2} + \left(\ell - \left|m - n\right|\right)}}} \]
            4. associate-*r/N/A

              \[\leadsto \frac{\cos \left(\frac{K \cdot \left(m + n\right)}{2} - M\right) \cdot e^{0}}{\color{blue}{e^{{\left(\frac{m + n}{2} - M\right)}^{2} + \left(\ell - \left|m - n\right|\right)}}} \]
            5. exp-0N/A

              \[\leadsto \frac{\cos \left(\frac{K \cdot \left(m + n\right)}{2} - M\right) \cdot 1}{e^{{\left(\frac{m + n}{2} - M\right)}^{2} + \color{blue}{\left(\ell - \left|m - n\right|\right)}}} \]
            6. *-rgt-identityN/A

              \[\leadsto \frac{\cos \left(\frac{K \cdot \left(m + n\right)}{2} - M\right)}{e^{\color{blue}{{\left(\frac{m + n}{2} - M\right)}^{2} + \left(\ell - \left|m - n\right|\right)}}} \]
            7. /-lowering-/.f64N/A

              \[\leadsto \mathsf{/.f64}\left(\cos \left(\frac{K \cdot \left(m + n\right)}{2} - M\right), \color{blue}{\left(e^{{\left(\frac{m + n}{2} - M\right)}^{2} + \left(\ell - \left|m - n\right|\right)}\right)}\right) \]
          3. Simplified72.8%

            \[\leadsto \color{blue}{\frac{\cos \left(\frac{K \cdot \left(m + n\right)}{2} - M\right)}{e^{\left(\left(\frac{m + n}{2} - M\right) \cdot \left(\frac{m + n}{2} - M\right) + \ell\right) - \left|m - n\right|}}} \]
          4. Add Preprocessing
          5. Taylor expanded in K around 0

            \[\leadsto \mathsf{/.f64}\left(\color{blue}{\cos \left(\mathsf{neg}\left(M\right)\right)}, \mathsf{exp.f64}\left(\mathsf{\_.f64}\left(\mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\mathsf{/.f64}\left(\mathsf{+.f64}\left(m, n\right), 2\right), M\right), \mathsf{\_.f64}\left(\mathsf{/.f64}\left(\mathsf{+.f64}\left(m, n\right), 2\right), M\right)\right), \ell\right), \mathsf{fabs.f64}\left(\mathsf{\_.f64}\left(m, n\right)\right)\right)\right)\right) \]
          6. Step-by-step derivation
            1. cos-negN/A

              \[\leadsto \mathsf{/.f64}\left(\cos M, \mathsf{exp.f64}\left(\color{blue}{\mathsf{\_.f64}\left(\mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\mathsf{/.f64}\left(\mathsf{+.f64}\left(m, n\right), 2\right), M\right), \mathsf{\_.f64}\left(\mathsf{/.f64}\left(\mathsf{+.f64}\left(m, n\right), 2\right), M\right)\right), \ell\right), \mathsf{fabs.f64}\left(\mathsf{\_.f64}\left(m, n\right)\right)\right)}\right)\right) \]
            2. cos-lowering-cos.f6492.6%

              \[\leadsto \mathsf{/.f64}\left(\mathsf{cos.f64}\left(M\right), \mathsf{exp.f64}\left(\color{blue}{\mathsf{\_.f64}\left(\mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\mathsf{/.f64}\left(\mathsf{+.f64}\left(m, n\right), 2\right), M\right), \mathsf{\_.f64}\left(\mathsf{/.f64}\left(\mathsf{+.f64}\left(m, n\right), 2\right), M\right)\right), \ell\right), \mathsf{fabs.f64}\left(\mathsf{\_.f64}\left(m, n\right)\right)\right)}\right)\right) \]
          7. Simplified92.6%

            \[\leadsto \frac{\color{blue}{\cos M}}{e^{\left(\left(\frac{m + n}{2} - M\right) \cdot \left(\frac{m + n}{2} - M\right) + \ell\right) - \left|m - n\right|}} \]
          8. Taylor expanded in m around inf

            \[\leadsto \mathsf{/.f64}\left(\mathsf{cos.f64}\left(M\right), \mathsf{exp.f64}\left(\color{blue}{\left(\frac{1}{4} \cdot {m}^{2}\right)}\right)\right) \]
          9. Step-by-step derivation
            1. *-lowering-*.f64N/A

              \[\leadsto \mathsf{/.f64}\left(\mathsf{cos.f64}\left(M\right), \mathsf{exp.f64}\left(\mathsf{*.f64}\left(\frac{1}{4}, \left({m}^{2}\right)\right)\right)\right) \]
            2. unpow2N/A

              \[\leadsto \mathsf{/.f64}\left(\mathsf{cos.f64}\left(M\right), \mathsf{exp.f64}\left(\mathsf{*.f64}\left(\frac{1}{4}, \left(m \cdot m\right)\right)\right)\right) \]
            3. *-lowering-*.f6452.6%

              \[\leadsto \mathsf{/.f64}\left(\mathsf{cos.f64}\left(M\right), \mathsf{exp.f64}\left(\mathsf{*.f64}\left(\frac{1}{4}, \mathsf{*.f64}\left(m, m\right)\right)\right)\right) \]
          10. Simplified52.6%

            \[\leadsto \frac{\cos M}{e^{\color{blue}{0.25 \cdot \left(m \cdot m\right)}}} \]

          if 5.1999999999999997e-210 < n < 9.4e13

          1. Initial program 73.8%

            \[\cos \left(\frac{K \cdot \left(m + n\right)}{2} - M\right) \cdot e^{\left(-{\left(\frac{m + n}{2} - M\right)}^{2}\right) - \left(\ell - \left|m - n\right|\right)} \]
          2. Step-by-step derivation
            1. neg-sub0N/A

              \[\leadsto \cos \left(\frac{K \cdot \left(m + n\right)}{2} - M\right) \cdot e^{\left(0 - {\left(\frac{m + n}{2} - M\right)}^{2}\right) - \left(\ell - \left|m - n\right|\right)} \]
            2. associate--l-N/A

              \[\leadsto \cos \left(\frac{K \cdot \left(m + n\right)}{2} - M\right) \cdot e^{0 - \left({\left(\frac{m + n}{2} - M\right)}^{2} + \left(\ell - \left|m - n\right|\right)\right)} \]
            3. exp-diffN/A

              \[\leadsto \cos \left(\frac{K \cdot \left(m + n\right)}{2} - M\right) \cdot \frac{e^{0}}{\color{blue}{e^{{\left(\frac{m + n}{2} - M\right)}^{2} + \left(\ell - \left|m - n\right|\right)}}} \]
            4. associate-*r/N/A

              \[\leadsto \frac{\cos \left(\frac{K \cdot \left(m + n\right)}{2} - M\right) \cdot e^{0}}{\color{blue}{e^{{\left(\frac{m + n}{2} - M\right)}^{2} + \left(\ell - \left|m - n\right|\right)}}} \]
            5. exp-0N/A

              \[\leadsto \frac{\cos \left(\frac{K \cdot \left(m + n\right)}{2} - M\right) \cdot 1}{e^{{\left(\frac{m + n}{2} - M\right)}^{2} + \color{blue}{\left(\ell - \left|m - n\right|\right)}}} \]
            6. *-rgt-identityN/A

              \[\leadsto \frac{\cos \left(\frac{K \cdot \left(m + n\right)}{2} - M\right)}{e^{\color{blue}{{\left(\frac{m + n}{2} - M\right)}^{2} + \left(\ell - \left|m - n\right|\right)}}} \]
            7. /-lowering-/.f64N/A

              \[\leadsto \mathsf{/.f64}\left(\cos \left(\frac{K \cdot \left(m + n\right)}{2} - M\right), \color{blue}{\left(e^{{\left(\frac{m + n}{2} - M\right)}^{2} + \left(\ell - \left|m - n\right|\right)}\right)}\right) \]
          3. Simplified73.8%

            \[\leadsto \color{blue}{\frac{\cos \left(\frac{K \cdot \left(m + n\right)}{2} - M\right)}{e^{\left(\left(\frac{m + n}{2} - M\right) \cdot \left(\frac{m + n}{2} - M\right) + \ell\right) - \left|m - n\right|}}} \]
          4. Add Preprocessing
          5. Taylor expanded in K around 0

            \[\leadsto \mathsf{/.f64}\left(\color{blue}{\cos \left(\mathsf{neg}\left(M\right)\right)}, \mathsf{exp.f64}\left(\mathsf{\_.f64}\left(\mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\mathsf{/.f64}\left(\mathsf{+.f64}\left(m, n\right), 2\right), M\right), \mathsf{\_.f64}\left(\mathsf{/.f64}\left(\mathsf{+.f64}\left(m, n\right), 2\right), M\right)\right), \ell\right), \mathsf{fabs.f64}\left(\mathsf{\_.f64}\left(m, n\right)\right)\right)\right)\right) \]
          6. Step-by-step derivation
            1. cos-negN/A

              \[\leadsto \mathsf{/.f64}\left(\cos M, \mathsf{exp.f64}\left(\color{blue}{\mathsf{\_.f64}\left(\mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\mathsf{/.f64}\left(\mathsf{+.f64}\left(m, n\right), 2\right), M\right), \mathsf{\_.f64}\left(\mathsf{/.f64}\left(\mathsf{+.f64}\left(m, n\right), 2\right), M\right)\right), \ell\right), \mathsf{fabs.f64}\left(\mathsf{\_.f64}\left(m, n\right)\right)\right)}\right)\right) \]
            2. cos-lowering-cos.f6494.9%

              \[\leadsto \mathsf{/.f64}\left(\mathsf{cos.f64}\left(M\right), \mathsf{exp.f64}\left(\color{blue}{\mathsf{\_.f64}\left(\mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\mathsf{/.f64}\left(\mathsf{+.f64}\left(m, n\right), 2\right), M\right), \mathsf{\_.f64}\left(\mathsf{/.f64}\left(\mathsf{+.f64}\left(m, n\right), 2\right), M\right)\right), \ell\right), \mathsf{fabs.f64}\left(\mathsf{\_.f64}\left(m, n\right)\right)\right)}\right)\right) \]
          7. Simplified94.9%

            \[\leadsto \frac{\color{blue}{\cos M}}{e^{\left(\left(\frac{m + n}{2} - M\right) \cdot \left(\frac{m + n}{2} - M\right) + \ell\right) - \left|m - n\right|}} \]
          8. Taylor expanded in M around inf

            \[\leadsto \mathsf{/.f64}\left(\mathsf{cos.f64}\left(M\right), \mathsf{exp.f64}\left(\color{blue}{\left({M}^{2}\right)}\right)\right) \]
          9. Step-by-step derivation
            1. unpow2N/A

              \[\leadsto \mathsf{/.f64}\left(\mathsf{cos.f64}\left(M\right), \mathsf{exp.f64}\left(\left(M \cdot M\right)\right)\right) \]
            2. *-lowering-*.f6464.0%

              \[\leadsto \mathsf{/.f64}\left(\mathsf{cos.f64}\left(M\right), \mathsf{exp.f64}\left(\mathsf{*.f64}\left(M, M\right)\right)\right) \]
          10. Simplified64.0%

            \[\leadsto \frac{\cos M}{e^{\color{blue}{M \cdot M}}} \]

          if 9.4e13 < n

          1. Initial program 63.6%

            \[\cos \left(\frac{K \cdot \left(m + n\right)}{2} - M\right) \cdot e^{\left(-{\left(\frac{m + n}{2} - M\right)}^{2}\right) - \left(\ell - \left|m - n\right|\right)} \]
          2. Step-by-step derivation
            1. neg-sub0N/A

              \[\leadsto \cos \left(\frac{K \cdot \left(m + n\right)}{2} - M\right) \cdot e^{\left(0 - {\left(\frac{m + n}{2} - M\right)}^{2}\right) - \left(\ell - \left|m - n\right|\right)} \]
            2. associate--l-N/A

              \[\leadsto \cos \left(\frac{K \cdot \left(m + n\right)}{2} - M\right) \cdot e^{0 - \left({\left(\frac{m + n}{2} - M\right)}^{2} + \left(\ell - \left|m - n\right|\right)\right)} \]
            3. exp-diffN/A

              \[\leadsto \cos \left(\frac{K \cdot \left(m + n\right)}{2} - M\right) \cdot \frac{e^{0}}{\color{blue}{e^{{\left(\frac{m + n}{2} - M\right)}^{2} + \left(\ell - \left|m - n\right|\right)}}} \]
            4. associate-*r/N/A

              \[\leadsto \frac{\cos \left(\frac{K \cdot \left(m + n\right)}{2} - M\right) \cdot e^{0}}{\color{blue}{e^{{\left(\frac{m + n}{2} - M\right)}^{2} + \left(\ell - \left|m - n\right|\right)}}} \]
            5. exp-0N/A

              \[\leadsto \frac{\cos \left(\frac{K \cdot \left(m + n\right)}{2} - M\right) \cdot 1}{e^{{\left(\frac{m + n}{2} - M\right)}^{2} + \color{blue}{\left(\ell - \left|m - n\right|\right)}}} \]
            6. *-rgt-identityN/A

              \[\leadsto \frac{\cos \left(\frac{K \cdot \left(m + n\right)}{2} - M\right)}{e^{\color{blue}{{\left(\frac{m + n}{2} - M\right)}^{2} + \left(\ell - \left|m - n\right|\right)}}} \]
            7. /-lowering-/.f64N/A

              \[\leadsto \mathsf{/.f64}\left(\cos \left(\frac{K \cdot \left(m + n\right)}{2} - M\right), \color{blue}{\left(e^{{\left(\frac{m + n}{2} - M\right)}^{2} + \left(\ell - \left|m - n\right|\right)}\right)}\right) \]
          3. Simplified63.6%

            \[\leadsto \color{blue}{\frac{\cos \left(\frac{K \cdot \left(m + n\right)}{2} - M\right)}{e^{\left(\left(\frac{m + n}{2} - M\right) \cdot \left(\frac{m + n}{2} - M\right) + \ell\right) - \left|m - n\right|}}} \]
          4. Add Preprocessing
          5. Taylor expanded in K around 0

            \[\leadsto \mathsf{/.f64}\left(\color{blue}{\cos \left(\mathsf{neg}\left(M\right)\right)}, \mathsf{exp.f64}\left(\mathsf{\_.f64}\left(\mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\mathsf{/.f64}\left(\mathsf{+.f64}\left(m, n\right), 2\right), M\right), \mathsf{\_.f64}\left(\mathsf{/.f64}\left(\mathsf{+.f64}\left(m, n\right), 2\right), M\right)\right), \ell\right), \mathsf{fabs.f64}\left(\mathsf{\_.f64}\left(m, n\right)\right)\right)\right)\right) \]
          6. Step-by-step derivation
            1. cos-negN/A

              \[\leadsto \mathsf{/.f64}\left(\cos M, \mathsf{exp.f64}\left(\color{blue}{\mathsf{\_.f64}\left(\mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\mathsf{/.f64}\left(\mathsf{+.f64}\left(m, n\right), 2\right), M\right), \mathsf{\_.f64}\left(\mathsf{/.f64}\left(\mathsf{+.f64}\left(m, n\right), 2\right), M\right)\right), \ell\right), \mathsf{fabs.f64}\left(\mathsf{\_.f64}\left(m, n\right)\right)\right)}\right)\right) \]
            2. cos-lowering-cos.f64100.0%

              \[\leadsto \mathsf{/.f64}\left(\mathsf{cos.f64}\left(M\right), \mathsf{exp.f64}\left(\color{blue}{\mathsf{\_.f64}\left(\mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\mathsf{/.f64}\left(\mathsf{+.f64}\left(m, n\right), 2\right), M\right), \mathsf{\_.f64}\left(\mathsf{/.f64}\left(\mathsf{+.f64}\left(m, n\right), 2\right), M\right)\right), \ell\right), \mathsf{fabs.f64}\left(\mathsf{\_.f64}\left(m, n\right)\right)\right)}\right)\right) \]
          7. Simplified100.0%

            \[\leadsto \frac{\color{blue}{\cos M}}{e^{\left(\left(\frac{m + n}{2} - M\right) \cdot \left(\frac{m + n}{2} - M\right) + \ell\right) - \left|m - n\right|}} \]
          8. Taylor expanded in M around 0

            \[\leadsto \color{blue}{\frac{1}{e^{\left(\ell + \frac{1}{4} \cdot {\left(m + n\right)}^{2}\right) - \left|m - n\right|}}} \]
          9. Step-by-step derivation
            1. /-lowering-/.f64N/A

              \[\leadsto \mathsf{/.f64}\left(1, \color{blue}{\left(e^{\left(\ell + \frac{1}{4} \cdot {\left(m + n\right)}^{2}\right) - \left|m - n\right|}\right)}\right) \]
            2. exp-lowering-exp.f64N/A

              \[\leadsto \mathsf{/.f64}\left(1, \mathsf{exp.f64}\left(\left(\left(\ell + \frac{1}{4} \cdot {\left(m + n\right)}^{2}\right) - \left|m - n\right|\right)\right)\right) \]
            3. fabs-subN/A

              \[\leadsto \mathsf{/.f64}\left(1, \mathsf{exp.f64}\left(\left(\left(\ell + \frac{1}{4} \cdot {\left(m + n\right)}^{2}\right) - \left|n - m\right|\right)\right)\right) \]
            4. associate--l+N/A

              \[\leadsto \mathsf{/.f64}\left(1, \mathsf{exp.f64}\left(\left(\ell + \left(\frac{1}{4} \cdot {\left(m + n\right)}^{2} - \left|n - m\right|\right)\right)\right)\right) \]
            5. +-lowering-+.f64N/A

              \[\leadsto \mathsf{/.f64}\left(1, \mathsf{exp.f64}\left(\mathsf{+.f64}\left(\ell, \left(\frac{1}{4} \cdot {\left(m + n\right)}^{2} - \left|n - m\right|\right)\right)\right)\right) \]
            6. --lowering--.f64N/A

              \[\leadsto \mathsf{/.f64}\left(1, \mathsf{exp.f64}\left(\mathsf{+.f64}\left(\ell, \mathsf{\_.f64}\left(\left(\frac{1}{4} \cdot {\left(m + n\right)}^{2}\right), \left(\left|n - m\right|\right)\right)\right)\right)\right) \]
            7. *-lowering-*.f64N/A

              \[\leadsto \mathsf{/.f64}\left(1, \mathsf{exp.f64}\left(\mathsf{+.f64}\left(\ell, \mathsf{\_.f64}\left(\mathsf{*.f64}\left(\frac{1}{4}, \left({\left(m + n\right)}^{2}\right)\right), \left(\left|n - m\right|\right)\right)\right)\right)\right) \]
            8. unpow2N/A

              \[\leadsto \mathsf{/.f64}\left(1, \mathsf{exp.f64}\left(\mathsf{+.f64}\left(\ell, \mathsf{\_.f64}\left(\mathsf{*.f64}\left(\frac{1}{4}, \left(\left(m + n\right) \cdot \left(m + n\right)\right)\right), \left(\left|n - m\right|\right)\right)\right)\right)\right) \]
            9. *-lowering-*.f64N/A

              \[\leadsto \mathsf{/.f64}\left(1, \mathsf{exp.f64}\left(\mathsf{+.f64}\left(\ell, \mathsf{\_.f64}\left(\mathsf{*.f64}\left(\frac{1}{4}, \mathsf{*.f64}\left(\left(m + n\right), \left(m + n\right)\right)\right), \left(\left|n - m\right|\right)\right)\right)\right)\right) \]
            10. +-lowering-+.f64N/A

              \[\leadsto \mathsf{/.f64}\left(1, \mathsf{exp.f64}\left(\mathsf{+.f64}\left(\ell, \mathsf{\_.f64}\left(\mathsf{*.f64}\left(\frac{1}{4}, \mathsf{*.f64}\left(\mathsf{+.f64}\left(m, n\right), \left(m + n\right)\right)\right), \left(\left|n - m\right|\right)\right)\right)\right)\right) \]
            11. +-lowering-+.f64N/A

              \[\leadsto \mathsf{/.f64}\left(1, \mathsf{exp.f64}\left(\mathsf{+.f64}\left(\ell, \mathsf{\_.f64}\left(\mathsf{*.f64}\left(\frac{1}{4}, \mathsf{*.f64}\left(\mathsf{+.f64}\left(m, n\right), \mathsf{+.f64}\left(m, n\right)\right)\right), \left(\left|n - m\right|\right)\right)\right)\right)\right) \]
            12. sub-negN/A

              \[\leadsto \mathsf{/.f64}\left(1, \mathsf{exp.f64}\left(\mathsf{+.f64}\left(\ell, \mathsf{\_.f64}\left(\mathsf{*.f64}\left(\frac{1}{4}, \mathsf{*.f64}\left(\mathsf{+.f64}\left(m, n\right), \mathsf{+.f64}\left(m, n\right)\right)\right), \left(\left|n + \left(\mathsf{neg}\left(m\right)\right)\right|\right)\right)\right)\right)\right) \]
            13. mul-1-negN/A

              \[\leadsto \mathsf{/.f64}\left(1, \mathsf{exp.f64}\left(\mathsf{+.f64}\left(\ell, \mathsf{\_.f64}\left(\mathsf{*.f64}\left(\frac{1}{4}, \mathsf{*.f64}\left(\mathsf{+.f64}\left(m, n\right), \mathsf{+.f64}\left(m, n\right)\right)\right), \left(\left|n + -1 \cdot m\right|\right)\right)\right)\right)\right) \]
            14. fabs-lowering-fabs.f64N/A

              \[\leadsto \mathsf{/.f64}\left(1, \mathsf{exp.f64}\left(\mathsf{+.f64}\left(\ell, \mathsf{\_.f64}\left(\mathsf{*.f64}\left(\frac{1}{4}, \mathsf{*.f64}\left(\mathsf{+.f64}\left(m, n\right), \mathsf{+.f64}\left(m, n\right)\right)\right), \mathsf{fabs.f64}\left(\left(n + -1 \cdot m\right)\right)\right)\right)\right)\right) \]
            15. mul-1-negN/A

              \[\leadsto \mathsf{/.f64}\left(1, \mathsf{exp.f64}\left(\mathsf{+.f64}\left(\ell, \mathsf{\_.f64}\left(\mathsf{*.f64}\left(\frac{1}{4}, \mathsf{*.f64}\left(\mathsf{+.f64}\left(m, n\right), \mathsf{+.f64}\left(m, n\right)\right)\right), \mathsf{fabs.f64}\left(\left(n + \left(\mathsf{neg}\left(m\right)\right)\right)\right)\right)\right)\right)\right) \]
            16. sub-negN/A

              \[\leadsto \mathsf{/.f64}\left(1, \mathsf{exp.f64}\left(\mathsf{+.f64}\left(\ell, \mathsf{\_.f64}\left(\mathsf{*.f64}\left(\frac{1}{4}, \mathsf{*.f64}\left(\mathsf{+.f64}\left(m, n\right), \mathsf{+.f64}\left(m, n\right)\right)\right), \mathsf{fabs.f64}\left(\left(n - m\right)\right)\right)\right)\right)\right) \]
            17. --lowering--.f64100.0%

              \[\leadsto \mathsf{/.f64}\left(1, \mathsf{exp.f64}\left(\mathsf{+.f64}\left(\ell, \mathsf{\_.f64}\left(\mathsf{*.f64}\left(\frac{1}{4}, \mathsf{*.f64}\left(\mathsf{+.f64}\left(m, n\right), \mathsf{+.f64}\left(m, n\right)\right)\right), \mathsf{fabs.f64}\left(\mathsf{\_.f64}\left(n, m\right)\right)\right)\right)\right)\right) \]
          10. Simplified100.0%

            \[\leadsto \color{blue}{\frac{1}{e^{\ell + \left(0.25 \cdot \left(\left(m + n\right) \cdot \left(m + n\right)\right) - \left|n - m\right|\right)}}} \]
          11. Taylor expanded in n around inf

            \[\leadsto \mathsf{/.f64}\left(1, \mathsf{exp.f64}\left(\color{blue}{\left(\frac{1}{4} \cdot {n}^{2}\right)}\right)\right) \]
          12. Step-by-step derivation
            1. *-lowering-*.f64N/A

              \[\leadsto \mathsf{/.f64}\left(1, \mathsf{exp.f64}\left(\mathsf{*.f64}\left(\frac{1}{4}, \left({n}^{2}\right)\right)\right)\right) \]
            2. unpow2N/A

              \[\leadsto \mathsf{/.f64}\left(1, \mathsf{exp.f64}\left(\mathsf{*.f64}\left(\frac{1}{4}, \left(n \cdot n\right)\right)\right)\right) \]
            3. *-lowering-*.f64100.0%

              \[\leadsto \mathsf{/.f64}\left(1, \mathsf{exp.f64}\left(\mathsf{*.f64}\left(\frac{1}{4}, \mathsf{*.f64}\left(n, n\right)\right)\right)\right) \]
          13. Simplified100.0%

            \[\leadsto \frac{1}{e^{\color{blue}{0.25 \cdot \left(n \cdot n\right)}}} \]
        3. Recombined 3 regimes into one program.
        4. Add Preprocessing

        Alternative 9: 65.6% accurate, 2.0× speedup?

        \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;n \leq 10^{-208}:\\ \;\;\;\;\frac{1}{e^{0.25 \cdot \left(m \cdot m\right)}}\\ \mathbf{elif}\;n \leq 94000000000000:\\ \;\;\;\;\frac{\cos M}{e^{M \cdot M}}\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{e^{0.25 \cdot \left(n \cdot n\right)}}\\ \end{array} \end{array} \]
        (FPCore (K m n M l)
         :precision binary64
         (if (<= n 1e-208)
           (/ 1.0 (exp (* 0.25 (* m m))))
           (if (<= n 94000000000000.0)
             (/ (cos M) (exp (* M M)))
             (/ 1.0 (exp (* 0.25 (* n n)))))))
        double code(double K, double m, double n, double M, double l) {
        	double tmp;
        	if (n <= 1e-208) {
        		tmp = 1.0 / exp((0.25 * (m * m)));
        	} else if (n <= 94000000000000.0) {
        		tmp = cos(M) / exp((M * M));
        	} else {
        		tmp = 1.0 / exp((0.25 * (n * n)));
        	}
        	return tmp;
        }
        
        real(8) function code(k, m, n, m_1, l)
            real(8), intent (in) :: k
            real(8), intent (in) :: m
            real(8), intent (in) :: n
            real(8), intent (in) :: m_1
            real(8), intent (in) :: l
            real(8) :: tmp
            if (n <= 1d-208) then
                tmp = 1.0d0 / exp((0.25d0 * (m * m)))
            else if (n <= 94000000000000.0d0) then
                tmp = cos(m_1) / exp((m_1 * m_1))
            else
                tmp = 1.0d0 / exp((0.25d0 * (n * n)))
            end if
            code = tmp
        end function
        
        public static double code(double K, double m, double n, double M, double l) {
        	double tmp;
        	if (n <= 1e-208) {
        		tmp = 1.0 / Math.exp((0.25 * (m * m)));
        	} else if (n <= 94000000000000.0) {
        		tmp = Math.cos(M) / Math.exp((M * M));
        	} else {
        		tmp = 1.0 / Math.exp((0.25 * (n * n)));
        	}
        	return tmp;
        }
        
        def code(K, m, n, M, l):
        	tmp = 0
        	if n <= 1e-208:
        		tmp = 1.0 / math.exp((0.25 * (m * m)))
        	elif n <= 94000000000000.0:
        		tmp = math.cos(M) / math.exp((M * M))
        	else:
        		tmp = 1.0 / math.exp((0.25 * (n * n)))
        	return tmp
        
        function code(K, m, n, M, l)
        	tmp = 0.0
        	if (n <= 1e-208)
        		tmp = Float64(1.0 / exp(Float64(0.25 * Float64(m * m))));
        	elseif (n <= 94000000000000.0)
        		tmp = Float64(cos(M) / exp(Float64(M * M)));
        	else
        		tmp = Float64(1.0 / exp(Float64(0.25 * Float64(n * n))));
        	end
        	return tmp
        end
        
        function tmp_2 = code(K, m, n, M, l)
        	tmp = 0.0;
        	if (n <= 1e-208)
        		tmp = 1.0 / exp((0.25 * (m * m)));
        	elseif (n <= 94000000000000.0)
        		tmp = cos(M) / exp((M * M));
        	else
        		tmp = 1.0 / exp((0.25 * (n * n)));
        	end
        	tmp_2 = tmp;
        end
        
        code[K_, m_, n_, M_, l_] := If[LessEqual[n, 1e-208], N[(1.0 / N[Exp[N[(0.25 * N[(m * m), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[n, 94000000000000.0], N[(N[Cos[M], $MachinePrecision] / N[Exp[N[(M * M), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(1.0 / N[Exp[N[(0.25 * N[(n * n), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]
        
        \begin{array}{l}
        
        \\
        \begin{array}{l}
        \mathbf{if}\;n \leq 10^{-208}:\\
        \;\;\;\;\frac{1}{e^{0.25 \cdot \left(m \cdot m\right)}}\\
        
        \mathbf{elif}\;n \leq 94000000000000:\\
        \;\;\;\;\frac{\cos M}{e^{M \cdot M}}\\
        
        \mathbf{else}:\\
        \;\;\;\;\frac{1}{e^{0.25 \cdot \left(n \cdot n\right)}}\\
        
        
        \end{array}
        \end{array}
        
        Derivation
        1. Split input into 3 regimes
        2. if n < 1.0000000000000001e-208

          1. Initial program 72.8%

            \[\cos \left(\frac{K \cdot \left(m + n\right)}{2} - M\right) \cdot e^{\left(-{\left(\frac{m + n}{2} - M\right)}^{2}\right) - \left(\ell - \left|m - n\right|\right)} \]
          2. Step-by-step derivation
            1. neg-sub0N/A

              \[\leadsto \cos \left(\frac{K \cdot \left(m + n\right)}{2} - M\right) \cdot e^{\left(0 - {\left(\frac{m + n}{2} - M\right)}^{2}\right) - \left(\ell - \left|m - n\right|\right)} \]
            2. associate--l-N/A

              \[\leadsto \cos \left(\frac{K \cdot \left(m + n\right)}{2} - M\right) \cdot e^{0 - \left({\left(\frac{m + n}{2} - M\right)}^{2} + \left(\ell - \left|m - n\right|\right)\right)} \]
            3. exp-diffN/A

              \[\leadsto \cos \left(\frac{K \cdot \left(m + n\right)}{2} - M\right) \cdot \frac{e^{0}}{\color{blue}{e^{{\left(\frac{m + n}{2} - M\right)}^{2} + \left(\ell - \left|m - n\right|\right)}}} \]
            4. associate-*r/N/A

              \[\leadsto \frac{\cos \left(\frac{K \cdot \left(m + n\right)}{2} - M\right) \cdot e^{0}}{\color{blue}{e^{{\left(\frac{m + n}{2} - M\right)}^{2} + \left(\ell - \left|m - n\right|\right)}}} \]
            5. exp-0N/A

              \[\leadsto \frac{\cos \left(\frac{K \cdot \left(m + n\right)}{2} - M\right) \cdot 1}{e^{{\left(\frac{m + n}{2} - M\right)}^{2} + \color{blue}{\left(\ell - \left|m - n\right|\right)}}} \]
            6. *-rgt-identityN/A

              \[\leadsto \frac{\cos \left(\frac{K \cdot \left(m + n\right)}{2} - M\right)}{e^{\color{blue}{{\left(\frac{m + n}{2} - M\right)}^{2} + \left(\ell - \left|m - n\right|\right)}}} \]
            7. /-lowering-/.f64N/A

              \[\leadsto \mathsf{/.f64}\left(\cos \left(\frac{K \cdot \left(m + n\right)}{2} - M\right), \color{blue}{\left(e^{{\left(\frac{m + n}{2} - M\right)}^{2} + \left(\ell - \left|m - n\right|\right)}\right)}\right) \]
          3. Simplified72.8%

            \[\leadsto \color{blue}{\frac{\cos \left(\frac{K \cdot \left(m + n\right)}{2} - M\right)}{e^{\left(\left(\frac{m + n}{2} - M\right) \cdot \left(\frac{m + n}{2} - M\right) + \ell\right) - \left|m - n\right|}}} \]
          4. Add Preprocessing
          5. Taylor expanded in K around 0

            \[\leadsto \mathsf{/.f64}\left(\color{blue}{\cos \left(\mathsf{neg}\left(M\right)\right)}, \mathsf{exp.f64}\left(\mathsf{\_.f64}\left(\mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\mathsf{/.f64}\left(\mathsf{+.f64}\left(m, n\right), 2\right), M\right), \mathsf{\_.f64}\left(\mathsf{/.f64}\left(\mathsf{+.f64}\left(m, n\right), 2\right), M\right)\right), \ell\right), \mathsf{fabs.f64}\left(\mathsf{\_.f64}\left(m, n\right)\right)\right)\right)\right) \]
          6. Step-by-step derivation
            1. cos-negN/A

              \[\leadsto \mathsf{/.f64}\left(\cos M, \mathsf{exp.f64}\left(\color{blue}{\mathsf{\_.f64}\left(\mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\mathsf{/.f64}\left(\mathsf{+.f64}\left(m, n\right), 2\right), M\right), \mathsf{\_.f64}\left(\mathsf{/.f64}\left(\mathsf{+.f64}\left(m, n\right), 2\right), M\right)\right), \ell\right), \mathsf{fabs.f64}\left(\mathsf{\_.f64}\left(m, n\right)\right)\right)}\right)\right) \]
            2. cos-lowering-cos.f6492.6%

              \[\leadsto \mathsf{/.f64}\left(\mathsf{cos.f64}\left(M\right), \mathsf{exp.f64}\left(\color{blue}{\mathsf{\_.f64}\left(\mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\mathsf{/.f64}\left(\mathsf{+.f64}\left(m, n\right), 2\right), M\right), \mathsf{\_.f64}\left(\mathsf{/.f64}\left(\mathsf{+.f64}\left(m, n\right), 2\right), M\right)\right), \ell\right), \mathsf{fabs.f64}\left(\mathsf{\_.f64}\left(m, n\right)\right)\right)}\right)\right) \]
          7. Simplified92.6%

            \[\leadsto \frac{\color{blue}{\cos M}}{e^{\left(\left(\frac{m + n}{2} - M\right) \cdot \left(\frac{m + n}{2} - M\right) + \ell\right) - \left|m - n\right|}} \]
          8. Taylor expanded in M around 0

            \[\leadsto \color{blue}{\frac{1}{e^{\left(\ell + \frac{1}{4} \cdot {\left(m + n\right)}^{2}\right) - \left|m - n\right|}}} \]
          9. Step-by-step derivation
            1. /-lowering-/.f64N/A

              \[\leadsto \mathsf{/.f64}\left(1, \color{blue}{\left(e^{\left(\ell + \frac{1}{4} \cdot {\left(m + n\right)}^{2}\right) - \left|m - n\right|}\right)}\right) \]
            2. exp-lowering-exp.f64N/A

              \[\leadsto \mathsf{/.f64}\left(1, \mathsf{exp.f64}\left(\left(\left(\ell + \frac{1}{4} \cdot {\left(m + n\right)}^{2}\right) - \left|m - n\right|\right)\right)\right) \]
            3. fabs-subN/A

              \[\leadsto \mathsf{/.f64}\left(1, \mathsf{exp.f64}\left(\left(\left(\ell + \frac{1}{4} \cdot {\left(m + n\right)}^{2}\right) - \left|n - m\right|\right)\right)\right) \]
            4. associate--l+N/A

              \[\leadsto \mathsf{/.f64}\left(1, \mathsf{exp.f64}\left(\left(\ell + \left(\frac{1}{4} \cdot {\left(m + n\right)}^{2} - \left|n - m\right|\right)\right)\right)\right) \]
            5. +-lowering-+.f64N/A

              \[\leadsto \mathsf{/.f64}\left(1, \mathsf{exp.f64}\left(\mathsf{+.f64}\left(\ell, \left(\frac{1}{4} \cdot {\left(m + n\right)}^{2} - \left|n - m\right|\right)\right)\right)\right) \]
            6. --lowering--.f64N/A

              \[\leadsto \mathsf{/.f64}\left(1, \mathsf{exp.f64}\left(\mathsf{+.f64}\left(\ell, \mathsf{\_.f64}\left(\left(\frac{1}{4} \cdot {\left(m + n\right)}^{2}\right), \left(\left|n - m\right|\right)\right)\right)\right)\right) \]
            7. *-lowering-*.f64N/A

              \[\leadsto \mathsf{/.f64}\left(1, \mathsf{exp.f64}\left(\mathsf{+.f64}\left(\ell, \mathsf{\_.f64}\left(\mathsf{*.f64}\left(\frac{1}{4}, \left({\left(m + n\right)}^{2}\right)\right), \left(\left|n - m\right|\right)\right)\right)\right)\right) \]
            8. unpow2N/A

              \[\leadsto \mathsf{/.f64}\left(1, \mathsf{exp.f64}\left(\mathsf{+.f64}\left(\ell, \mathsf{\_.f64}\left(\mathsf{*.f64}\left(\frac{1}{4}, \left(\left(m + n\right) \cdot \left(m + n\right)\right)\right), \left(\left|n - m\right|\right)\right)\right)\right)\right) \]
            9. *-lowering-*.f64N/A

              \[\leadsto \mathsf{/.f64}\left(1, \mathsf{exp.f64}\left(\mathsf{+.f64}\left(\ell, \mathsf{\_.f64}\left(\mathsf{*.f64}\left(\frac{1}{4}, \mathsf{*.f64}\left(\left(m + n\right), \left(m + n\right)\right)\right), \left(\left|n - m\right|\right)\right)\right)\right)\right) \]
            10. +-lowering-+.f64N/A

              \[\leadsto \mathsf{/.f64}\left(1, \mathsf{exp.f64}\left(\mathsf{+.f64}\left(\ell, \mathsf{\_.f64}\left(\mathsf{*.f64}\left(\frac{1}{4}, \mathsf{*.f64}\left(\mathsf{+.f64}\left(m, n\right), \left(m + n\right)\right)\right), \left(\left|n - m\right|\right)\right)\right)\right)\right) \]
            11. +-lowering-+.f64N/A

              \[\leadsto \mathsf{/.f64}\left(1, \mathsf{exp.f64}\left(\mathsf{+.f64}\left(\ell, \mathsf{\_.f64}\left(\mathsf{*.f64}\left(\frac{1}{4}, \mathsf{*.f64}\left(\mathsf{+.f64}\left(m, n\right), \mathsf{+.f64}\left(m, n\right)\right)\right), \left(\left|n - m\right|\right)\right)\right)\right)\right) \]
            12. sub-negN/A

              \[\leadsto \mathsf{/.f64}\left(1, \mathsf{exp.f64}\left(\mathsf{+.f64}\left(\ell, \mathsf{\_.f64}\left(\mathsf{*.f64}\left(\frac{1}{4}, \mathsf{*.f64}\left(\mathsf{+.f64}\left(m, n\right), \mathsf{+.f64}\left(m, n\right)\right)\right), \left(\left|n + \left(\mathsf{neg}\left(m\right)\right)\right|\right)\right)\right)\right)\right) \]
            13. mul-1-negN/A

              \[\leadsto \mathsf{/.f64}\left(1, \mathsf{exp.f64}\left(\mathsf{+.f64}\left(\ell, \mathsf{\_.f64}\left(\mathsf{*.f64}\left(\frac{1}{4}, \mathsf{*.f64}\left(\mathsf{+.f64}\left(m, n\right), \mathsf{+.f64}\left(m, n\right)\right)\right), \left(\left|n + -1 \cdot m\right|\right)\right)\right)\right)\right) \]
            14. fabs-lowering-fabs.f64N/A

              \[\leadsto \mathsf{/.f64}\left(1, \mathsf{exp.f64}\left(\mathsf{+.f64}\left(\ell, \mathsf{\_.f64}\left(\mathsf{*.f64}\left(\frac{1}{4}, \mathsf{*.f64}\left(\mathsf{+.f64}\left(m, n\right), \mathsf{+.f64}\left(m, n\right)\right)\right), \mathsf{fabs.f64}\left(\left(n + -1 \cdot m\right)\right)\right)\right)\right)\right) \]
            15. mul-1-negN/A

              \[\leadsto \mathsf{/.f64}\left(1, \mathsf{exp.f64}\left(\mathsf{+.f64}\left(\ell, \mathsf{\_.f64}\left(\mathsf{*.f64}\left(\frac{1}{4}, \mathsf{*.f64}\left(\mathsf{+.f64}\left(m, n\right), \mathsf{+.f64}\left(m, n\right)\right)\right), \mathsf{fabs.f64}\left(\left(n + \left(\mathsf{neg}\left(m\right)\right)\right)\right)\right)\right)\right)\right) \]
            16. sub-negN/A

              \[\leadsto \mathsf{/.f64}\left(1, \mathsf{exp.f64}\left(\mathsf{+.f64}\left(\ell, \mathsf{\_.f64}\left(\mathsf{*.f64}\left(\frac{1}{4}, \mathsf{*.f64}\left(\mathsf{+.f64}\left(m, n\right), \mathsf{+.f64}\left(m, n\right)\right)\right), \mathsf{fabs.f64}\left(\left(n - m\right)\right)\right)\right)\right)\right) \]
            17. --lowering--.f6481.9%

              \[\leadsto \mathsf{/.f64}\left(1, \mathsf{exp.f64}\left(\mathsf{+.f64}\left(\ell, \mathsf{\_.f64}\left(\mathsf{*.f64}\left(\frac{1}{4}, \mathsf{*.f64}\left(\mathsf{+.f64}\left(m, n\right), \mathsf{+.f64}\left(m, n\right)\right)\right), \mathsf{fabs.f64}\left(\mathsf{\_.f64}\left(n, m\right)\right)\right)\right)\right)\right) \]
          10. Simplified81.9%

            \[\leadsto \color{blue}{\frac{1}{e^{\ell + \left(0.25 \cdot \left(\left(m + n\right) \cdot \left(m + n\right)\right) - \left|n - m\right|\right)}}} \]
          11. Taylor expanded in m around inf

            \[\leadsto \mathsf{/.f64}\left(1, \mathsf{exp.f64}\left(\color{blue}{\left(\frac{1}{4} \cdot {m}^{2}\right)}\right)\right) \]
          12. Step-by-step derivation
            1. *-lowering-*.f64N/A

              \[\leadsto \mathsf{/.f64}\left(1, \mathsf{exp.f64}\left(\mathsf{*.f64}\left(\frac{1}{4}, \left({m}^{2}\right)\right)\right)\right) \]
            2. unpow2N/A

              \[\leadsto \mathsf{/.f64}\left(1, \mathsf{exp.f64}\left(\mathsf{*.f64}\left(\frac{1}{4}, \left(m \cdot m\right)\right)\right)\right) \]
            3. *-lowering-*.f6452.6%

              \[\leadsto \mathsf{/.f64}\left(1, \mathsf{exp.f64}\left(\mathsf{*.f64}\left(\frac{1}{4}, \mathsf{*.f64}\left(m, m\right)\right)\right)\right) \]
          13. Simplified52.6%

            \[\leadsto \frac{1}{e^{\color{blue}{0.25 \cdot \left(m \cdot m\right)}}} \]

          if 1.0000000000000001e-208 < n < 9.4e13

          1. Initial program 73.8%

            \[\cos \left(\frac{K \cdot \left(m + n\right)}{2} - M\right) \cdot e^{\left(-{\left(\frac{m + n}{2} - M\right)}^{2}\right) - \left(\ell - \left|m - n\right|\right)} \]
          2. Step-by-step derivation
            1. neg-sub0N/A

              \[\leadsto \cos \left(\frac{K \cdot \left(m + n\right)}{2} - M\right) \cdot e^{\left(0 - {\left(\frac{m + n}{2} - M\right)}^{2}\right) - \left(\ell - \left|m - n\right|\right)} \]
            2. associate--l-N/A

              \[\leadsto \cos \left(\frac{K \cdot \left(m + n\right)}{2} - M\right) \cdot e^{0 - \left({\left(\frac{m + n}{2} - M\right)}^{2} + \left(\ell - \left|m - n\right|\right)\right)} \]
            3. exp-diffN/A

              \[\leadsto \cos \left(\frac{K \cdot \left(m + n\right)}{2} - M\right) \cdot \frac{e^{0}}{\color{blue}{e^{{\left(\frac{m + n}{2} - M\right)}^{2} + \left(\ell - \left|m - n\right|\right)}}} \]
            4. associate-*r/N/A

              \[\leadsto \frac{\cos \left(\frac{K \cdot \left(m + n\right)}{2} - M\right) \cdot e^{0}}{\color{blue}{e^{{\left(\frac{m + n}{2} - M\right)}^{2} + \left(\ell - \left|m - n\right|\right)}}} \]
            5. exp-0N/A

              \[\leadsto \frac{\cos \left(\frac{K \cdot \left(m + n\right)}{2} - M\right) \cdot 1}{e^{{\left(\frac{m + n}{2} - M\right)}^{2} + \color{blue}{\left(\ell - \left|m - n\right|\right)}}} \]
            6. *-rgt-identityN/A

              \[\leadsto \frac{\cos \left(\frac{K \cdot \left(m + n\right)}{2} - M\right)}{e^{\color{blue}{{\left(\frac{m + n}{2} - M\right)}^{2} + \left(\ell - \left|m - n\right|\right)}}} \]
            7. /-lowering-/.f64N/A

              \[\leadsto \mathsf{/.f64}\left(\cos \left(\frac{K \cdot \left(m + n\right)}{2} - M\right), \color{blue}{\left(e^{{\left(\frac{m + n}{2} - M\right)}^{2} + \left(\ell - \left|m - n\right|\right)}\right)}\right) \]
          3. Simplified73.8%

            \[\leadsto \color{blue}{\frac{\cos \left(\frac{K \cdot \left(m + n\right)}{2} - M\right)}{e^{\left(\left(\frac{m + n}{2} - M\right) \cdot \left(\frac{m + n}{2} - M\right) + \ell\right) - \left|m - n\right|}}} \]
          4. Add Preprocessing
          5. Taylor expanded in K around 0

            \[\leadsto \mathsf{/.f64}\left(\color{blue}{\cos \left(\mathsf{neg}\left(M\right)\right)}, \mathsf{exp.f64}\left(\mathsf{\_.f64}\left(\mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\mathsf{/.f64}\left(\mathsf{+.f64}\left(m, n\right), 2\right), M\right), \mathsf{\_.f64}\left(\mathsf{/.f64}\left(\mathsf{+.f64}\left(m, n\right), 2\right), M\right)\right), \ell\right), \mathsf{fabs.f64}\left(\mathsf{\_.f64}\left(m, n\right)\right)\right)\right)\right) \]
          6. Step-by-step derivation
            1. cos-negN/A

              \[\leadsto \mathsf{/.f64}\left(\cos M, \mathsf{exp.f64}\left(\color{blue}{\mathsf{\_.f64}\left(\mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\mathsf{/.f64}\left(\mathsf{+.f64}\left(m, n\right), 2\right), M\right), \mathsf{\_.f64}\left(\mathsf{/.f64}\left(\mathsf{+.f64}\left(m, n\right), 2\right), M\right)\right), \ell\right), \mathsf{fabs.f64}\left(\mathsf{\_.f64}\left(m, n\right)\right)\right)}\right)\right) \]
            2. cos-lowering-cos.f6494.9%

              \[\leadsto \mathsf{/.f64}\left(\mathsf{cos.f64}\left(M\right), \mathsf{exp.f64}\left(\color{blue}{\mathsf{\_.f64}\left(\mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\mathsf{/.f64}\left(\mathsf{+.f64}\left(m, n\right), 2\right), M\right), \mathsf{\_.f64}\left(\mathsf{/.f64}\left(\mathsf{+.f64}\left(m, n\right), 2\right), M\right)\right), \ell\right), \mathsf{fabs.f64}\left(\mathsf{\_.f64}\left(m, n\right)\right)\right)}\right)\right) \]
          7. Simplified94.9%

            \[\leadsto \frac{\color{blue}{\cos M}}{e^{\left(\left(\frac{m + n}{2} - M\right) \cdot \left(\frac{m + n}{2} - M\right) + \ell\right) - \left|m - n\right|}} \]
          8. Taylor expanded in M around inf

            \[\leadsto \mathsf{/.f64}\left(\mathsf{cos.f64}\left(M\right), \mathsf{exp.f64}\left(\color{blue}{\left({M}^{2}\right)}\right)\right) \]
          9. Step-by-step derivation
            1. unpow2N/A

              \[\leadsto \mathsf{/.f64}\left(\mathsf{cos.f64}\left(M\right), \mathsf{exp.f64}\left(\left(M \cdot M\right)\right)\right) \]
            2. *-lowering-*.f6464.0%

              \[\leadsto \mathsf{/.f64}\left(\mathsf{cos.f64}\left(M\right), \mathsf{exp.f64}\left(\mathsf{*.f64}\left(M, M\right)\right)\right) \]
          10. Simplified64.0%

            \[\leadsto \frac{\cos M}{e^{\color{blue}{M \cdot M}}} \]

          if 9.4e13 < n

          1. Initial program 63.6%

            \[\cos \left(\frac{K \cdot \left(m + n\right)}{2} - M\right) \cdot e^{\left(-{\left(\frac{m + n}{2} - M\right)}^{2}\right) - \left(\ell - \left|m - n\right|\right)} \]
          2. Step-by-step derivation
            1. neg-sub0N/A

              \[\leadsto \cos \left(\frac{K \cdot \left(m + n\right)}{2} - M\right) \cdot e^{\left(0 - {\left(\frac{m + n}{2} - M\right)}^{2}\right) - \left(\ell - \left|m - n\right|\right)} \]
            2. associate--l-N/A

              \[\leadsto \cos \left(\frac{K \cdot \left(m + n\right)}{2} - M\right) \cdot e^{0 - \left({\left(\frac{m + n}{2} - M\right)}^{2} + \left(\ell - \left|m - n\right|\right)\right)} \]
            3. exp-diffN/A

              \[\leadsto \cos \left(\frac{K \cdot \left(m + n\right)}{2} - M\right) \cdot \frac{e^{0}}{\color{blue}{e^{{\left(\frac{m + n}{2} - M\right)}^{2} + \left(\ell - \left|m - n\right|\right)}}} \]
            4. associate-*r/N/A

              \[\leadsto \frac{\cos \left(\frac{K \cdot \left(m + n\right)}{2} - M\right) \cdot e^{0}}{\color{blue}{e^{{\left(\frac{m + n}{2} - M\right)}^{2} + \left(\ell - \left|m - n\right|\right)}}} \]
            5. exp-0N/A

              \[\leadsto \frac{\cos \left(\frac{K \cdot \left(m + n\right)}{2} - M\right) \cdot 1}{e^{{\left(\frac{m + n}{2} - M\right)}^{2} + \color{blue}{\left(\ell - \left|m - n\right|\right)}}} \]
            6. *-rgt-identityN/A

              \[\leadsto \frac{\cos \left(\frac{K \cdot \left(m + n\right)}{2} - M\right)}{e^{\color{blue}{{\left(\frac{m + n}{2} - M\right)}^{2} + \left(\ell - \left|m - n\right|\right)}}} \]
            7. /-lowering-/.f64N/A

              \[\leadsto \mathsf{/.f64}\left(\cos \left(\frac{K \cdot \left(m + n\right)}{2} - M\right), \color{blue}{\left(e^{{\left(\frac{m + n}{2} - M\right)}^{2} + \left(\ell - \left|m - n\right|\right)}\right)}\right) \]
          3. Simplified63.6%

            \[\leadsto \color{blue}{\frac{\cos \left(\frac{K \cdot \left(m + n\right)}{2} - M\right)}{e^{\left(\left(\frac{m + n}{2} - M\right) \cdot \left(\frac{m + n}{2} - M\right) + \ell\right) - \left|m - n\right|}}} \]
          4. Add Preprocessing
          5. Taylor expanded in K around 0

            \[\leadsto \mathsf{/.f64}\left(\color{blue}{\cos \left(\mathsf{neg}\left(M\right)\right)}, \mathsf{exp.f64}\left(\mathsf{\_.f64}\left(\mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\mathsf{/.f64}\left(\mathsf{+.f64}\left(m, n\right), 2\right), M\right), \mathsf{\_.f64}\left(\mathsf{/.f64}\left(\mathsf{+.f64}\left(m, n\right), 2\right), M\right)\right), \ell\right), \mathsf{fabs.f64}\left(\mathsf{\_.f64}\left(m, n\right)\right)\right)\right)\right) \]
          6. Step-by-step derivation
            1. cos-negN/A

              \[\leadsto \mathsf{/.f64}\left(\cos M, \mathsf{exp.f64}\left(\color{blue}{\mathsf{\_.f64}\left(\mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\mathsf{/.f64}\left(\mathsf{+.f64}\left(m, n\right), 2\right), M\right), \mathsf{\_.f64}\left(\mathsf{/.f64}\left(\mathsf{+.f64}\left(m, n\right), 2\right), M\right)\right), \ell\right), \mathsf{fabs.f64}\left(\mathsf{\_.f64}\left(m, n\right)\right)\right)}\right)\right) \]
            2. cos-lowering-cos.f64100.0%

              \[\leadsto \mathsf{/.f64}\left(\mathsf{cos.f64}\left(M\right), \mathsf{exp.f64}\left(\color{blue}{\mathsf{\_.f64}\left(\mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\mathsf{/.f64}\left(\mathsf{+.f64}\left(m, n\right), 2\right), M\right), \mathsf{\_.f64}\left(\mathsf{/.f64}\left(\mathsf{+.f64}\left(m, n\right), 2\right), M\right)\right), \ell\right), \mathsf{fabs.f64}\left(\mathsf{\_.f64}\left(m, n\right)\right)\right)}\right)\right) \]
          7. Simplified100.0%

            \[\leadsto \frac{\color{blue}{\cos M}}{e^{\left(\left(\frac{m + n}{2} - M\right) \cdot \left(\frac{m + n}{2} - M\right) + \ell\right) - \left|m - n\right|}} \]
          8. Taylor expanded in M around 0

            \[\leadsto \color{blue}{\frac{1}{e^{\left(\ell + \frac{1}{4} \cdot {\left(m + n\right)}^{2}\right) - \left|m - n\right|}}} \]
          9. Step-by-step derivation
            1. /-lowering-/.f64N/A

              \[\leadsto \mathsf{/.f64}\left(1, \color{blue}{\left(e^{\left(\ell + \frac{1}{4} \cdot {\left(m + n\right)}^{2}\right) - \left|m - n\right|}\right)}\right) \]
            2. exp-lowering-exp.f64N/A

              \[\leadsto \mathsf{/.f64}\left(1, \mathsf{exp.f64}\left(\left(\left(\ell + \frac{1}{4} \cdot {\left(m + n\right)}^{2}\right) - \left|m - n\right|\right)\right)\right) \]
            3. fabs-subN/A

              \[\leadsto \mathsf{/.f64}\left(1, \mathsf{exp.f64}\left(\left(\left(\ell + \frac{1}{4} \cdot {\left(m + n\right)}^{2}\right) - \left|n - m\right|\right)\right)\right) \]
            4. associate--l+N/A

              \[\leadsto \mathsf{/.f64}\left(1, \mathsf{exp.f64}\left(\left(\ell + \left(\frac{1}{4} \cdot {\left(m + n\right)}^{2} - \left|n - m\right|\right)\right)\right)\right) \]
            5. +-lowering-+.f64N/A

              \[\leadsto \mathsf{/.f64}\left(1, \mathsf{exp.f64}\left(\mathsf{+.f64}\left(\ell, \left(\frac{1}{4} \cdot {\left(m + n\right)}^{2} - \left|n - m\right|\right)\right)\right)\right) \]
            6. --lowering--.f64N/A

              \[\leadsto \mathsf{/.f64}\left(1, \mathsf{exp.f64}\left(\mathsf{+.f64}\left(\ell, \mathsf{\_.f64}\left(\left(\frac{1}{4} \cdot {\left(m + n\right)}^{2}\right), \left(\left|n - m\right|\right)\right)\right)\right)\right) \]
            7. *-lowering-*.f64N/A

              \[\leadsto \mathsf{/.f64}\left(1, \mathsf{exp.f64}\left(\mathsf{+.f64}\left(\ell, \mathsf{\_.f64}\left(\mathsf{*.f64}\left(\frac{1}{4}, \left({\left(m + n\right)}^{2}\right)\right), \left(\left|n - m\right|\right)\right)\right)\right)\right) \]
            8. unpow2N/A

              \[\leadsto \mathsf{/.f64}\left(1, \mathsf{exp.f64}\left(\mathsf{+.f64}\left(\ell, \mathsf{\_.f64}\left(\mathsf{*.f64}\left(\frac{1}{4}, \left(\left(m + n\right) \cdot \left(m + n\right)\right)\right), \left(\left|n - m\right|\right)\right)\right)\right)\right) \]
            9. *-lowering-*.f64N/A

              \[\leadsto \mathsf{/.f64}\left(1, \mathsf{exp.f64}\left(\mathsf{+.f64}\left(\ell, \mathsf{\_.f64}\left(\mathsf{*.f64}\left(\frac{1}{4}, \mathsf{*.f64}\left(\left(m + n\right), \left(m + n\right)\right)\right), \left(\left|n - m\right|\right)\right)\right)\right)\right) \]
            10. +-lowering-+.f64N/A

              \[\leadsto \mathsf{/.f64}\left(1, \mathsf{exp.f64}\left(\mathsf{+.f64}\left(\ell, \mathsf{\_.f64}\left(\mathsf{*.f64}\left(\frac{1}{4}, \mathsf{*.f64}\left(\mathsf{+.f64}\left(m, n\right), \left(m + n\right)\right)\right), \left(\left|n - m\right|\right)\right)\right)\right)\right) \]
            11. +-lowering-+.f64N/A

              \[\leadsto \mathsf{/.f64}\left(1, \mathsf{exp.f64}\left(\mathsf{+.f64}\left(\ell, \mathsf{\_.f64}\left(\mathsf{*.f64}\left(\frac{1}{4}, \mathsf{*.f64}\left(\mathsf{+.f64}\left(m, n\right), \mathsf{+.f64}\left(m, n\right)\right)\right), \left(\left|n - m\right|\right)\right)\right)\right)\right) \]
            12. sub-negN/A

              \[\leadsto \mathsf{/.f64}\left(1, \mathsf{exp.f64}\left(\mathsf{+.f64}\left(\ell, \mathsf{\_.f64}\left(\mathsf{*.f64}\left(\frac{1}{4}, \mathsf{*.f64}\left(\mathsf{+.f64}\left(m, n\right), \mathsf{+.f64}\left(m, n\right)\right)\right), \left(\left|n + \left(\mathsf{neg}\left(m\right)\right)\right|\right)\right)\right)\right)\right) \]
            13. mul-1-negN/A

              \[\leadsto \mathsf{/.f64}\left(1, \mathsf{exp.f64}\left(\mathsf{+.f64}\left(\ell, \mathsf{\_.f64}\left(\mathsf{*.f64}\left(\frac{1}{4}, \mathsf{*.f64}\left(\mathsf{+.f64}\left(m, n\right), \mathsf{+.f64}\left(m, n\right)\right)\right), \left(\left|n + -1 \cdot m\right|\right)\right)\right)\right)\right) \]
            14. fabs-lowering-fabs.f64N/A

              \[\leadsto \mathsf{/.f64}\left(1, \mathsf{exp.f64}\left(\mathsf{+.f64}\left(\ell, \mathsf{\_.f64}\left(\mathsf{*.f64}\left(\frac{1}{4}, \mathsf{*.f64}\left(\mathsf{+.f64}\left(m, n\right), \mathsf{+.f64}\left(m, n\right)\right)\right), \mathsf{fabs.f64}\left(\left(n + -1 \cdot m\right)\right)\right)\right)\right)\right) \]
            15. mul-1-negN/A

              \[\leadsto \mathsf{/.f64}\left(1, \mathsf{exp.f64}\left(\mathsf{+.f64}\left(\ell, \mathsf{\_.f64}\left(\mathsf{*.f64}\left(\frac{1}{4}, \mathsf{*.f64}\left(\mathsf{+.f64}\left(m, n\right), \mathsf{+.f64}\left(m, n\right)\right)\right), \mathsf{fabs.f64}\left(\left(n + \left(\mathsf{neg}\left(m\right)\right)\right)\right)\right)\right)\right)\right) \]
            16. sub-negN/A

              \[\leadsto \mathsf{/.f64}\left(1, \mathsf{exp.f64}\left(\mathsf{+.f64}\left(\ell, \mathsf{\_.f64}\left(\mathsf{*.f64}\left(\frac{1}{4}, \mathsf{*.f64}\left(\mathsf{+.f64}\left(m, n\right), \mathsf{+.f64}\left(m, n\right)\right)\right), \mathsf{fabs.f64}\left(\left(n - m\right)\right)\right)\right)\right)\right) \]
            17. --lowering--.f64100.0%

              \[\leadsto \mathsf{/.f64}\left(1, \mathsf{exp.f64}\left(\mathsf{+.f64}\left(\ell, \mathsf{\_.f64}\left(\mathsf{*.f64}\left(\frac{1}{4}, \mathsf{*.f64}\left(\mathsf{+.f64}\left(m, n\right), \mathsf{+.f64}\left(m, n\right)\right)\right), \mathsf{fabs.f64}\left(\mathsf{\_.f64}\left(n, m\right)\right)\right)\right)\right)\right) \]
          10. Simplified100.0%

            \[\leadsto \color{blue}{\frac{1}{e^{\ell + \left(0.25 \cdot \left(\left(m + n\right) \cdot \left(m + n\right)\right) - \left|n - m\right|\right)}}} \]
          11. Taylor expanded in n around inf

            \[\leadsto \mathsf{/.f64}\left(1, \mathsf{exp.f64}\left(\color{blue}{\left(\frac{1}{4} \cdot {n}^{2}\right)}\right)\right) \]
          12. Step-by-step derivation
            1. *-lowering-*.f64N/A

              \[\leadsto \mathsf{/.f64}\left(1, \mathsf{exp.f64}\left(\mathsf{*.f64}\left(\frac{1}{4}, \left({n}^{2}\right)\right)\right)\right) \]
            2. unpow2N/A

              \[\leadsto \mathsf{/.f64}\left(1, \mathsf{exp.f64}\left(\mathsf{*.f64}\left(\frac{1}{4}, \left(n \cdot n\right)\right)\right)\right) \]
            3. *-lowering-*.f64100.0%

              \[\leadsto \mathsf{/.f64}\left(1, \mathsf{exp.f64}\left(\mathsf{*.f64}\left(\frac{1}{4}, \mathsf{*.f64}\left(n, n\right)\right)\right)\right) \]
          13. Simplified100.0%

            \[\leadsto \frac{1}{e^{\color{blue}{0.25 \cdot \left(n \cdot n\right)}}} \]
        3. Recombined 3 regimes into one program.
        4. Add Preprocessing

        Alternative 10: 63.5% accurate, 2.0× speedup?

        \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;n \leq 5.5 \cdot 10^{-161}:\\ \;\;\;\;\frac{1}{e^{0.25 \cdot \left(m \cdot m\right)}}\\ \mathbf{elif}\;n \leq 94000000000000:\\ \;\;\;\;\frac{\cos M}{e^{\ell}}\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{e^{0.25 \cdot \left(n \cdot n\right)}}\\ \end{array} \end{array} \]
        (FPCore (K m n M l)
         :precision binary64
         (if (<= n 5.5e-161)
           (/ 1.0 (exp (* 0.25 (* m m))))
           (if (<= n 94000000000000.0)
             (/ (cos M) (exp l))
             (/ 1.0 (exp (* 0.25 (* n n)))))))
        double code(double K, double m, double n, double M, double l) {
        	double tmp;
        	if (n <= 5.5e-161) {
        		tmp = 1.0 / exp((0.25 * (m * m)));
        	} else if (n <= 94000000000000.0) {
        		tmp = cos(M) / exp(l);
        	} else {
        		tmp = 1.0 / exp((0.25 * (n * n)));
        	}
        	return tmp;
        }
        
        real(8) function code(k, m, n, m_1, l)
            real(8), intent (in) :: k
            real(8), intent (in) :: m
            real(8), intent (in) :: n
            real(8), intent (in) :: m_1
            real(8), intent (in) :: l
            real(8) :: tmp
            if (n <= 5.5d-161) then
                tmp = 1.0d0 / exp((0.25d0 * (m * m)))
            else if (n <= 94000000000000.0d0) then
                tmp = cos(m_1) / exp(l)
            else
                tmp = 1.0d0 / exp((0.25d0 * (n * n)))
            end if
            code = tmp
        end function
        
        public static double code(double K, double m, double n, double M, double l) {
        	double tmp;
        	if (n <= 5.5e-161) {
        		tmp = 1.0 / Math.exp((0.25 * (m * m)));
        	} else if (n <= 94000000000000.0) {
        		tmp = Math.cos(M) / Math.exp(l);
        	} else {
        		tmp = 1.0 / Math.exp((0.25 * (n * n)));
        	}
        	return tmp;
        }
        
        def code(K, m, n, M, l):
        	tmp = 0
        	if n <= 5.5e-161:
        		tmp = 1.0 / math.exp((0.25 * (m * m)))
        	elif n <= 94000000000000.0:
        		tmp = math.cos(M) / math.exp(l)
        	else:
        		tmp = 1.0 / math.exp((0.25 * (n * n)))
        	return tmp
        
        function code(K, m, n, M, l)
        	tmp = 0.0
        	if (n <= 5.5e-161)
        		tmp = Float64(1.0 / exp(Float64(0.25 * Float64(m * m))));
        	elseif (n <= 94000000000000.0)
        		tmp = Float64(cos(M) / exp(l));
        	else
        		tmp = Float64(1.0 / exp(Float64(0.25 * Float64(n * n))));
        	end
        	return tmp
        end
        
        function tmp_2 = code(K, m, n, M, l)
        	tmp = 0.0;
        	if (n <= 5.5e-161)
        		tmp = 1.0 / exp((0.25 * (m * m)));
        	elseif (n <= 94000000000000.0)
        		tmp = cos(M) / exp(l);
        	else
        		tmp = 1.0 / exp((0.25 * (n * n)));
        	end
        	tmp_2 = tmp;
        end
        
        code[K_, m_, n_, M_, l_] := If[LessEqual[n, 5.5e-161], N[(1.0 / N[Exp[N[(0.25 * N[(m * m), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[n, 94000000000000.0], N[(N[Cos[M], $MachinePrecision] / N[Exp[l], $MachinePrecision]), $MachinePrecision], N[(1.0 / N[Exp[N[(0.25 * N[(n * n), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]
        
        \begin{array}{l}
        
        \\
        \begin{array}{l}
        \mathbf{if}\;n \leq 5.5 \cdot 10^{-161}:\\
        \;\;\;\;\frac{1}{e^{0.25 \cdot \left(m \cdot m\right)}}\\
        
        \mathbf{elif}\;n \leq 94000000000000:\\
        \;\;\;\;\frac{\cos M}{e^{\ell}}\\
        
        \mathbf{else}:\\
        \;\;\;\;\frac{1}{e^{0.25 \cdot \left(n \cdot n\right)}}\\
        
        
        \end{array}
        \end{array}
        
        Derivation
        1. Split input into 3 regimes
        2. if n < 5.5e-161

          1. Initial program 73.5%

            \[\cos \left(\frac{K \cdot \left(m + n\right)}{2} - M\right) \cdot e^{\left(-{\left(\frac{m + n}{2} - M\right)}^{2}\right) - \left(\ell - \left|m - n\right|\right)} \]
          2. Step-by-step derivation
            1. neg-sub0N/A

              \[\leadsto \cos \left(\frac{K \cdot \left(m + n\right)}{2} - M\right) \cdot e^{\left(0 - {\left(\frac{m + n}{2} - M\right)}^{2}\right) - \left(\ell - \left|m - n\right|\right)} \]
            2. associate--l-N/A

              \[\leadsto \cos \left(\frac{K \cdot \left(m + n\right)}{2} - M\right) \cdot e^{0 - \left({\left(\frac{m + n}{2} - M\right)}^{2} + \left(\ell - \left|m - n\right|\right)\right)} \]
            3. exp-diffN/A

              \[\leadsto \cos \left(\frac{K \cdot \left(m + n\right)}{2} - M\right) \cdot \frac{e^{0}}{\color{blue}{e^{{\left(\frac{m + n}{2} - M\right)}^{2} + \left(\ell - \left|m - n\right|\right)}}} \]
            4. associate-*r/N/A

              \[\leadsto \frac{\cos \left(\frac{K \cdot \left(m + n\right)}{2} - M\right) \cdot e^{0}}{\color{blue}{e^{{\left(\frac{m + n}{2} - M\right)}^{2} + \left(\ell - \left|m - n\right|\right)}}} \]
            5. exp-0N/A

              \[\leadsto \frac{\cos \left(\frac{K \cdot \left(m + n\right)}{2} - M\right) \cdot 1}{e^{{\left(\frac{m + n}{2} - M\right)}^{2} + \color{blue}{\left(\ell - \left|m - n\right|\right)}}} \]
            6. *-rgt-identityN/A

              \[\leadsto \frac{\cos \left(\frac{K \cdot \left(m + n\right)}{2} - M\right)}{e^{\color{blue}{{\left(\frac{m + n}{2} - M\right)}^{2} + \left(\ell - \left|m - n\right|\right)}}} \]
            7. /-lowering-/.f64N/A

              \[\leadsto \mathsf{/.f64}\left(\cos \left(\frac{K \cdot \left(m + n\right)}{2} - M\right), \color{blue}{\left(e^{{\left(\frac{m + n}{2} - M\right)}^{2} + \left(\ell - \left|m - n\right|\right)}\right)}\right) \]
          3. Simplified73.5%

            \[\leadsto \color{blue}{\frac{\cos \left(\frac{K \cdot \left(m + n\right)}{2} - M\right)}{e^{\left(\left(\frac{m + n}{2} - M\right) \cdot \left(\frac{m + n}{2} - M\right) + \ell\right) - \left|m - n\right|}}} \]
          4. Add Preprocessing
          5. Taylor expanded in K around 0

            \[\leadsto \mathsf{/.f64}\left(\color{blue}{\cos \left(\mathsf{neg}\left(M\right)\right)}, \mathsf{exp.f64}\left(\mathsf{\_.f64}\left(\mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\mathsf{/.f64}\left(\mathsf{+.f64}\left(m, n\right), 2\right), M\right), \mathsf{\_.f64}\left(\mathsf{/.f64}\left(\mathsf{+.f64}\left(m, n\right), 2\right), M\right)\right), \ell\right), \mathsf{fabs.f64}\left(\mathsf{\_.f64}\left(m, n\right)\right)\right)\right)\right) \]
          6. Step-by-step derivation
            1. cos-negN/A

              \[\leadsto \mathsf{/.f64}\left(\cos M, \mathsf{exp.f64}\left(\color{blue}{\mathsf{\_.f64}\left(\mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\mathsf{/.f64}\left(\mathsf{+.f64}\left(m, n\right), 2\right), M\right), \mathsf{\_.f64}\left(\mathsf{/.f64}\left(\mathsf{+.f64}\left(m, n\right), 2\right), M\right)\right), \ell\right), \mathsf{fabs.f64}\left(\mathsf{\_.f64}\left(m, n\right)\right)\right)}\right)\right) \]
            2. cos-lowering-cos.f6493.2%

              \[\leadsto \mathsf{/.f64}\left(\mathsf{cos.f64}\left(M\right), \mathsf{exp.f64}\left(\color{blue}{\mathsf{\_.f64}\left(\mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\mathsf{/.f64}\left(\mathsf{+.f64}\left(m, n\right), 2\right), M\right), \mathsf{\_.f64}\left(\mathsf{/.f64}\left(\mathsf{+.f64}\left(m, n\right), 2\right), M\right)\right), \ell\right), \mathsf{fabs.f64}\left(\mathsf{\_.f64}\left(m, n\right)\right)\right)}\right)\right) \]
          7. Simplified93.2%

            \[\leadsto \frac{\color{blue}{\cos M}}{e^{\left(\left(\frac{m + n}{2} - M\right) \cdot \left(\frac{m + n}{2} - M\right) + \ell\right) - \left|m - n\right|}} \]
          8. Taylor expanded in M around 0

            \[\leadsto \color{blue}{\frac{1}{e^{\left(\ell + \frac{1}{4} \cdot {\left(m + n\right)}^{2}\right) - \left|m - n\right|}}} \]
          9. Step-by-step derivation
            1. /-lowering-/.f64N/A

              \[\leadsto \mathsf{/.f64}\left(1, \color{blue}{\left(e^{\left(\ell + \frac{1}{4} \cdot {\left(m + n\right)}^{2}\right) - \left|m - n\right|}\right)}\right) \]
            2. exp-lowering-exp.f64N/A

              \[\leadsto \mathsf{/.f64}\left(1, \mathsf{exp.f64}\left(\left(\left(\ell + \frac{1}{4} \cdot {\left(m + n\right)}^{2}\right) - \left|m - n\right|\right)\right)\right) \]
            3. fabs-subN/A

              \[\leadsto \mathsf{/.f64}\left(1, \mathsf{exp.f64}\left(\left(\left(\ell + \frac{1}{4} \cdot {\left(m + n\right)}^{2}\right) - \left|n - m\right|\right)\right)\right) \]
            4. associate--l+N/A

              \[\leadsto \mathsf{/.f64}\left(1, \mathsf{exp.f64}\left(\left(\ell + \left(\frac{1}{4} \cdot {\left(m + n\right)}^{2} - \left|n - m\right|\right)\right)\right)\right) \]
            5. +-lowering-+.f64N/A

              \[\leadsto \mathsf{/.f64}\left(1, \mathsf{exp.f64}\left(\mathsf{+.f64}\left(\ell, \left(\frac{1}{4} \cdot {\left(m + n\right)}^{2} - \left|n - m\right|\right)\right)\right)\right) \]
            6. --lowering--.f64N/A

              \[\leadsto \mathsf{/.f64}\left(1, \mathsf{exp.f64}\left(\mathsf{+.f64}\left(\ell, \mathsf{\_.f64}\left(\left(\frac{1}{4} \cdot {\left(m + n\right)}^{2}\right), \left(\left|n - m\right|\right)\right)\right)\right)\right) \]
            7. *-lowering-*.f64N/A

              \[\leadsto \mathsf{/.f64}\left(1, \mathsf{exp.f64}\left(\mathsf{+.f64}\left(\ell, \mathsf{\_.f64}\left(\mathsf{*.f64}\left(\frac{1}{4}, \left({\left(m + n\right)}^{2}\right)\right), \left(\left|n - m\right|\right)\right)\right)\right)\right) \]
            8. unpow2N/A

              \[\leadsto \mathsf{/.f64}\left(1, \mathsf{exp.f64}\left(\mathsf{+.f64}\left(\ell, \mathsf{\_.f64}\left(\mathsf{*.f64}\left(\frac{1}{4}, \left(\left(m + n\right) \cdot \left(m + n\right)\right)\right), \left(\left|n - m\right|\right)\right)\right)\right)\right) \]
            9. *-lowering-*.f64N/A

              \[\leadsto \mathsf{/.f64}\left(1, \mathsf{exp.f64}\left(\mathsf{+.f64}\left(\ell, \mathsf{\_.f64}\left(\mathsf{*.f64}\left(\frac{1}{4}, \mathsf{*.f64}\left(\left(m + n\right), \left(m + n\right)\right)\right), \left(\left|n - m\right|\right)\right)\right)\right)\right) \]
            10. +-lowering-+.f64N/A

              \[\leadsto \mathsf{/.f64}\left(1, \mathsf{exp.f64}\left(\mathsf{+.f64}\left(\ell, \mathsf{\_.f64}\left(\mathsf{*.f64}\left(\frac{1}{4}, \mathsf{*.f64}\left(\mathsf{+.f64}\left(m, n\right), \left(m + n\right)\right)\right), \left(\left|n - m\right|\right)\right)\right)\right)\right) \]
            11. +-lowering-+.f64N/A

              \[\leadsto \mathsf{/.f64}\left(1, \mathsf{exp.f64}\left(\mathsf{+.f64}\left(\ell, \mathsf{\_.f64}\left(\mathsf{*.f64}\left(\frac{1}{4}, \mathsf{*.f64}\left(\mathsf{+.f64}\left(m, n\right), \mathsf{+.f64}\left(m, n\right)\right)\right), \left(\left|n - m\right|\right)\right)\right)\right)\right) \]
            12. sub-negN/A

              \[\leadsto \mathsf{/.f64}\left(1, \mathsf{exp.f64}\left(\mathsf{+.f64}\left(\ell, \mathsf{\_.f64}\left(\mathsf{*.f64}\left(\frac{1}{4}, \mathsf{*.f64}\left(\mathsf{+.f64}\left(m, n\right), \mathsf{+.f64}\left(m, n\right)\right)\right), \left(\left|n + \left(\mathsf{neg}\left(m\right)\right)\right|\right)\right)\right)\right)\right) \]
            13. mul-1-negN/A

              \[\leadsto \mathsf{/.f64}\left(1, \mathsf{exp.f64}\left(\mathsf{+.f64}\left(\ell, \mathsf{\_.f64}\left(\mathsf{*.f64}\left(\frac{1}{4}, \mathsf{*.f64}\left(\mathsf{+.f64}\left(m, n\right), \mathsf{+.f64}\left(m, n\right)\right)\right), \left(\left|n + -1 \cdot m\right|\right)\right)\right)\right)\right) \]
            14. fabs-lowering-fabs.f64N/A

              \[\leadsto \mathsf{/.f64}\left(1, \mathsf{exp.f64}\left(\mathsf{+.f64}\left(\ell, \mathsf{\_.f64}\left(\mathsf{*.f64}\left(\frac{1}{4}, \mathsf{*.f64}\left(\mathsf{+.f64}\left(m, n\right), \mathsf{+.f64}\left(m, n\right)\right)\right), \mathsf{fabs.f64}\left(\left(n + -1 \cdot m\right)\right)\right)\right)\right)\right) \]
            15. mul-1-negN/A

              \[\leadsto \mathsf{/.f64}\left(1, \mathsf{exp.f64}\left(\mathsf{+.f64}\left(\ell, \mathsf{\_.f64}\left(\mathsf{*.f64}\left(\frac{1}{4}, \mathsf{*.f64}\left(\mathsf{+.f64}\left(m, n\right), \mathsf{+.f64}\left(m, n\right)\right)\right), \mathsf{fabs.f64}\left(\left(n + \left(\mathsf{neg}\left(m\right)\right)\right)\right)\right)\right)\right)\right) \]
            16. sub-negN/A

              \[\leadsto \mathsf{/.f64}\left(1, \mathsf{exp.f64}\left(\mathsf{+.f64}\left(\ell, \mathsf{\_.f64}\left(\mathsf{*.f64}\left(\frac{1}{4}, \mathsf{*.f64}\left(\mathsf{+.f64}\left(m, n\right), \mathsf{+.f64}\left(m, n\right)\right)\right), \mathsf{fabs.f64}\left(\left(n - m\right)\right)\right)\right)\right)\right) \]
            17. --lowering--.f6481.2%

              \[\leadsto \mathsf{/.f64}\left(1, \mathsf{exp.f64}\left(\mathsf{+.f64}\left(\ell, \mathsf{\_.f64}\left(\mathsf{*.f64}\left(\frac{1}{4}, \mathsf{*.f64}\left(\mathsf{+.f64}\left(m, n\right), \mathsf{+.f64}\left(m, n\right)\right)\right), \mathsf{fabs.f64}\left(\mathsf{\_.f64}\left(n, m\right)\right)\right)\right)\right)\right) \]
          10. Simplified81.2%

            \[\leadsto \color{blue}{\frac{1}{e^{\ell + \left(0.25 \cdot \left(\left(m + n\right) \cdot \left(m + n\right)\right) - \left|n - m\right|\right)}}} \]
          11. Taylor expanded in m around inf

            \[\leadsto \mathsf{/.f64}\left(1, \mathsf{exp.f64}\left(\color{blue}{\left(\frac{1}{4} \cdot {m}^{2}\right)}\right)\right) \]
          12. Step-by-step derivation
            1. *-lowering-*.f64N/A

              \[\leadsto \mathsf{/.f64}\left(1, \mathsf{exp.f64}\left(\mathsf{*.f64}\left(\frac{1}{4}, \left({m}^{2}\right)\right)\right)\right) \]
            2. unpow2N/A

              \[\leadsto \mathsf{/.f64}\left(1, \mathsf{exp.f64}\left(\mathsf{*.f64}\left(\frac{1}{4}, \left(m \cdot m\right)\right)\right)\right) \]
            3. *-lowering-*.f6453.3%

              \[\leadsto \mathsf{/.f64}\left(1, \mathsf{exp.f64}\left(\mathsf{*.f64}\left(\frac{1}{4}, \mathsf{*.f64}\left(m, m\right)\right)\right)\right) \]
          13. Simplified53.3%

            \[\leadsto \frac{1}{e^{\color{blue}{0.25 \cdot \left(m \cdot m\right)}}} \]

          if 5.5e-161 < n < 9.4e13

          1. Initial program 71.6%

            \[\cos \left(\frac{K \cdot \left(m + n\right)}{2} - M\right) \cdot e^{\left(-{\left(\frac{m + n}{2} - M\right)}^{2}\right) - \left(\ell - \left|m - n\right|\right)} \]
          2. Step-by-step derivation
            1. neg-sub0N/A

              \[\leadsto \cos \left(\frac{K \cdot \left(m + n\right)}{2} - M\right) \cdot e^{\left(0 - {\left(\frac{m + n}{2} - M\right)}^{2}\right) - \left(\ell - \left|m - n\right|\right)} \]
            2. associate--l-N/A

              \[\leadsto \cos \left(\frac{K \cdot \left(m + n\right)}{2} - M\right) \cdot e^{0 - \left({\left(\frac{m + n}{2} - M\right)}^{2} + \left(\ell - \left|m - n\right|\right)\right)} \]
            3. exp-diffN/A

              \[\leadsto \cos \left(\frac{K \cdot \left(m + n\right)}{2} - M\right) \cdot \frac{e^{0}}{\color{blue}{e^{{\left(\frac{m + n}{2} - M\right)}^{2} + \left(\ell - \left|m - n\right|\right)}}} \]
            4. associate-*r/N/A

              \[\leadsto \frac{\cos \left(\frac{K \cdot \left(m + n\right)}{2} - M\right) \cdot e^{0}}{\color{blue}{e^{{\left(\frac{m + n}{2} - M\right)}^{2} + \left(\ell - \left|m - n\right|\right)}}} \]
            5. exp-0N/A

              \[\leadsto \frac{\cos \left(\frac{K \cdot \left(m + n\right)}{2} - M\right) \cdot 1}{e^{{\left(\frac{m + n}{2} - M\right)}^{2} + \color{blue}{\left(\ell - \left|m - n\right|\right)}}} \]
            6. *-rgt-identityN/A

              \[\leadsto \frac{\cos \left(\frac{K \cdot \left(m + n\right)}{2} - M\right)}{e^{\color{blue}{{\left(\frac{m + n}{2} - M\right)}^{2} + \left(\ell - \left|m - n\right|\right)}}} \]
            7. /-lowering-/.f64N/A

              \[\leadsto \mathsf{/.f64}\left(\cos \left(\frac{K \cdot \left(m + n\right)}{2} - M\right), \color{blue}{\left(e^{{\left(\frac{m + n}{2} - M\right)}^{2} + \left(\ell - \left|m - n\right|\right)}\right)}\right) \]
          3. Simplified71.6%

            \[\leadsto \color{blue}{\frac{\cos \left(\frac{K \cdot \left(m + n\right)}{2} - M\right)}{e^{\left(\left(\frac{m + n}{2} - M\right) \cdot \left(\frac{m + n}{2} - M\right) + \ell\right) - \left|m - n\right|}}} \]
          4. Add Preprocessing
          5. Taylor expanded in K around 0

            \[\leadsto \mathsf{/.f64}\left(\color{blue}{\cos \left(\mathsf{neg}\left(M\right)\right)}, \mathsf{exp.f64}\left(\mathsf{\_.f64}\left(\mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\mathsf{/.f64}\left(\mathsf{+.f64}\left(m, n\right), 2\right), M\right), \mathsf{\_.f64}\left(\mathsf{/.f64}\left(\mathsf{+.f64}\left(m, n\right), 2\right), M\right)\right), \ell\right), \mathsf{fabs.f64}\left(\mathsf{\_.f64}\left(m, n\right)\right)\right)\right)\right) \]
          6. Step-by-step derivation
            1. cos-negN/A

              \[\leadsto \mathsf{/.f64}\left(\cos M, \mathsf{exp.f64}\left(\color{blue}{\mathsf{\_.f64}\left(\mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\mathsf{/.f64}\left(\mathsf{+.f64}\left(m, n\right), 2\right), M\right), \mathsf{\_.f64}\left(\mathsf{/.f64}\left(\mathsf{+.f64}\left(m, n\right), 2\right), M\right)\right), \ell\right), \mathsf{fabs.f64}\left(\mathsf{\_.f64}\left(m, n\right)\right)\right)}\right)\right) \]
            2. cos-lowering-cos.f6493.0%

              \[\leadsto \mathsf{/.f64}\left(\mathsf{cos.f64}\left(M\right), \mathsf{exp.f64}\left(\color{blue}{\mathsf{\_.f64}\left(\mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\mathsf{/.f64}\left(\mathsf{+.f64}\left(m, n\right), 2\right), M\right), \mathsf{\_.f64}\left(\mathsf{/.f64}\left(\mathsf{+.f64}\left(m, n\right), 2\right), M\right)\right), \ell\right), \mathsf{fabs.f64}\left(\mathsf{\_.f64}\left(m, n\right)\right)\right)}\right)\right) \]
          7. Simplified93.0%

            \[\leadsto \frac{\color{blue}{\cos M}}{e^{\left(\left(\frac{m + n}{2} - M\right) \cdot \left(\frac{m + n}{2} - M\right) + \ell\right) - \left|m - n\right|}} \]
          8. Taylor expanded in l around inf

            \[\leadsto \mathsf{/.f64}\left(\mathsf{cos.f64}\left(M\right), \mathsf{exp.f64}\left(\color{blue}{\ell}\right)\right) \]
          9. Step-by-step derivation
            1. Simplified41.8%

              \[\leadsto \frac{\cos M}{e^{\color{blue}{\ell}}} \]

            if 9.4e13 < n

            1. Initial program 63.6%

              \[\cos \left(\frac{K \cdot \left(m + n\right)}{2} - M\right) \cdot e^{\left(-{\left(\frac{m + n}{2} - M\right)}^{2}\right) - \left(\ell - \left|m - n\right|\right)} \]
            2. Step-by-step derivation
              1. neg-sub0N/A

                \[\leadsto \cos \left(\frac{K \cdot \left(m + n\right)}{2} - M\right) \cdot e^{\left(0 - {\left(\frac{m + n}{2} - M\right)}^{2}\right) - \left(\ell - \left|m - n\right|\right)} \]
              2. associate--l-N/A

                \[\leadsto \cos \left(\frac{K \cdot \left(m + n\right)}{2} - M\right) \cdot e^{0 - \left({\left(\frac{m + n}{2} - M\right)}^{2} + \left(\ell - \left|m - n\right|\right)\right)} \]
              3. exp-diffN/A

                \[\leadsto \cos \left(\frac{K \cdot \left(m + n\right)}{2} - M\right) \cdot \frac{e^{0}}{\color{blue}{e^{{\left(\frac{m + n}{2} - M\right)}^{2} + \left(\ell - \left|m - n\right|\right)}}} \]
              4. associate-*r/N/A

                \[\leadsto \frac{\cos \left(\frac{K \cdot \left(m + n\right)}{2} - M\right) \cdot e^{0}}{\color{blue}{e^{{\left(\frac{m + n}{2} - M\right)}^{2} + \left(\ell - \left|m - n\right|\right)}}} \]
              5. exp-0N/A

                \[\leadsto \frac{\cos \left(\frac{K \cdot \left(m + n\right)}{2} - M\right) \cdot 1}{e^{{\left(\frac{m + n}{2} - M\right)}^{2} + \color{blue}{\left(\ell - \left|m - n\right|\right)}}} \]
              6. *-rgt-identityN/A

                \[\leadsto \frac{\cos \left(\frac{K \cdot \left(m + n\right)}{2} - M\right)}{e^{\color{blue}{{\left(\frac{m + n}{2} - M\right)}^{2} + \left(\ell - \left|m - n\right|\right)}}} \]
              7. /-lowering-/.f64N/A

                \[\leadsto \mathsf{/.f64}\left(\cos \left(\frac{K \cdot \left(m + n\right)}{2} - M\right), \color{blue}{\left(e^{{\left(\frac{m + n}{2} - M\right)}^{2} + \left(\ell - \left|m - n\right|\right)}\right)}\right) \]
            3. Simplified63.6%

              \[\leadsto \color{blue}{\frac{\cos \left(\frac{K \cdot \left(m + n\right)}{2} - M\right)}{e^{\left(\left(\frac{m + n}{2} - M\right) \cdot \left(\frac{m + n}{2} - M\right) + \ell\right) - \left|m - n\right|}}} \]
            4. Add Preprocessing
            5. Taylor expanded in K around 0

              \[\leadsto \mathsf{/.f64}\left(\color{blue}{\cos \left(\mathsf{neg}\left(M\right)\right)}, \mathsf{exp.f64}\left(\mathsf{\_.f64}\left(\mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\mathsf{/.f64}\left(\mathsf{+.f64}\left(m, n\right), 2\right), M\right), \mathsf{\_.f64}\left(\mathsf{/.f64}\left(\mathsf{+.f64}\left(m, n\right), 2\right), M\right)\right), \ell\right), \mathsf{fabs.f64}\left(\mathsf{\_.f64}\left(m, n\right)\right)\right)\right)\right) \]
            6. Step-by-step derivation
              1. cos-negN/A

                \[\leadsto \mathsf{/.f64}\left(\cos M, \mathsf{exp.f64}\left(\color{blue}{\mathsf{\_.f64}\left(\mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\mathsf{/.f64}\left(\mathsf{+.f64}\left(m, n\right), 2\right), M\right), \mathsf{\_.f64}\left(\mathsf{/.f64}\left(\mathsf{+.f64}\left(m, n\right), 2\right), M\right)\right), \ell\right), \mathsf{fabs.f64}\left(\mathsf{\_.f64}\left(m, n\right)\right)\right)}\right)\right) \]
              2. cos-lowering-cos.f64100.0%

                \[\leadsto \mathsf{/.f64}\left(\mathsf{cos.f64}\left(M\right), \mathsf{exp.f64}\left(\color{blue}{\mathsf{\_.f64}\left(\mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\mathsf{/.f64}\left(\mathsf{+.f64}\left(m, n\right), 2\right), M\right), \mathsf{\_.f64}\left(\mathsf{/.f64}\left(\mathsf{+.f64}\left(m, n\right), 2\right), M\right)\right), \ell\right), \mathsf{fabs.f64}\left(\mathsf{\_.f64}\left(m, n\right)\right)\right)}\right)\right) \]
            7. Simplified100.0%

              \[\leadsto \frac{\color{blue}{\cos M}}{e^{\left(\left(\frac{m + n}{2} - M\right) \cdot \left(\frac{m + n}{2} - M\right) + \ell\right) - \left|m - n\right|}} \]
            8. Taylor expanded in M around 0

              \[\leadsto \color{blue}{\frac{1}{e^{\left(\ell + \frac{1}{4} \cdot {\left(m + n\right)}^{2}\right) - \left|m - n\right|}}} \]
            9. Step-by-step derivation
              1. /-lowering-/.f64N/A

                \[\leadsto \mathsf{/.f64}\left(1, \color{blue}{\left(e^{\left(\ell + \frac{1}{4} \cdot {\left(m + n\right)}^{2}\right) - \left|m - n\right|}\right)}\right) \]
              2. exp-lowering-exp.f64N/A

                \[\leadsto \mathsf{/.f64}\left(1, \mathsf{exp.f64}\left(\left(\left(\ell + \frac{1}{4} \cdot {\left(m + n\right)}^{2}\right) - \left|m - n\right|\right)\right)\right) \]
              3. fabs-subN/A

                \[\leadsto \mathsf{/.f64}\left(1, \mathsf{exp.f64}\left(\left(\left(\ell + \frac{1}{4} \cdot {\left(m + n\right)}^{2}\right) - \left|n - m\right|\right)\right)\right) \]
              4. associate--l+N/A

                \[\leadsto \mathsf{/.f64}\left(1, \mathsf{exp.f64}\left(\left(\ell + \left(\frac{1}{4} \cdot {\left(m + n\right)}^{2} - \left|n - m\right|\right)\right)\right)\right) \]
              5. +-lowering-+.f64N/A

                \[\leadsto \mathsf{/.f64}\left(1, \mathsf{exp.f64}\left(\mathsf{+.f64}\left(\ell, \left(\frac{1}{4} \cdot {\left(m + n\right)}^{2} - \left|n - m\right|\right)\right)\right)\right) \]
              6. --lowering--.f64N/A

                \[\leadsto \mathsf{/.f64}\left(1, \mathsf{exp.f64}\left(\mathsf{+.f64}\left(\ell, \mathsf{\_.f64}\left(\left(\frac{1}{4} \cdot {\left(m + n\right)}^{2}\right), \left(\left|n - m\right|\right)\right)\right)\right)\right) \]
              7. *-lowering-*.f64N/A

                \[\leadsto \mathsf{/.f64}\left(1, \mathsf{exp.f64}\left(\mathsf{+.f64}\left(\ell, \mathsf{\_.f64}\left(\mathsf{*.f64}\left(\frac{1}{4}, \left({\left(m + n\right)}^{2}\right)\right), \left(\left|n - m\right|\right)\right)\right)\right)\right) \]
              8. unpow2N/A

                \[\leadsto \mathsf{/.f64}\left(1, \mathsf{exp.f64}\left(\mathsf{+.f64}\left(\ell, \mathsf{\_.f64}\left(\mathsf{*.f64}\left(\frac{1}{4}, \left(\left(m + n\right) \cdot \left(m + n\right)\right)\right), \left(\left|n - m\right|\right)\right)\right)\right)\right) \]
              9. *-lowering-*.f64N/A

                \[\leadsto \mathsf{/.f64}\left(1, \mathsf{exp.f64}\left(\mathsf{+.f64}\left(\ell, \mathsf{\_.f64}\left(\mathsf{*.f64}\left(\frac{1}{4}, \mathsf{*.f64}\left(\left(m + n\right), \left(m + n\right)\right)\right), \left(\left|n - m\right|\right)\right)\right)\right)\right) \]
              10. +-lowering-+.f64N/A

                \[\leadsto \mathsf{/.f64}\left(1, \mathsf{exp.f64}\left(\mathsf{+.f64}\left(\ell, \mathsf{\_.f64}\left(\mathsf{*.f64}\left(\frac{1}{4}, \mathsf{*.f64}\left(\mathsf{+.f64}\left(m, n\right), \left(m + n\right)\right)\right), \left(\left|n - m\right|\right)\right)\right)\right)\right) \]
              11. +-lowering-+.f64N/A

                \[\leadsto \mathsf{/.f64}\left(1, \mathsf{exp.f64}\left(\mathsf{+.f64}\left(\ell, \mathsf{\_.f64}\left(\mathsf{*.f64}\left(\frac{1}{4}, \mathsf{*.f64}\left(\mathsf{+.f64}\left(m, n\right), \mathsf{+.f64}\left(m, n\right)\right)\right), \left(\left|n - m\right|\right)\right)\right)\right)\right) \]
              12. sub-negN/A

                \[\leadsto \mathsf{/.f64}\left(1, \mathsf{exp.f64}\left(\mathsf{+.f64}\left(\ell, \mathsf{\_.f64}\left(\mathsf{*.f64}\left(\frac{1}{4}, \mathsf{*.f64}\left(\mathsf{+.f64}\left(m, n\right), \mathsf{+.f64}\left(m, n\right)\right)\right), \left(\left|n + \left(\mathsf{neg}\left(m\right)\right)\right|\right)\right)\right)\right)\right) \]
              13. mul-1-negN/A

                \[\leadsto \mathsf{/.f64}\left(1, \mathsf{exp.f64}\left(\mathsf{+.f64}\left(\ell, \mathsf{\_.f64}\left(\mathsf{*.f64}\left(\frac{1}{4}, \mathsf{*.f64}\left(\mathsf{+.f64}\left(m, n\right), \mathsf{+.f64}\left(m, n\right)\right)\right), \left(\left|n + -1 \cdot m\right|\right)\right)\right)\right)\right) \]
              14. fabs-lowering-fabs.f64N/A

                \[\leadsto \mathsf{/.f64}\left(1, \mathsf{exp.f64}\left(\mathsf{+.f64}\left(\ell, \mathsf{\_.f64}\left(\mathsf{*.f64}\left(\frac{1}{4}, \mathsf{*.f64}\left(\mathsf{+.f64}\left(m, n\right), \mathsf{+.f64}\left(m, n\right)\right)\right), \mathsf{fabs.f64}\left(\left(n + -1 \cdot m\right)\right)\right)\right)\right)\right) \]
              15. mul-1-negN/A

                \[\leadsto \mathsf{/.f64}\left(1, \mathsf{exp.f64}\left(\mathsf{+.f64}\left(\ell, \mathsf{\_.f64}\left(\mathsf{*.f64}\left(\frac{1}{4}, \mathsf{*.f64}\left(\mathsf{+.f64}\left(m, n\right), \mathsf{+.f64}\left(m, n\right)\right)\right), \mathsf{fabs.f64}\left(\left(n + \left(\mathsf{neg}\left(m\right)\right)\right)\right)\right)\right)\right)\right) \]
              16. sub-negN/A

                \[\leadsto \mathsf{/.f64}\left(1, \mathsf{exp.f64}\left(\mathsf{+.f64}\left(\ell, \mathsf{\_.f64}\left(\mathsf{*.f64}\left(\frac{1}{4}, \mathsf{*.f64}\left(\mathsf{+.f64}\left(m, n\right), \mathsf{+.f64}\left(m, n\right)\right)\right), \mathsf{fabs.f64}\left(\left(n - m\right)\right)\right)\right)\right)\right) \]
              17. --lowering--.f64100.0%

                \[\leadsto \mathsf{/.f64}\left(1, \mathsf{exp.f64}\left(\mathsf{+.f64}\left(\ell, \mathsf{\_.f64}\left(\mathsf{*.f64}\left(\frac{1}{4}, \mathsf{*.f64}\left(\mathsf{+.f64}\left(m, n\right), \mathsf{+.f64}\left(m, n\right)\right)\right), \mathsf{fabs.f64}\left(\mathsf{\_.f64}\left(n, m\right)\right)\right)\right)\right)\right) \]
            10. Simplified100.0%

              \[\leadsto \color{blue}{\frac{1}{e^{\ell + \left(0.25 \cdot \left(\left(m + n\right) \cdot \left(m + n\right)\right) - \left|n - m\right|\right)}}} \]
            11. Taylor expanded in n around inf

              \[\leadsto \mathsf{/.f64}\left(1, \mathsf{exp.f64}\left(\color{blue}{\left(\frac{1}{4} \cdot {n}^{2}\right)}\right)\right) \]
            12. Step-by-step derivation
              1. *-lowering-*.f64N/A

                \[\leadsto \mathsf{/.f64}\left(1, \mathsf{exp.f64}\left(\mathsf{*.f64}\left(\frac{1}{4}, \left({n}^{2}\right)\right)\right)\right) \]
              2. unpow2N/A

                \[\leadsto \mathsf{/.f64}\left(1, \mathsf{exp.f64}\left(\mathsf{*.f64}\left(\frac{1}{4}, \left(n \cdot n\right)\right)\right)\right) \]
              3. *-lowering-*.f64100.0%

                \[\leadsto \mathsf{/.f64}\left(1, \mathsf{exp.f64}\left(\mathsf{*.f64}\left(\frac{1}{4}, \mathsf{*.f64}\left(n, n\right)\right)\right)\right) \]
            13. Simplified100.0%

              \[\leadsto \frac{1}{e^{\color{blue}{0.25 \cdot \left(n \cdot n\right)}}} \]
          10. Recombined 3 regimes into one program.
          11. Add Preprocessing

          Alternative 11: 64.4% accurate, 3.6× speedup?

          \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;n \leq 3.6 \cdot 10^{-73}:\\ \;\;\;\;\frac{1}{e^{0.25 \cdot \left(m \cdot m\right)}}\\ \mathbf{elif}\;n \leq 94000000000000:\\ \;\;\;\;\frac{1 + \left(M \cdot M\right) \cdot -0.5}{e^{\ell}}\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{e^{0.25 \cdot \left(n \cdot n\right)}}\\ \end{array} \end{array} \]
          (FPCore (K m n M l)
           :precision binary64
           (if (<= n 3.6e-73)
             (/ 1.0 (exp (* 0.25 (* m m))))
             (if (<= n 94000000000000.0)
               (/ (+ 1.0 (* (* M M) -0.5)) (exp l))
               (/ 1.0 (exp (* 0.25 (* n n)))))))
          double code(double K, double m, double n, double M, double l) {
          	double tmp;
          	if (n <= 3.6e-73) {
          		tmp = 1.0 / exp((0.25 * (m * m)));
          	} else if (n <= 94000000000000.0) {
          		tmp = (1.0 + ((M * M) * -0.5)) / exp(l);
          	} else {
          		tmp = 1.0 / exp((0.25 * (n * n)));
          	}
          	return tmp;
          }
          
          real(8) function code(k, m, n, m_1, l)
              real(8), intent (in) :: k
              real(8), intent (in) :: m
              real(8), intent (in) :: n
              real(8), intent (in) :: m_1
              real(8), intent (in) :: l
              real(8) :: tmp
              if (n <= 3.6d-73) then
                  tmp = 1.0d0 / exp((0.25d0 * (m * m)))
              else if (n <= 94000000000000.0d0) then
                  tmp = (1.0d0 + ((m_1 * m_1) * (-0.5d0))) / exp(l)
              else
                  tmp = 1.0d0 / exp((0.25d0 * (n * n)))
              end if
              code = tmp
          end function
          
          public static double code(double K, double m, double n, double M, double l) {
          	double tmp;
          	if (n <= 3.6e-73) {
          		tmp = 1.0 / Math.exp((0.25 * (m * m)));
          	} else if (n <= 94000000000000.0) {
          		tmp = (1.0 + ((M * M) * -0.5)) / Math.exp(l);
          	} else {
          		tmp = 1.0 / Math.exp((0.25 * (n * n)));
          	}
          	return tmp;
          }
          
          def code(K, m, n, M, l):
          	tmp = 0
          	if n <= 3.6e-73:
          		tmp = 1.0 / math.exp((0.25 * (m * m)))
          	elif n <= 94000000000000.0:
          		tmp = (1.0 + ((M * M) * -0.5)) / math.exp(l)
          	else:
          		tmp = 1.0 / math.exp((0.25 * (n * n)))
          	return tmp
          
          function code(K, m, n, M, l)
          	tmp = 0.0
          	if (n <= 3.6e-73)
          		tmp = Float64(1.0 / exp(Float64(0.25 * Float64(m * m))));
          	elseif (n <= 94000000000000.0)
          		tmp = Float64(Float64(1.0 + Float64(Float64(M * M) * -0.5)) / exp(l));
          	else
          		tmp = Float64(1.0 / exp(Float64(0.25 * Float64(n * n))));
          	end
          	return tmp
          end
          
          function tmp_2 = code(K, m, n, M, l)
          	tmp = 0.0;
          	if (n <= 3.6e-73)
          		tmp = 1.0 / exp((0.25 * (m * m)));
          	elseif (n <= 94000000000000.0)
          		tmp = (1.0 + ((M * M) * -0.5)) / exp(l);
          	else
          		tmp = 1.0 / exp((0.25 * (n * n)));
          	end
          	tmp_2 = tmp;
          end
          
          code[K_, m_, n_, M_, l_] := If[LessEqual[n, 3.6e-73], N[(1.0 / N[Exp[N[(0.25 * N[(m * m), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[n, 94000000000000.0], N[(N[(1.0 + N[(N[(M * M), $MachinePrecision] * -0.5), $MachinePrecision]), $MachinePrecision] / N[Exp[l], $MachinePrecision]), $MachinePrecision], N[(1.0 / N[Exp[N[(0.25 * N[(n * n), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]
          
          \begin{array}{l}
          
          \\
          \begin{array}{l}
          \mathbf{if}\;n \leq 3.6 \cdot 10^{-73}:\\
          \;\;\;\;\frac{1}{e^{0.25 \cdot \left(m \cdot m\right)}}\\
          
          \mathbf{elif}\;n \leq 94000000000000:\\
          \;\;\;\;\frac{1 + \left(M \cdot M\right) \cdot -0.5}{e^{\ell}}\\
          
          \mathbf{else}:\\
          \;\;\;\;\frac{1}{e^{0.25 \cdot \left(n \cdot n\right)}}\\
          
          
          \end{array}
          \end{array}
          
          Derivation
          1. Split input into 3 regimes
          2. if n < 3.5999999999999999e-73

            1. Initial program 74.4%

              \[\cos \left(\frac{K \cdot \left(m + n\right)}{2} - M\right) \cdot e^{\left(-{\left(\frac{m + n}{2} - M\right)}^{2}\right) - \left(\ell - \left|m - n\right|\right)} \]
            2. Step-by-step derivation
              1. neg-sub0N/A

                \[\leadsto \cos \left(\frac{K \cdot \left(m + n\right)}{2} - M\right) \cdot e^{\left(0 - {\left(\frac{m + n}{2} - M\right)}^{2}\right) - \left(\ell - \left|m - n\right|\right)} \]
              2. associate--l-N/A

                \[\leadsto \cos \left(\frac{K \cdot \left(m + n\right)}{2} - M\right) \cdot e^{0 - \left({\left(\frac{m + n}{2} - M\right)}^{2} + \left(\ell - \left|m - n\right|\right)\right)} \]
              3. exp-diffN/A

                \[\leadsto \cos \left(\frac{K \cdot \left(m + n\right)}{2} - M\right) \cdot \frac{e^{0}}{\color{blue}{e^{{\left(\frac{m + n}{2} - M\right)}^{2} + \left(\ell - \left|m - n\right|\right)}}} \]
              4. associate-*r/N/A

                \[\leadsto \frac{\cos \left(\frac{K \cdot \left(m + n\right)}{2} - M\right) \cdot e^{0}}{\color{blue}{e^{{\left(\frac{m + n}{2} - M\right)}^{2} + \left(\ell - \left|m - n\right|\right)}}} \]
              5. exp-0N/A

                \[\leadsto \frac{\cos \left(\frac{K \cdot \left(m + n\right)}{2} - M\right) \cdot 1}{e^{{\left(\frac{m + n}{2} - M\right)}^{2} + \color{blue}{\left(\ell - \left|m - n\right|\right)}}} \]
              6. *-rgt-identityN/A

                \[\leadsto \frac{\cos \left(\frac{K \cdot \left(m + n\right)}{2} - M\right)}{e^{\color{blue}{{\left(\frac{m + n}{2} - M\right)}^{2} + \left(\ell - \left|m - n\right|\right)}}} \]
              7. /-lowering-/.f64N/A

                \[\leadsto \mathsf{/.f64}\left(\cos \left(\frac{K \cdot \left(m + n\right)}{2} - M\right), \color{blue}{\left(e^{{\left(\frac{m + n}{2} - M\right)}^{2} + \left(\ell - \left|m - n\right|\right)}\right)}\right) \]
            3. Simplified74.4%

              \[\leadsto \color{blue}{\frac{\cos \left(\frac{K \cdot \left(m + n\right)}{2} - M\right)}{e^{\left(\left(\frac{m + n}{2} - M\right) \cdot \left(\frac{m + n}{2} - M\right) + \ell\right) - \left|m - n\right|}}} \]
            4. Add Preprocessing
            5. Taylor expanded in K around 0

              \[\leadsto \mathsf{/.f64}\left(\color{blue}{\cos \left(\mathsf{neg}\left(M\right)\right)}, \mathsf{exp.f64}\left(\mathsf{\_.f64}\left(\mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\mathsf{/.f64}\left(\mathsf{+.f64}\left(m, n\right), 2\right), M\right), \mathsf{\_.f64}\left(\mathsf{/.f64}\left(\mathsf{+.f64}\left(m, n\right), 2\right), M\right)\right), \ell\right), \mathsf{fabs.f64}\left(\mathsf{\_.f64}\left(m, n\right)\right)\right)\right)\right) \]
            6. Step-by-step derivation
              1. cos-negN/A

                \[\leadsto \mathsf{/.f64}\left(\cos M, \mathsf{exp.f64}\left(\color{blue}{\mathsf{\_.f64}\left(\mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\mathsf{/.f64}\left(\mathsf{+.f64}\left(m, n\right), 2\right), M\right), \mathsf{\_.f64}\left(\mathsf{/.f64}\left(\mathsf{+.f64}\left(m, n\right), 2\right), M\right)\right), \ell\right), \mathsf{fabs.f64}\left(\mathsf{\_.f64}\left(m, n\right)\right)\right)}\right)\right) \]
              2. cos-lowering-cos.f6493.8%

                \[\leadsto \mathsf{/.f64}\left(\mathsf{cos.f64}\left(M\right), \mathsf{exp.f64}\left(\color{blue}{\mathsf{\_.f64}\left(\mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\mathsf{/.f64}\left(\mathsf{+.f64}\left(m, n\right), 2\right), M\right), \mathsf{\_.f64}\left(\mathsf{/.f64}\left(\mathsf{+.f64}\left(m, n\right), 2\right), M\right)\right), \ell\right), \mathsf{fabs.f64}\left(\mathsf{\_.f64}\left(m, n\right)\right)\right)}\right)\right) \]
            7. Simplified93.8%

              \[\leadsto \frac{\color{blue}{\cos M}}{e^{\left(\left(\frac{m + n}{2} - M\right) \cdot \left(\frac{m + n}{2} - M\right) + \ell\right) - \left|m - n\right|}} \]
            8. Taylor expanded in M around 0

              \[\leadsto \color{blue}{\frac{1}{e^{\left(\ell + \frac{1}{4} \cdot {\left(m + n\right)}^{2}\right) - \left|m - n\right|}}} \]
            9. Step-by-step derivation
              1. /-lowering-/.f64N/A

                \[\leadsto \mathsf{/.f64}\left(1, \color{blue}{\left(e^{\left(\ell + \frac{1}{4} \cdot {\left(m + n\right)}^{2}\right) - \left|m - n\right|}\right)}\right) \]
              2. exp-lowering-exp.f64N/A

                \[\leadsto \mathsf{/.f64}\left(1, \mathsf{exp.f64}\left(\left(\left(\ell + \frac{1}{4} \cdot {\left(m + n\right)}^{2}\right) - \left|m - n\right|\right)\right)\right) \]
              3. fabs-subN/A

                \[\leadsto \mathsf{/.f64}\left(1, \mathsf{exp.f64}\left(\left(\left(\ell + \frac{1}{4} \cdot {\left(m + n\right)}^{2}\right) - \left|n - m\right|\right)\right)\right) \]
              4. associate--l+N/A

                \[\leadsto \mathsf{/.f64}\left(1, \mathsf{exp.f64}\left(\left(\ell + \left(\frac{1}{4} \cdot {\left(m + n\right)}^{2} - \left|n - m\right|\right)\right)\right)\right) \]
              5. +-lowering-+.f64N/A

                \[\leadsto \mathsf{/.f64}\left(1, \mathsf{exp.f64}\left(\mathsf{+.f64}\left(\ell, \left(\frac{1}{4} \cdot {\left(m + n\right)}^{2} - \left|n - m\right|\right)\right)\right)\right) \]
              6. --lowering--.f64N/A

                \[\leadsto \mathsf{/.f64}\left(1, \mathsf{exp.f64}\left(\mathsf{+.f64}\left(\ell, \mathsf{\_.f64}\left(\left(\frac{1}{4} \cdot {\left(m + n\right)}^{2}\right), \left(\left|n - m\right|\right)\right)\right)\right)\right) \]
              7. *-lowering-*.f64N/A

                \[\leadsto \mathsf{/.f64}\left(1, \mathsf{exp.f64}\left(\mathsf{+.f64}\left(\ell, \mathsf{\_.f64}\left(\mathsf{*.f64}\left(\frac{1}{4}, \left({\left(m + n\right)}^{2}\right)\right), \left(\left|n - m\right|\right)\right)\right)\right)\right) \]
              8. unpow2N/A

                \[\leadsto \mathsf{/.f64}\left(1, \mathsf{exp.f64}\left(\mathsf{+.f64}\left(\ell, \mathsf{\_.f64}\left(\mathsf{*.f64}\left(\frac{1}{4}, \left(\left(m + n\right) \cdot \left(m + n\right)\right)\right), \left(\left|n - m\right|\right)\right)\right)\right)\right) \]
              9. *-lowering-*.f64N/A

                \[\leadsto \mathsf{/.f64}\left(1, \mathsf{exp.f64}\left(\mathsf{+.f64}\left(\ell, \mathsf{\_.f64}\left(\mathsf{*.f64}\left(\frac{1}{4}, \mathsf{*.f64}\left(\left(m + n\right), \left(m + n\right)\right)\right), \left(\left|n - m\right|\right)\right)\right)\right)\right) \]
              10. +-lowering-+.f64N/A

                \[\leadsto \mathsf{/.f64}\left(1, \mathsf{exp.f64}\left(\mathsf{+.f64}\left(\ell, \mathsf{\_.f64}\left(\mathsf{*.f64}\left(\frac{1}{4}, \mathsf{*.f64}\left(\mathsf{+.f64}\left(m, n\right), \left(m + n\right)\right)\right), \left(\left|n - m\right|\right)\right)\right)\right)\right) \]
              11. +-lowering-+.f64N/A

                \[\leadsto \mathsf{/.f64}\left(1, \mathsf{exp.f64}\left(\mathsf{+.f64}\left(\ell, \mathsf{\_.f64}\left(\mathsf{*.f64}\left(\frac{1}{4}, \mathsf{*.f64}\left(\mathsf{+.f64}\left(m, n\right), \mathsf{+.f64}\left(m, n\right)\right)\right), \left(\left|n - m\right|\right)\right)\right)\right)\right) \]
              12. sub-negN/A

                \[\leadsto \mathsf{/.f64}\left(1, \mathsf{exp.f64}\left(\mathsf{+.f64}\left(\ell, \mathsf{\_.f64}\left(\mathsf{*.f64}\left(\frac{1}{4}, \mathsf{*.f64}\left(\mathsf{+.f64}\left(m, n\right), \mathsf{+.f64}\left(m, n\right)\right)\right), \left(\left|n + \left(\mathsf{neg}\left(m\right)\right)\right|\right)\right)\right)\right)\right) \]
              13. mul-1-negN/A

                \[\leadsto \mathsf{/.f64}\left(1, \mathsf{exp.f64}\left(\mathsf{+.f64}\left(\ell, \mathsf{\_.f64}\left(\mathsf{*.f64}\left(\frac{1}{4}, \mathsf{*.f64}\left(\mathsf{+.f64}\left(m, n\right), \mathsf{+.f64}\left(m, n\right)\right)\right), \left(\left|n + -1 \cdot m\right|\right)\right)\right)\right)\right) \]
              14. fabs-lowering-fabs.f64N/A

                \[\leadsto \mathsf{/.f64}\left(1, \mathsf{exp.f64}\left(\mathsf{+.f64}\left(\ell, \mathsf{\_.f64}\left(\mathsf{*.f64}\left(\frac{1}{4}, \mathsf{*.f64}\left(\mathsf{+.f64}\left(m, n\right), \mathsf{+.f64}\left(m, n\right)\right)\right), \mathsf{fabs.f64}\left(\left(n + -1 \cdot m\right)\right)\right)\right)\right)\right) \]
              15. mul-1-negN/A

                \[\leadsto \mathsf{/.f64}\left(1, \mathsf{exp.f64}\left(\mathsf{+.f64}\left(\ell, \mathsf{\_.f64}\left(\mathsf{*.f64}\left(\frac{1}{4}, \mathsf{*.f64}\left(\mathsf{+.f64}\left(m, n\right), \mathsf{+.f64}\left(m, n\right)\right)\right), \mathsf{fabs.f64}\left(\left(n + \left(\mathsf{neg}\left(m\right)\right)\right)\right)\right)\right)\right)\right) \]
              16. sub-negN/A

                \[\leadsto \mathsf{/.f64}\left(1, \mathsf{exp.f64}\left(\mathsf{+.f64}\left(\ell, \mathsf{\_.f64}\left(\mathsf{*.f64}\left(\frac{1}{4}, \mathsf{*.f64}\left(\mathsf{+.f64}\left(m, n\right), \mathsf{+.f64}\left(m, n\right)\right)\right), \mathsf{fabs.f64}\left(\left(n - m\right)\right)\right)\right)\right)\right) \]
              17. --lowering--.f6480.5%

                \[\leadsto \mathsf{/.f64}\left(1, \mathsf{exp.f64}\left(\mathsf{+.f64}\left(\ell, \mathsf{\_.f64}\left(\mathsf{*.f64}\left(\frac{1}{4}, \mathsf{*.f64}\left(\mathsf{+.f64}\left(m, n\right), \mathsf{+.f64}\left(m, n\right)\right)\right), \mathsf{fabs.f64}\left(\mathsf{\_.f64}\left(n, m\right)\right)\right)\right)\right)\right) \]
            10. Simplified80.5%

              \[\leadsto \color{blue}{\frac{1}{e^{\ell + \left(0.25 \cdot \left(\left(m + n\right) \cdot \left(m + n\right)\right) - \left|n - m\right|\right)}}} \]
            11. Taylor expanded in m around inf

              \[\leadsto \mathsf{/.f64}\left(1, \mathsf{exp.f64}\left(\color{blue}{\left(\frac{1}{4} \cdot {m}^{2}\right)}\right)\right) \]
            12. Step-by-step derivation
              1. *-lowering-*.f64N/A

                \[\leadsto \mathsf{/.f64}\left(1, \mathsf{exp.f64}\left(\mathsf{*.f64}\left(\frac{1}{4}, \left({m}^{2}\right)\right)\right)\right) \]
              2. unpow2N/A

                \[\leadsto \mathsf{/.f64}\left(1, \mathsf{exp.f64}\left(\mathsf{*.f64}\left(\frac{1}{4}, \left(m \cdot m\right)\right)\right)\right) \]
              3. *-lowering-*.f6454.0%

                \[\leadsto \mathsf{/.f64}\left(1, \mathsf{exp.f64}\left(\mathsf{*.f64}\left(\frac{1}{4}, \mathsf{*.f64}\left(m, m\right)\right)\right)\right) \]
            13. Simplified54.0%

              \[\leadsto \frac{1}{e^{\color{blue}{0.25 \cdot \left(m \cdot m\right)}}} \]

            if 3.5999999999999999e-73 < n < 9.4e13

            1. Initial program 64.5%

              \[\cos \left(\frac{K \cdot \left(m + n\right)}{2} - M\right) \cdot e^{\left(-{\left(\frac{m + n}{2} - M\right)}^{2}\right) - \left(\ell - \left|m - n\right|\right)} \]
            2. Step-by-step derivation
              1. neg-sub0N/A

                \[\leadsto \cos \left(\frac{K \cdot \left(m + n\right)}{2} - M\right) \cdot e^{\left(0 - {\left(\frac{m + n}{2} - M\right)}^{2}\right) - \left(\ell - \left|m - n\right|\right)} \]
              2. associate--l-N/A

                \[\leadsto \cos \left(\frac{K \cdot \left(m + n\right)}{2} - M\right) \cdot e^{0 - \left({\left(\frac{m + n}{2} - M\right)}^{2} + \left(\ell - \left|m - n\right|\right)\right)} \]
              3. exp-diffN/A

                \[\leadsto \cos \left(\frac{K \cdot \left(m + n\right)}{2} - M\right) \cdot \frac{e^{0}}{\color{blue}{e^{{\left(\frac{m + n}{2} - M\right)}^{2} + \left(\ell - \left|m - n\right|\right)}}} \]
              4. associate-*r/N/A

                \[\leadsto \frac{\cos \left(\frac{K \cdot \left(m + n\right)}{2} - M\right) \cdot e^{0}}{\color{blue}{e^{{\left(\frac{m + n}{2} - M\right)}^{2} + \left(\ell - \left|m - n\right|\right)}}} \]
              5. exp-0N/A

                \[\leadsto \frac{\cos \left(\frac{K \cdot \left(m + n\right)}{2} - M\right) \cdot 1}{e^{{\left(\frac{m + n}{2} - M\right)}^{2} + \color{blue}{\left(\ell - \left|m - n\right|\right)}}} \]
              6. *-rgt-identityN/A

                \[\leadsto \frac{\cos \left(\frac{K \cdot \left(m + n\right)}{2} - M\right)}{e^{\color{blue}{{\left(\frac{m + n}{2} - M\right)}^{2} + \left(\ell - \left|m - n\right|\right)}}} \]
              7. /-lowering-/.f64N/A

                \[\leadsto \mathsf{/.f64}\left(\cos \left(\frac{K \cdot \left(m + n\right)}{2} - M\right), \color{blue}{\left(e^{{\left(\frac{m + n}{2} - M\right)}^{2} + \left(\ell - \left|m - n\right|\right)}\right)}\right) \]
            3. Simplified64.5%

              \[\leadsto \color{blue}{\frac{\cos \left(\frac{K \cdot \left(m + n\right)}{2} - M\right)}{e^{\left(\left(\frac{m + n}{2} - M\right) \cdot \left(\frac{m + n}{2} - M\right) + \ell\right) - \left|m - n\right|}}} \]
            4. Add Preprocessing
            5. Taylor expanded in K around 0

              \[\leadsto \mathsf{/.f64}\left(\color{blue}{\cos \left(\mathsf{neg}\left(M\right)\right)}, \mathsf{exp.f64}\left(\mathsf{\_.f64}\left(\mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\mathsf{/.f64}\left(\mathsf{+.f64}\left(m, n\right), 2\right), M\right), \mathsf{\_.f64}\left(\mathsf{/.f64}\left(\mathsf{+.f64}\left(m, n\right), 2\right), M\right)\right), \ell\right), \mathsf{fabs.f64}\left(\mathsf{\_.f64}\left(m, n\right)\right)\right)\right)\right) \]
            6. Step-by-step derivation
              1. cos-negN/A

                \[\leadsto \mathsf{/.f64}\left(\cos M, \mathsf{exp.f64}\left(\color{blue}{\mathsf{\_.f64}\left(\mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\mathsf{/.f64}\left(\mathsf{+.f64}\left(m, n\right), 2\right), M\right), \mathsf{\_.f64}\left(\mathsf{/.f64}\left(\mathsf{+.f64}\left(m, n\right), 2\right), M\right)\right), \ell\right), \mathsf{fabs.f64}\left(\mathsf{\_.f64}\left(m, n\right)\right)\right)}\right)\right) \]
              2. cos-lowering-cos.f6489.5%

                \[\leadsto \mathsf{/.f64}\left(\mathsf{cos.f64}\left(M\right), \mathsf{exp.f64}\left(\color{blue}{\mathsf{\_.f64}\left(\mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\mathsf{/.f64}\left(\mathsf{+.f64}\left(m, n\right), 2\right), M\right), \mathsf{\_.f64}\left(\mathsf{/.f64}\left(\mathsf{+.f64}\left(m, n\right), 2\right), M\right)\right), \ell\right), \mathsf{fabs.f64}\left(\mathsf{\_.f64}\left(m, n\right)\right)\right)}\right)\right) \]
            7. Simplified89.5%

              \[\leadsto \frac{\color{blue}{\cos M}}{e^{\left(\left(\frac{m + n}{2} - M\right) \cdot \left(\frac{m + n}{2} - M\right) + \ell\right) - \left|m - n\right|}} \]
            8. Taylor expanded in l around inf

              \[\leadsto \mathsf{/.f64}\left(\mathsf{cos.f64}\left(M\right), \mathsf{exp.f64}\left(\color{blue}{\ell}\right)\right) \]
            9. Step-by-step derivation
              1. Simplified42.3%

                \[\leadsto \frac{\cos M}{e^{\color{blue}{\ell}}} \]
              2. Taylor expanded in M around 0

                \[\leadsto \mathsf{/.f64}\left(\color{blue}{\left(1 + \frac{-1}{2} \cdot {M}^{2}\right)}, \mathsf{exp.f64}\left(\ell\right)\right) \]
              3. Step-by-step derivation
                1. +-lowering-+.f64N/A

                  \[\leadsto \mathsf{/.f64}\left(\mathsf{+.f64}\left(1, \left(\frac{-1}{2} \cdot {M}^{2}\right)\right), \mathsf{exp.f64}\left(\color{blue}{\ell}\right)\right) \]
                2. *-lowering-*.f64N/A

                  \[\leadsto \mathsf{/.f64}\left(\mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\frac{-1}{2}, \left({M}^{2}\right)\right)\right), \mathsf{exp.f64}\left(\ell\right)\right) \]
                3. unpow2N/A

                  \[\leadsto \mathsf{/.f64}\left(\mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\frac{-1}{2}, \left(M \cdot M\right)\right)\right), \mathsf{exp.f64}\left(\ell\right)\right) \]
                4. *-lowering-*.f6442.0%

                  \[\leadsto \mathsf{/.f64}\left(\mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\frac{-1}{2}, \mathsf{*.f64}\left(M, M\right)\right)\right), \mathsf{exp.f64}\left(\ell\right)\right) \]
              4. Simplified42.0%

                \[\leadsto \frac{\color{blue}{1 + -0.5 \cdot \left(M \cdot M\right)}}{e^{\ell}} \]

              if 9.4e13 < n

              1. Initial program 63.6%

                \[\cos \left(\frac{K \cdot \left(m + n\right)}{2} - M\right) \cdot e^{\left(-{\left(\frac{m + n}{2} - M\right)}^{2}\right) - \left(\ell - \left|m - n\right|\right)} \]
              2. Step-by-step derivation
                1. neg-sub0N/A

                  \[\leadsto \cos \left(\frac{K \cdot \left(m + n\right)}{2} - M\right) \cdot e^{\left(0 - {\left(\frac{m + n}{2} - M\right)}^{2}\right) - \left(\ell - \left|m - n\right|\right)} \]
                2. associate--l-N/A

                  \[\leadsto \cos \left(\frac{K \cdot \left(m + n\right)}{2} - M\right) \cdot e^{0 - \left({\left(\frac{m + n}{2} - M\right)}^{2} + \left(\ell - \left|m - n\right|\right)\right)} \]
                3. exp-diffN/A

                  \[\leadsto \cos \left(\frac{K \cdot \left(m + n\right)}{2} - M\right) \cdot \frac{e^{0}}{\color{blue}{e^{{\left(\frac{m + n}{2} - M\right)}^{2} + \left(\ell - \left|m - n\right|\right)}}} \]
                4. associate-*r/N/A

                  \[\leadsto \frac{\cos \left(\frac{K \cdot \left(m + n\right)}{2} - M\right) \cdot e^{0}}{\color{blue}{e^{{\left(\frac{m + n}{2} - M\right)}^{2} + \left(\ell - \left|m - n\right|\right)}}} \]
                5. exp-0N/A

                  \[\leadsto \frac{\cos \left(\frac{K \cdot \left(m + n\right)}{2} - M\right) \cdot 1}{e^{{\left(\frac{m + n}{2} - M\right)}^{2} + \color{blue}{\left(\ell - \left|m - n\right|\right)}}} \]
                6. *-rgt-identityN/A

                  \[\leadsto \frac{\cos \left(\frac{K \cdot \left(m + n\right)}{2} - M\right)}{e^{\color{blue}{{\left(\frac{m + n}{2} - M\right)}^{2} + \left(\ell - \left|m - n\right|\right)}}} \]
                7. /-lowering-/.f64N/A

                  \[\leadsto \mathsf{/.f64}\left(\cos \left(\frac{K \cdot \left(m + n\right)}{2} - M\right), \color{blue}{\left(e^{{\left(\frac{m + n}{2} - M\right)}^{2} + \left(\ell - \left|m - n\right|\right)}\right)}\right) \]
              3. Simplified63.6%

                \[\leadsto \color{blue}{\frac{\cos \left(\frac{K \cdot \left(m + n\right)}{2} - M\right)}{e^{\left(\left(\frac{m + n}{2} - M\right) \cdot \left(\frac{m + n}{2} - M\right) + \ell\right) - \left|m - n\right|}}} \]
              4. Add Preprocessing
              5. Taylor expanded in K around 0

                \[\leadsto \mathsf{/.f64}\left(\color{blue}{\cos \left(\mathsf{neg}\left(M\right)\right)}, \mathsf{exp.f64}\left(\mathsf{\_.f64}\left(\mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\mathsf{/.f64}\left(\mathsf{+.f64}\left(m, n\right), 2\right), M\right), \mathsf{\_.f64}\left(\mathsf{/.f64}\left(\mathsf{+.f64}\left(m, n\right), 2\right), M\right)\right), \ell\right), \mathsf{fabs.f64}\left(\mathsf{\_.f64}\left(m, n\right)\right)\right)\right)\right) \]
              6. Step-by-step derivation
                1. cos-negN/A

                  \[\leadsto \mathsf{/.f64}\left(\cos M, \mathsf{exp.f64}\left(\color{blue}{\mathsf{\_.f64}\left(\mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\mathsf{/.f64}\left(\mathsf{+.f64}\left(m, n\right), 2\right), M\right), \mathsf{\_.f64}\left(\mathsf{/.f64}\left(\mathsf{+.f64}\left(m, n\right), 2\right), M\right)\right), \ell\right), \mathsf{fabs.f64}\left(\mathsf{\_.f64}\left(m, n\right)\right)\right)}\right)\right) \]
                2. cos-lowering-cos.f64100.0%

                  \[\leadsto \mathsf{/.f64}\left(\mathsf{cos.f64}\left(M\right), \mathsf{exp.f64}\left(\color{blue}{\mathsf{\_.f64}\left(\mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\mathsf{/.f64}\left(\mathsf{+.f64}\left(m, n\right), 2\right), M\right), \mathsf{\_.f64}\left(\mathsf{/.f64}\left(\mathsf{+.f64}\left(m, n\right), 2\right), M\right)\right), \ell\right), \mathsf{fabs.f64}\left(\mathsf{\_.f64}\left(m, n\right)\right)\right)}\right)\right) \]
              7. Simplified100.0%

                \[\leadsto \frac{\color{blue}{\cos M}}{e^{\left(\left(\frac{m + n}{2} - M\right) \cdot \left(\frac{m + n}{2} - M\right) + \ell\right) - \left|m - n\right|}} \]
              8. Taylor expanded in M around 0

                \[\leadsto \color{blue}{\frac{1}{e^{\left(\ell + \frac{1}{4} \cdot {\left(m + n\right)}^{2}\right) - \left|m - n\right|}}} \]
              9. Step-by-step derivation
                1. /-lowering-/.f64N/A

                  \[\leadsto \mathsf{/.f64}\left(1, \color{blue}{\left(e^{\left(\ell + \frac{1}{4} \cdot {\left(m + n\right)}^{2}\right) - \left|m - n\right|}\right)}\right) \]
                2. exp-lowering-exp.f64N/A

                  \[\leadsto \mathsf{/.f64}\left(1, \mathsf{exp.f64}\left(\left(\left(\ell + \frac{1}{4} \cdot {\left(m + n\right)}^{2}\right) - \left|m - n\right|\right)\right)\right) \]
                3. fabs-subN/A

                  \[\leadsto \mathsf{/.f64}\left(1, \mathsf{exp.f64}\left(\left(\left(\ell + \frac{1}{4} \cdot {\left(m + n\right)}^{2}\right) - \left|n - m\right|\right)\right)\right) \]
                4. associate--l+N/A

                  \[\leadsto \mathsf{/.f64}\left(1, \mathsf{exp.f64}\left(\left(\ell + \left(\frac{1}{4} \cdot {\left(m + n\right)}^{2} - \left|n - m\right|\right)\right)\right)\right) \]
                5. +-lowering-+.f64N/A

                  \[\leadsto \mathsf{/.f64}\left(1, \mathsf{exp.f64}\left(\mathsf{+.f64}\left(\ell, \left(\frac{1}{4} \cdot {\left(m + n\right)}^{2} - \left|n - m\right|\right)\right)\right)\right) \]
                6. --lowering--.f64N/A

                  \[\leadsto \mathsf{/.f64}\left(1, \mathsf{exp.f64}\left(\mathsf{+.f64}\left(\ell, \mathsf{\_.f64}\left(\left(\frac{1}{4} \cdot {\left(m + n\right)}^{2}\right), \left(\left|n - m\right|\right)\right)\right)\right)\right) \]
                7. *-lowering-*.f64N/A

                  \[\leadsto \mathsf{/.f64}\left(1, \mathsf{exp.f64}\left(\mathsf{+.f64}\left(\ell, \mathsf{\_.f64}\left(\mathsf{*.f64}\left(\frac{1}{4}, \left({\left(m + n\right)}^{2}\right)\right), \left(\left|n - m\right|\right)\right)\right)\right)\right) \]
                8. unpow2N/A

                  \[\leadsto \mathsf{/.f64}\left(1, \mathsf{exp.f64}\left(\mathsf{+.f64}\left(\ell, \mathsf{\_.f64}\left(\mathsf{*.f64}\left(\frac{1}{4}, \left(\left(m + n\right) \cdot \left(m + n\right)\right)\right), \left(\left|n - m\right|\right)\right)\right)\right)\right) \]
                9. *-lowering-*.f64N/A

                  \[\leadsto \mathsf{/.f64}\left(1, \mathsf{exp.f64}\left(\mathsf{+.f64}\left(\ell, \mathsf{\_.f64}\left(\mathsf{*.f64}\left(\frac{1}{4}, \mathsf{*.f64}\left(\left(m + n\right), \left(m + n\right)\right)\right), \left(\left|n - m\right|\right)\right)\right)\right)\right) \]
                10. +-lowering-+.f64N/A

                  \[\leadsto \mathsf{/.f64}\left(1, \mathsf{exp.f64}\left(\mathsf{+.f64}\left(\ell, \mathsf{\_.f64}\left(\mathsf{*.f64}\left(\frac{1}{4}, \mathsf{*.f64}\left(\mathsf{+.f64}\left(m, n\right), \left(m + n\right)\right)\right), \left(\left|n - m\right|\right)\right)\right)\right)\right) \]
                11. +-lowering-+.f64N/A

                  \[\leadsto \mathsf{/.f64}\left(1, \mathsf{exp.f64}\left(\mathsf{+.f64}\left(\ell, \mathsf{\_.f64}\left(\mathsf{*.f64}\left(\frac{1}{4}, \mathsf{*.f64}\left(\mathsf{+.f64}\left(m, n\right), \mathsf{+.f64}\left(m, n\right)\right)\right), \left(\left|n - m\right|\right)\right)\right)\right)\right) \]
                12. sub-negN/A

                  \[\leadsto \mathsf{/.f64}\left(1, \mathsf{exp.f64}\left(\mathsf{+.f64}\left(\ell, \mathsf{\_.f64}\left(\mathsf{*.f64}\left(\frac{1}{4}, \mathsf{*.f64}\left(\mathsf{+.f64}\left(m, n\right), \mathsf{+.f64}\left(m, n\right)\right)\right), \left(\left|n + \left(\mathsf{neg}\left(m\right)\right)\right|\right)\right)\right)\right)\right) \]
                13. mul-1-negN/A

                  \[\leadsto \mathsf{/.f64}\left(1, \mathsf{exp.f64}\left(\mathsf{+.f64}\left(\ell, \mathsf{\_.f64}\left(\mathsf{*.f64}\left(\frac{1}{4}, \mathsf{*.f64}\left(\mathsf{+.f64}\left(m, n\right), \mathsf{+.f64}\left(m, n\right)\right)\right), \left(\left|n + -1 \cdot m\right|\right)\right)\right)\right)\right) \]
                14. fabs-lowering-fabs.f64N/A

                  \[\leadsto \mathsf{/.f64}\left(1, \mathsf{exp.f64}\left(\mathsf{+.f64}\left(\ell, \mathsf{\_.f64}\left(\mathsf{*.f64}\left(\frac{1}{4}, \mathsf{*.f64}\left(\mathsf{+.f64}\left(m, n\right), \mathsf{+.f64}\left(m, n\right)\right)\right), \mathsf{fabs.f64}\left(\left(n + -1 \cdot m\right)\right)\right)\right)\right)\right) \]
                15. mul-1-negN/A

                  \[\leadsto \mathsf{/.f64}\left(1, \mathsf{exp.f64}\left(\mathsf{+.f64}\left(\ell, \mathsf{\_.f64}\left(\mathsf{*.f64}\left(\frac{1}{4}, \mathsf{*.f64}\left(\mathsf{+.f64}\left(m, n\right), \mathsf{+.f64}\left(m, n\right)\right)\right), \mathsf{fabs.f64}\left(\left(n + \left(\mathsf{neg}\left(m\right)\right)\right)\right)\right)\right)\right)\right) \]
                16. sub-negN/A

                  \[\leadsto \mathsf{/.f64}\left(1, \mathsf{exp.f64}\left(\mathsf{+.f64}\left(\ell, \mathsf{\_.f64}\left(\mathsf{*.f64}\left(\frac{1}{4}, \mathsf{*.f64}\left(\mathsf{+.f64}\left(m, n\right), \mathsf{+.f64}\left(m, n\right)\right)\right), \mathsf{fabs.f64}\left(\left(n - m\right)\right)\right)\right)\right)\right) \]
                17. --lowering--.f64100.0%

                  \[\leadsto \mathsf{/.f64}\left(1, \mathsf{exp.f64}\left(\mathsf{+.f64}\left(\ell, \mathsf{\_.f64}\left(\mathsf{*.f64}\left(\frac{1}{4}, \mathsf{*.f64}\left(\mathsf{+.f64}\left(m, n\right), \mathsf{+.f64}\left(m, n\right)\right)\right), \mathsf{fabs.f64}\left(\mathsf{\_.f64}\left(n, m\right)\right)\right)\right)\right)\right) \]
              10. Simplified100.0%

                \[\leadsto \color{blue}{\frac{1}{e^{\ell + \left(0.25 \cdot \left(\left(m + n\right) \cdot \left(m + n\right)\right) - \left|n - m\right|\right)}}} \]
              11. Taylor expanded in n around inf

                \[\leadsto \mathsf{/.f64}\left(1, \mathsf{exp.f64}\left(\color{blue}{\left(\frac{1}{4} \cdot {n}^{2}\right)}\right)\right) \]
              12. Step-by-step derivation
                1. *-lowering-*.f64N/A

                  \[\leadsto \mathsf{/.f64}\left(1, \mathsf{exp.f64}\left(\mathsf{*.f64}\left(\frac{1}{4}, \left({n}^{2}\right)\right)\right)\right) \]
                2. unpow2N/A

                  \[\leadsto \mathsf{/.f64}\left(1, \mathsf{exp.f64}\left(\mathsf{*.f64}\left(\frac{1}{4}, \left(n \cdot n\right)\right)\right)\right) \]
                3. *-lowering-*.f64100.0%

                  \[\leadsto \mathsf{/.f64}\left(1, \mathsf{exp.f64}\left(\mathsf{*.f64}\left(\frac{1}{4}, \mathsf{*.f64}\left(n, n\right)\right)\right)\right) \]
              13. Simplified100.0%

                \[\leadsto \frac{1}{e^{\color{blue}{0.25 \cdot \left(n \cdot n\right)}}} \]
            10. Recombined 3 regimes into one program.
            11. Final simplification60.6%

              \[\leadsto \begin{array}{l} \mathbf{if}\;n \leq 3.6 \cdot 10^{-73}:\\ \;\;\;\;\frac{1}{e^{0.25 \cdot \left(m \cdot m\right)}}\\ \mathbf{elif}\;n \leq 94000000000000:\\ \;\;\;\;\frac{1 + \left(M \cdot M\right) \cdot -0.5}{e^{\ell}}\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{e^{0.25 \cdot \left(n \cdot n\right)}}\\ \end{array} \]
            12. Add Preprocessing

            Alternative 12: 63.6% accurate, 3.6× speedup?

            \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;n \leq 6.4 \cdot 10^{-161}:\\ \;\;\;\;\frac{1}{e^{0.25 \cdot \left(m \cdot m\right)}}\\ \mathbf{elif}\;n \leq 94000000000000:\\ \;\;\;\;\frac{1}{e^{\ell}}\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{e^{0.25 \cdot \left(n \cdot n\right)}}\\ \end{array} \end{array} \]
            (FPCore (K m n M l)
             :precision binary64
             (if (<= n 6.4e-161)
               (/ 1.0 (exp (* 0.25 (* m m))))
               (if (<= n 94000000000000.0)
                 (/ 1.0 (exp l))
                 (/ 1.0 (exp (* 0.25 (* n n)))))))
            double code(double K, double m, double n, double M, double l) {
            	double tmp;
            	if (n <= 6.4e-161) {
            		tmp = 1.0 / exp((0.25 * (m * m)));
            	} else if (n <= 94000000000000.0) {
            		tmp = 1.0 / exp(l);
            	} else {
            		tmp = 1.0 / exp((0.25 * (n * n)));
            	}
            	return tmp;
            }
            
            real(8) function code(k, m, n, m_1, l)
                real(8), intent (in) :: k
                real(8), intent (in) :: m
                real(8), intent (in) :: n
                real(8), intent (in) :: m_1
                real(8), intent (in) :: l
                real(8) :: tmp
                if (n <= 6.4d-161) then
                    tmp = 1.0d0 / exp((0.25d0 * (m * m)))
                else if (n <= 94000000000000.0d0) then
                    tmp = 1.0d0 / exp(l)
                else
                    tmp = 1.0d0 / exp((0.25d0 * (n * n)))
                end if
                code = tmp
            end function
            
            public static double code(double K, double m, double n, double M, double l) {
            	double tmp;
            	if (n <= 6.4e-161) {
            		tmp = 1.0 / Math.exp((0.25 * (m * m)));
            	} else if (n <= 94000000000000.0) {
            		tmp = 1.0 / Math.exp(l);
            	} else {
            		tmp = 1.0 / Math.exp((0.25 * (n * n)));
            	}
            	return tmp;
            }
            
            def code(K, m, n, M, l):
            	tmp = 0
            	if n <= 6.4e-161:
            		tmp = 1.0 / math.exp((0.25 * (m * m)))
            	elif n <= 94000000000000.0:
            		tmp = 1.0 / math.exp(l)
            	else:
            		tmp = 1.0 / math.exp((0.25 * (n * n)))
            	return tmp
            
            function code(K, m, n, M, l)
            	tmp = 0.0
            	if (n <= 6.4e-161)
            		tmp = Float64(1.0 / exp(Float64(0.25 * Float64(m * m))));
            	elseif (n <= 94000000000000.0)
            		tmp = Float64(1.0 / exp(l));
            	else
            		tmp = Float64(1.0 / exp(Float64(0.25 * Float64(n * n))));
            	end
            	return tmp
            end
            
            function tmp_2 = code(K, m, n, M, l)
            	tmp = 0.0;
            	if (n <= 6.4e-161)
            		tmp = 1.0 / exp((0.25 * (m * m)));
            	elseif (n <= 94000000000000.0)
            		tmp = 1.0 / exp(l);
            	else
            		tmp = 1.0 / exp((0.25 * (n * n)));
            	end
            	tmp_2 = tmp;
            end
            
            code[K_, m_, n_, M_, l_] := If[LessEqual[n, 6.4e-161], N[(1.0 / N[Exp[N[(0.25 * N[(m * m), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[n, 94000000000000.0], N[(1.0 / N[Exp[l], $MachinePrecision]), $MachinePrecision], N[(1.0 / N[Exp[N[(0.25 * N[(n * n), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]
            
            \begin{array}{l}
            
            \\
            \begin{array}{l}
            \mathbf{if}\;n \leq 6.4 \cdot 10^{-161}:\\
            \;\;\;\;\frac{1}{e^{0.25 \cdot \left(m \cdot m\right)}}\\
            
            \mathbf{elif}\;n \leq 94000000000000:\\
            \;\;\;\;\frac{1}{e^{\ell}}\\
            
            \mathbf{else}:\\
            \;\;\;\;\frac{1}{e^{0.25 \cdot \left(n \cdot n\right)}}\\
            
            
            \end{array}
            \end{array}
            
            Derivation
            1. Split input into 3 regimes
            2. if n < 6.39999999999999971e-161

              1. Initial program 73.5%

                \[\cos \left(\frac{K \cdot \left(m + n\right)}{2} - M\right) \cdot e^{\left(-{\left(\frac{m + n}{2} - M\right)}^{2}\right) - \left(\ell - \left|m - n\right|\right)} \]
              2. Step-by-step derivation
                1. neg-sub0N/A

                  \[\leadsto \cos \left(\frac{K \cdot \left(m + n\right)}{2} - M\right) \cdot e^{\left(0 - {\left(\frac{m + n}{2} - M\right)}^{2}\right) - \left(\ell - \left|m - n\right|\right)} \]
                2. associate--l-N/A

                  \[\leadsto \cos \left(\frac{K \cdot \left(m + n\right)}{2} - M\right) \cdot e^{0 - \left({\left(\frac{m + n}{2} - M\right)}^{2} + \left(\ell - \left|m - n\right|\right)\right)} \]
                3. exp-diffN/A

                  \[\leadsto \cos \left(\frac{K \cdot \left(m + n\right)}{2} - M\right) \cdot \frac{e^{0}}{\color{blue}{e^{{\left(\frac{m + n}{2} - M\right)}^{2} + \left(\ell - \left|m - n\right|\right)}}} \]
                4. associate-*r/N/A

                  \[\leadsto \frac{\cos \left(\frac{K \cdot \left(m + n\right)}{2} - M\right) \cdot e^{0}}{\color{blue}{e^{{\left(\frac{m + n}{2} - M\right)}^{2} + \left(\ell - \left|m - n\right|\right)}}} \]
                5. exp-0N/A

                  \[\leadsto \frac{\cos \left(\frac{K \cdot \left(m + n\right)}{2} - M\right) \cdot 1}{e^{{\left(\frac{m + n}{2} - M\right)}^{2} + \color{blue}{\left(\ell - \left|m - n\right|\right)}}} \]
                6. *-rgt-identityN/A

                  \[\leadsto \frac{\cos \left(\frac{K \cdot \left(m + n\right)}{2} - M\right)}{e^{\color{blue}{{\left(\frac{m + n}{2} - M\right)}^{2} + \left(\ell - \left|m - n\right|\right)}}} \]
                7. /-lowering-/.f64N/A

                  \[\leadsto \mathsf{/.f64}\left(\cos \left(\frac{K \cdot \left(m + n\right)}{2} - M\right), \color{blue}{\left(e^{{\left(\frac{m + n}{2} - M\right)}^{2} + \left(\ell - \left|m - n\right|\right)}\right)}\right) \]
              3. Simplified73.5%

                \[\leadsto \color{blue}{\frac{\cos \left(\frac{K \cdot \left(m + n\right)}{2} - M\right)}{e^{\left(\left(\frac{m + n}{2} - M\right) \cdot \left(\frac{m + n}{2} - M\right) + \ell\right) - \left|m - n\right|}}} \]
              4. Add Preprocessing
              5. Taylor expanded in K around 0

                \[\leadsto \mathsf{/.f64}\left(\color{blue}{\cos \left(\mathsf{neg}\left(M\right)\right)}, \mathsf{exp.f64}\left(\mathsf{\_.f64}\left(\mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\mathsf{/.f64}\left(\mathsf{+.f64}\left(m, n\right), 2\right), M\right), \mathsf{\_.f64}\left(\mathsf{/.f64}\left(\mathsf{+.f64}\left(m, n\right), 2\right), M\right)\right), \ell\right), \mathsf{fabs.f64}\left(\mathsf{\_.f64}\left(m, n\right)\right)\right)\right)\right) \]
              6. Step-by-step derivation
                1. cos-negN/A

                  \[\leadsto \mathsf{/.f64}\left(\cos M, \mathsf{exp.f64}\left(\color{blue}{\mathsf{\_.f64}\left(\mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\mathsf{/.f64}\left(\mathsf{+.f64}\left(m, n\right), 2\right), M\right), \mathsf{\_.f64}\left(\mathsf{/.f64}\left(\mathsf{+.f64}\left(m, n\right), 2\right), M\right)\right), \ell\right), \mathsf{fabs.f64}\left(\mathsf{\_.f64}\left(m, n\right)\right)\right)}\right)\right) \]
                2. cos-lowering-cos.f6493.2%

                  \[\leadsto \mathsf{/.f64}\left(\mathsf{cos.f64}\left(M\right), \mathsf{exp.f64}\left(\color{blue}{\mathsf{\_.f64}\left(\mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\mathsf{/.f64}\left(\mathsf{+.f64}\left(m, n\right), 2\right), M\right), \mathsf{\_.f64}\left(\mathsf{/.f64}\left(\mathsf{+.f64}\left(m, n\right), 2\right), M\right)\right), \ell\right), \mathsf{fabs.f64}\left(\mathsf{\_.f64}\left(m, n\right)\right)\right)}\right)\right) \]
              7. Simplified93.2%

                \[\leadsto \frac{\color{blue}{\cos M}}{e^{\left(\left(\frac{m + n}{2} - M\right) \cdot \left(\frac{m + n}{2} - M\right) + \ell\right) - \left|m - n\right|}} \]
              8. Taylor expanded in M around 0

                \[\leadsto \color{blue}{\frac{1}{e^{\left(\ell + \frac{1}{4} \cdot {\left(m + n\right)}^{2}\right) - \left|m - n\right|}}} \]
              9. Step-by-step derivation
                1. /-lowering-/.f64N/A

                  \[\leadsto \mathsf{/.f64}\left(1, \color{blue}{\left(e^{\left(\ell + \frac{1}{4} \cdot {\left(m + n\right)}^{2}\right) - \left|m - n\right|}\right)}\right) \]
                2. exp-lowering-exp.f64N/A

                  \[\leadsto \mathsf{/.f64}\left(1, \mathsf{exp.f64}\left(\left(\left(\ell + \frac{1}{4} \cdot {\left(m + n\right)}^{2}\right) - \left|m - n\right|\right)\right)\right) \]
                3. fabs-subN/A

                  \[\leadsto \mathsf{/.f64}\left(1, \mathsf{exp.f64}\left(\left(\left(\ell + \frac{1}{4} \cdot {\left(m + n\right)}^{2}\right) - \left|n - m\right|\right)\right)\right) \]
                4. associate--l+N/A

                  \[\leadsto \mathsf{/.f64}\left(1, \mathsf{exp.f64}\left(\left(\ell + \left(\frac{1}{4} \cdot {\left(m + n\right)}^{2} - \left|n - m\right|\right)\right)\right)\right) \]
                5. +-lowering-+.f64N/A

                  \[\leadsto \mathsf{/.f64}\left(1, \mathsf{exp.f64}\left(\mathsf{+.f64}\left(\ell, \left(\frac{1}{4} \cdot {\left(m + n\right)}^{2} - \left|n - m\right|\right)\right)\right)\right) \]
                6. --lowering--.f64N/A

                  \[\leadsto \mathsf{/.f64}\left(1, \mathsf{exp.f64}\left(\mathsf{+.f64}\left(\ell, \mathsf{\_.f64}\left(\left(\frac{1}{4} \cdot {\left(m + n\right)}^{2}\right), \left(\left|n - m\right|\right)\right)\right)\right)\right) \]
                7. *-lowering-*.f64N/A

                  \[\leadsto \mathsf{/.f64}\left(1, \mathsf{exp.f64}\left(\mathsf{+.f64}\left(\ell, \mathsf{\_.f64}\left(\mathsf{*.f64}\left(\frac{1}{4}, \left({\left(m + n\right)}^{2}\right)\right), \left(\left|n - m\right|\right)\right)\right)\right)\right) \]
                8. unpow2N/A

                  \[\leadsto \mathsf{/.f64}\left(1, \mathsf{exp.f64}\left(\mathsf{+.f64}\left(\ell, \mathsf{\_.f64}\left(\mathsf{*.f64}\left(\frac{1}{4}, \left(\left(m + n\right) \cdot \left(m + n\right)\right)\right), \left(\left|n - m\right|\right)\right)\right)\right)\right) \]
                9. *-lowering-*.f64N/A

                  \[\leadsto \mathsf{/.f64}\left(1, \mathsf{exp.f64}\left(\mathsf{+.f64}\left(\ell, \mathsf{\_.f64}\left(\mathsf{*.f64}\left(\frac{1}{4}, \mathsf{*.f64}\left(\left(m + n\right), \left(m + n\right)\right)\right), \left(\left|n - m\right|\right)\right)\right)\right)\right) \]
                10. +-lowering-+.f64N/A

                  \[\leadsto \mathsf{/.f64}\left(1, \mathsf{exp.f64}\left(\mathsf{+.f64}\left(\ell, \mathsf{\_.f64}\left(\mathsf{*.f64}\left(\frac{1}{4}, \mathsf{*.f64}\left(\mathsf{+.f64}\left(m, n\right), \left(m + n\right)\right)\right), \left(\left|n - m\right|\right)\right)\right)\right)\right) \]
                11. +-lowering-+.f64N/A

                  \[\leadsto \mathsf{/.f64}\left(1, \mathsf{exp.f64}\left(\mathsf{+.f64}\left(\ell, \mathsf{\_.f64}\left(\mathsf{*.f64}\left(\frac{1}{4}, \mathsf{*.f64}\left(\mathsf{+.f64}\left(m, n\right), \mathsf{+.f64}\left(m, n\right)\right)\right), \left(\left|n - m\right|\right)\right)\right)\right)\right) \]
                12. sub-negN/A

                  \[\leadsto \mathsf{/.f64}\left(1, \mathsf{exp.f64}\left(\mathsf{+.f64}\left(\ell, \mathsf{\_.f64}\left(\mathsf{*.f64}\left(\frac{1}{4}, \mathsf{*.f64}\left(\mathsf{+.f64}\left(m, n\right), \mathsf{+.f64}\left(m, n\right)\right)\right), \left(\left|n + \left(\mathsf{neg}\left(m\right)\right)\right|\right)\right)\right)\right)\right) \]
                13. mul-1-negN/A

                  \[\leadsto \mathsf{/.f64}\left(1, \mathsf{exp.f64}\left(\mathsf{+.f64}\left(\ell, \mathsf{\_.f64}\left(\mathsf{*.f64}\left(\frac{1}{4}, \mathsf{*.f64}\left(\mathsf{+.f64}\left(m, n\right), \mathsf{+.f64}\left(m, n\right)\right)\right), \left(\left|n + -1 \cdot m\right|\right)\right)\right)\right)\right) \]
                14. fabs-lowering-fabs.f64N/A

                  \[\leadsto \mathsf{/.f64}\left(1, \mathsf{exp.f64}\left(\mathsf{+.f64}\left(\ell, \mathsf{\_.f64}\left(\mathsf{*.f64}\left(\frac{1}{4}, \mathsf{*.f64}\left(\mathsf{+.f64}\left(m, n\right), \mathsf{+.f64}\left(m, n\right)\right)\right), \mathsf{fabs.f64}\left(\left(n + -1 \cdot m\right)\right)\right)\right)\right)\right) \]
                15. mul-1-negN/A

                  \[\leadsto \mathsf{/.f64}\left(1, \mathsf{exp.f64}\left(\mathsf{+.f64}\left(\ell, \mathsf{\_.f64}\left(\mathsf{*.f64}\left(\frac{1}{4}, \mathsf{*.f64}\left(\mathsf{+.f64}\left(m, n\right), \mathsf{+.f64}\left(m, n\right)\right)\right), \mathsf{fabs.f64}\left(\left(n + \left(\mathsf{neg}\left(m\right)\right)\right)\right)\right)\right)\right)\right) \]
                16. sub-negN/A

                  \[\leadsto \mathsf{/.f64}\left(1, \mathsf{exp.f64}\left(\mathsf{+.f64}\left(\ell, \mathsf{\_.f64}\left(\mathsf{*.f64}\left(\frac{1}{4}, \mathsf{*.f64}\left(\mathsf{+.f64}\left(m, n\right), \mathsf{+.f64}\left(m, n\right)\right)\right), \mathsf{fabs.f64}\left(\left(n - m\right)\right)\right)\right)\right)\right) \]
                17. --lowering--.f6481.2%

                  \[\leadsto \mathsf{/.f64}\left(1, \mathsf{exp.f64}\left(\mathsf{+.f64}\left(\ell, \mathsf{\_.f64}\left(\mathsf{*.f64}\left(\frac{1}{4}, \mathsf{*.f64}\left(\mathsf{+.f64}\left(m, n\right), \mathsf{+.f64}\left(m, n\right)\right)\right), \mathsf{fabs.f64}\left(\mathsf{\_.f64}\left(n, m\right)\right)\right)\right)\right)\right) \]
              10. Simplified81.2%

                \[\leadsto \color{blue}{\frac{1}{e^{\ell + \left(0.25 \cdot \left(\left(m + n\right) \cdot \left(m + n\right)\right) - \left|n - m\right|\right)}}} \]
              11. Taylor expanded in m around inf

                \[\leadsto \mathsf{/.f64}\left(1, \mathsf{exp.f64}\left(\color{blue}{\left(\frac{1}{4} \cdot {m}^{2}\right)}\right)\right) \]
              12. Step-by-step derivation
                1. *-lowering-*.f64N/A

                  \[\leadsto \mathsf{/.f64}\left(1, \mathsf{exp.f64}\left(\mathsf{*.f64}\left(\frac{1}{4}, \left({m}^{2}\right)\right)\right)\right) \]
                2. unpow2N/A

                  \[\leadsto \mathsf{/.f64}\left(1, \mathsf{exp.f64}\left(\mathsf{*.f64}\left(\frac{1}{4}, \left(m \cdot m\right)\right)\right)\right) \]
                3. *-lowering-*.f6453.3%

                  \[\leadsto \mathsf{/.f64}\left(1, \mathsf{exp.f64}\left(\mathsf{*.f64}\left(\frac{1}{4}, \mathsf{*.f64}\left(m, m\right)\right)\right)\right) \]
              13. Simplified53.3%

                \[\leadsto \frac{1}{e^{\color{blue}{0.25 \cdot \left(m \cdot m\right)}}} \]

              if 6.39999999999999971e-161 < n < 9.4e13

              1. Initial program 71.6%

                \[\cos \left(\frac{K \cdot \left(m + n\right)}{2} - M\right) \cdot e^{\left(-{\left(\frac{m + n}{2} - M\right)}^{2}\right) - \left(\ell - \left|m - n\right|\right)} \]
              2. Step-by-step derivation
                1. neg-sub0N/A

                  \[\leadsto \cos \left(\frac{K \cdot \left(m + n\right)}{2} - M\right) \cdot e^{\left(0 - {\left(\frac{m + n}{2} - M\right)}^{2}\right) - \left(\ell - \left|m - n\right|\right)} \]
                2. associate--l-N/A

                  \[\leadsto \cos \left(\frac{K \cdot \left(m + n\right)}{2} - M\right) \cdot e^{0 - \left({\left(\frac{m + n}{2} - M\right)}^{2} + \left(\ell - \left|m - n\right|\right)\right)} \]
                3. exp-diffN/A

                  \[\leadsto \cos \left(\frac{K \cdot \left(m + n\right)}{2} - M\right) \cdot \frac{e^{0}}{\color{blue}{e^{{\left(\frac{m + n}{2} - M\right)}^{2} + \left(\ell - \left|m - n\right|\right)}}} \]
                4. associate-*r/N/A

                  \[\leadsto \frac{\cos \left(\frac{K \cdot \left(m + n\right)}{2} - M\right) \cdot e^{0}}{\color{blue}{e^{{\left(\frac{m + n}{2} - M\right)}^{2} + \left(\ell - \left|m - n\right|\right)}}} \]
                5. exp-0N/A

                  \[\leadsto \frac{\cos \left(\frac{K \cdot \left(m + n\right)}{2} - M\right) \cdot 1}{e^{{\left(\frac{m + n}{2} - M\right)}^{2} + \color{blue}{\left(\ell - \left|m - n\right|\right)}}} \]
                6. *-rgt-identityN/A

                  \[\leadsto \frac{\cos \left(\frac{K \cdot \left(m + n\right)}{2} - M\right)}{e^{\color{blue}{{\left(\frac{m + n}{2} - M\right)}^{2} + \left(\ell - \left|m - n\right|\right)}}} \]
                7. /-lowering-/.f64N/A

                  \[\leadsto \mathsf{/.f64}\left(\cos \left(\frac{K \cdot \left(m + n\right)}{2} - M\right), \color{blue}{\left(e^{{\left(\frac{m + n}{2} - M\right)}^{2} + \left(\ell - \left|m - n\right|\right)}\right)}\right) \]
              3. Simplified71.6%

                \[\leadsto \color{blue}{\frac{\cos \left(\frac{K \cdot \left(m + n\right)}{2} - M\right)}{e^{\left(\left(\frac{m + n}{2} - M\right) \cdot \left(\frac{m + n}{2} - M\right) + \ell\right) - \left|m - n\right|}}} \]
              4. Add Preprocessing
              5. Taylor expanded in K around 0

                \[\leadsto \mathsf{/.f64}\left(\color{blue}{\cos \left(\mathsf{neg}\left(M\right)\right)}, \mathsf{exp.f64}\left(\mathsf{\_.f64}\left(\mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\mathsf{/.f64}\left(\mathsf{+.f64}\left(m, n\right), 2\right), M\right), \mathsf{\_.f64}\left(\mathsf{/.f64}\left(\mathsf{+.f64}\left(m, n\right), 2\right), M\right)\right), \ell\right), \mathsf{fabs.f64}\left(\mathsf{\_.f64}\left(m, n\right)\right)\right)\right)\right) \]
              6. Step-by-step derivation
                1. cos-negN/A

                  \[\leadsto \mathsf{/.f64}\left(\cos M, \mathsf{exp.f64}\left(\color{blue}{\mathsf{\_.f64}\left(\mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\mathsf{/.f64}\left(\mathsf{+.f64}\left(m, n\right), 2\right), M\right), \mathsf{\_.f64}\left(\mathsf{/.f64}\left(\mathsf{+.f64}\left(m, n\right), 2\right), M\right)\right), \ell\right), \mathsf{fabs.f64}\left(\mathsf{\_.f64}\left(m, n\right)\right)\right)}\right)\right) \]
                2. cos-lowering-cos.f6493.0%

                  \[\leadsto \mathsf{/.f64}\left(\mathsf{cos.f64}\left(M\right), \mathsf{exp.f64}\left(\color{blue}{\mathsf{\_.f64}\left(\mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\mathsf{/.f64}\left(\mathsf{+.f64}\left(m, n\right), 2\right), M\right), \mathsf{\_.f64}\left(\mathsf{/.f64}\left(\mathsf{+.f64}\left(m, n\right), 2\right), M\right)\right), \ell\right), \mathsf{fabs.f64}\left(\mathsf{\_.f64}\left(m, n\right)\right)\right)}\right)\right) \]
              7. Simplified93.0%

                \[\leadsto \frac{\color{blue}{\cos M}}{e^{\left(\left(\frac{m + n}{2} - M\right) \cdot \left(\frac{m + n}{2} - M\right) + \ell\right) - \left|m - n\right|}} \]
              8. Taylor expanded in l around inf

                \[\leadsto \mathsf{/.f64}\left(\mathsf{cos.f64}\left(M\right), \mathsf{exp.f64}\left(\color{blue}{\ell}\right)\right) \]
              9. Step-by-step derivation
                1. Simplified41.8%

                  \[\leadsto \frac{\cos M}{e^{\color{blue}{\ell}}} \]
                2. Taylor expanded in M around 0

                  \[\leadsto \mathsf{/.f64}\left(\color{blue}{1}, \mathsf{exp.f64}\left(\ell\right)\right) \]
                3. Step-by-step derivation
                  1. Simplified41.8%

                    \[\leadsto \frac{\color{blue}{1}}{e^{\ell}} \]

                  if 9.4e13 < n

                  1. Initial program 63.6%

                    \[\cos \left(\frac{K \cdot \left(m + n\right)}{2} - M\right) \cdot e^{\left(-{\left(\frac{m + n}{2} - M\right)}^{2}\right) - \left(\ell - \left|m - n\right|\right)} \]
                  2. Step-by-step derivation
                    1. neg-sub0N/A

                      \[\leadsto \cos \left(\frac{K \cdot \left(m + n\right)}{2} - M\right) \cdot e^{\left(0 - {\left(\frac{m + n}{2} - M\right)}^{2}\right) - \left(\ell - \left|m - n\right|\right)} \]
                    2. associate--l-N/A

                      \[\leadsto \cos \left(\frac{K \cdot \left(m + n\right)}{2} - M\right) \cdot e^{0 - \left({\left(\frac{m + n}{2} - M\right)}^{2} + \left(\ell - \left|m - n\right|\right)\right)} \]
                    3. exp-diffN/A

                      \[\leadsto \cos \left(\frac{K \cdot \left(m + n\right)}{2} - M\right) \cdot \frac{e^{0}}{\color{blue}{e^{{\left(\frac{m + n}{2} - M\right)}^{2} + \left(\ell - \left|m - n\right|\right)}}} \]
                    4. associate-*r/N/A

                      \[\leadsto \frac{\cos \left(\frac{K \cdot \left(m + n\right)}{2} - M\right) \cdot e^{0}}{\color{blue}{e^{{\left(\frac{m + n}{2} - M\right)}^{2} + \left(\ell - \left|m - n\right|\right)}}} \]
                    5. exp-0N/A

                      \[\leadsto \frac{\cos \left(\frac{K \cdot \left(m + n\right)}{2} - M\right) \cdot 1}{e^{{\left(\frac{m + n}{2} - M\right)}^{2} + \color{blue}{\left(\ell - \left|m - n\right|\right)}}} \]
                    6. *-rgt-identityN/A

                      \[\leadsto \frac{\cos \left(\frac{K \cdot \left(m + n\right)}{2} - M\right)}{e^{\color{blue}{{\left(\frac{m + n}{2} - M\right)}^{2} + \left(\ell - \left|m - n\right|\right)}}} \]
                    7. /-lowering-/.f64N/A

                      \[\leadsto \mathsf{/.f64}\left(\cos \left(\frac{K \cdot \left(m + n\right)}{2} - M\right), \color{blue}{\left(e^{{\left(\frac{m + n}{2} - M\right)}^{2} + \left(\ell - \left|m - n\right|\right)}\right)}\right) \]
                  3. Simplified63.6%

                    \[\leadsto \color{blue}{\frac{\cos \left(\frac{K \cdot \left(m + n\right)}{2} - M\right)}{e^{\left(\left(\frac{m + n}{2} - M\right) \cdot \left(\frac{m + n}{2} - M\right) + \ell\right) - \left|m - n\right|}}} \]
                  4. Add Preprocessing
                  5. Taylor expanded in K around 0

                    \[\leadsto \mathsf{/.f64}\left(\color{blue}{\cos \left(\mathsf{neg}\left(M\right)\right)}, \mathsf{exp.f64}\left(\mathsf{\_.f64}\left(\mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\mathsf{/.f64}\left(\mathsf{+.f64}\left(m, n\right), 2\right), M\right), \mathsf{\_.f64}\left(\mathsf{/.f64}\left(\mathsf{+.f64}\left(m, n\right), 2\right), M\right)\right), \ell\right), \mathsf{fabs.f64}\left(\mathsf{\_.f64}\left(m, n\right)\right)\right)\right)\right) \]
                  6. Step-by-step derivation
                    1. cos-negN/A

                      \[\leadsto \mathsf{/.f64}\left(\cos M, \mathsf{exp.f64}\left(\color{blue}{\mathsf{\_.f64}\left(\mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\mathsf{/.f64}\left(\mathsf{+.f64}\left(m, n\right), 2\right), M\right), \mathsf{\_.f64}\left(\mathsf{/.f64}\left(\mathsf{+.f64}\left(m, n\right), 2\right), M\right)\right), \ell\right), \mathsf{fabs.f64}\left(\mathsf{\_.f64}\left(m, n\right)\right)\right)}\right)\right) \]
                    2. cos-lowering-cos.f64100.0%

                      \[\leadsto \mathsf{/.f64}\left(\mathsf{cos.f64}\left(M\right), \mathsf{exp.f64}\left(\color{blue}{\mathsf{\_.f64}\left(\mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\mathsf{/.f64}\left(\mathsf{+.f64}\left(m, n\right), 2\right), M\right), \mathsf{\_.f64}\left(\mathsf{/.f64}\left(\mathsf{+.f64}\left(m, n\right), 2\right), M\right)\right), \ell\right), \mathsf{fabs.f64}\left(\mathsf{\_.f64}\left(m, n\right)\right)\right)}\right)\right) \]
                  7. Simplified100.0%

                    \[\leadsto \frac{\color{blue}{\cos M}}{e^{\left(\left(\frac{m + n}{2} - M\right) \cdot \left(\frac{m + n}{2} - M\right) + \ell\right) - \left|m - n\right|}} \]
                  8. Taylor expanded in M around 0

                    \[\leadsto \color{blue}{\frac{1}{e^{\left(\ell + \frac{1}{4} \cdot {\left(m + n\right)}^{2}\right) - \left|m - n\right|}}} \]
                  9. Step-by-step derivation
                    1. /-lowering-/.f64N/A

                      \[\leadsto \mathsf{/.f64}\left(1, \color{blue}{\left(e^{\left(\ell + \frac{1}{4} \cdot {\left(m + n\right)}^{2}\right) - \left|m - n\right|}\right)}\right) \]
                    2. exp-lowering-exp.f64N/A

                      \[\leadsto \mathsf{/.f64}\left(1, \mathsf{exp.f64}\left(\left(\left(\ell + \frac{1}{4} \cdot {\left(m + n\right)}^{2}\right) - \left|m - n\right|\right)\right)\right) \]
                    3. fabs-subN/A

                      \[\leadsto \mathsf{/.f64}\left(1, \mathsf{exp.f64}\left(\left(\left(\ell + \frac{1}{4} \cdot {\left(m + n\right)}^{2}\right) - \left|n - m\right|\right)\right)\right) \]
                    4. associate--l+N/A

                      \[\leadsto \mathsf{/.f64}\left(1, \mathsf{exp.f64}\left(\left(\ell + \left(\frac{1}{4} \cdot {\left(m + n\right)}^{2} - \left|n - m\right|\right)\right)\right)\right) \]
                    5. +-lowering-+.f64N/A

                      \[\leadsto \mathsf{/.f64}\left(1, \mathsf{exp.f64}\left(\mathsf{+.f64}\left(\ell, \left(\frac{1}{4} \cdot {\left(m + n\right)}^{2} - \left|n - m\right|\right)\right)\right)\right) \]
                    6. --lowering--.f64N/A

                      \[\leadsto \mathsf{/.f64}\left(1, \mathsf{exp.f64}\left(\mathsf{+.f64}\left(\ell, \mathsf{\_.f64}\left(\left(\frac{1}{4} \cdot {\left(m + n\right)}^{2}\right), \left(\left|n - m\right|\right)\right)\right)\right)\right) \]
                    7. *-lowering-*.f64N/A

                      \[\leadsto \mathsf{/.f64}\left(1, \mathsf{exp.f64}\left(\mathsf{+.f64}\left(\ell, \mathsf{\_.f64}\left(\mathsf{*.f64}\left(\frac{1}{4}, \left({\left(m + n\right)}^{2}\right)\right), \left(\left|n - m\right|\right)\right)\right)\right)\right) \]
                    8. unpow2N/A

                      \[\leadsto \mathsf{/.f64}\left(1, \mathsf{exp.f64}\left(\mathsf{+.f64}\left(\ell, \mathsf{\_.f64}\left(\mathsf{*.f64}\left(\frac{1}{4}, \left(\left(m + n\right) \cdot \left(m + n\right)\right)\right), \left(\left|n - m\right|\right)\right)\right)\right)\right) \]
                    9. *-lowering-*.f64N/A

                      \[\leadsto \mathsf{/.f64}\left(1, \mathsf{exp.f64}\left(\mathsf{+.f64}\left(\ell, \mathsf{\_.f64}\left(\mathsf{*.f64}\left(\frac{1}{4}, \mathsf{*.f64}\left(\left(m + n\right), \left(m + n\right)\right)\right), \left(\left|n - m\right|\right)\right)\right)\right)\right) \]
                    10. +-lowering-+.f64N/A

                      \[\leadsto \mathsf{/.f64}\left(1, \mathsf{exp.f64}\left(\mathsf{+.f64}\left(\ell, \mathsf{\_.f64}\left(\mathsf{*.f64}\left(\frac{1}{4}, \mathsf{*.f64}\left(\mathsf{+.f64}\left(m, n\right), \left(m + n\right)\right)\right), \left(\left|n - m\right|\right)\right)\right)\right)\right) \]
                    11. +-lowering-+.f64N/A

                      \[\leadsto \mathsf{/.f64}\left(1, \mathsf{exp.f64}\left(\mathsf{+.f64}\left(\ell, \mathsf{\_.f64}\left(\mathsf{*.f64}\left(\frac{1}{4}, \mathsf{*.f64}\left(\mathsf{+.f64}\left(m, n\right), \mathsf{+.f64}\left(m, n\right)\right)\right), \left(\left|n - m\right|\right)\right)\right)\right)\right) \]
                    12. sub-negN/A

                      \[\leadsto \mathsf{/.f64}\left(1, \mathsf{exp.f64}\left(\mathsf{+.f64}\left(\ell, \mathsf{\_.f64}\left(\mathsf{*.f64}\left(\frac{1}{4}, \mathsf{*.f64}\left(\mathsf{+.f64}\left(m, n\right), \mathsf{+.f64}\left(m, n\right)\right)\right), \left(\left|n + \left(\mathsf{neg}\left(m\right)\right)\right|\right)\right)\right)\right)\right) \]
                    13. mul-1-negN/A

                      \[\leadsto \mathsf{/.f64}\left(1, \mathsf{exp.f64}\left(\mathsf{+.f64}\left(\ell, \mathsf{\_.f64}\left(\mathsf{*.f64}\left(\frac{1}{4}, \mathsf{*.f64}\left(\mathsf{+.f64}\left(m, n\right), \mathsf{+.f64}\left(m, n\right)\right)\right), \left(\left|n + -1 \cdot m\right|\right)\right)\right)\right)\right) \]
                    14. fabs-lowering-fabs.f64N/A

                      \[\leadsto \mathsf{/.f64}\left(1, \mathsf{exp.f64}\left(\mathsf{+.f64}\left(\ell, \mathsf{\_.f64}\left(\mathsf{*.f64}\left(\frac{1}{4}, \mathsf{*.f64}\left(\mathsf{+.f64}\left(m, n\right), \mathsf{+.f64}\left(m, n\right)\right)\right), \mathsf{fabs.f64}\left(\left(n + -1 \cdot m\right)\right)\right)\right)\right)\right) \]
                    15. mul-1-negN/A

                      \[\leadsto \mathsf{/.f64}\left(1, \mathsf{exp.f64}\left(\mathsf{+.f64}\left(\ell, \mathsf{\_.f64}\left(\mathsf{*.f64}\left(\frac{1}{4}, \mathsf{*.f64}\left(\mathsf{+.f64}\left(m, n\right), \mathsf{+.f64}\left(m, n\right)\right)\right), \mathsf{fabs.f64}\left(\left(n + \left(\mathsf{neg}\left(m\right)\right)\right)\right)\right)\right)\right)\right) \]
                    16. sub-negN/A

                      \[\leadsto \mathsf{/.f64}\left(1, \mathsf{exp.f64}\left(\mathsf{+.f64}\left(\ell, \mathsf{\_.f64}\left(\mathsf{*.f64}\left(\frac{1}{4}, \mathsf{*.f64}\left(\mathsf{+.f64}\left(m, n\right), \mathsf{+.f64}\left(m, n\right)\right)\right), \mathsf{fabs.f64}\left(\left(n - m\right)\right)\right)\right)\right)\right) \]
                    17. --lowering--.f64100.0%

                      \[\leadsto \mathsf{/.f64}\left(1, \mathsf{exp.f64}\left(\mathsf{+.f64}\left(\ell, \mathsf{\_.f64}\left(\mathsf{*.f64}\left(\frac{1}{4}, \mathsf{*.f64}\left(\mathsf{+.f64}\left(m, n\right), \mathsf{+.f64}\left(m, n\right)\right)\right), \mathsf{fabs.f64}\left(\mathsf{\_.f64}\left(n, m\right)\right)\right)\right)\right)\right) \]
                  10. Simplified100.0%

                    \[\leadsto \color{blue}{\frac{1}{e^{\ell + \left(0.25 \cdot \left(\left(m + n\right) \cdot \left(m + n\right)\right) - \left|n - m\right|\right)}}} \]
                  11. Taylor expanded in n around inf

                    \[\leadsto \mathsf{/.f64}\left(1, \mathsf{exp.f64}\left(\color{blue}{\left(\frac{1}{4} \cdot {n}^{2}\right)}\right)\right) \]
                  12. Step-by-step derivation
                    1. *-lowering-*.f64N/A

                      \[\leadsto \mathsf{/.f64}\left(1, \mathsf{exp.f64}\left(\mathsf{*.f64}\left(\frac{1}{4}, \left({n}^{2}\right)\right)\right)\right) \]
                    2. unpow2N/A

                      \[\leadsto \mathsf{/.f64}\left(1, \mathsf{exp.f64}\left(\mathsf{*.f64}\left(\frac{1}{4}, \left(n \cdot n\right)\right)\right)\right) \]
                    3. *-lowering-*.f64100.0%

                      \[\leadsto \mathsf{/.f64}\left(1, \mathsf{exp.f64}\left(\mathsf{*.f64}\left(\frac{1}{4}, \mathsf{*.f64}\left(n, n\right)\right)\right)\right) \]
                  13. Simplified100.0%

                    \[\leadsto \frac{1}{e^{\color{blue}{0.25 \cdot \left(n \cdot n\right)}}} \]
                4. Recombined 3 regimes into one program.
                5. Add Preprocessing

                Alternative 13: 69.5% accurate, 3.6× speedup?

                \[\begin{array}{l} \\ \begin{array}{l} t_0 := \frac{1}{e^{0.25 \cdot \left(m \cdot m\right)}}\\ \mathbf{if}\;m \leq -54:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;m \leq 3.3 \cdot 10^{-12}:\\ \;\;\;\;\frac{1}{e^{\ell}}\\ \mathbf{else}:\\ \;\;\;\;t\_0\\ \end{array} \end{array} \]
                (FPCore (K m n M l)
                 :precision binary64
                 (let* ((t_0 (/ 1.0 (exp (* 0.25 (* m m))))))
                   (if (<= m -54.0) t_0 (if (<= m 3.3e-12) (/ 1.0 (exp l)) t_0))))
                double code(double K, double m, double n, double M, double l) {
                	double t_0 = 1.0 / exp((0.25 * (m * m)));
                	double tmp;
                	if (m <= -54.0) {
                		tmp = t_0;
                	} else if (m <= 3.3e-12) {
                		tmp = 1.0 / exp(l);
                	} else {
                		tmp = t_0;
                	}
                	return tmp;
                }
                
                real(8) function code(k, m, n, m_1, l)
                    real(8), intent (in) :: k
                    real(8), intent (in) :: m
                    real(8), intent (in) :: n
                    real(8), intent (in) :: m_1
                    real(8), intent (in) :: l
                    real(8) :: t_0
                    real(8) :: tmp
                    t_0 = 1.0d0 / exp((0.25d0 * (m * m)))
                    if (m <= (-54.0d0)) then
                        tmp = t_0
                    else if (m <= 3.3d-12) then
                        tmp = 1.0d0 / exp(l)
                    else
                        tmp = t_0
                    end if
                    code = tmp
                end function
                
                public static double code(double K, double m, double n, double M, double l) {
                	double t_0 = 1.0 / Math.exp((0.25 * (m * m)));
                	double tmp;
                	if (m <= -54.0) {
                		tmp = t_0;
                	} else if (m <= 3.3e-12) {
                		tmp = 1.0 / Math.exp(l);
                	} else {
                		tmp = t_0;
                	}
                	return tmp;
                }
                
                def code(K, m, n, M, l):
                	t_0 = 1.0 / math.exp((0.25 * (m * m)))
                	tmp = 0
                	if m <= -54.0:
                		tmp = t_0
                	elif m <= 3.3e-12:
                		tmp = 1.0 / math.exp(l)
                	else:
                		tmp = t_0
                	return tmp
                
                function code(K, m, n, M, l)
                	t_0 = Float64(1.0 / exp(Float64(0.25 * Float64(m * m))))
                	tmp = 0.0
                	if (m <= -54.0)
                		tmp = t_0;
                	elseif (m <= 3.3e-12)
                		tmp = Float64(1.0 / exp(l));
                	else
                		tmp = t_0;
                	end
                	return tmp
                end
                
                function tmp_2 = code(K, m, n, M, l)
                	t_0 = 1.0 / exp((0.25 * (m * m)));
                	tmp = 0.0;
                	if (m <= -54.0)
                		tmp = t_0;
                	elseif (m <= 3.3e-12)
                		tmp = 1.0 / exp(l);
                	else
                		tmp = t_0;
                	end
                	tmp_2 = tmp;
                end
                
                code[K_, m_, n_, M_, l_] := Block[{t$95$0 = N[(1.0 / N[Exp[N[(0.25 * N[(m * m), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[m, -54.0], t$95$0, If[LessEqual[m, 3.3e-12], N[(1.0 / N[Exp[l], $MachinePrecision]), $MachinePrecision], t$95$0]]]
                
                \begin{array}{l}
                
                \\
                \begin{array}{l}
                t_0 := \frac{1}{e^{0.25 \cdot \left(m \cdot m\right)}}\\
                \mathbf{if}\;m \leq -54:\\
                \;\;\;\;t\_0\\
                
                \mathbf{elif}\;m \leq 3.3 \cdot 10^{-12}:\\
                \;\;\;\;\frac{1}{e^{\ell}}\\
                
                \mathbf{else}:\\
                \;\;\;\;t\_0\\
                
                
                \end{array}
                \end{array}
                
                Derivation
                1. Split input into 2 regimes
                2. if m < -54 or 3.3000000000000001e-12 < m

                  1. Initial program 67.7%

                    \[\cos \left(\frac{K \cdot \left(m + n\right)}{2} - M\right) \cdot e^{\left(-{\left(\frac{m + n}{2} - M\right)}^{2}\right) - \left(\ell - \left|m - n\right|\right)} \]
                  2. Step-by-step derivation
                    1. neg-sub0N/A

                      \[\leadsto \cos \left(\frac{K \cdot \left(m + n\right)}{2} - M\right) \cdot e^{\left(0 - {\left(\frac{m + n}{2} - M\right)}^{2}\right) - \left(\ell - \left|m - n\right|\right)} \]
                    2. associate--l-N/A

                      \[\leadsto \cos \left(\frac{K \cdot \left(m + n\right)}{2} - M\right) \cdot e^{0 - \left({\left(\frac{m + n}{2} - M\right)}^{2} + \left(\ell - \left|m - n\right|\right)\right)} \]
                    3. exp-diffN/A

                      \[\leadsto \cos \left(\frac{K \cdot \left(m + n\right)}{2} - M\right) \cdot \frac{e^{0}}{\color{blue}{e^{{\left(\frac{m + n}{2} - M\right)}^{2} + \left(\ell - \left|m - n\right|\right)}}} \]
                    4. associate-*r/N/A

                      \[\leadsto \frac{\cos \left(\frac{K \cdot \left(m + n\right)}{2} - M\right) \cdot e^{0}}{\color{blue}{e^{{\left(\frac{m + n}{2} - M\right)}^{2} + \left(\ell - \left|m - n\right|\right)}}} \]
                    5. exp-0N/A

                      \[\leadsto \frac{\cos \left(\frac{K \cdot \left(m + n\right)}{2} - M\right) \cdot 1}{e^{{\left(\frac{m + n}{2} - M\right)}^{2} + \color{blue}{\left(\ell - \left|m - n\right|\right)}}} \]
                    6. *-rgt-identityN/A

                      \[\leadsto \frac{\cos \left(\frac{K \cdot \left(m + n\right)}{2} - M\right)}{e^{\color{blue}{{\left(\frac{m + n}{2} - M\right)}^{2} + \left(\ell - \left|m - n\right|\right)}}} \]
                    7. /-lowering-/.f64N/A

                      \[\leadsto \mathsf{/.f64}\left(\cos \left(\frac{K \cdot \left(m + n\right)}{2} - M\right), \color{blue}{\left(e^{{\left(\frac{m + n}{2} - M\right)}^{2} + \left(\ell - \left|m - n\right|\right)}\right)}\right) \]
                  3. Simplified67.7%

                    \[\leadsto \color{blue}{\frac{\cos \left(\frac{K \cdot \left(m + n\right)}{2} - M\right)}{e^{\left(\left(\frac{m + n}{2} - M\right) \cdot \left(\frac{m + n}{2} - M\right) + \ell\right) - \left|m - n\right|}}} \]
                  4. Add Preprocessing
                  5. Taylor expanded in K around 0

                    \[\leadsto \mathsf{/.f64}\left(\color{blue}{\cos \left(\mathsf{neg}\left(M\right)\right)}, \mathsf{exp.f64}\left(\mathsf{\_.f64}\left(\mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\mathsf{/.f64}\left(\mathsf{+.f64}\left(m, n\right), 2\right), M\right), \mathsf{\_.f64}\left(\mathsf{/.f64}\left(\mathsf{+.f64}\left(m, n\right), 2\right), M\right)\right), \ell\right), \mathsf{fabs.f64}\left(\mathsf{\_.f64}\left(m, n\right)\right)\right)\right)\right) \]
                  6. Step-by-step derivation
                    1. cos-negN/A

                      \[\leadsto \mathsf{/.f64}\left(\cos M, \mathsf{exp.f64}\left(\color{blue}{\mathsf{\_.f64}\left(\mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\mathsf{/.f64}\left(\mathsf{+.f64}\left(m, n\right), 2\right), M\right), \mathsf{\_.f64}\left(\mathsf{/.f64}\left(\mathsf{+.f64}\left(m, n\right), 2\right), M\right)\right), \ell\right), \mathsf{fabs.f64}\left(\mathsf{\_.f64}\left(m, n\right)\right)\right)}\right)\right) \]
                    2. cos-lowering-cos.f6499.2%

                      \[\leadsto \mathsf{/.f64}\left(\mathsf{cos.f64}\left(M\right), \mathsf{exp.f64}\left(\color{blue}{\mathsf{\_.f64}\left(\mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\mathsf{/.f64}\left(\mathsf{+.f64}\left(m, n\right), 2\right), M\right), \mathsf{\_.f64}\left(\mathsf{/.f64}\left(\mathsf{+.f64}\left(m, n\right), 2\right), M\right)\right), \ell\right), \mathsf{fabs.f64}\left(\mathsf{\_.f64}\left(m, n\right)\right)\right)}\right)\right) \]
                  7. Simplified99.2%

                    \[\leadsto \frac{\color{blue}{\cos M}}{e^{\left(\left(\frac{m + n}{2} - M\right) \cdot \left(\frac{m + n}{2} - M\right) + \ell\right) - \left|m - n\right|}} \]
                  8. Taylor expanded in M around 0

                    \[\leadsto \color{blue}{\frac{1}{e^{\left(\ell + \frac{1}{4} \cdot {\left(m + n\right)}^{2}\right) - \left|m - n\right|}}} \]
                  9. Step-by-step derivation
                    1. /-lowering-/.f64N/A

                      \[\leadsto \mathsf{/.f64}\left(1, \color{blue}{\left(e^{\left(\ell + \frac{1}{4} \cdot {\left(m + n\right)}^{2}\right) - \left|m - n\right|}\right)}\right) \]
                    2. exp-lowering-exp.f64N/A

                      \[\leadsto \mathsf{/.f64}\left(1, \mathsf{exp.f64}\left(\left(\left(\ell + \frac{1}{4} \cdot {\left(m + n\right)}^{2}\right) - \left|m - n\right|\right)\right)\right) \]
                    3. fabs-subN/A

                      \[\leadsto \mathsf{/.f64}\left(1, \mathsf{exp.f64}\left(\left(\left(\ell + \frac{1}{4} \cdot {\left(m + n\right)}^{2}\right) - \left|n - m\right|\right)\right)\right) \]
                    4. associate--l+N/A

                      \[\leadsto \mathsf{/.f64}\left(1, \mathsf{exp.f64}\left(\left(\ell + \left(\frac{1}{4} \cdot {\left(m + n\right)}^{2} - \left|n - m\right|\right)\right)\right)\right) \]
                    5. +-lowering-+.f64N/A

                      \[\leadsto \mathsf{/.f64}\left(1, \mathsf{exp.f64}\left(\mathsf{+.f64}\left(\ell, \left(\frac{1}{4} \cdot {\left(m + n\right)}^{2} - \left|n - m\right|\right)\right)\right)\right) \]
                    6. --lowering--.f64N/A

                      \[\leadsto \mathsf{/.f64}\left(1, \mathsf{exp.f64}\left(\mathsf{+.f64}\left(\ell, \mathsf{\_.f64}\left(\left(\frac{1}{4} \cdot {\left(m + n\right)}^{2}\right), \left(\left|n - m\right|\right)\right)\right)\right)\right) \]
                    7. *-lowering-*.f64N/A

                      \[\leadsto \mathsf{/.f64}\left(1, \mathsf{exp.f64}\left(\mathsf{+.f64}\left(\ell, \mathsf{\_.f64}\left(\mathsf{*.f64}\left(\frac{1}{4}, \left({\left(m + n\right)}^{2}\right)\right), \left(\left|n - m\right|\right)\right)\right)\right)\right) \]
                    8. unpow2N/A

                      \[\leadsto \mathsf{/.f64}\left(1, \mathsf{exp.f64}\left(\mathsf{+.f64}\left(\ell, \mathsf{\_.f64}\left(\mathsf{*.f64}\left(\frac{1}{4}, \left(\left(m + n\right) \cdot \left(m + n\right)\right)\right), \left(\left|n - m\right|\right)\right)\right)\right)\right) \]
                    9. *-lowering-*.f64N/A

                      \[\leadsto \mathsf{/.f64}\left(1, \mathsf{exp.f64}\left(\mathsf{+.f64}\left(\ell, \mathsf{\_.f64}\left(\mathsf{*.f64}\left(\frac{1}{4}, \mathsf{*.f64}\left(\left(m + n\right), \left(m + n\right)\right)\right), \left(\left|n - m\right|\right)\right)\right)\right)\right) \]
                    10. +-lowering-+.f64N/A

                      \[\leadsto \mathsf{/.f64}\left(1, \mathsf{exp.f64}\left(\mathsf{+.f64}\left(\ell, \mathsf{\_.f64}\left(\mathsf{*.f64}\left(\frac{1}{4}, \mathsf{*.f64}\left(\mathsf{+.f64}\left(m, n\right), \left(m + n\right)\right)\right), \left(\left|n - m\right|\right)\right)\right)\right)\right) \]
                    11. +-lowering-+.f64N/A

                      \[\leadsto \mathsf{/.f64}\left(1, \mathsf{exp.f64}\left(\mathsf{+.f64}\left(\ell, \mathsf{\_.f64}\left(\mathsf{*.f64}\left(\frac{1}{4}, \mathsf{*.f64}\left(\mathsf{+.f64}\left(m, n\right), \mathsf{+.f64}\left(m, n\right)\right)\right), \left(\left|n - m\right|\right)\right)\right)\right)\right) \]
                    12. sub-negN/A

                      \[\leadsto \mathsf{/.f64}\left(1, \mathsf{exp.f64}\left(\mathsf{+.f64}\left(\ell, \mathsf{\_.f64}\left(\mathsf{*.f64}\left(\frac{1}{4}, \mathsf{*.f64}\left(\mathsf{+.f64}\left(m, n\right), \mathsf{+.f64}\left(m, n\right)\right)\right), \left(\left|n + \left(\mathsf{neg}\left(m\right)\right)\right|\right)\right)\right)\right)\right) \]
                    13. mul-1-negN/A

                      \[\leadsto \mathsf{/.f64}\left(1, \mathsf{exp.f64}\left(\mathsf{+.f64}\left(\ell, \mathsf{\_.f64}\left(\mathsf{*.f64}\left(\frac{1}{4}, \mathsf{*.f64}\left(\mathsf{+.f64}\left(m, n\right), \mathsf{+.f64}\left(m, n\right)\right)\right), \left(\left|n + -1 \cdot m\right|\right)\right)\right)\right)\right) \]
                    14. fabs-lowering-fabs.f64N/A

                      \[\leadsto \mathsf{/.f64}\left(1, \mathsf{exp.f64}\left(\mathsf{+.f64}\left(\ell, \mathsf{\_.f64}\left(\mathsf{*.f64}\left(\frac{1}{4}, \mathsf{*.f64}\left(\mathsf{+.f64}\left(m, n\right), \mathsf{+.f64}\left(m, n\right)\right)\right), \mathsf{fabs.f64}\left(\left(n + -1 \cdot m\right)\right)\right)\right)\right)\right) \]
                    15. mul-1-negN/A

                      \[\leadsto \mathsf{/.f64}\left(1, \mathsf{exp.f64}\left(\mathsf{+.f64}\left(\ell, \mathsf{\_.f64}\left(\mathsf{*.f64}\left(\frac{1}{4}, \mathsf{*.f64}\left(\mathsf{+.f64}\left(m, n\right), \mathsf{+.f64}\left(m, n\right)\right)\right), \mathsf{fabs.f64}\left(\left(n + \left(\mathsf{neg}\left(m\right)\right)\right)\right)\right)\right)\right)\right) \]
                    16. sub-negN/A

                      \[\leadsto \mathsf{/.f64}\left(1, \mathsf{exp.f64}\left(\mathsf{+.f64}\left(\ell, \mathsf{\_.f64}\left(\mathsf{*.f64}\left(\frac{1}{4}, \mathsf{*.f64}\left(\mathsf{+.f64}\left(m, n\right), \mathsf{+.f64}\left(m, n\right)\right)\right), \mathsf{fabs.f64}\left(\left(n - m\right)\right)\right)\right)\right)\right) \]
                    17. --lowering--.f6494.8%

                      \[\leadsto \mathsf{/.f64}\left(1, \mathsf{exp.f64}\left(\mathsf{+.f64}\left(\ell, \mathsf{\_.f64}\left(\mathsf{*.f64}\left(\frac{1}{4}, \mathsf{*.f64}\left(\mathsf{+.f64}\left(m, n\right), \mathsf{+.f64}\left(m, n\right)\right)\right), \mathsf{fabs.f64}\left(\mathsf{\_.f64}\left(n, m\right)\right)\right)\right)\right)\right) \]
                  10. Simplified94.8%

                    \[\leadsto \color{blue}{\frac{1}{e^{\ell + \left(0.25 \cdot \left(\left(m + n\right) \cdot \left(m + n\right)\right) - \left|n - m\right|\right)}}} \]
                  11. Taylor expanded in m around inf

                    \[\leadsto \mathsf{/.f64}\left(1, \mathsf{exp.f64}\left(\color{blue}{\left(\frac{1}{4} \cdot {m}^{2}\right)}\right)\right) \]
                  12. Step-by-step derivation
                    1. *-lowering-*.f64N/A

                      \[\leadsto \mathsf{/.f64}\left(1, \mathsf{exp.f64}\left(\mathsf{*.f64}\left(\frac{1}{4}, \left({m}^{2}\right)\right)\right)\right) \]
                    2. unpow2N/A

                      \[\leadsto \mathsf{/.f64}\left(1, \mathsf{exp.f64}\left(\mathsf{*.f64}\left(\frac{1}{4}, \left(m \cdot m\right)\right)\right)\right) \]
                    3. *-lowering-*.f6493.4%

                      \[\leadsto \mathsf{/.f64}\left(1, \mathsf{exp.f64}\left(\mathsf{*.f64}\left(\frac{1}{4}, \mathsf{*.f64}\left(m, m\right)\right)\right)\right) \]
                  13. Simplified93.4%

                    \[\leadsto \frac{1}{e^{\color{blue}{0.25 \cdot \left(m \cdot m\right)}}} \]

                  if -54 < m < 3.3000000000000001e-12

                  1. Initial program 75.6%

                    \[\cos \left(\frac{K \cdot \left(m + n\right)}{2} - M\right) \cdot e^{\left(-{\left(\frac{m + n}{2} - M\right)}^{2}\right) - \left(\ell - \left|m - n\right|\right)} \]
                  2. Step-by-step derivation
                    1. neg-sub0N/A

                      \[\leadsto \cos \left(\frac{K \cdot \left(m + n\right)}{2} - M\right) \cdot e^{\left(0 - {\left(\frac{m + n}{2} - M\right)}^{2}\right) - \left(\ell - \left|m - n\right|\right)} \]
                    2. associate--l-N/A

                      \[\leadsto \cos \left(\frac{K \cdot \left(m + n\right)}{2} - M\right) \cdot e^{0 - \left({\left(\frac{m + n}{2} - M\right)}^{2} + \left(\ell - \left|m - n\right|\right)\right)} \]
                    3. exp-diffN/A

                      \[\leadsto \cos \left(\frac{K \cdot \left(m + n\right)}{2} - M\right) \cdot \frac{e^{0}}{\color{blue}{e^{{\left(\frac{m + n}{2} - M\right)}^{2} + \left(\ell - \left|m - n\right|\right)}}} \]
                    4. associate-*r/N/A

                      \[\leadsto \frac{\cos \left(\frac{K \cdot \left(m + n\right)}{2} - M\right) \cdot e^{0}}{\color{blue}{e^{{\left(\frac{m + n}{2} - M\right)}^{2} + \left(\ell - \left|m - n\right|\right)}}} \]
                    5. exp-0N/A

                      \[\leadsto \frac{\cos \left(\frac{K \cdot \left(m + n\right)}{2} - M\right) \cdot 1}{e^{{\left(\frac{m + n}{2} - M\right)}^{2} + \color{blue}{\left(\ell - \left|m - n\right|\right)}}} \]
                    6. *-rgt-identityN/A

                      \[\leadsto \frac{\cos \left(\frac{K \cdot \left(m + n\right)}{2} - M\right)}{e^{\color{blue}{{\left(\frac{m + n}{2} - M\right)}^{2} + \left(\ell - \left|m - n\right|\right)}}} \]
                    7. /-lowering-/.f64N/A

                      \[\leadsto \mathsf{/.f64}\left(\cos \left(\frac{K \cdot \left(m + n\right)}{2} - M\right), \color{blue}{\left(e^{{\left(\frac{m + n}{2} - M\right)}^{2} + \left(\ell - \left|m - n\right|\right)}\right)}\right) \]
                  3. Simplified75.6%

                    \[\leadsto \color{blue}{\frac{\cos \left(\frac{K \cdot \left(m + n\right)}{2} - M\right)}{e^{\left(\left(\frac{m + n}{2} - M\right) \cdot \left(\frac{m + n}{2} - M\right) + \ell\right) - \left|m - n\right|}}} \]
                  4. Add Preprocessing
                  5. Taylor expanded in K around 0

                    \[\leadsto \mathsf{/.f64}\left(\color{blue}{\cos \left(\mathsf{neg}\left(M\right)\right)}, \mathsf{exp.f64}\left(\mathsf{\_.f64}\left(\mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\mathsf{/.f64}\left(\mathsf{+.f64}\left(m, n\right), 2\right), M\right), \mathsf{\_.f64}\left(\mathsf{/.f64}\left(\mathsf{+.f64}\left(m, n\right), 2\right), M\right)\right), \ell\right), \mathsf{fabs.f64}\left(\mathsf{\_.f64}\left(m, n\right)\right)\right)\right)\right) \]
                  6. Step-by-step derivation
                    1. cos-negN/A

                      \[\leadsto \mathsf{/.f64}\left(\cos M, \mathsf{exp.f64}\left(\color{blue}{\mathsf{\_.f64}\left(\mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\mathsf{/.f64}\left(\mathsf{+.f64}\left(m, n\right), 2\right), M\right), \mathsf{\_.f64}\left(\mathsf{/.f64}\left(\mathsf{+.f64}\left(m, n\right), 2\right), M\right)\right), \ell\right), \mathsf{fabs.f64}\left(\mathsf{\_.f64}\left(m, n\right)\right)\right)}\right)\right) \]
                    2. cos-lowering-cos.f6489.1%

                      \[\leadsto \mathsf{/.f64}\left(\mathsf{cos.f64}\left(M\right), \mathsf{exp.f64}\left(\color{blue}{\mathsf{\_.f64}\left(\mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\mathsf{/.f64}\left(\mathsf{+.f64}\left(m, n\right), 2\right), M\right), \mathsf{\_.f64}\left(\mathsf{/.f64}\left(\mathsf{+.f64}\left(m, n\right), 2\right), M\right)\right), \ell\right), \mathsf{fabs.f64}\left(\mathsf{\_.f64}\left(m, n\right)\right)\right)}\right)\right) \]
                  7. Simplified89.1%

                    \[\leadsto \frac{\color{blue}{\cos M}}{e^{\left(\left(\frac{m + n}{2} - M\right) \cdot \left(\frac{m + n}{2} - M\right) + \ell\right) - \left|m - n\right|}} \]
                  8. Taylor expanded in l around inf

                    \[\leadsto \mathsf{/.f64}\left(\mathsf{cos.f64}\left(M\right), \mathsf{exp.f64}\left(\color{blue}{\ell}\right)\right) \]
                  9. Step-by-step derivation
                    1. Simplified40.8%

                      \[\leadsto \frac{\cos M}{e^{\color{blue}{\ell}}} \]
                    2. Taylor expanded in M around 0

                      \[\leadsto \mathsf{/.f64}\left(\color{blue}{1}, \mathsf{exp.f64}\left(\ell\right)\right) \]
                    3. Step-by-step derivation
                      1. Simplified40.8%

                        \[\leadsto \frac{\color{blue}{1}}{e^{\ell}} \]
                    4. Recombined 2 regimes into one program.
                    5. Add Preprocessing

                    Alternative 14: 35.7% accurate, 4.1× speedup?

                    \[\begin{array}{l} \\ \frac{1}{e^{\ell}} \end{array} \]
                    (FPCore (K m n M l) :precision binary64 (/ 1.0 (exp l)))
                    double code(double K, double m, double n, double M, double l) {
                    	return 1.0 / exp(l);
                    }
                    
                    real(8) function code(k, m, n, m_1, l)
                        real(8), intent (in) :: k
                        real(8), intent (in) :: m
                        real(8), intent (in) :: n
                        real(8), intent (in) :: m_1
                        real(8), intent (in) :: l
                        code = 1.0d0 / exp(l)
                    end function
                    
                    public static double code(double K, double m, double n, double M, double l) {
                    	return 1.0 / Math.exp(l);
                    }
                    
                    def code(K, m, n, M, l):
                    	return 1.0 / math.exp(l)
                    
                    function code(K, m, n, M, l)
                    	return Float64(1.0 / exp(l))
                    end
                    
                    function tmp = code(K, m, n, M, l)
                    	tmp = 1.0 / exp(l);
                    end
                    
                    code[K_, m_, n_, M_, l_] := N[(1.0 / N[Exp[l], $MachinePrecision]), $MachinePrecision]
                    
                    \begin{array}{l}
                    
                    \\
                    \frac{1}{e^{\ell}}
                    \end{array}
                    
                    Derivation
                    1. Initial program 71.5%

                      \[\cos \left(\frac{K \cdot \left(m + n\right)}{2} - M\right) \cdot e^{\left(-{\left(\frac{m + n}{2} - M\right)}^{2}\right) - \left(\ell - \left|m - n\right|\right)} \]
                    2. Step-by-step derivation
                      1. neg-sub0N/A

                        \[\leadsto \cos \left(\frac{K \cdot \left(m + n\right)}{2} - M\right) \cdot e^{\left(0 - {\left(\frac{m + n}{2} - M\right)}^{2}\right) - \left(\ell - \left|m - n\right|\right)} \]
                      2. associate--l-N/A

                        \[\leadsto \cos \left(\frac{K \cdot \left(m + n\right)}{2} - M\right) \cdot e^{0 - \left({\left(\frac{m + n}{2} - M\right)}^{2} + \left(\ell - \left|m - n\right|\right)\right)} \]
                      3. exp-diffN/A

                        \[\leadsto \cos \left(\frac{K \cdot \left(m + n\right)}{2} - M\right) \cdot \frac{e^{0}}{\color{blue}{e^{{\left(\frac{m + n}{2} - M\right)}^{2} + \left(\ell - \left|m - n\right|\right)}}} \]
                      4. associate-*r/N/A

                        \[\leadsto \frac{\cos \left(\frac{K \cdot \left(m + n\right)}{2} - M\right) \cdot e^{0}}{\color{blue}{e^{{\left(\frac{m + n}{2} - M\right)}^{2} + \left(\ell - \left|m - n\right|\right)}}} \]
                      5. exp-0N/A

                        \[\leadsto \frac{\cos \left(\frac{K \cdot \left(m + n\right)}{2} - M\right) \cdot 1}{e^{{\left(\frac{m + n}{2} - M\right)}^{2} + \color{blue}{\left(\ell - \left|m - n\right|\right)}}} \]
                      6. *-rgt-identityN/A

                        \[\leadsto \frac{\cos \left(\frac{K \cdot \left(m + n\right)}{2} - M\right)}{e^{\color{blue}{{\left(\frac{m + n}{2} - M\right)}^{2} + \left(\ell - \left|m - n\right|\right)}}} \]
                      7. /-lowering-/.f64N/A

                        \[\leadsto \mathsf{/.f64}\left(\cos \left(\frac{K \cdot \left(m + n\right)}{2} - M\right), \color{blue}{\left(e^{{\left(\frac{m + n}{2} - M\right)}^{2} + \left(\ell - \left|m - n\right|\right)}\right)}\right) \]
                    3. Simplified71.5%

                      \[\leadsto \color{blue}{\frac{\cos \left(\frac{K \cdot \left(m + n\right)}{2} - M\right)}{e^{\left(\left(\frac{m + n}{2} - M\right) \cdot \left(\frac{m + n}{2} - M\right) + \ell\right) - \left|m - n\right|}}} \]
                    4. Add Preprocessing
                    5. Taylor expanded in K around 0

                      \[\leadsto \mathsf{/.f64}\left(\color{blue}{\cos \left(\mathsf{neg}\left(M\right)\right)}, \mathsf{exp.f64}\left(\mathsf{\_.f64}\left(\mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\mathsf{/.f64}\left(\mathsf{+.f64}\left(m, n\right), 2\right), M\right), \mathsf{\_.f64}\left(\mathsf{/.f64}\left(\mathsf{+.f64}\left(m, n\right), 2\right), M\right)\right), \ell\right), \mathsf{fabs.f64}\left(\mathsf{\_.f64}\left(m, n\right)\right)\right)\right)\right) \]
                    6. Step-by-step derivation
                      1. cos-negN/A

                        \[\leadsto \mathsf{/.f64}\left(\cos M, \mathsf{exp.f64}\left(\color{blue}{\mathsf{\_.f64}\left(\mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\mathsf{/.f64}\left(\mathsf{+.f64}\left(m, n\right), 2\right), M\right), \mathsf{\_.f64}\left(\mathsf{/.f64}\left(\mathsf{+.f64}\left(m, n\right), 2\right), M\right)\right), \ell\right), \mathsf{fabs.f64}\left(\mathsf{\_.f64}\left(m, n\right)\right)\right)}\right)\right) \]
                      2. cos-lowering-cos.f6494.4%

                        \[\leadsto \mathsf{/.f64}\left(\mathsf{cos.f64}\left(M\right), \mathsf{exp.f64}\left(\color{blue}{\mathsf{\_.f64}\left(\mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\mathsf{/.f64}\left(\mathsf{+.f64}\left(m, n\right), 2\right), M\right), \mathsf{\_.f64}\left(\mathsf{/.f64}\left(\mathsf{+.f64}\left(m, n\right), 2\right), M\right)\right), \ell\right), \mathsf{fabs.f64}\left(\mathsf{\_.f64}\left(m, n\right)\right)\right)}\right)\right) \]
                    7. Simplified94.4%

                      \[\leadsto \frac{\color{blue}{\cos M}}{e^{\left(\left(\frac{m + n}{2} - M\right) \cdot \left(\frac{m + n}{2} - M\right) + \ell\right) - \left|m - n\right|}} \]
                    8. Taylor expanded in l around inf

                      \[\leadsto \mathsf{/.f64}\left(\mathsf{cos.f64}\left(M\right), \mathsf{exp.f64}\left(\color{blue}{\ell}\right)\right) \]
                    9. Step-by-step derivation
                      1. Simplified35.8%

                        \[\leadsto \frac{\cos M}{e^{\color{blue}{\ell}}} \]
                      2. Taylor expanded in M around 0

                        \[\leadsto \mathsf{/.f64}\left(\color{blue}{1}, \mathsf{exp.f64}\left(\ell\right)\right) \]
                      3. Step-by-step derivation
                        1. Simplified35.4%

                          \[\leadsto \frac{\color{blue}{1}}{e^{\ell}} \]
                        2. Add Preprocessing

                        Alternative 15: 7.0% accurate, 4.2× speedup?

                        \[\begin{array}{l} \\ \cos M \end{array} \]
                        (FPCore (K m n M l) :precision binary64 (cos M))
                        double code(double K, double m, double n, double M, double l) {
                        	return cos(M);
                        }
                        
                        real(8) function code(k, m, n, m_1, l)
                            real(8), intent (in) :: k
                            real(8), intent (in) :: m
                            real(8), intent (in) :: n
                            real(8), intent (in) :: m_1
                            real(8), intent (in) :: l
                            code = cos(m_1)
                        end function
                        
                        public static double code(double K, double m, double n, double M, double l) {
                        	return Math.cos(M);
                        }
                        
                        def code(K, m, n, M, l):
                        	return math.cos(M)
                        
                        function code(K, m, n, M, l)
                        	return cos(M)
                        end
                        
                        function tmp = code(K, m, n, M, l)
                        	tmp = cos(M);
                        end
                        
                        code[K_, m_, n_, M_, l_] := N[Cos[M], $MachinePrecision]
                        
                        \begin{array}{l}
                        
                        \\
                        \cos M
                        \end{array}
                        
                        Derivation
                        1. Initial program 71.5%

                          \[\cos \left(\frac{K \cdot \left(m + n\right)}{2} - M\right) \cdot e^{\left(-{\left(\frac{m + n}{2} - M\right)}^{2}\right) - \left(\ell - \left|m - n\right|\right)} \]
                        2. Step-by-step derivation
                          1. neg-sub0N/A

                            \[\leadsto \cos \left(\frac{K \cdot \left(m + n\right)}{2} - M\right) \cdot e^{\left(0 - {\left(\frac{m + n}{2} - M\right)}^{2}\right) - \left(\ell - \left|m - n\right|\right)} \]
                          2. associate--l-N/A

                            \[\leadsto \cos \left(\frac{K \cdot \left(m + n\right)}{2} - M\right) \cdot e^{0 - \left({\left(\frac{m + n}{2} - M\right)}^{2} + \left(\ell - \left|m - n\right|\right)\right)} \]
                          3. exp-diffN/A

                            \[\leadsto \cos \left(\frac{K \cdot \left(m + n\right)}{2} - M\right) \cdot \frac{e^{0}}{\color{blue}{e^{{\left(\frac{m + n}{2} - M\right)}^{2} + \left(\ell - \left|m - n\right|\right)}}} \]
                          4. associate-*r/N/A

                            \[\leadsto \frac{\cos \left(\frac{K \cdot \left(m + n\right)}{2} - M\right) \cdot e^{0}}{\color{blue}{e^{{\left(\frac{m + n}{2} - M\right)}^{2} + \left(\ell - \left|m - n\right|\right)}}} \]
                          5. exp-0N/A

                            \[\leadsto \frac{\cos \left(\frac{K \cdot \left(m + n\right)}{2} - M\right) \cdot 1}{e^{{\left(\frac{m + n}{2} - M\right)}^{2} + \color{blue}{\left(\ell - \left|m - n\right|\right)}}} \]
                          6. *-rgt-identityN/A

                            \[\leadsto \frac{\cos \left(\frac{K \cdot \left(m + n\right)}{2} - M\right)}{e^{\color{blue}{{\left(\frac{m + n}{2} - M\right)}^{2} + \left(\ell - \left|m - n\right|\right)}}} \]
                          7. /-lowering-/.f64N/A

                            \[\leadsto \mathsf{/.f64}\left(\cos \left(\frac{K \cdot \left(m + n\right)}{2} - M\right), \color{blue}{\left(e^{{\left(\frac{m + n}{2} - M\right)}^{2} + \left(\ell - \left|m - n\right|\right)}\right)}\right) \]
                        3. Simplified71.5%

                          \[\leadsto \color{blue}{\frac{\cos \left(\frac{K \cdot \left(m + n\right)}{2} - M\right)}{e^{\left(\left(\frac{m + n}{2} - M\right) \cdot \left(\frac{m + n}{2} - M\right) + \ell\right) - \left|m - n\right|}}} \]
                        4. Add Preprocessing
                        5. Taylor expanded in K around 0

                          \[\leadsto \mathsf{/.f64}\left(\color{blue}{\cos \left(\mathsf{neg}\left(M\right)\right)}, \mathsf{exp.f64}\left(\mathsf{\_.f64}\left(\mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\mathsf{/.f64}\left(\mathsf{+.f64}\left(m, n\right), 2\right), M\right), \mathsf{\_.f64}\left(\mathsf{/.f64}\left(\mathsf{+.f64}\left(m, n\right), 2\right), M\right)\right), \ell\right), \mathsf{fabs.f64}\left(\mathsf{\_.f64}\left(m, n\right)\right)\right)\right)\right) \]
                        6. Step-by-step derivation
                          1. cos-negN/A

                            \[\leadsto \mathsf{/.f64}\left(\cos M, \mathsf{exp.f64}\left(\color{blue}{\mathsf{\_.f64}\left(\mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\mathsf{/.f64}\left(\mathsf{+.f64}\left(m, n\right), 2\right), M\right), \mathsf{\_.f64}\left(\mathsf{/.f64}\left(\mathsf{+.f64}\left(m, n\right), 2\right), M\right)\right), \ell\right), \mathsf{fabs.f64}\left(\mathsf{\_.f64}\left(m, n\right)\right)\right)}\right)\right) \]
                          2. cos-lowering-cos.f6494.4%

                            \[\leadsto \mathsf{/.f64}\left(\mathsf{cos.f64}\left(M\right), \mathsf{exp.f64}\left(\color{blue}{\mathsf{\_.f64}\left(\mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\mathsf{/.f64}\left(\mathsf{+.f64}\left(m, n\right), 2\right), M\right), \mathsf{\_.f64}\left(\mathsf{/.f64}\left(\mathsf{+.f64}\left(m, n\right), 2\right), M\right)\right), \ell\right), \mathsf{fabs.f64}\left(\mathsf{\_.f64}\left(m, n\right)\right)\right)}\right)\right) \]
                        7. Simplified94.4%

                          \[\leadsto \frac{\color{blue}{\cos M}}{e^{\left(\left(\frac{m + n}{2} - M\right) \cdot \left(\frac{m + n}{2} - M\right) + \ell\right) - \left|m - n\right|}} \]
                        8. Taylor expanded in l around inf

                          \[\leadsto \mathsf{/.f64}\left(\mathsf{cos.f64}\left(M\right), \mathsf{exp.f64}\left(\color{blue}{\ell}\right)\right) \]
                        9. Step-by-step derivation
                          1. Simplified35.8%

                            \[\leadsto \frac{\cos M}{e^{\color{blue}{\ell}}} \]
                          2. Taylor expanded in l around 0

                            \[\leadsto \color{blue}{\cos M} \]
                          3. Step-by-step derivation
                            1. cos-lowering-cos.f647.3%

                              \[\leadsto \mathsf{cos.f64}\left(M\right) \]
                          4. Simplified7.3%

                            \[\leadsto \color{blue}{\cos M} \]
                          5. Add Preprocessing

                          Alternative 16: 7.0% accurate, 425.0× speedup?

                          \[\begin{array}{l} \\ 1 \end{array} \]
                          (FPCore (K m n M l) :precision binary64 1.0)
                          double code(double K, double m, double n, double M, double l) {
                          	return 1.0;
                          }
                          
                          real(8) function code(k, m, n, m_1, l)
                              real(8), intent (in) :: k
                              real(8), intent (in) :: m
                              real(8), intent (in) :: n
                              real(8), intent (in) :: m_1
                              real(8), intent (in) :: l
                              code = 1.0d0
                          end function
                          
                          public static double code(double K, double m, double n, double M, double l) {
                          	return 1.0;
                          }
                          
                          def code(K, m, n, M, l):
                          	return 1.0
                          
                          function code(K, m, n, M, l)
                          	return 1.0
                          end
                          
                          function tmp = code(K, m, n, M, l)
                          	tmp = 1.0;
                          end
                          
                          code[K_, m_, n_, M_, l_] := 1.0
                          
                          \begin{array}{l}
                          
                          \\
                          1
                          \end{array}
                          
                          Derivation
                          1. Initial program 71.5%

                            \[\cos \left(\frac{K \cdot \left(m + n\right)}{2} - M\right) \cdot e^{\left(-{\left(\frac{m + n}{2} - M\right)}^{2}\right) - \left(\ell - \left|m - n\right|\right)} \]
                          2. Step-by-step derivation
                            1. neg-sub0N/A

                              \[\leadsto \cos \left(\frac{K \cdot \left(m + n\right)}{2} - M\right) \cdot e^{\left(0 - {\left(\frac{m + n}{2} - M\right)}^{2}\right) - \left(\ell - \left|m - n\right|\right)} \]
                            2. associate--l-N/A

                              \[\leadsto \cos \left(\frac{K \cdot \left(m + n\right)}{2} - M\right) \cdot e^{0 - \left({\left(\frac{m + n}{2} - M\right)}^{2} + \left(\ell - \left|m - n\right|\right)\right)} \]
                            3. exp-diffN/A

                              \[\leadsto \cos \left(\frac{K \cdot \left(m + n\right)}{2} - M\right) \cdot \frac{e^{0}}{\color{blue}{e^{{\left(\frac{m + n}{2} - M\right)}^{2} + \left(\ell - \left|m - n\right|\right)}}} \]
                            4. associate-*r/N/A

                              \[\leadsto \frac{\cos \left(\frac{K \cdot \left(m + n\right)}{2} - M\right) \cdot e^{0}}{\color{blue}{e^{{\left(\frac{m + n}{2} - M\right)}^{2} + \left(\ell - \left|m - n\right|\right)}}} \]
                            5. exp-0N/A

                              \[\leadsto \frac{\cos \left(\frac{K \cdot \left(m + n\right)}{2} - M\right) \cdot 1}{e^{{\left(\frac{m + n}{2} - M\right)}^{2} + \color{blue}{\left(\ell - \left|m - n\right|\right)}}} \]
                            6. *-rgt-identityN/A

                              \[\leadsto \frac{\cos \left(\frac{K \cdot \left(m + n\right)}{2} - M\right)}{e^{\color{blue}{{\left(\frac{m + n}{2} - M\right)}^{2} + \left(\ell - \left|m - n\right|\right)}}} \]
                            7. /-lowering-/.f64N/A

                              \[\leadsto \mathsf{/.f64}\left(\cos \left(\frac{K \cdot \left(m + n\right)}{2} - M\right), \color{blue}{\left(e^{{\left(\frac{m + n}{2} - M\right)}^{2} + \left(\ell - \left|m - n\right|\right)}\right)}\right) \]
                          3. Simplified71.5%

                            \[\leadsto \color{blue}{\frac{\cos \left(\frac{K \cdot \left(m + n\right)}{2} - M\right)}{e^{\left(\left(\frac{m + n}{2} - M\right) \cdot \left(\frac{m + n}{2} - M\right) + \ell\right) - \left|m - n\right|}}} \]
                          4. Add Preprocessing
                          5. Taylor expanded in K around 0

                            \[\leadsto \mathsf{/.f64}\left(\color{blue}{\cos \left(\mathsf{neg}\left(M\right)\right)}, \mathsf{exp.f64}\left(\mathsf{\_.f64}\left(\mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\mathsf{/.f64}\left(\mathsf{+.f64}\left(m, n\right), 2\right), M\right), \mathsf{\_.f64}\left(\mathsf{/.f64}\left(\mathsf{+.f64}\left(m, n\right), 2\right), M\right)\right), \ell\right), \mathsf{fabs.f64}\left(\mathsf{\_.f64}\left(m, n\right)\right)\right)\right)\right) \]
                          6. Step-by-step derivation
                            1. cos-negN/A

                              \[\leadsto \mathsf{/.f64}\left(\cos M, \mathsf{exp.f64}\left(\color{blue}{\mathsf{\_.f64}\left(\mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\mathsf{/.f64}\left(\mathsf{+.f64}\left(m, n\right), 2\right), M\right), \mathsf{\_.f64}\left(\mathsf{/.f64}\left(\mathsf{+.f64}\left(m, n\right), 2\right), M\right)\right), \ell\right), \mathsf{fabs.f64}\left(\mathsf{\_.f64}\left(m, n\right)\right)\right)}\right)\right) \]
                            2. cos-lowering-cos.f6494.4%

                              \[\leadsto \mathsf{/.f64}\left(\mathsf{cos.f64}\left(M\right), \mathsf{exp.f64}\left(\color{blue}{\mathsf{\_.f64}\left(\mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{\_.f64}\left(\mathsf{/.f64}\left(\mathsf{+.f64}\left(m, n\right), 2\right), M\right), \mathsf{\_.f64}\left(\mathsf{/.f64}\left(\mathsf{+.f64}\left(m, n\right), 2\right), M\right)\right), \ell\right), \mathsf{fabs.f64}\left(\mathsf{\_.f64}\left(m, n\right)\right)\right)}\right)\right) \]
                          7. Simplified94.4%

                            \[\leadsto \frac{\color{blue}{\cos M}}{e^{\left(\left(\frac{m + n}{2} - M\right) \cdot \left(\frac{m + n}{2} - M\right) + \ell\right) - \left|m - n\right|}} \]
                          8. Taylor expanded in l around inf

                            \[\leadsto \mathsf{/.f64}\left(\mathsf{cos.f64}\left(M\right), \mathsf{exp.f64}\left(\color{blue}{\ell}\right)\right) \]
                          9. Step-by-step derivation
                            1. Simplified35.8%

                              \[\leadsto \frac{\cos M}{e^{\color{blue}{\ell}}} \]
                            2. Taylor expanded in l around 0

                              \[\leadsto \color{blue}{\cos M} \]
                            3. Step-by-step derivation
                              1. cos-lowering-cos.f647.3%

                                \[\leadsto \mathsf{cos.f64}\left(M\right) \]
                            4. Simplified7.3%

                              \[\leadsto \color{blue}{\cos M} \]
                            5. Taylor expanded in M around 0

                              \[\leadsto \color{blue}{1} \]
                            6. Step-by-step derivation
                              1. Simplified7.3%

                                \[\leadsto \color{blue}{1} \]
                              2. Add Preprocessing

                              Reproduce

                              ?
                              herbie shell --seed 2024145 
                              (FPCore (K m n M l)
                                :name "Maksimov and Kolovsky, Equation (32)"
                                :precision binary64
                                (* (cos (- (/ (* K (+ m n)) 2.0) M)) (exp (- (- (pow (- (/ (+ m n) 2.0) M) 2.0)) (- l (fabs (- m n)))))))