Maksimov and Kolovsky, Equation (32)

Percentage Accurate: 75.2% → 96.4%
Time: 14.0s
Alternatives: 10
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 10 alternatives:

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

Initial Program: 75.2% 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.4% 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 77.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. Simplified77.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.f6496.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. Simplified96.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. Add Preprocessing

Alternative 2: 94.6% accurate, 1.9× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \frac{\cos M}{e^{M \cdot M}}\\ \mathbf{if}\;M \leq -8 \cdot 10^{+75}:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;M \leq 86:\\ \;\;\;\;e^{\left(\left|m - n\right| - 0.25 \cdot \left(\left(m + n\right) \cdot \left(m + n\right)\right)\right) - \ell}\\ \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 -8e+75)
     t_0
     (if (<= M 86.0)
       (exp (- (- (fabs (- m n)) (* 0.25 (* (+ m n) (+ m n)))) l))
       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 <= -8e+75) {
		tmp = t_0;
	} else if (M <= 86.0) {
		tmp = exp(((fabs((m - n)) - (0.25 * ((m + n) * (m + n)))) - 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 = cos(m_1) / exp((m_1 * m_1))
    if (m_1 <= (-8d+75)) then
        tmp = t_0
    else if (m_1 <= 86.0d0) then
        tmp = exp(((abs((m - n)) - (0.25d0 * ((m + n) * (m + n)))) - 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 = Math.cos(M) / Math.exp((M * M));
	double tmp;
	if (M <= -8e+75) {
		tmp = t_0;
	} else if (M <= 86.0) {
		tmp = Math.exp(((Math.abs((m - n)) - (0.25 * ((m + n) * (m + n)))) - l));
	} 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 <= -8e+75:
		tmp = t_0
	elif M <= 86.0:
		tmp = math.exp(((math.fabs((m - n)) - (0.25 * ((m + n) * (m + n)))) - l))
	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 <= -8e+75)
		tmp = t_0;
	elseif (M <= 86.0)
		tmp = exp(Float64(Float64(abs(Float64(m - n)) - Float64(0.25 * Float64(Float64(m + n) * Float64(m + n)))) - l));
	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 <= -8e+75)
		tmp = t_0;
	elseif (M <= 86.0)
		tmp = exp(((abs((m - n)) - (0.25 * ((m + n) * (m + n)))) - l));
	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, -8e+75], t$95$0, If[LessEqual[M, 86.0], N[Exp[N[(N[(N[Abs[N[(m - n), $MachinePrecision]], $MachinePrecision] - N[(0.25 * N[(N[(m + n), $MachinePrecision] * N[(m + n), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - l), $MachinePrecision]], $MachinePrecision], t$95$0]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \frac{\cos M}{e^{M \cdot M}}\\
\mathbf{if}\;M \leq -8 \cdot 10^{+75}:\\
\;\;\;\;t\_0\\

\mathbf{elif}\;M \leq 86:\\
\;\;\;\;e^{\left(\left|m - n\right| - 0.25 \cdot \left(\left(m + n\right) \cdot \left(m + n\right)\right)\right) - \ell}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if M < -7.99999999999999941e75 or 86 < M

    1. Initial program 82.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. Simplified82.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 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-*.f6499.1%

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

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

    if -7.99999999999999941e75 < M < 86

    1. Initial program 73.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. Simplified73.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.f6494.3%

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

      \[\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. rec-expN/A

        \[\leadsto e^{\mathsf{neg}\left(\left(\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{exp.f64}\left(\left(\mathsf{neg}\left(\left(\left(\ell + \frac{1}{4} \cdot {\left(m + n\right)}^{2}\right) - \left|m - n\right|\right)\right)\right)\right) \]
      3. neg-sub0N/A

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

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

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

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

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

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

        \[\leadsto \mathsf{exp.f64}\left(\mathsf{\_.f64}\left(0, \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|m - n\right|\right)\right)\right)\right)\right) \]
      10. *-lowering-*.f64N/A

        \[\leadsto \mathsf{exp.f64}\left(\mathsf{\_.f64}\left(0, \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|m - n\right|\right)\right)\right)\right)\right) \]
      11. +-lowering-+.f64N/A

        \[\leadsto \mathsf{exp.f64}\left(\mathsf{\_.f64}\left(0, \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|m - n\right|\right)\right)\right)\right)\right) \]
      12. +-lowering-+.f64N/A

        \[\leadsto \mathsf{exp.f64}\left(\mathsf{\_.f64}\left(0, \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|m - n\right|\right)\right)\right)\right)\right) \]
      13. fabs-subN/A

        \[\leadsto \mathsf{exp.f64}\left(\mathsf{\_.f64}\left(0, \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) \]
      14. sub-negN/A

        \[\leadsto \mathsf{exp.f64}\left(\mathsf{\_.f64}\left(0, \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) \]
      15. mul-1-negN/A

        \[\leadsto \mathsf{exp.f64}\left(\mathsf{\_.f64}\left(0, \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) \]
      16. fabs-lowering-fabs.f64N/A

        \[\leadsto \mathsf{exp.f64}\left(\mathsf{\_.f64}\left(0, \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) \]
      17. mul-1-negN/A

        \[\leadsto \mathsf{exp.f64}\left(\mathsf{\_.f64}\left(0, \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) \]
      18. sub-negN/A

        \[\leadsto \mathsf{exp.f64}\left(\mathsf{\_.f64}\left(0, \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) \]
      19. --lowering--.f6493.7%

        \[\leadsto \mathsf{exp.f64}\left(\mathsf{\_.f64}\left(0, \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.7%

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

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

Alternative 3: 65.5% accurate, 2.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;m \leq -54:\\ \;\;\;\;e^{\left(m \cdot m\right) \cdot -0.25}\\ \mathbf{elif}\;m \leq 1.4 \cdot 10^{-305}:\\ \;\;\;\;\frac{\cos M}{e^{M \cdot M}}\\ \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 (<= m -54.0)
   (exp (* (* m m) -0.25))
   (if (<= m 1.4e-305)
     (/ (cos M) (exp (* M M)))
     (/ (cos M) (exp (* 0.25 (* n n)))))))
double code(double K, double m, double n, double M, double l) {
	double tmp;
	if (m <= -54.0) {
		tmp = exp(((m * m) * -0.25));
	} else if (m <= 1.4e-305) {
		tmp = cos(M) / exp((M * M));
	} 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 (m <= (-54.0d0)) then
        tmp = exp(((m * m) * (-0.25d0)))
    else if (m <= 1.4d-305) then
        tmp = cos(m_1) / exp((m_1 * m_1))
    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 (m <= -54.0) {
		tmp = Math.exp(((m * m) * -0.25));
	} else if (m <= 1.4e-305) {
		tmp = Math.cos(M) / Math.exp((M * M));
	} else {
		tmp = Math.cos(M) / Math.exp((0.25 * (n * n)));
	}
	return tmp;
}
def code(K, m, n, M, l):
	tmp = 0
	if m <= -54.0:
		tmp = math.exp(((m * m) * -0.25))
	elif m <= 1.4e-305:
		tmp = math.cos(M) / math.exp((M * M))
	else:
		tmp = math.cos(M) / math.exp((0.25 * (n * n)))
	return tmp
function code(K, m, n, M, l)
	tmp = 0.0
	if (m <= -54.0)
		tmp = exp(Float64(Float64(m * m) * -0.25));
	elseif (m <= 1.4e-305)
		tmp = Float64(cos(M) / exp(Float64(M * M)));
	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 (m <= -54.0)
		tmp = exp(((m * m) * -0.25));
	elseif (m <= 1.4e-305)
		tmp = cos(M) / exp((M * M));
	else
		tmp = cos(M) / exp((0.25 * (n * n)));
	end
	tmp_2 = tmp;
end
code[K_, m_, n_, M_, l_] := If[LessEqual[m, -54.0], N[Exp[N[(N[(m * m), $MachinePrecision] * -0.25), $MachinePrecision]], $MachinePrecision], If[LessEqual[m, 1.4e-305], N[(N[Cos[M], $MachinePrecision] / N[Exp[N[(M * M), $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}\;m \leq -54:\\
\;\;\;\;e^{\left(m \cdot m\right) \cdot -0.25}\\

\mathbf{elif}\;m \leq 1.4 \cdot 10^{-305}:\\
\;\;\;\;\frac{\cos M}{e^{M \cdot M}}\\

\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 m < -54

    1. Initial program 76.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. Simplified76.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. rec-expN/A

        \[\leadsto e^{\mathsf{neg}\left(\left(\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{exp.f64}\left(\left(\mathsf{neg}\left(\left(\left(\ell + \frac{1}{4} \cdot {\left(m + n\right)}^{2}\right) - \left|m - n\right|\right)\right)\right)\right) \]
      3. neg-sub0N/A

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

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

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

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

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

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

        \[\leadsto \mathsf{exp.f64}\left(\mathsf{\_.f64}\left(0, \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|m - n\right|\right)\right)\right)\right)\right) \]
      10. *-lowering-*.f64N/A

        \[\leadsto \mathsf{exp.f64}\left(\mathsf{\_.f64}\left(0, \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|m - n\right|\right)\right)\right)\right)\right) \]
      11. +-lowering-+.f64N/A

        \[\leadsto \mathsf{exp.f64}\left(\mathsf{\_.f64}\left(0, \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|m - n\right|\right)\right)\right)\right)\right) \]
      12. +-lowering-+.f64N/A

        \[\leadsto \mathsf{exp.f64}\left(\mathsf{\_.f64}\left(0, \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|m - n\right|\right)\right)\right)\right)\right) \]
      13. fabs-subN/A

        \[\leadsto \mathsf{exp.f64}\left(\mathsf{\_.f64}\left(0, \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) \]
      14. sub-negN/A

        \[\leadsto \mathsf{exp.f64}\left(\mathsf{\_.f64}\left(0, \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) \]
      15. mul-1-negN/A

        \[\leadsto \mathsf{exp.f64}\left(\mathsf{\_.f64}\left(0, \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) \]
      16. fabs-lowering-fabs.f64N/A

        \[\leadsto \mathsf{exp.f64}\left(\mathsf{\_.f64}\left(0, \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) \]
      17. mul-1-negN/A

        \[\leadsto \mathsf{exp.f64}\left(\mathsf{\_.f64}\left(0, \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) \]
      18. sub-negN/A

        \[\leadsto \mathsf{exp.f64}\left(\mathsf{\_.f64}\left(0, \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) \]
      19. --lowering--.f6495.4%

        \[\leadsto \mathsf{exp.f64}\left(\mathsf{\_.f64}\left(0, \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. Simplified95.4%

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

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

        \[\leadsto \mathsf{exp.f64}\left(\left({m}^{2} \cdot \frac{-1}{4}\right)\right) \]
      2. *-lowering-*.f64N/A

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

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

        \[\leadsto \mathsf{exp.f64}\left(\mathsf{*.f64}\left(\mathsf{*.f64}\left(m, m\right), \frac{-1}{4}\right)\right) \]
    13. Simplified96.9%

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

    if -54 < m < 1.40000000000000007e-305

    1. Initial program 78.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. Simplified78.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.f6489.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. Simplified89.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 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-*.f6457.4%

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

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

    if 1.40000000000000007e-305 < m

    1. Initial program 77.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. Simplified77.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.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. Simplified98.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 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-*.f6457.7%

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

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

Alternative 4: 72.6% accurate, 2.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;m \leq -2.45 \cdot 10^{+22}:\\ \;\;\;\;e^{\left(m \cdot m\right) \cdot -0.25}\\ \mathbf{else}:\\ \;\;\;\;e^{\left|m - n\right| - \left(\ell + 0.25 \cdot \left(n \cdot n\right)\right)}\\ \end{array} \end{array} \]
(FPCore (K m n M l)
 :precision binary64
 (if (<= m -2.45e+22)
   (exp (* (* m m) -0.25))
   (exp (- (fabs (- m n)) (+ l (* 0.25 (* n n)))))))
double code(double K, double m, double n, double M, double l) {
	double tmp;
	if (m <= -2.45e+22) {
		tmp = exp(((m * m) * -0.25));
	} else {
		tmp = exp((fabs((m - n)) - (l + (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 (m <= (-2.45d+22)) then
        tmp = exp(((m * m) * (-0.25d0)))
    else
        tmp = exp((abs((m - n)) - (l + (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 (m <= -2.45e+22) {
		tmp = Math.exp(((m * m) * -0.25));
	} else {
		tmp = Math.exp((Math.abs((m - n)) - (l + (0.25 * (n * n)))));
	}
	return tmp;
}
def code(K, m, n, M, l):
	tmp = 0
	if m <= -2.45e+22:
		tmp = math.exp(((m * m) * -0.25))
	else:
		tmp = math.exp((math.fabs((m - n)) - (l + (0.25 * (n * n)))))
	return tmp
function code(K, m, n, M, l)
	tmp = 0.0
	if (m <= -2.45e+22)
		tmp = exp(Float64(Float64(m * m) * -0.25));
	else
		tmp = exp(Float64(abs(Float64(m - n)) - Float64(l + Float64(0.25 * Float64(n * n)))));
	end
	return tmp
end
function tmp_2 = code(K, m, n, M, l)
	tmp = 0.0;
	if (m <= -2.45e+22)
		tmp = exp(((m * m) * -0.25));
	else
		tmp = exp((abs((m - n)) - (l + (0.25 * (n * n)))));
	end
	tmp_2 = tmp;
end
code[K_, m_, n_, M_, l_] := If[LessEqual[m, -2.45e+22], N[Exp[N[(N[(m * m), $MachinePrecision] * -0.25), $MachinePrecision]], $MachinePrecision], N[Exp[N[(N[Abs[N[(m - n), $MachinePrecision]], $MachinePrecision] - N[(l + N[(0.25 * N[(n * n), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;m \leq -2.45 \cdot 10^{+22}:\\
\;\;\;\;e^{\left(m \cdot m\right) \cdot -0.25}\\

\mathbf{else}:\\
\;\;\;\;e^{\left|m - n\right| - \left(\ell + 0.25 \cdot \left(n \cdot n\right)\right)}\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if m < -2.4499999999999999e22

    1. Initial program 77.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. Simplified77.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 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. rec-expN/A

        \[\leadsto e^{\mathsf{neg}\left(\left(\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{exp.f64}\left(\left(\mathsf{neg}\left(\left(\left(\ell + \frac{1}{4} \cdot {\left(m + n\right)}^{2}\right) - \left|m - n\right|\right)\right)\right)\right) \]
      3. neg-sub0N/A

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

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

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

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

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

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

        \[\leadsto \mathsf{exp.f64}\left(\mathsf{\_.f64}\left(0, \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|m - n\right|\right)\right)\right)\right)\right) \]
      10. *-lowering-*.f64N/A

        \[\leadsto \mathsf{exp.f64}\left(\mathsf{\_.f64}\left(0, \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|m - n\right|\right)\right)\right)\right)\right) \]
      11. +-lowering-+.f64N/A

        \[\leadsto \mathsf{exp.f64}\left(\mathsf{\_.f64}\left(0, \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|m - n\right|\right)\right)\right)\right)\right) \]
      12. +-lowering-+.f64N/A

        \[\leadsto \mathsf{exp.f64}\left(\mathsf{\_.f64}\left(0, \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|m - n\right|\right)\right)\right)\right)\right) \]
      13. fabs-subN/A

        \[\leadsto \mathsf{exp.f64}\left(\mathsf{\_.f64}\left(0, \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) \]
      14. sub-negN/A

        \[\leadsto \mathsf{exp.f64}\left(\mathsf{\_.f64}\left(0, \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) \]
      15. mul-1-negN/A

        \[\leadsto \mathsf{exp.f64}\left(\mathsf{\_.f64}\left(0, \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) \]
      16. fabs-lowering-fabs.f64N/A

        \[\leadsto \mathsf{exp.f64}\left(\mathsf{\_.f64}\left(0, \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) \]
      17. mul-1-negN/A

        \[\leadsto \mathsf{exp.f64}\left(\mathsf{\_.f64}\left(0, \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) \]
      18. sub-negN/A

        \[\leadsto \mathsf{exp.f64}\left(\mathsf{\_.f64}\left(0, \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) \]
      19. --lowering--.f6495.2%

        \[\leadsto \mathsf{exp.f64}\left(\mathsf{\_.f64}\left(0, \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. Simplified95.2%

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

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

        \[\leadsto \mathsf{exp.f64}\left(\left({m}^{2} \cdot \frac{-1}{4}\right)\right) \]
      2. *-lowering-*.f64N/A

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

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

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

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

    if -2.4499999999999999e22 < m

    1. Initial program 77.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. Simplified77.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.f6495.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. Simplified95.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. rec-expN/A

        \[\leadsto e^{\mathsf{neg}\left(\left(\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{exp.f64}\left(\left(\mathsf{neg}\left(\left(\left(\ell + \frac{1}{4} \cdot {\left(m + n\right)}^{2}\right) - \left|m - n\right|\right)\right)\right)\right) \]
      3. neg-sub0N/A

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

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

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

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

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

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

        \[\leadsto \mathsf{exp.f64}\left(\mathsf{\_.f64}\left(0, \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|m - n\right|\right)\right)\right)\right)\right) \]
      10. *-lowering-*.f64N/A

        \[\leadsto \mathsf{exp.f64}\left(\mathsf{\_.f64}\left(0, \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|m - n\right|\right)\right)\right)\right)\right) \]
      11. +-lowering-+.f64N/A

        \[\leadsto \mathsf{exp.f64}\left(\mathsf{\_.f64}\left(0, \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|m - n\right|\right)\right)\right)\right)\right) \]
      12. +-lowering-+.f64N/A

        \[\leadsto \mathsf{exp.f64}\left(\mathsf{\_.f64}\left(0, \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|m - n\right|\right)\right)\right)\right)\right) \]
      13. fabs-subN/A

        \[\leadsto \mathsf{exp.f64}\left(\mathsf{\_.f64}\left(0, \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) \]
      14. sub-negN/A

        \[\leadsto \mathsf{exp.f64}\left(\mathsf{\_.f64}\left(0, \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) \]
      15. mul-1-negN/A

        \[\leadsto \mathsf{exp.f64}\left(\mathsf{\_.f64}\left(0, \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) \]
      16. fabs-lowering-fabs.f64N/A

        \[\leadsto \mathsf{exp.f64}\left(\mathsf{\_.f64}\left(0, \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) \]
      17. mul-1-negN/A

        \[\leadsto \mathsf{exp.f64}\left(\mathsf{\_.f64}\left(0, \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) \]
      18. sub-negN/A

        \[\leadsto \mathsf{exp.f64}\left(\mathsf{\_.f64}\left(0, \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) \]
      19. --lowering--.f6483.7%

        \[\leadsto \mathsf{exp.f64}\left(\mathsf{\_.f64}\left(0, \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. Simplified83.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 5: 65.4% accurate, 2.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;m \leq -55:\\ \;\;\;\;e^{\left(m \cdot m\right) \cdot -0.25}\\ \mathbf{elif}\;m \leq 9.2 \cdot 10^{-306}:\\ \;\;\;\;\frac{\cos M}{e^{M \cdot M}}\\ \mathbf{else}:\\ \;\;\;\;e^{-0.25 \cdot \left(n \cdot n\right)}\\ \end{array} \end{array} \]
(FPCore (K m n M l)
 :precision binary64
 (if (<= m -55.0)
   (exp (* (* m m) -0.25))
   (if (<= m 9.2e-306) (/ (cos M) (exp (* M M))) (exp (* -0.25 (* n n))))))
double code(double K, double m, double n, double M, double l) {
	double tmp;
	if (m <= -55.0) {
		tmp = exp(((m * m) * -0.25));
	} else if (m <= 9.2e-306) {
		tmp = cos(M) / exp((M * M));
	} else {
		tmp = 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 (m <= (-55.0d0)) then
        tmp = exp(((m * m) * (-0.25d0)))
    else if (m <= 9.2d-306) then
        tmp = cos(m_1) / exp((m_1 * m_1))
    else
        tmp = 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 (m <= -55.0) {
		tmp = Math.exp(((m * m) * -0.25));
	} else if (m <= 9.2e-306) {
		tmp = Math.cos(M) / Math.exp((M * M));
	} else {
		tmp = Math.exp((-0.25 * (n * n)));
	}
	return tmp;
}
def code(K, m, n, M, l):
	tmp = 0
	if m <= -55.0:
		tmp = math.exp(((m * m) * -0.25))
	elif m <= 9.2e-306:
		tmp = math.cos(M) / math.exp((M * M))
	else:
		tmp = math.exp((-0.25 * (n * n)))
	return tmp
function code(K, m, n, M, l)
	tmp = 0.0
	if (m <= -55.0)
		tmp = exp(Float64(Float64(m * m) * -0.25));
	elseif (m <= 9.2e-306)
		tmp = Float64(cos(M) / exp(Float64(M * M)));
	else
		tmp = exp(Float64(-0.25 * Float64(n * n)));
	end
	return tmp
end
function tmp_2 = code(K, m, n, M, l)
	tmp = 0.0;
	if (m <= -55.0)
		tmp = exp(((m * m) * -0.25));
	elseif (m <= 9.2e-306)
		tmp = cos(M) / exp((M * M));
	else
		tmp = exp((-0.25 * (n * n)));
	end
	tmp_2 = tmp;
end
code[K_, m_, n_, M_, l_] := If[LessEqual[m, -55.0], N[Exp[N[(N[(m * m), $MachinePrecision] * -0.25), $MachinePrecision]], $MachinePrecision], If[LessEqual[m, 9.2e-306], N[(N[Cos[M], $MachinePrecision] / N[Exp[N[(M * M), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[Exp[N[(-0.25 * N[(n * n), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;m \leq -55:\\
\;\;\;\;e^{\left(m \cdot m\right) \cdot -0.25}\\

\mathbf{elif}\;m \leq 9.2 \cdot 10^{-306}:\\
\;\;\;\;\frac{\cos M}{e^{M \cdot M}}\\

\mathbf{else}:\\
\;\;\;\;e^{-0.25 \cdot \left(n \cdot n\right)}\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if m < -55

    1. Initial program 76.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. Simplified76.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. rec-expN/A

        \[\leadsto e^{\mathsf{neg}\left(\left(\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{exp.f64}\left(\left(\mathsf{neg}\left(\left(\left(\ell + \frac{1}{4} \cdot {\left(m + n\right)}^{2}\right) - \left|m - n\right|\right)\right)\right)\right) \]
      3. neg-sub0N/A

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

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

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

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

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

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

        \[\leadsto \mathsf{exp.f64}\left(\mathsf{\_.f64}\left(0, \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|m - n\right|\right)\right)\right)\right)\right) \]
      10. *-lowering-*.f64N/A

        \[\leadsto \mathsf{exp.f64}\left(\mathsf{\_.f64}\left(0, \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|m - n\right|\right)\right)\right)\right)\right) \]
      11. +-lowering-+.f64N/A

        \[\leadsto \mathsf{exp.f64}\left(\mathsf{\_.f64}\left(0, \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|m - n\right|\right)\right)\right)\right)\right) \]
      12. +-lowering-+.f64N/A

        \[\leadsto \mathsf{exp.f64}\left(\mathsf{\_.f64}\left(0, \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|m - n\right|\right)\right)\right)\right)\right) \]
      13. fabs-subN/A

        \[\leadsto \mathsf{exp.f64}\left(\mathsf{\_.f64}\left(0, \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) \]
      14. sub-negN/A

        \[\leadsto \mathsf{exp.f64}\left(\mathsf{\_.f64}\left(0, \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) \]
      15. mul-1-negN/A

        \[\leadsto \mathsf{exp.f64}\left(\mathsf{\_.f64}\left(0, \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) \]
      16. fabs-lowering-fabs.f64N/A

        \[\leadsto \mathsf{exp.f64}\left(\mathsf{\_.f64}\left(0, \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) \]
      17. mul-1-negN/A

        \[\leadsto \mathsf{exp.f64}\left(\mathsf{\_.f64}\left(0, \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) \]
      18. sub-negN/A

        \[\leadsto \mathsf{exp.f64}\left(\mathsf{\_.f64}\left(0, \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) \]
      19. --lowering--.f6495.4%

        \[\leadsto \mathsf{exp.f64}\left(\mathsf{\_.f64}\left(0, \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. Simplified95.4%

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

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

        \[\leadsto \mathsf{exp.f64}\left(\left({m}^{2} \cdot \frac{-1}{4}\right)\right) \]
      2. *-lowering-*.f64N/A

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

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

        \[\leadsto \mathsf{exp.f64}\left(\mathsf{*.f64}\left(\mathsf{*.f64}\left(m, m\right), \frac{-1}{4}\right)\right) \]
    13. Simplified96.9%

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

    if -55 < m < 9.19999999999999956e-306

    1. Initial program 78.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. Simplified78.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.f6489.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. Simplified89.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 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-*.f6457.4%

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

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

    if 9.19999999999999956e-306 < m

    1. Initial program 77.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. Simplified77.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.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. Simplified98.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. rec-expN/A

        \[\leadsto e^{\mathsf{neg}\left(\left(\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{exp.f64}\left(\left(\mathsf{neg}\left(\left(\left(\ell + \frac{1}{4} \cdot {\left(m + n\right)}^{2}\right) - \left|m - n\right|\right)\right)\right)\right) \]
      3. neg-sub0N/A

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

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

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

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

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

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

        \[\leadsto \mathsf{exp.f64}\left(\mathsf{\_.f64}\left(0, \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|m - n\right|\right)\right)\right)\right)\right) \]
      10. *-lowering-*.f64N/A

        \[\leadsto \mathsf{exp.f64}\left(\mathsf{\_.f64}\left(0, \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|m - n\right|\right)\right)\right)\right)\right) \]
      11. +-lowering-+.f64N/A

        \[\leadsto \mathsf{exp.f64}\left(\mathsf{\_.f64}\left(0, \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|m - n\right|\right)\right)\right)\right)\right) \]
      12. +-lowering-+.f64N/A

        \[\leadsto \mathsf{exp.f64}\left(\mathsf{\_.f64}\left(0, \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|m - n\right|\right)\right)\right)\right)\right) \]
      13. fabs-subN/A

        \[\leadsto \mathsf{exp.f64}\left(\mathsf{\_.f64}\left(0, \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) \]
      14. sub-negN/A

        \[\leadsto \mathsf{exp.f64}\left(\mathsf{\_.f64}\left(0, \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) \]
      15. mul-1-negN/A

        \[\leadsto \mathsf{exp.f64}\left(\mathsf{\_.f64}\left(0, \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) \]
      16. fabs-lowering-fabs.f64N/A

        \[\leadsto \mathsf{exp.f64}\left(\mathsf{\_.f64}\left(0, \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) \]
      17. mul-1-negN/A

        \[\leadsto \mathsf{exp.f64}\left(\mathsf{\_.f64}\left(0, \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) \]
      18. sub-negN/A

        \[\leadsto \mathsf{exp.f64}\left(\mathsf{\_.f64}\left(0, \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) \]
      19. --lowering--.f6489.5%

        \[\leadsto \mathsf{exp.f64}\left(\mathsf{\_.f64}\left(0, \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. Simplified89.5%

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

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

        \[\leadsto \mathsf{exp.f64}\left(\left({n}^{2} \cdot \frac{-1}{4}\right)\right) \]
      2. *-lowering-*.f64N/A

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

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

        \[\leadsto \mathsf{exp.f64}\left(\mathsf{*.f64}\left(\mathsf{*.f64}\left(n, n\right), \frac{-1}{4}\right)\right) \]
    13. Simplified57.7%

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

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

Alternative 6: 67.8% accurate, 3.7× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := e^{\left(m \cdot m\right) \cdot -0.25}\\ \mathbf{if}\;m \leq -9.5 \cdot 10^{+17}:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;m \leq 3.9 \cdot 10^{-16}:\\ \;\;\;\;e^{0 - \ell}\\ \mathbf{else}:\\ \;\;\;\;t\_0\\ \end{array} \end{array} \]
(FPCore (K m n M l)
 :precision binary64
 (let* ((t_0 (exp (* (* m m) -0.25))))
   (if (<= m -9.5e+17) t_0 (if (<= m 3.9e-16) (exp (- 0.0 l)) t_0))))
double code(double K, double m, double n, double M, double l) {
	double t_0 = exp(((m * m) * -0.25));
	double tmp;
	if (m <= -9.5e+17) {
		tmp = t_0;
	} else if (m <= 3.9e-16) {
		tmp = exp((0.0 - 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 = exp(((m * m) * (-0.25d0)))
    if (m <= (-9.5d+17)) then
        tmp = t_0
    else if (m <= 3.9d-16) then
        tmp = exp((0.0d0 - 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 = Math.exp(((m * m) * -0.25));
	double tmp;
	if (m <= -9.5e+17) {
		tmp = t_0;
	} else if (m <= 3.9e-16) {
		tmp = Math.exp((0.0 - l));
	} else {
		tmp = t_0;
	}
	return tmp;
}
def code(K, m, n, M, l):
	t_0 = math.exp(((m * m) * -0.25))
	tmp = 0
	if m <= -9.5e+17:
		tmp = t_0
	elif m <= 3.9e-16:
		tmp = math.exp((0.0 - l))
	else:
		tmp = t_0
	return tmp
function code(K, m, n, M, l)
	t_0 = exp(Float64(Float64(m * m) * -0.25))
	tmp = 0.0
	if (m <= -9.5e+17)
		tmp = t_0;
	elseif (m <= 3.9e-16)
		tmp = exp(Float64(0.0 - l));
	else
		tmp = t_0;
	end
	return tmp
end
function tmp_2 = code(K, m, n, M, l)
	t_0 = exp(((m * m) * -0.25));
	tmp = 0.0;
	if (m <= -9.5e+17)
		tmp = t_0;
	elseif (m <= 3.9e-16)
		tmp = exp((0.0 - l));
	else
		tmp = t_0;
	end
	tmp_2 = tmp;
end
code[K_, m_, n_, M_, l_] := Block[{t$95$0 = N[Exp[N[(N[(m * m), $MachinePrecision] * -0.25), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[m, -9.5e+17], t$95$0, If[LessEqual[m, 3.9e-16], N[Exp[N[(0.0 - l), $MachinePrecision]], $MachinePrecision], t$95$0]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := e^{\left(m \cdot m\right) \cdot -0.25}\\
\mathbf{if}\;m \leq -9.5 \cdot 10^{+17}:\\
\;\;\;\;t\_0\\

\mathbf{elif}\;m \leq 3.9 \cdot 10^{-16}:\\
\;\;\;\;e^{0 - \ell}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if m < -9.5e17 or 3.89999999999999977e-16 < m

    1. Initial program 77.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. Simplified77.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.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. rec-expN/A

        \[\leadsto e^{\mathsf{neg}\left(\left(\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{exp.f64}\left(\left(\mathsf{neg}\left(\left(\left(\ell + \frac{1}{4} \cdot {\left(m + n\right)}^{2}\right) - \left|m - n\right|\right)\right)\right)\right) \]
      3. neg-sub0N/A

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

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

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

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

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

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

        \[\leadsto \mathsf{exp.f64}\left(\mathsf{\_.f64}\left(0, \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|m - n\right|\right)\right)\right)\right)\right) \]
      10. *-lowering-*.f64N/A

        \[\leadsto \mathsf{exp.f64}\left(\mathsf{\_.f64}\left(0, \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|m - n\right|\right)\right)\right)\right)\right) \]
      11. +-lowering-+.f64N/A

        \[\leadsto \mathsf{exp.f64}\left(\mathsf{\_.f64}\left(0, \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|m - n\right|\right)\right)\right)\right)\right) \]
      12. +-lowering-+.f64N/A

        \[\leadsto \mathsf{exp.f64}\left(\mathsf{\_.f64}\left(0, \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|m - n\right|\right)\right)\right)\right)\right) \]
      13. fabs-subN/A

        \[\leadsto \mathsf{exp.f64}\left(\mathsf{\_.f64}\left(0, \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) \]
      14. sub-negN/A

        \[\leadsto \mathsf{exp.f64}\left(\mathsf{\_.f64}\left(0, \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) \]
      15. mul-1-negN/A

        \[\leadsto \mathsf{exp.f64}\left(\mathsf{\_.f64}\left(0, \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) \]
      16. fabs-lowering-fabs.f64N/A

        \[\leadsto \mathsf{exp.f64}\left(\mathsf{\_.f64}\left(0, \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) \]
      17. mul-1-negN/A

        \[\leadsto \mathsf{exp.f64}\left(\mathsf{\_.f64}\left(0, \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) \]
      18. sub-negN/A

        \[\leadsto \mathsf{exp.f64}\left(\mathsf{\_.f64}\left(0, \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) \]
      19. --lowering--.f6496.4%

        \[\leadsto \mathsf{exp.f64}\left(\mathsf{\_.f64}\left(0, \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. Simplified96.4%

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

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

        \[\leadsto \mathsf{exp.f64}\left(\left({m}^{2} \cdot \frac{-1}{4}\right)\right) \]
      2. *-lowering-*.f64N/A

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

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

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

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

    if -9.5e17 < m < 3.89999999999999977e-16

    1. Initial program 77.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. Simplified77.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.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. rec-expN/A

        \[\leadsto e^{\mathsf{neg}\left(\left(\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{exp.f64}\left(\left(\mathsf{neg}\left(\left(\left(\ell + \frac{1}{4} \cdot {\left(m + n\right)}^{2}\right) - \left|m - n\right|\right)\right)\right)\right) \]
      3. neg-sub0N/A

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

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

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

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

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

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

        \[\leadsto \mathsf{exp.f64}\left(\mathsf{\_.f64}\left(0, \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|m - n\right|\right)\right)\right)\right)\right) \]
      10. *-lowering-*.f64N/A

        \[\leadsto \mathsf{exp.f64}\left(\mathsf{\_.f64}\left(0, \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|m - n\right|\right)\right)\right)\right)\right) \]
      11. +-lowering-+.f64N/A

        \[\leadsto \mathsf{exp.f64}\left(\mathsf{\_.f64}\left(0, \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|m - n\right|\right)\right)\right)\right)\right) \]
      12. +-lowering-+.f64N/A

        \[\leadsto \mathsf{exp.f64}\left(\mathsf{\_.f64}\left(0, \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|m - n\right|\right)\right)\right)\right)\right) \]
      13. fabs-subN/A

        \[\leadsto \mathsf{exp.f64}\left(\mathsf{\_.f64}\left(0, \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) \]
      14. sub-negN/A

        \[\leadsto \mathsf{exp.f64}\left(\mathsf{\_.f64}\left(0, \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) \]
      15. mul-1-negN/A

        \[\leadsto \mathsf{exp.f64}\left(\mathsf{\_.f64}\left(0, \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) \]
      16. fabs-lowering-fabs.f64N/A

        \[\leadsto \mathsf{exp.f64}\left(\mathsf{\_.f64}\left(0, \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) \]
      17. mul-1-negN/A

        \[\leadsto \mathsf{exp.f64}\left(\mathsf{\_.f64}\left(0, \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) \]
      18. sub-negN/A

        \[\leadsto \mathsf{exp.f64}\left(\mathsf{\_.f64}\left(0, \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) \]
      19. --lowering--.f6475.2%

        \[\leadsto \mathsf{exp.f64}\left(\mathsf{\_.f64}\left(0, \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. Simplified75.2%

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

      \[\leadsto \mathsf{exp.f64}\left(\color{blue}{\left(-1 \cdot \ell\right)}\right) \]
    12. Step-by-step derivation
      1. neg-mul-1N/A

        \[\leadsto \mathsf{exp.f64}\left(\left(\mathsf{neg}\left(\ell\right)\right)\right) \]
      2. neg-sub0N/A

        \[\leadsto \mathsf{exp.f64}\left(\left(0 - \ell\right)\right) \]
      3. --lowering--.f6442.5%

        \[\leadsto \mathsf{exp.f64}\left(\mathsf{\_.f64}\left(0, \ell\right)\right) \]
    13. Simplified42.5%

      \[\leadsto e^{\color{blue}{0 - \ell}} \]
  3. Recombined 2 regimes into one program.
  4. Add Preprocessing

Alternative 7: 65.3% accurate, 3.9× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;n \leq 54:\\ \;\;\;\;e^{\left(m \cdot m\right) \cdot -0.25}\\ \mathbf{else}:\\ \;\;\;\;e^{-0.25 \cdot \left(n \cdot n\right)}\\ \end{array} \end{array} \]
(FPCore (K m n M l)
 :precision binary64
 (if (<= n 54.0) (exp (* (* m m) -0.25)) (exp (* -0.25 (* n n)))))
double code(double K, double m, double n, double M, double l) {
	double tmp;
	if (n <= 54.0) {
		tmp = exp(((m * m) * -0.25));
	} else {
		tmp = 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 <= 54.0d0) then
        tmp = exp(((m * m) * (-0.25d0)))
    else
        tmp = 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 <= 54.0) {
		tmp = Math.exp(((m * m) * -0.25));
	} else {
		tmp = Math.exp((-0.25 * (n * n)));
	}
	return tmp;
}
def code(K, m, n, M, l):
	tmp = 0
	if n <= 54.0:
		tmp = math.exp(((m * m) * -0.25))
	else:
		tmp = math.exp((-0.25 * (n * n)))
	return tmp
function code(K, m, n, M, l)
	tmp = 0.0
	if (n <= 54.0)
		tmp = exp(Float64(Float64(m * m) * -0.25));
	else
		tmp = 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 <= 54.0)
		tmp = exp(((m * m) * -0.25));
	else
		tmp = exp((-0.25 * (n * n)));
	end
	tmp_2 = tmp;
end
code[K_, m_, n_, M_, l_] := If[LessEqual[n, 54.0], N[Exp[N[(N[(m * m), $MachinePrecision] * -0.25), $MachinePrecision]], $MachinePrecision], N[Exp[N[(-0.25 * N[(n * n), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;n \leq 54:\\
\;\;\;\;e^{\left(m \cdot m\right) \cdot -0.25}\\

\mathbf{else}:\\
\;\;\;\;e^{-0.25 \cdot \left(n \cdot n\right)}\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if n < 54

    1. Initial program 79.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. Simplified79.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.f6496.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. Simplified96.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. rec-expN/A

        \[\leadsto e^{\mathsf{neg}\left(\left(\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{exp.f64}\left(\left(\mathsf{neg}\left(\left(\left(\ell + \frac{1}{4} \cdot {\left(m + n\right)}^{2}\right) - \left|m - n\right|\right)\right)\right)\right) \]
      3. neg-sub0N/A

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

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

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

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

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

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

        \[\leadsto \mathsf{exp.f64}\left(\mathsf{\_.f64}\left(0, \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|m - n\right|\right)\right)\right)\right)\right) \]
      10. *-lowering-*.f64N/A

        \[\leadsto \mathsf{exp.f64}\left(\mathsf{\_.f64}\left(0, \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|m - n\right|\right)\right)\right)\right)\right) \]
      11. +-lowering-+.f64N/A

        \[\leadsto \mathsf{exp.f64}\left(\mathsf{\_.f64}\left(0, \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|m - n\right|\right)\right)\right)\right)\right) \]
      12. +-lowering-+.f64N/A

        \[\leadsto \mathsf{exp.f64}\left(\mathsf{\_.f64}\left(0, \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|m - n\right|\right)\right)\right)\right)\right) \]
      13. fabs-subN/A

        \[\leadsto \mathsf{exp.f64}\left(\mathsf{\_.f64}\left(0, \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) \]
      14. sub-negN/A

        \[\leadsto \mathsf{exp.f64}\left(\mathsf{\_.f64}\left(0, \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) \]
      15. mul-1-negN/A

        \[\leadsto \mathsf{exp.f64}\left(\mathsf{\_.f64}\left(0, \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) \]
      16. fabs-lowering-fabs.f64N/A

        \[\leadsto \mathsf{exp.f64}\left(\mathsf{\_.f64}\left(0, \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) \]
      17. mul-1-negN/A

        \[\leadsto \mathsf{exp.f64}\left(\mathsf{\_.f64}\left(0, \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) \]
      18. sub-negN/A

        \[\leadsto \mathsf{exp.f64}\left(\mathsf{\_.f64}\left(0, \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) \]
      19. --lowering--.f6482.7%

        \[\leadsto \mathsf{exp.f64}\left(\mathsf{\_.f64}\left(0, \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. Simplified82.7%

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

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

        \[\leadsto \mathsf{exp.f64}\left(\left({m}^{2} \cdot \frac{-1}{4}\right)\right) \]
      2. *-lowering-*.f64N/A

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

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

        \[\leadsto \mathsf{exp.f64}\left(\mathsf{*.f64}\left(\mathsf{*.f64}\left(m, m\right), \frac{-1}{4}\right)\right) \]
    13. Simplified55.8%

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

    if 54 < n

    1. Initial program 70.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. Simplified70.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.f6498.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. Simplified98.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 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. rec-expN/A

        \[\leadsto e^{\mathsf{neg}\left(\left(\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{exp.f64}\left(\left(\mathsf{neg}\left(\left(\left(\ell + \frac{1}{4} \cdot {\left(m + n\right)}^{2}\right) - \left|m - n\right|\right)\right)\right)\right) \]
      3. neg-sub0N/A

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

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

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

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

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

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

        \[\leadsto \mathsf{exp.f64}\left(\mathsf{\_.f64}\left(0, \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|m - n\right|\right)\right)\right)\right)\right) \]
      10. *-lowering-*.f64N/A

        \[\leadsto \mathsf{exp.f64}\left(\mathsf{\_.f64}\left(0, \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|m - n\right|\right)\right)\right)\right)\right) \]
      11. +-lowering-+.f64N/A

        \[\leadsto \mathsf{exp.f64}\left(\mathsf{\_.f64}\left(0, \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|m - n\right|\right)\right)\right)\right)\right) \]
      12. +-lowering-+.f64N/A

        \[\leadsto \mathsf{exp.f64}\left(\mathsf{\_.f64}\left(0, \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|m - n\right|\right)\right)\right)\right)\right) \]
      13. fabs-subN/A

        \[\leadsto \mathsf{exp.f64}\left(\mathsf{\_.f64}\left(0, \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) \]
      14. sub-negN/A

        \[\leadsto \mathsf{exp.f64}\left(\mathsf{\_.f64}\left(0, \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) \]
      15. mul-1-negN/A

        \[\leadsto \mathsf{exp.f64}\left(\mathsf{\_.f64}\left(0, \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) \]
      16. fabs-lowering-fabs.f64N/A

        \[\leadsto \mathsf{exp.f64}\left(\mathsf{\_.f64}\left(0, \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) \]
      17. mul-1-negN/A

        \[\leadsto \mathsf{exp.f64}\left(\mathsf{\_.f64}\left(0, \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) \]
      18. sub-negN/A

        \[\leadsto \mathsf{exp.f64}\left(\mathsf{\_.f64}\left(0, \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) \]
      19. --lowering--.f6498.4%

        \[\leadsto \mathsf{exp.f64}\left(\mathsf{\_.f64}\left(0, \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. Simplified98.4%

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

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

        \[\leadsto \mathsf{exp.f64}\left(\left({n}^{2} \cdot \frac{-1}{4}\right)\right) \]
      2. *-lowering-*.f64N/A

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

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

        \[\leadsto \mathsf{exp.f64}\left(\mathsf{*.f64}\left(\mathsf{*.f64}\left(n, n\right), \frac{-1}{4}\right)\right) \]
    13. Simplified96.8%

      \[\leadsto e^{\color{blue}{\left(n \cdot n\right) \cdot -0.25}} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification65.6%

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

Alternative 8: 35.4% accurate, 4.1× speedup?

\[\begin{array}{l} \\ e^{0 - \ell} \end{array} \]
(FPCore (K m n M l) :precision binary64 (exp (- 0.0 l)))
double code(double K, double m, double n, double M, double l) {
	return exp((0.0 - 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 = exp((0.0d0 - l))
end function
public static double code(double K, double m, double n, double M, double l) {
	return Math.exp((0.0 - l));
}
def code(K, m, n, M, l):
	return math.exp((0.0 - l))
function code(K, m, n, M, l)
	return exp(Float64(0.0 - l))
end
function tmp = code(K, m, n, M, l)
	tmp = exp((0.0 - l));
end
code[K_, m_, n_, M_, l_] := N[Exp[N[(0.0 - l), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}

\\
e^{0 - \ell}
\end{array}
Derivation
  1. Initial program 77.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. Simplified77.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.f6496.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. Simplified96.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. rec-expN/A

      \[\leadsto e^{\mathsf{neg}\left(\left(\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{exp.f64}\left(\left(\mathsf{neg}\left(\left(\left(\ell + \frac{1}{4} \cdot {\left(m + n\right)}^{2}\right) - \left|m - n\right|\right)\right)\right)\right) \]
    3. neg-sub0N/A

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

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

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

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

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

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

      \[\leadsto \mathsf{exp.f64}\left(\mathsf{\_.f64}\left(0, \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|m - n\right|\right)\right)\right)\right)\right) \]
    10. *-lowering-*.f64N/A

      \[\leadsto \mathsf{exp.f64}\left(\mathsf{\_.f64}\left(0, \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|m - n\right|\right)\right)\right)\right)\right) \]
    11. +-lowering-+.f64N/A

      \[\leadsto \mathsf{exp.f64}\left(\mathsf{\_.f64}\left(0, \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|m - n\right|\right)\right)\right)\right)\right) \]
    12. +-lowering-+.f64N/A

      \[\leadsto \mathsf{exp.f64}\left(\mathsf{\_.f64}\left(0, \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|m - n\right|\right)\right)\right)\right)\right) \]
    13. fabs-subN/A

      \[\leadsto \mathsf{exp.f64}\left(\mathsf{\_.f64}\left(0, \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) \]
    14. sub-negN/A

      \[\leadsto \mathsf{exp.f64}\left(\mathsf{\_.f64}\left(0, \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) \]
    15. mul-1-negN/A

      \[\leadsto \mathsf{exp.f64}\left(\mathsf{\_.f64}\left(0, \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) \]
    16. fabs-lowering-fabs.f64N/A

      \[\leadsto \mathsf{exp.f64}\left(\mathsf{\_.f64}\left(0, \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) \]
    17. mul-1-negN/A

      \[\leadsto \mathsf{exp.f64}\left(\mathsf{\_.f64}\left(0, \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) \]
    18. sub-negN/A

      \[\leadsto \mathsf{exp.f64}\left(\mathsf{\_.f64}\left(0, \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) \]
    19. --lowering--.f6486.5%

      \[\leadsto \mathsf{exp.f64}\left(\mathsf{\_.f64}\left(0, \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. Simplified86.5%

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

    \[\leadsto \mathsf{exp.f64}\left(\color{blue}{\left(-1 \cdot \ell\right)}\right) \]
  12. Step-by-step derivation
    1. neg-mul-1N/A

      \[\leadsto \mathsf{exp.f64}\left(\left(\mathsf{neg}\left(\ell\right)\right)\right) \]
    2. neg-sub0N/A

      \[\leadsto \mathsf{exp.f64}\left(\left(0 - \ell\right)\right) \]
    3. --lowering--.f6436.5%

      \[\leadsto \mathsf{exp.f64}\left(\mathsf{\_.f64}\left(0, \ell\right)\right) \]
  13. Simplified36.5%

    \[\leadsto e^{\color{blue}{0 - \ell}} \]
  14. Add Preprocessing

Alternative 9: 9.4% accurate, 47.2× speedup?

\[\begin{array}{l} \\ 1 + \ell \cdot \left(\ell \cdot 0.5 + -1\right) \end{array} \]
(FPCore (K m n M l) :precision binary64 (+ 1.0 (* l (+ (* l 0.5) -1.0))))
double code(double K, double m, double n, double M, double l) {
	return 1.0 + (l * ((l * 0.5) + -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 + (l * ((l * 0.5d0) + (-1.0d0)))
end function
public static double code(double K, double m, double n, double M, double l) {
	return 1.0 + (l * ((l * 0.5) + -1.0));
}
def code(K, m, n, M, l):
	return 1.0 + (l * ((l * 0.5) + -1.0))
function code(K, m, n, M, l)
	return Float64(1.0 + Float64(l * Float64(Float64(l * 0.5) + -1.0)))
end
function tmp = code(K, m, n, M, l)
	tmp = 1.0 + (l * ((l * 0.5) + -1.0));
end
code[K_, m_, n_, M_, l_] := N[(1.0 + N[(l * N[(N[(l * 0.5), $MachinePrecision] + -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
1 + \ell \cdot \left(\ell \cdot 0.5 + -1\right)
\end{array}
Derivation
  1. Initial program 77.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. Add Preprocessing
  3. Taylor expanded in l 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(\color{blue}{\left(-1 \cdot \ell\right)}\right)\right) \]
  4. Step-by-step derivation
    1. mul-1-negN/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(\left(\mathsf{neg}\left(\ell\right)\right)\right)\right) \]
    2. neg-sub0N/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(\left(0 - \ell\right)\right)\right) \]
    3. --lowering--.f6433.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(0, \ell\right)\right)\right) \]
  5. Simplified33.5%

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

    \[\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), \color{blue}{\left(1 + \ell \cdot \left(\frac{1}{2} \cdot \ell - 1\right)\right)}\right) \]
  7. Step-by-step derivation
    1. +-lowering-+.f64N/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{+.f64}\left(1, \color{blue}{\left(\ell \cdot \left(\frac{1}{2} \cdot \ell - 1\right)\right)}\right)\right) \]
    2. *-lowering-*.f64N/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{+.f64}\left(1, \mathsf{*.f64}\left(\ell, \color{blue}{\left(\frac{1}{2} \cdot \ell - 1\right)}\right)\right)\right) \]
    3. sub-negN/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{+.f64}\left(1, \mathsf{*.f64}\left(\ell, \left(\frac{1}{2} \cdot \ell + \color{blue}{\left(\mathsf{neg}\left(1\right)\right)}\right)\right)\right)\right) \]
    4. metadata-evalN/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{+.f64}\left(1, \mathsf{*.f64}\left(\ell, \left(\frac{1}{2} \cdot \ell + -1\right)\right)\right)\right) \]
    5. +-lowering-+.f64N/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{+.f64}\left(1, \mathsf{*.f64}\left(\ell, \mathsf{+.f64}\left(\left(\frac{1}{2} \cdot \ell\right), \color{blue}{-1}\right)\right)\right)\right) \]
    6. *-commutativeN/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{+.f64}\left(1, \mathsf{*.f64}\left(\ell, \mathsf{+.f64}\left(\left(\ell \cdot \frac{1}{2}\right), -1\right)\right)\right)\right) \]
    7. *-lowering-*.f6410.7%

      \[\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{+.f64}\left(1, \mathsf{*.f64}\left(\ell, \mathsf{+.f64}\left(\mathsf{*.f64}\left(\ell, \frac{1}{2}\right), -1\right)\right)\right)\right) \]
  8. Simplified10.7%

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

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

      \[\leadsto \mathsf{*.f64}\left(\cos M, \mathsf{+.f64}\left(\color{blue}{1}, \mathsf{*.f64}\left(\ell, \mathsf{+.f64}\left(\mathsf{*.f64}\left(\ell, \frac{1}{2}\right), -1\right)\right)\right)\right) \]
    2. cos-lowering-cos.f649.8%

      \[\leadsto \mathsf{*.f64}\left(\mathsf{cos.f64}\left(M\right), \mathsf{+.f64}\left(\color{blue}{1}, \mathsf{*.f64}\left(\ell, \mathsf{+.f64}\left(\mathsf{*.f64}\left(\ell, \frac{1}{2}\right), -1\right)\right)\right)\right) \]
  11. Simplified9.8%

    \[\leadsto \color{blue}{\cos M} \cdot \left(1 + \ell \cdot \left(\ell \cdot 0.5 + -1\right)\right) \]
  12. Taylor expanded in M around 0

    \[\leadsto \color{blue}{1 + \ell \cdot \left(\frac{1}{2} \cdot \ell - 1\right)} \]
  13. Step-by-step derivation
    1. +-lowering-+.f64N/A

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

      \[\leadsto \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\ell, \color{blue}{\left(\frac{1}{2} \cdot \ell - 1\right)}\right)\right) \]
    3. sub-negN/A

      \[\leadsto \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\ell, \left(\frac{1}{2} \cdot \ell + \color{blue}{\left(\mathsf{neg}\left(1\right)\right)}\right)\right)\right) \]
    4. metadata-evalN/A

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

      \[\leadsto \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\ell, \mathsf{+.f64}\left(\left(\frac{1}{2} \cdot \ell\right), \color{blue}{-1}\right)\right)\right) \]
    6. *-lowering-*.f649.8%

      \[\leadsto \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\ell, \mathsf{+.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \ell\right), -1\right)\right)\right) \]
  14. Simplified9.8%

    \[\leadsto \color{blue}{1 + \ell \cdot \left(0.5 \cdot \ell + -1\right)} \]
  15. Final simplification9.8%

    \[\leadsto 1 + \ell \cdot \left(\ell \cdot 0.5 + -1\right) \]
  16. Add Preprocessing

Alternative 10: 7.1% 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 77.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. Add Preprocessing
  3. Taylor expanded in n 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(\color{blue}{\left(\frac{-1}{4} \cdot {n}^{2}\right)}\right)\right) \]
  4. Step-by-step derivation
    1. *-lowering-*.f64N/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(\frac{-1}{4}, \left({n}^{2}\right)\right)\right)\right) \]
    2. 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(\frac{-1}{4}, \left(n \cdot n\right)\right)\right)\right) \]
    3. *-lowering-*.f6437.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(\frac{-1}{4}, \mathsf{*.f64}\left(n, n\right)\right)\right)\right) \]
  5. Simplified37.9%

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

    \[\leadsto \color{blue}{\cos \left(\frac{1}{2} \cdot \left(K \cdot m\right) - M\right)} \]
  7. Step-by-step derivation
    1. cos-lowering-cos.f64N/A

      \[\leadsto \mathsf{cos.f64}\left(\left(\frac{1}{2} \cdot \left(K \cdot m\right) - M\right)\right) \]
    2. --lowering--.f64N/A

      \[\leadsto \mathsf{cos.f64}\left(\mathsf{\_.f64}\left(\left(\frac{1}{2} \cdot \left(K \cdot m\right)\right), M\right)\right) \]
    3. *-lowering-*.f64N/A

      \[\leadsto \mathsf{cos.f64}\left(\mathsf{\_.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \left(K \cdot m\right)\right), M\right)\right) \]
    4. *-commutativeN/A

      \[\leadsto \mathsf{cos.f64}\left(\mathsf{\_.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \left(m \cdot K\right)\right), M\right)\right) \]
    5. *-lowering-*.f648.2%

      \[\leadsto \mathsf{cos.f64}\left(\mathsf{\_.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(m, K\right)\right), M\right)\right) \]
  8. Simplified8.2%

    \[\leadsto \color{blue}{\cos \left(0.5 \cdot \left(m \cdot K\right) - M\right)} \]
  9. Taylor expanded in m around 0

    \[\leadsto \color{blue}{\cos \left(\mathsf{neg}\left(M\right)\right)} \]
  10. Step-by-step derivation
    1. cos-negN/A

      \[\leadsto \cos M \]
    2. cos-lowering-cos.f648.4%

      \[\leadsto \mathsf{cos.f64}\left(M\right) \]
  11. Simplified8.4%

    \[\leadsto \color{blue}{\cos M} \]
  12. Taylor expanded in M around 0

    \[\leadsto \color{blue}{1} \]
  13. Step-by-step derivation
    1. Simplified8.4%

      \[\leadsto \color{blue}{1} \]
    2. Add Preprocessing

    Reproduce

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