Maksimov and Kolovsky, Equation (32)

Percentage Accurate: 76.6% → 96.9%
Time: 13.7s
Alternatives: 10
Speedup: 3.7×

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: 76.6% 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.9% accurate, 1.3× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := 0.5 \cdot \left(n + m\right)\\ \cos M \cdot e^{\left|n - m\right| + \left(\left(t\_0 - M\right) \cdot \left(M - t\_0\right) - \ell\right)} \end{array} \end{array} \]
(FPCore (K m n M l)
 :precision binary64
 (let* ((t_0 (* 0.5 (+ n m))))
   (* (cos M) (exp (+ (fabs (- n m)) (- (* (- t_0 M) (- M t_0)) l))))))
double code(double K, double m, double n, double M, double l) {
	double t_0 = 0.5 * (n + m);
	return cos(M) * exp((fabs((n - m)) + (((t_0 - M) * (M - t_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
    real(8) :: t_0
    t_0 = 0.5d0 * (n + m)
    code = cos(m_1) * exp((abs((n - m)) + (((t_0 - m_1) * (m_1 - t_0)) - l)))
end function
public static double code(double K, double m, double n, double M, double l) {
	double t_0 = 0.5 * (n + m);
	return Math.cos(M) * Math.exp((Math.abs((n - m)) + (((t_0 - M) * (M - t_0)) - l)));
}
def code(K, m, n, M, l):
	t_0 = 0.5 * (n + m)
	return math.cos(M) * math.exp((math.fabs((n - m)) + (((t_0 - M) * (M - t_0)) - l)))
function code(K, m, n, M, l)
	t_0 = Float64(0.5 * Float64(n + m))
	return Float64(cos(M) * exp(Float64(abs(Float64(n - m)) + Float64(Float64(Float64(t_0 - M) * Float64(M - t_0)) - l))))
end
function tmp = code(K, m, n, M, l)
	t_0 = 0.5 * (n + m);
	tmp = cos(M) * exp((abs((n - m)) + (((t_0 - M) * (M - t_0)) - l)));
end
code[K_, m_, n_, M_, l_] := Block[{t$95$0 = N[(0.5 * N[(n + m), $MachinePrecision]), $MachinePrecision]}, N[(N[Cos[M], $MachinePrecision] * N[Exp[N[(N[Abs[N[(n - m), $MachinePrecision]], $MachinePrecision] + N[(N[(N[(t$95$0 - M), $MachinePrecision] * N[(M - t$95$0), $MachinePrecision]), $MachinePrecision] - l), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := 0.5 \cdot \left(n + m\right)\\
\cos M \cdot e^{\left|n - m\right| + \left(\left(t\_0 - M\right) \cdot \left(M - t\_0\right) - \ell\right)}
\end{array}
\end{array}
Derivation
  1. Initial program 76.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. Add Preprocessing
  3. Taylor expanded in K around 0

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \mathsf{*.f64}\left(\mathsf{cos.f64}\left(M\right), \mathsf{exp.f64}\left(\mathsf{\_.f64}\left(\mathsf{fabs.f64}\left(\mathsf{\_.f64}\left(n, m\right)\right), \mathsf{+.f64}\left(\ell, \mathsf{*.f64}\left(\mathsf{\_.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{+.f64}\left(m, n\right)\right), M\right), \mathsf{\_.f64}\left(\left(\frac{1}{2} \cdot \left(m + n\right)\right), M\right)\right)\right)\right)\right)\right) \]
  5. Simplified96.4%

    \[\leadsto \color{blue}{\cos M \cdot e^{\left|n - m\right| - \left(\ell + \left(0.5 \cdot \left(m + n\right) - M\right) \cdot \left(0.5 \cdot \left(m + n\right) - M\right)\right)}} \]
  6. Final simplification96.4%

    \[\leadsto \cos M \cdot e^{\left|n - m\right| + \left(\left(0.5 \cdot \left(n + m\right) - M\right) \cdot \left(M - 0.5 \cdot \left(n + m\right)\right) - \ell\right)} \]
  7. Add Preprocessing

Alternative 2: 96.2% accurate, 1.8× speedup?

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

\\
\begin{array}{l}
t_0 := e^{0 - M \cdot M}\\
t_1 := 0.5 \cdot \left(n + m\right)\\
\mathbf{if}\;M \leq -1 \cdot 10^{+116}:\\
\;\;\;\;t\_0\\

\mathbf{elif}\;M \leq 1.85 \cdot 10^{+33}:\\
\;\;\;\;e^{\left|n - m\right| + \left(\left(t\_1 - M\right) \cdot \left(M - t\_1\right) - \ell\right)} \cdot \left(1 + \left(M \cdot M\right) \cdot -0.5\right)\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if M < -1.00000000000000002e116 or 1.8499999999999999e33 < M

    1. Initial program 83.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. Add Preprocessing
    3. Taylor expanded in M around inf

      \[\leadsto \mathsf{*.f64}\left(\mathsf{cos.f64}\left(\mathsf{\_.f64}\left(\mathsf{/.f64}\left(\mathsf{*.f64}\left(K, \mathsf{+.f64}\left(m, n\right)\right), 2\right), M\right)\right), \mathsf{exp.f64}\left(\color{blue}{\left(-1 \cdot {M}^{2}\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({M}^{2}\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 - {M}^{2}\right)\right)\right) \]
      3. --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(0, \left({M}^{2}\right)\right)\right)\right) \]
      4. 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(0, \left(M \cdot M\right)\right)\right)\right) \]
      5. *-lowering-*.f6481.2%

        \[\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, \mathsf{*.f64}\left(M, M\right)\right)\right)\right) \]
    5. Simplified81.2%

      \[\leadsto \cos \left(\frac{K \cdot \left(m + n\right)}{2} - M\right) \cdot e^{\color{blue}{0 - M \cdot M}} \]
    6. 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(0, \mathsf{*.f64}\left(M, M\right)\right)\right)\right) \]
    7. Step-by-step derivation
      1. cos-negN/A

        \[\leadsto \mathsf{*.f64}\left(\cos M, \mathsf{exp.f64}\left(\color{blue}{\mathsf{\_.f64}\left(0, \mathsf{*.f64}\left(M, M\right)\right)}\right)\right) \]
      2. cos-lowering-cos.f6498.1%

        \[\leadsto \mathsf{*.f64}\left(\mathsf{cos.f64}\left(M\right), \mathsf{exp.f64}\left(\color{blue}{\mathsf{\_.f64}\left(0, \mathsf{*.f64}\left(M, M\right)\right)}\right)\right) \]
    8. Simplified98.1%

      \[\leadsto \color{blue}{\cos M} \cdot e^{0 - M \cdot M} \]
    9. Taylor expanded in M around 0

      \[\leadsto \mathsf{*.f64}\left(\color{blue}{1}, \mathsf{exp.f64}\left(\mathsf{\_.f64}\left(0, \mathsf{*.f64}\left(M, M\right)\right)\right)\right) \]
    10. Step-by-step derivation
      1. Simplified98.1%

        \[\leadsto \color{blue}{1} \cdot e^{0 - M \cdot M} \]

      if -1.00000000000000002e116 < M < 1.8499999999999999e33

      1. Initial program 71.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. Add Preprocessing
      3. Taylor expanded in K around 0

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

          \[\leadsto \mathsf{*.f64}\left(\mathsf{cos.f64}\left(M\right), \mathsf{exp.f64}\left(\mathsf{\_.f64}\left(\mathsf{fabs.f64}\left(\mathsf{\_.f64}\left(n, m\right)\right), \mathsf{+.f64}\left(\ell, \mathsf{*.f64}\left(\mathsf{\_.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{+.f64}\left(m, n\right)\right), M\right), \mathsf{\_.f64}\left(\left(\frac{1}{2} \cdot \left(m + n\right)\right), M\right)\right)\right)\right)\right)\right) \]
      5. Simplified94.1%

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

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

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

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

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

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

        \[\leadsto \color{blue}{\left(1 + -0.5 \cdot \left(M \cdot M\right)\right)} \cdot e^{\left|n - m\right| - \left(\ell + \left(0.5 \cdot \left(m + n\right) - M\right) \cdot \left(0.5 \cdot \left(m + n\right) - M\right)\right)} \]
    11. Recombined 2 regimes into one program.
    12. Final simplification95.6%

      \[\leadsto \begin{array}{l} \mathbf{if}\;M \leq -1 \cdot 10^{+116}:\\ \;\;\;\;e^{0 - M \cdot M}\\ \mathbf{elif}\;M \leq 1.85 \cdot 10^{+33}:\\ \;\;\;\;e^{\left|n - m\right| + \left(\left(0.5 \cdot \left(n + m\right) - M\right) \cdot \left(M - 0.5 \cdot \left(n + m\right)\right) - \ell\right)} \cdot \left(1 + \left(M \cdot M\right) \cdot -0.5\right)\\ \mathbf{else}:\\ \;\;\;\;e^{0 - M \cdot M}\\ \end{array} \]
    13. Add Preprocessing

    Alternative 3: 72.0% accurate, 1.9× speedup?

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

      1. Initial program 75.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 K around 0

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

          \[\leadsto \mathsf{*.f64}\left(\mathsf{cos.f64}\left(M\right), \mathsf{exp.f64}\left(\mathsf{*.f64}\left(\frac{-1}{4}, \mathsf{*.f64}\left(m, m\right)\right)\right)\right) \]
      8. Simplified53.2%

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

      if -1.5e-175 < n < 3250

      1. Initial program 82.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

          \[\leadsto \mathsf{*.f64}\left(\mathsf{cos.f64}\left(M\right), \mathsf{exp.f64}\left(\mathsf{\_.f64}\left(\mathsf{fabs.f64}\left(\mathsf{\_.f64}\left(n, m\right)\right), \mathsf{+.f64}\left(\ell, \mathsf{*.f64}\left(\mathsf{\_.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{+.f64}\left(m, n\right)\right), M\right), \mathsf{\_.f64}\left(\left(\frac{1}{2} \cdot \left(m + n\right)\right), M\right)\right)\right)\right)\right)\right) \]
      5. Simplified94.1%

        \[\leadsto \color{blue}{\cos M \cdot e^{\left|n - m\right| - \left(\ell + \left(0.5 \cdot \left(m + n\right) - M\right) \cdot \left(0.5 \cdot \left(m + n\right) - M\right)\right)}} \]
      6. Step-by-step derivation
        1. exp-diffN/A

          \[\leadsto \mathsf{*.f64}\left(\mathsf{cos.f64}\left(M\right), \left(\frac{e^{\left|n - m\right|}}{\color{blue}{e^{\ell + \left(\frac{1}{2} \cdot \left(m + n\right) - M\right) \cdot \left(\frac{1}{2} \cdot \left(m + n\right) - M\right)}}}\right)\right) \]
        2. +-commutativeN/A

          \[\leadsto \mathsf{*.f64}\left(\mathsf{cos.f64}\left(M\right), \left(\frac{e^{\left|n - m\right|}}{e^{\left(\frac{1}{2} \cdot \left(m + n\right) - M\right) \cdot \left(\frac{1}{2} \cdot \left(m + n\right) - M\right) + \ell}}\right)\right) \]
        3. pow2N/A

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

          \[\leadsto \mathsf{*.f64}\left(\mathsf{cos.f64}\left(M\right), \left(\frac{e^{\left|n - m\right|}}{e^{{\left(\left(m + n\right) \cdot \frac{1}{2} - M\right)}^{2} + \ell}}\right)\right) \]
        5. metadata-evalN/A

          \[\leadsto \mathsf{*.f64}\left(\mathsf{cos.f64}\left(M\right), \left(\frac{e^{\left|n - m\right|}}{e^{{\left(\left(m + n\right) \cdot \frac{1}{2} - M\right)}^{2} + \ell}}\right)\right) \]
        6. div-invN/A

          \[\leadsto \mathsf{*.f64}\left(\mathsf{cos.f64}\left(M\right), \left(\frac{e^{\left|n - m\right|}}{e^{{\left(\frac{m + n}{2} - M\right)}^{2} + \ell}}\right)\right) \]
        7. pow2N/A

          \[\leadsto \mathsf{*.f64}\left(\mathsf{cos.f64}\left(M\right), \left(\frac{e^{\left|n - m\right|}}{e^{\left(\frac{m + n}{2} - M\right) \cdot \left(\frac{m + n}{2} - M\right) + \ell}}\right)\right) \]
        8. clear-numN/A

          \[\leadsto \mathsf{*.f64}\left(\mathsf{cos.f64}\left(M\right), \left(\frac{1}{\color{blue}{\frac{e^{\left(\frac{m + n}{2} - M\right) \cdot \left(\frac{m + n}{2} - M\right) + \ell}}{e^{\left|n - m\right|}}}}\right)\right) \]
        9. fabs-subN/A

          \[\leadsto \mathsf{*.f64}\left(\mathsf{cos.f64}\left(M\right), \left(\frac{1}{\frac{e^{\left(\frac{m + n}{2} - M\right) \cdot \left(\frac{m + n}{2} - M\right) + \ell}}{e^{\left|m - n\right|}}}\right)\right) \]
        10. exp-diffN/A

          \[\leadsto \mathsf{*.f64}\left(\mathsf{cos.f64}\left(M\right), \left(\frac{1}{e^{\left(\left(\frac{m + n}{2} - M\right) \cdot \left(\frac{m + n}{2} - M\right) + \ell\right) - \left|m - n\right|}}\right)\right) \]
      7. Applied egg-rr90.2%

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

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

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

          \[\leadsto \mathsf{*.f64}\left(\mathsf{cos.f64}\left(M\right), \mathsf{/.f64}\left(-1, \mathsf{\_.f64}\left(0, \mathsf{exp.f64}\left(\mathsf{+.f64}\left(\ell, \mathsf{*.f64}\left(M, M\right)\right)\right)\right)\right)\right) \]
      10. Simplified75.0%

        \[\leadsto \cos M \cdot \frac{-1}{0 - e^{\ell + \color{blue}{M \cdot M}}} \]

      if 3250 < n

      1. Initial program 69.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 K around 0

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

          \[\leadsto \mathsf{*.f64}\left(\mathsf{cos.f64}\left(M\right), \mathsf{exp.f64}\left(\mathsf{\_.f64}\left(\mathsf{fabs.f64}\left(\mathsf{\_.f64}\left(n, m\right)\right), \mathsf{+.f64}\left(\ell, \mathsf{*.f64}\left(\mathsf{\_.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{+.f64}\left(m, n\right)\right), M\right), \mathsf{\_.f64}\left(\left(\frac{1}{2} \cdot \left(m + n\right)\right), M\right)\right)\right)\right)\right)\right) \]
      5. Simplified98.4%

        \[\leadsto \color{blue}{\cos M \cdot e^{\left|n - m\right| - \left(\ell + \left(0.5 \cdot \left(m + n\right) - M\right) \cdot \left(0.5 \cdot \left(m + n\right) - M\right)\right)}} \]
      6. 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) \]
      7. 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-*.f6496.8%

          \[\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) \]
      8. Simplified96.8%

        \[\leadsto \cos M \cdot e^{\color{blue}{-0.25 \cdot \left(n \cdot n\right)}} \]
      9. Taylor expanded in M around 0

        \[\leadsto \color{blue}{e^{\frac{-1}{4} \cdot {n}^{2}}} \]
      10. Step-by-step derivation
        1. exp-lowering-exp.f64N/A

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

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

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

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

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

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

    Alternative 4: 71.5% accurate, 2.0× speedup?

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

      1. Initial program 75.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      if -3.49999999999999996e-181 < n < 3250

      1. Initial program 82.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. Add Preprocessing
      3. Taylor expanded in K around 0

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

          \[\leadsto \mathsf{*.f64}\left(\mathsf{cos.f64}\left(M\right), \mathsf{exp.f64}\left(\mathsf{\_.f64}\left(\mathsf{fabs.f64}\left(\mathsf{\_.f64}\left(n, m\right)\right), \mathsf{+.f64}\left(\ell, \mathsf{*.f64}\left(\mathsf{\_.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{+.f64}\left(m, n\right)\right), M\right), \mathsf{\_.f64}\left(\left(\frac{1}{2} \cdot \left(m + n\right)\right), M\right)\right)\right)\right)\right)\right) \]
      5. Simplified94.0%

        \[\leadsto \color{blue}{\cos M \cdot e^{\left|n - m\right| - \left(\ell + \left(0.5 \cdot \left(m + n\right) - M\right) \cdot \left(0.5 \cdot \left(m + n\right) - M\right)\right)}} \]
      6. Step-by-step derivation
        1. exp-diffN/A

          \[\leadsto \mathsf{*.f64}\left(\mathsf{cos.f64}\left(M\right), \left(\frac{e^{\left|n - m\right|}}{\color{blue}{e^{\ell + \left(\frac{1}{2} \cdot \left(m + n\right) - M\right) \cdot \left(\frac{1}{2} \cdot \left(m + n\right) - M\right)}}}\right)\right) \]
        2. +-commutativeN/A

          \[\leadsto \mathsf{*.f64}\left(\mathsf{cos.f64}\left(M\right), \left(\frac{e^{\left|n - m\right|}}{e^{\left(\frac{1}{2} \cdot \left(m + n\right) - M\right) \cdot \left(\frac{1}{2} \cdot \left(m + n\right) - M\right) + \ell}}\right)\right) \]
        3. pow2N/A

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

          \[\leadsto \mathsf{*.f64}\left(\mathsf{cos.f64}\left(M\right), \left(\frac{e^{\left|n - m\right|}}{e^{{\left(\left(m + n\right) \cdot \frac{1}{2} - M\right)}^{2} + \ell}}\right)\right) \]
        5. metadata-evalN/A

          \[\leadsto \mathsf{*.f64}\left(\mathsf{cos.f64}\left(M\right), \left(\frac{e^{\left|n - m\right|}}{e^{{\left(\left(m + n\right) \cdot \frac{1}{2} - M\right)}^{2} + \ell}}\right)\right) \]
        6. div-invN/A

          \[\leadsto \mathsf{*.f64}\left(\mathsf{cos.f64}\left(M\right), \left(\frac{e^{\left|n - m\right|}}{e^{{\left(\frac{m + n}{2} - M\right)}^{2} + \ell}}\right)\right) \]
        7. pow2N/A

          \[\leadsto \mathsf{*.f64}\left(\mathsf{cos.f64}\left(M\right), \left(\frac{e^{\left|n - m\right|}}{e^{\left(\frac{m + n}{2} - M\right) \cdot \left(\frac{m + n}{2} - M\right) + \ell}}\right)\right) \]
        8. clear-numN/A

          \[\leadsto \mathsf{*.f64}\left(\mathsf{cos.f64}\left(M\right), \left(\frac{1}{\color{blue}{\frac{e^{\left(\frac{m + n}{2} - M\right) \cdot \left(\frac{m + n}{2} - M\right) + \ell}}{e^{\left|n - m\right|}}}}\right)\right) \]
        9. fabs-subN/A

          \[\leadsto \mathsf{*.f64}\left(\mathsf{cos.f64}\left(M\right), \left(\frac{1}{\frac{e^{\left(\frac{m + n}{2} - M\right) \cdot \left(\frac{m + n}{2} - M\right) + \ell}}{e^{\left|m - n\right|}}}\right)\right) \]
        10. exp-diffN/A

          \[\leadsto \mathsf{*.f64}\left(\mathsf{cos.f64}\left(M\right), \left(\frac{1}{e^{\left(\left(\frac{m + n}{2} - M\right) \cdot \left(\frac{m + n}{2} - M\right) + \ell\right) - \left|m - n\right|}}\right)\right) \]
      7. Applied egg-rr90.1%

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

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

          \[\leadsto \mathsf{*.f64}\left(\mathsf{cos.f64}\left(M\right), \mathsf{/.f64}\left(-1, \mathsf{\_.f64}\left(0, \mathsf{exp.f64}\left(\mathsf{+.f64}\left(\ell, \left(M \cdot M\right)\right)\right)\right)\right)\right) \]
        2. *-lowering-*.f6474.7%

          \[\leadsto \mathsf{*.f64}\left(\mathsf{cos.f64}\left(M\right), \mathsf{/.f64}\left(-1, \mathsf{\_.f64}\left(0, \mathsf{exp.f64}\left(\mathsf{+.f64}\left(\ell, \mathsf{*.f64}\left(M, M\right)\right)\right)\right)\right)\right) \]
      10. Simplified74.7%

        \[\leadsto \cos M \cdot \frac{-1}{0 - e^{\ell + \color{blue}{M \cdot M}}} \]
      11. Taylor expanded in M around 0

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

          \[\leadsto \color{blue}{1} \cdot \frac{-1}{0 - e^{\ell + M \cdot M}} \]

        if 3250 < n

        1. Initial program 69.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 K around 0

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

            \[\leadsto \mathsf{*.f64}\left(\mathsf{cos.f64}\left(M\right), \mathsf{exp.f64}\left(\mathsf{\_.f64}\left(\mathsf{fabs.f64}\left(\mathsf{\_.f64}\left(n, m\right)\right), \mathsf{+.f64}\left(\ell, \mathsf{*.f64}\left(\mathsf{\_.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{+.f64}\left(m, n\right)\right), M\right), \mathsf{\_.f64}\left(\left(\frac{1}{2} \cdot \left(m + n\right)\right), M\right)\right)\right)\right)\right)\right) \]
        5. Simplified98.4%

          \[\leadsto \color{blue}{\cos M \cdot e^{\left|n - m\right| - \left(\ell + \left(0.5 \cdot \left(m + n\right) - M\right) \cdot \left(0.5 \cdot \left(m + n\right) - M\right)\right)}} \]
        6. 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) \]
        7. 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-*.f6496.8%

            \[\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) \]
        8. Simplified96.8%

          \[\leadsto \cos M \cdot e^{\color{blue}{-0.25 \cdot \left(n \cdot n\right)}} \]
        9. Taylor expanded in M around 0

          \[\leadsto \color{blue}{e^{\frac{-1}{4} \cdot {n}^{2}}} \]
        10. Step-by-step derivation
          1. exp-lowering-exp.f64N/A

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

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

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

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

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

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

      Alternative 5: 86.2% accurate, 3.6× speedup?

      \[\begin{array}{l} \\ \begin{array}{l} t_0 := e^{-0.25 \cdot \left(n \cdot n\right)}\\ \mathbf{if}\;n \leq -2050000:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;n \leq 3250:\\ \;\;\;\;\frac{0 - -1}{e^{\ell + M \cdot M}}\\ \mathbf{else}:\\ \;\;\;\;t\_0\\ \end{array} \end{array} \]
      (FPCore (K m n M l)
       :precision binary64
       (let* ((t_0 (exp (* -0.25 (* n n)))))
         (if (<= n -2050000.0)
           t_0
           (if (<= n 3250.0) (/ (- 0.0 -1.0) (exp (+ l (* M M)))) t_0))))
      double code(double K, double m, double n, double M, double l) {
      	double t_0 = exp((-0.25 * (n * n)));
      	double tmp;
      	if (n <= -2050000.0) {
      		tmp = t_0;
      	} else if (n <= 3250.0) {
      		tmp = (0.0 - -1.0) / exp((l + (M * M)));
      	} 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(((-0.25d0) * (n * n)))
          if (n <= (-2050000.0d0)) then
              tmp = t_0
          else if (n <= 3250.0d0) then
              tmp = (0.0d0 - (-1.0d0)) / exp((l + (m_1 * m_1)))
          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((-0.25 * (n * n)));
      	double tmp;
      	if (n <= -2050000.0) {
      		tmp = t_0;
      	} else if (n <= 3250.0) {
      		tmp = (0.0 - -1.0) / Math.exp((l + (M * M)));
      	} else {
      		tmp = t_0;
      	}
      	return tmp;
      }
      
      def code(K, m, n, M, l):
      	t_0 = math.exp((-0.25 * (n * n)))
      	tmp = 0
      	if n <= -2050000.0:
      		tmp = t_0
      	elif n <= 3250.0:
      		tmp = (0.0 - -1.0) / math.exp((l + (M * M)))
      	else:
      		tmp = t_0
      	return tmp
      
      function code(K, m, n, M, l)
      	t_0 = exp(Float64(-0.25 * Float64(n * n)))
      	tmp = 0.0
      	if (n <= -2050000.0)
      		tmp = t_0;
      	elseif (n <= 3250.0)
      		tmp = Float64(Float64(0.0 - -1.0) / exp(Float64(l + Float64(M * M))));
      	else
      		tmp = t_0;
      	end
      	return tmp
      end
      
      function tmp_2 = code(K, m, n, M, l)
      	t_0 = exp((-0.25 * (n * n)));
      	tmp = 0.0;
      	if (n <= -2050000.0)
      		tmp = t_0;
      	elseif (n <= 3250.0)
      		tmp = (0.0 - -1.0) / exp((l + (M * M)));
      	else
      		tmp = t_0;
      	end
      	tmp_2 = tmp;
      end
      
      code[K_, m_, n_, M_, l_] := Block[{t$95$0 = N[Exp[N[(-0.25 * N[(n * n), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[n, -2050000.0], t$95$0, If[LessEqual[n, 3250.0], N[(N[(0.0 - -1.0), $MachinePrecision] / N[Exp[N[(l + N[(M * M), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], t$95$0]]]
      
      \begin{array}{l}
      
      \\
      \begin{array}{l}
      t_0 := e^{-0.25 \cdot \left(n \cdot n\right)}\\
      \mathbf{if}\;n \leq -2050000:\\
      \;\;\;\;t\_0\\
      
      \mathbf{elif}\;n \leq 3250:\\
      \;\;\;\;\frac{0 - -1}{e^{\ell + M \cdot M}}\\
      
      \mathbf{else}:\\
      \;\;\;\;t\_0\\
      
      
      \end{array}
      \end{array}
      
      Derivation
      1. Split input into 2 regimes
      2. if n < -2.05e6 or 3250 < n

        1. Initial program 72.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. Add Preprocessing
        3. Taylor expanded in K around 0

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

          \[\leadsto \color{blue}{\cos M \cdot e^{\left|n - m\right| - \left(\ell + \left(0.5 \cdot \left(m + n\right) - M\right) \cdot \left(0.5 \cdot \left(m + n\right) - M\right)\right)}} \]
        6. 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) \]
        7. 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-*.f6495.6%

            \[\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) \]
        8. Simplified95.6%

          \[\leadsto \cos M \cdot e^{\color{blue}{-0.25 \cdot \left(n \cdot n\right)}} \]
        9. Taylor expanded in M around 0

          \[\leadsto \color{blue}{e^{\frac{-1}{4} \cdot {n}^{2}}} \]
        10. Step-by-step derivation
          1. exp-lowering-exp.f64N/A

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

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

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

            \[\leadsto \mathsf{exp.f64}\left(\mathsf{*.f64}\left(\frac{-1}{4}, \mathsf{*.f64}\left(n, n\right)\right)\right) \]
        11. Simplified95.6%

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

        if -2.05e6 < n < 3250

        1. Initial program 80.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

            \[\leadsto \mathsf{*.f64}\left(\mathsf{cos.f64}\left(M\right), \mathsf{exp.f64}\left(\mathsf{\_.f64}\left(\mathsf{fabs.f64}\left(\mathsf{\_.f64}\left(n, m\right)\right), \mathsf{+.f64}\left(\ell, \mathsf{*.f64}\left(\mathsf{\_.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{+.f64}\left(m, n\right)\right), M\right), \mathsf{\_.f64}\left(\left(\frac{1}{2} \cdot \left(m + n\right)\right), M\right)\right)\right)\right)\right)\right) \]
        5. Simplified94.1%

          \[\leadsto \color{blue}{\cos M \cdot e^{\left|n - m\right| - \left(\ell + \left(0.5 \cdot \left(m + n\right) - M\right) \cdot \left(0.5 \cdot \left(m + n\right) - M\right)\right)}} \]
        6. Step-by-step derivation
          1. exp-diffN/A

            \[\leadsto \mathsf{*.f64}\left(\mathsf{cos.f64}\left(M\right), \left(\frac{e^{\left|n - m\right|}}{\color{blue}{e^{\ell + \left(\frac{1}{2} \cdot \left(m + n\right) - M\right) \cdot \left(\frac{1}{2} \cdot \left(m + n\right) - M\right)}}}\right)\right) \]
          2. +-commutativeN/A

            \[\leadsto \mathsf{*.f64}\left(\mathsf{cos.f64}\left(M\right), \left(\frac{e^{\left|n - m\right|}}{e^{\left(\frac{1}{2} \cdot \left(m + n\right) - M\right) \cdot \left(\frac{1}{2} \cdot \left(m + n\right) - M\right) + \ell}}\right)\right) \]
          3. pow2N/A

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

            \[\leadsto \mathsf{*.f64}\left(\mathsf{cos.f64}\left(M\right), \left(\frac{e^{\left|n - m\right|}}{e^{{\left(\left(m + n\right) \cdot \frac{1}{2} - M\right)}^{2} + \ell}}\right)\right) \]
          5. metadata-evalN/A

            \[\leadsto \mathsf{*.f64}\left(\mathsf{cos.f64}\left(M\right), \left(\frac{e^{\left|n - m\right|}}{e^{{\left(\left(m + n\right) \cdot \frac{1}{2} - M\right)}^{2} + \ell}}\right)\right) \]
          6. div-invN/A

            \[\leadsto \mathsf{*.f64}\left(\mathsf{cos.f64}\left(M\right), \left(\frac{e^{\left|n - m\right|}}{e^{{\left(\frac{m + n}{2} - M\right)}^{2} + \ell}}\right)\right) \]
          7. pow2N/A

            \[\leadsto \mathsf{*.f64}\left(\mathsf{cos.f64}\left(M\right), \left(\frac{e^{\left|n - m\right|}}{e^{\left(\frac{m + n}{2} - M\right) \cdot \left(\frac{m + n}{2} - M\right) + \ell}}\right)\right) \]
          8. clear-numN/A

            \[\leadsto \mathsf{*.f64}\left(\mathsf{cos.f64}\left(M\right), \left(\frac{1}{\color{blue}{\frac{e^{\left(\frac{m + n}{2} - M\right) \cdot \left(\frac{m + n}{2} - M\right) + \ell}}{e^{\left|n - m\right|}}}}\right)\right) \]
          9. fabs-subN/A

            \[\leadsto \mathsf{*.f64}\left(\mathsf{cos.f64}\left(M\right), \left(\frac{1}{\frac{e^{\left(\frac{m + n}{2} - M\right) \cdot \left(\frac{m + n}{2} - M\right) + \ell}}{e^{\left|m - n\right|}}}\right)\right) \]
          10. exp-diffN/A

            \[\leadsto \mathsf{*.f64}\left(\mathsf{cos.f64}\left(M\right), \left(\frac{1}{e^{\left(\left(\frac{m + n}{2} - M\right) \cdot \left(\frac{m + n}{2} - M\right) + \ell\right) - \left|m - n\right|}}\right)\right) \]
        7. Applied egg-rr91.6%

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

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

            \[\leadsto \mathsf{*.f64}\left(\mathsf{cos.f64}\left(M\right), \mathsf{/.f64}\left(-1, \mathsf{\_.f64}\left(0, \mathsf{exp.f64}\left(\mathsf{+.f64}\left(\ell, \left(M \cdot M\right)\right)\right)\right)\right)\right) \]
          2. *-lowering-*.f6473.6%

            \[\leadsto \mathsf{*.f64}\left(\mathsf{cos.f64}\left(M\right), \mathsf{/.f64}\left(-1, \mathsf{\_.f64}\left(0, \mathsf{exp.f64}\left(\mathsf{+.f64}\left(\ell, \mathsf{*.f64}\left(M, M\right)\right)\right)\right)\right)\right) \]
        10. Simplified73.6%

          \[\leadsto \cos M \cdot \frac{-1}{0 - e^{\ell + \color{blue}{M \cdot M}}} \]
        11. Taylor expanded in M around 0

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

            \[\leadsto \color{blue}{1} \cdot \frac{-1}{0 - e^{\ell + M \cdot M}} \]
        13. Recombined 2 regimes into one program.
        14. Final simplification86.4%

          \[\leadsto \begin{array}{l} \mathbf{if}\;n \leq -2050000:\\ \;\;\;\;e^{-0.25 \cdot \left(n \cdot n\right)}\\ \mathbf{elif}\;n \leq 3250:\\ \;\;\;\;\frac{0 - -1}{e^{\ell + M \cdot M}}\\ \mathbf{else}:\\ \;\;\;\;e^{-0.25 \cdot \left(n \cdot n\right)}\\ \end{array} \]
        15. Add Preprocessing

        Alternative 6: 76.7% accurate, 3.7× speedup?

        \[\begin{array}{l} \\ \begin{array}{l} t_0 := e^{-0.25 \cdot \left(n \cdot n\right)}\\ \mathbf{if}\;n \leq -2050000:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;n \leq 54:\\ \;\;\;\;e^{0 - M \cdot M}\\ \mathbf{else}:\\ \;\;\;\;t\_0\\ \end{array} \end{array} \]
        (FPCore (K m n M l)
         :precision binary64
         (let* ((t_0 (exp (* -0.25 (* n n)))))
           (if (<= n -2050000.0) t_0 (if (<= n 54.0) (exp (- 0.0 (* M M))) t_0))))
        double code(double K, double m, double n, double M, double l) {
        	double t_0 = exp((-0.25 * (n * n)));
        	double tmp;
        	if (n <= -2050000.0) {
        		tmp = t_0;
        	} else if (n <= 54.0) {
        		tmp = exp((0.0 - (M * M)));
        	} 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(((-0.25d0) * (n * n)))
            if (n <= (-2050000.0d0)) then
                tmp = t_0
            else if (n <= 54.0d0) then
                tmp = exp((0.0d0 - (m_1 * m_1)))
            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((-0.25 * (n * n)));
        	double tmp;
        	if (n <= -2050000.0) {
        		tmp = t_0;
        	} else if (n <= 54.0) {
        		tmp = Math.exp((0.0 - (M * M)));
        	} else {
        		tmp = t_0;
        	}
        	return tmp;
        }
        
        def code(K, m, n, M, l):
        	t_0 = math.exp((-0.25 * (n * n)))
        	tmp = 0
        	if n <= -2050000.0:
        		tmp = t_0
        	elif n <= 54.0:
        		tmp = math.exp((0.0 - (M * M)))
        	else:
        		tmp = t_0
        	return tmp
        
        function code(K, m, n, M, l)
        	t_0 = exp(Float64(-0.25 * Float64(n * n)))
        	tmp = 0.0
        	if (n <= -2050000.0)
        		tmp = t_0;
        	elseif (n <= 54.0)
        		tmp = exp(Float64(0.0 - Float64(M * M)));
        	else
        		tmp = t_0;
        	end
        	return tmp
        end
        
        function tmp_2 = code(K, m, n, M, l)
        	t_0 = exp((-0.25 * (n * n)));
        	tmp = 0.0;
        	if (n <= -2050000.0)
        		tmp = t_0;
        	elseif (n <= 54.0)
        		tmp = exp((0.0 - (M * M)));
        	else
        		tmp = t_0;
        	end
        	tmp_2 = tmp;
        end
        
        code[K_, m_, n_, M_, l_] := Block[{t$95$0 = N[Exp[N[(-0.25 * N[(n * n), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[n, -2050000.0], t$95$0, If[LessEqual[n, 54.0], N[Exp[N[(0.0 - N[(M * M), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], t$95$0]]]
        
        \begin{array}{l}
        
        \\
        \begin{array}{l}
        t_0 := e^{-0.25 \cdot \left(n \cdot n\right)}\\
        \mathbf{if}\;n \leq -2050000:\\
        \;\;\;\;t\_0\\
        
        \mathbf{elif}\;n \leq 54:\\
        \;\;\;\;e^{0 - M \cdot M}\\
        
        \mathbf{else}:\\
        \;\;\;\;t\_0\\
        
        
        \end{array}
        \end{array}
        
        Derivation
        1. Split input into 2 regimes
        2. if n < -2.05e6 or 54 < n

          1. Initial program 72.1%

            \[\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 K around 0

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

              \[\leadsto \mathsf{*.f64}\left(\mathsf{cos.f64}\left(M\right), \mathsf{exp.f64}\left(\mathsf{\_.f64}\left(\mathsf{fabs.f64}\left(\mathsf{\_.f64}\left(n, m\right)\right), \mathsf{+.f64}\left(\ell, \mathsf{*.f64}\left(\mathsf{\_.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{+.f64}\left(m, n\right)\right), M\right), \mathsf{\_.f64}\left(\left(\frac{1}{2} \cdot \left(m + n\right)\right), M\right)\right)\right)\right)\right)\right) \]
          5. Simplified97.8%

            \[\leadsto \color{blue}{\cos M \cdot e^{\left|n - m\right| - \left(\ell + \left(0.5 \cdot \left(m + n\right) - M\right) \cdot \left(0.5 \cdot \left(m + n\right) - M\right)\right)}} \]
          6. 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) \]
          7. 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-*.f6494.9%

              \[\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) \]
          8. Simplified94.9%

            \[\leadsto \cos M \cdot e^{\color{blue}{-0.25 \cdot \left(n \cdot n\right)}} \]
          9. Taylor expanded in M around 0

            \[\leadsto \color{blue}{e^{\frac{-1}{4} \cdot {n}^{2}}} \]
          10. Step-by-step derivation
            1. exp-lowering-exp.f64N/A

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

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

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

              \[\leadsto \mathsf{exp.f64}\left(\mathsf{*.f64}\left(\frac{-1}{4}, \mathsf{*.f64}\left(n, n\right)\right)\right) \]
          11. Simplified94.9%

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

          if -2.05e6 < n < 54

          1. Initial program 80.9%

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

            \[\leadsto \mathsf{*.f64}\left(\mathsf{cos.f64}\left(\mathsf{\_.f64}\left(\mathsf{/.f64}\left(\mathsf{*.f64}\left(K, \mathsf{+.f64}\left(m, n\right)\right), 2\right), M\right)\right), \mathsf{exp.f64}\left(\color{blue}{\left(-1 \cdot {M}^{2}\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({M}^{2}\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 - {M}^{2}\right)\right)\right) \]
            3. --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(0, \left({M}^{2}\right)\right)\right)\right) \]
            4. 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(0, \left(M \cdot M\right)\right)\right)\right) \]
            5. *-lowering-*.f6453.2%

              \[\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, \mathsf{*.f64}\left(M, M\right)\right)\right)\right) \]
          5. Simplified53.2%

            \[\leadsto \cos \left(\frac{K \cdot \left(m + n\right)}{2} - M\right) \cdot e^{\color{blue}{0 - M \cdot M}} \]
          6. 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(0, \mathsf{*.f64}\left(M, M\right)\right)\right)\right) \]
          7. Step-by-step derivation
            1. cos-negN/A

              \[\leadsto \mathsf{*.f64}\left(\cos M, \mathsf{exp.f64}\left(\color{blue}{\mathsf{\_.f64}\left(0, \mathsf{*.f64}\left(M, M\right)\right)}\right)\right) \]
            2. cos-lowering-cos.f6459.9%

              \[\leadsto \mathsf{*.f64}\left(\mathsf{cos.f64}\left(M\right), \mathsf{exp.f64}\left(\color{blue}{\mathsf{\_.f64}\left(0, \mathsf{*.f64}\left(M, M\right)\right)}\right)\right) \]
          8. Simplified59.9%

            \[\leadsto \color{blue}{\cos M} \cdot e^{0 - M \cdot M} \]
          9. Taylor expanded in M around 0

            \[\leadsto \mathsf{*.f64}\left(\color{blue}{1}, \mathsf{exp.f64}\left(\mathsf{\_.f64}\left(0, \mathsf{*.f64}\left(M, M\right)\right)\right)\right) \]
          10. Step-by-step derivation
            1. Simplified59.8%

              \[\leadsto \color{blue}{1} \cdot e^{0 - M \cdot M} \]
          11. Recombined 2 regimes into one program.
          12. Final simplification78.4%

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

          Alternative 7: 68.7% accurate, 3.7× speedup?

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

            1. Initial program 72.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                \[\leadsto \mathsf{*.f64}\left(\mathsf{cos.f64}\left(M\right), \mathsf{exp.f64}\left(\mathsf{\_.f64}\left(\mathsf{fabs.f64}\left(\mathsf{\_.f64}\left(n, m\right)\right), \mathsf{+.f64}\left(\ell, \mathsf{*.f64}\left(\mathsf{\_.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{+.f64}\left(m, n\right)\right), M\right), \mathsf{\_.f64}\left(\left(\frac{1}{2} \cdot \left(m + n\right)\right), M\right)\right)\right)\right)\right)\right) \]
            5. Simplified97.9%

              \[\leadsto \color{blue}{\cos M \cdot e^{\left|n - m\right| - \left(\ell + \left(0.5 \cdot \left(m + n\right) - M\right) \cdot \left(0.5 \cdot \left(m + n\right) - M\right)\right)}} \]
            6. 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) \]
            7. 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-*.f6493.1%

                \[\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) \]
            8. Simplified93.1%

              \[\leadsto \cos M \cdot e^{\color{blue}{-0.25 \cdot \left(n \cdot n\right)}} \]
            9. Taylor expanded in M around 0

              \[\leadsto \color{blue}{e^{\frac{-1}{4} \cdot {n}^{2}}} \]
            10. Step-by-step derivation
              1. exp-lowering-exp.f64N/A

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

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

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

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

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

            if -2.5000000000000002e-19 < n < 21

            1. Initial program 81.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. Add Preprocessing
            3. Taylor expanded in K around 0

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

              \[\leadsto \color{blue}{\cos M \cdot e^{\left|n - m\right| - \left(\ell + \left(0.5 \cdot \left(m + n\right) - M\right) \cdot \left(0.5 \cdot \left(m + n\right) - M\right)\right)}} \]
            6. Step-by-step derivation
              1. exp-diffN/A

                \[\leadsto \mathsf{*.f64}\left(\mathsf{cos.f64}\left(M\right), \left(\frac{e^{\left|n - m\right|}}{\color{blue}{e^{\ell + \left(\frac{1}{2} \cdot \left(m + n\right) - M\right) \cdot \left(\frac{1}{2} \cdot \left(m + n\right) - M\right)}}}\right)\right) \]
              2. +-commutativeN/A

                \[\leadsto \mathsf{*.f64}\left(\mathsf{cos.f64}\left(M\right), \left(\frac{e^{\left|n - m\right|}}{e^{\left(\frac{1}{2} \cdot \left(m + n\right) - M\right) \cdot \left(\frac{1}{2} \cdot \left(m + n\right) - M\right) + \ell}}\right)\right) \]
              3. pow2N/A

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

                \[\leadsto \mathsf{*.f64}\left(\mathsf{cos.f64}\left(M\right), \left(\frac{e^{\left|n - m\right|}}{e^{{\left(\left(m + n\right) \cdot \frac{1}{2} - M\right)}^{2} + \ell}}\right)\right) \]
              5. metadata-evalN/A

                \[\leadsto \mathsf{*.f64}\left(\mathsf{cos.f64}\left(M\right), \left(\frac{e^{\left|n - m\right|}}{e^{{\left(\left(m + n\right) \cdot \frac{1}{2} - M\right)}^{2} + \ell}}\right)\right) \]
              6. div-invN/A

                \[\leadsto \mathsf{*.f64}\left(\mathsf{cos.f64}\left(M\right), \left(\frac{e^{\left|n - m\right|}}{e^{{\left(\frac{m + n}{2} - M\right)}^{2} + \ell}}\right)\right) \]
              7. pow2N/A

                \[\leadsto \mathsf{*.f64}\left(\mathsf{cos.f64}\left(M\right), \left(\frac{e^{\left|n - m\right|}}{e^{\left(\frac{m + n}{2} - M\right) \cdot \left(\frac{m + n}{2} - M\right) + \ell}}\right)\right) \]
              8. clear-numN/A

                \[\leadsto \mathsf{*.f64}\left(\mathsf{cos.f64}\left(M\right), \left(\frac{1}{\color{blue}{\frac{e^{\left(\frac{m + n}{2} - M\right) \cdot \left(\frac{m + n}{2} - M\right) + \ell}}{e^{\left|n - m\right|}}}}\right)\right) \]
              9. fabs-subN/A

                \[\leadsto \mathsf{*.f64}\left(\mathsf{cos.f64}\left(M\right), \left(\frac{1}{\frac{e^{\left(\frac{m + n}{2} - M\right) \cdot \left(\frac{m + n}{2} - M\right) + \ell}}{e^{\left|m - n\right|}}}\right)\right) \]
              10. exp-diffN/A

                \[\leadsto \mathsf{*.f64}\left(\mathsf{cos.f64}\left(M\right), \left(\frac{1}{e^{\left(\left(\frac{m + n}{2} - M\right) \cdot \left(\frac{m + n}{2} - M\right) + \ell\right) - \left|m - n\right|}}\right)\right) \]
            7. Applied egg-rr91.2%

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

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

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

                \[\leadsto \mathsf{*.f64}\left(\mathsf{cos.f64}\left(M\right), \mathsf{/.f64}\left(-1, \mathsf{\_.f64}\left(0, \mathsf{exp.f64}\left(\mathsf{+.f64}\left(\ell, \mathsf{*.f64}\left(M, M\right)\right)\right)\right)\right)\right) \]
            10. Simplified73.1%

              \[\leadsto \cos M \cdot \frac{-1}{0 - e^{\ell + \color{blue}{M \cdot M}}} \]
            11. Taylor expanded in M around 0

              \[\leadsto \color{blue}{\frac{1}{e^{\ell}}} \]
            12. Step-by-step derivation
              1. /-lowering-/.f64N/A

                \[\leadsto \mathsf{/.f64}\left(1, \color{blue}{\left(e^{\ell}\right)}\right) \]
              2. exp-lowering-exp.f6443.5%

                \[\leadsto \mathsf{/.f64}\left(1, \mathsf{exp.f64}\left(\ell\right)\right) \]
            13. Simplified43.5%

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

          Alternative 8: 35.3% accurate, 4.1× speedup?

          \[\begin{array}{l} \\ \frac{1}{e^{\ell}} \end{array} \]
          (FPCore (K m n M l) :precision binary64 (/ 1.0 (exp l)))
          double code(double K, double m, double n, double M, double l) {
          	return 1.0 / exp(l);
          }
          
          real(8) function code(k, m, n, m_1, l)
              real(8), intent (in) :: k
              real(8), intent (in) :: m
              real(8), intent (in) :: n
              real(8), intent (in) :: m_1
              real(8), intent (in) :: l
              code = 1.0d0 / exp(l)
          end function
          
          public static double code(double K, double m, double n, double M, double l) {
          	return 1.0 / Math.exp(l);
          }
          
          def code(K, m, n, M, l):
          	return 1.0 / math.exp(l)
          
          function code(K, m, n, M, l)
          	return Float64(1.0 / exp(l))
          end
          
          function tmp = code(K, m, n, M, l)
          	tmp = 1.0 / exp(l);
          end
          
          code[K_, m_, n_, M_, l_] := N[(1.0 / N[Exp[l], $MachinePrecision]), $MachinePrecision]
          
          \begin{array}{l}
          
          \\
          \frac{1}{e^{\ell}}
          \end{array}
          
          Derivation
          1. Initial program 76.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. Add Preprocessing
          3. Taylor expanded in K around 0

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

              \[\leadsto \mathsf{*.f64}\left(\mathsf{cos.f64}\left(M\right), \mathsf{exp.f64}\left(\mathsf{\_.f64}\left(\mathsf{fabs.f64}\left(\mathsf{\_.f64}\left(n, m\right)\right), \mathsf{+.f64}\left(\ell, \mathsf{*.f64}\left(\mathsf{\_.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{+.f64}\left(m, n\right)\right), M\right), \mathsf{\_.f64}\left(\left(\frac{1}{2} \cdot \left(m + n\right)\right), M\right)\right)\right)\right)\right)\right) \]
          5. Simplified96.4%

            \[\leadsto \color{blue}{\cos M \cdot e^{\left|n - m\right| - \left(\ell + \left(0.5 \cdot \left(m + n\right) - M\right) \cdot \left(0.5 \cdot \left(m + n\right) - M\right)\right)}} \]
          6. Step-by-step derivation
            1. exp-diffN/A

              \[\leadsto \mathsf{*.f64}\left(\mathsf{cos.f64}\left(M\right), \left(\frac{e^{\left|n - m\right|}}{\color{blue}{e^{\ell + \left(\frac{1}{2} \cdot \left(m + n\right) - M\right) \cdot \left(\frac{1}{2} \cdot \left(m + n\right) - M\right)}}}\right)\right) \]
            2. +-commutativeN/A

              \[\leadsto \mathsf{*.f64}\left(\mathsf{cos.f64}\left(M\right), \left(\frac{e^{\left|n - m\right|}}{e^{\left(\frac{1}{2} \cdot \left(m + n\right) - M\right) \cdot \left(\frac{1}{2} \cdot \left(m + n\right) - M\right) + \ell}}\right)\right) \]
            3. pow2N/A

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

              \[\leadsto \mathsf{*.f64}\left(\mathsf{cos.f64}\left(M\right), \left(\frac{e^{\left|n - m\right|}}{e^{{\left(\left(m + n\right) \cdot \frac{1}{2} - M\right)}^{2} + \ell}}\right)\right) \]
            5. metadata-evalN/A

              \[\leadsto \mathsf{*.f64}\left(\mathsf{cos.f64}\left(M\right), \left(\frac{e^{\left|n - m\right|}}{e^{{\left(\left(m + n\right) \cdot \frac{1}{2} - M\right)}^{2} + \ell}}\right)\right) \]
            6. div-invN/A

              \[\leadsto \mathsf{*.f64}\left(\mathsf{cos.f64}\left(M\right), \left(\frac{e^{\left|n - m\right|}}{e^{{\left(\frac{m + n}{2} - M\right)}^{2} + \ell}}\right)\right) \]
            7. pow2N/A

              \[\leadsto \mathsf{*.f64}\left(\mathsf{cos.f64}\left(M\right), \left(\frac{e^{\left|n - m\right|}}{e^{\left(\frac{m + n}{2} - M\right) \cdot \left(\frac{m + n}{2} - M\right) + \ell}}\right)\right) \]
            8. clear-numN/A

              \[\leadsto \mathsf{*.f64}\left(\mathsf{cos.f64}\left(M\right), \left(\frac{1}{\color{blue}{\frac{e^{\left(\frac{m + n}{2} - M\right) \cdot \left(\frac{m + n}{2} - M\right) + \ell}}{e^{\left|n - m\right|}}}}\right)\right) \]
            9. fabs-subN/A

              \[\leadsto \mathsf{*.f64}\left(\mathsf{cos.f64}\left(M\right), \left(\frac{1}{\frac{e^{\left(\frac{m + n}{2} - M\right) \cdot \left(\frac{m + n}{2} - M\right) + \ell}}{e^{\left|m - n\right|}}}\right)\right) \]
            10. exp-diffN/A

              \[\leadsto \mathsf{*.f64}\left(\mathsf{cos.f64}\left(M\right), \left(\frac{1}{e^{\left(\left(\frac{m + n}{2} - M\right) \cdot \left(\frac{m + n}{2} - M\right) + \ell\right) - \left|m - n\right|}}\right)\right) \]
          7. Applied egg-rr94.5%

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

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

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

              \[\leadsto \mathsf{*.f64}\left(\mathsf{cos.f64}\left(M\right), \mathsf{/.f64}\left(-1, \mathsf{\_.f64}\left(0, \mathsf{exp.f64}\left(\mathsf{+.f64}\left(\ell, \mathsf{*.f64}\left(M, M\right)\right)\right)\right)\right)\right) \]
          10. Simplified64.6%

            \[\leadsto \cos M \cdot \frac{-1}{0 - e^{\ell + \color{blue}{M \cdot M}}} \]
          11. Taylor expanded in M around 0

            \[\leadsto \color{blue}{\frac{1}{e^{\ell}}} \]
          12. Step-by-step derivation
            1. /-lowering-/.f64N/A

              \[\leadsto \mathsf{/.f64}\left(1, \color{blue}{\left(e^{\ell}\right)}\right) \]
            2. exp-lowering-exp.f6432.7%

              \[\leadsto \mathsf{/.f64}\left(1, \mathsf{exp.f64}\left(\ell\right)\right) \]
          13. Simplified32.7%

            \[\leadsto \color{blue}{\frac{1}{e^{\ell}}} \]
          14. Add Preprocessing

          Alternative 9: 7.1% accurate, 4.2× speedup?

          \[\begin{array}{l} \\ \cos M \end{array} \]
          (FPCore (K m n M l) :precision binary64 (cos M))
          double code(double K, double m, double n, double M, double l) {
          	return cos(M);
          }
          
          real(8) function code(k, m, n, m_1, l)
              real(8), intent (in) :: k
              real(8), intent (in) :: m
              real(8), intent (in) :: n
              real(8), intent (in) :: m_1
              real(8), intent (in) :: l
              code = cos(m_1)
          end function
          
          public static double code(double K, double m, double n, double M, double l) {
          	return Math.cos(M);
          }
          
          def code(K, m, n, M, l):
          	return math.cos(M)
          
          function code(K, m, n, M, l)
          	return cos(M)
          end
          
          function tmp = code(K, m, n, M, l)
          	tmp = cos(M);
          end
          
          code[K_, m_, n_, M_, l_] := N[Cos[M], $MachinePrecision]
          
          \begin{array}{l}
          
          \\
          \cos M
          \end{array}
          
          Derivation
          1. Initial program 76.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. Add Preprocessing
          3. Taylor expanded in K around 0

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

              \[\leadsto \mathsf{*.f64}\left(\mathsf{cos.f64}\left(M\right), \mathsf{exp.f64}\left(\mathsf{\_.f64}\left(\mathsf{fabs.f64}\left(\mathsf{\_.f64}\left(n, m\right)\right), \mathsf{+.f64}\left(\ell, \mathsf{*.f64}\left(\mathsf{\_.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{+.f64}\left(m, n\right)\right), M\right), \mathsf{\_.f64}\left(\left(\frac{1}{2} \cdot \left(m + n\right)\right), M\right)\right)\right)\right)\right)\right) \]
          5. Simplified96.4%

            \[\leadsto \color{blue}{\cos M \cdot e^{\left|n - m\right| - \left(\ell + \left(0.5 \cdot \left(m + n\right) - M\right) \cdot \left(0.5 \cdot \left(m + n\right) - M\right)\right)}} \]
          6. 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) \]
          7. 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-*.f6456.9%

              \[\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) \]
          8. Simplified56.9%

            \[\leadsto \cos M \cdot e^{\color{blue}{-0.25 \cdot \left(n \cdot n\right)}} \]
          9. Taylor expanded in n around 0

            \[\leadsto \color{blue}{\cos M} \]
          10. Step-by-step derivation
            1. cos-lowering-cos.f647.3%

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

            \[\leadsto \color{blue}{\cos M} \]
          12. 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 76.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. Add Preprocessing
          3. Taylor expanded in M around inf

            \[\leadsto \mathsf{*.f64}\left(\mathsf{cos.f64}\left(\mathsf{\_.f64}\left(\mathsf{/.f64}\left(\mathsf{*.f64}\left(K, \mathsf{+.f64}\left(m, n\right)\right), 2\right), M\right)\right), \mathsf{exp.f64}\left(\color{blue}{\left(-1 \cdot {M}^{2}\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({M}^{2}\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 - {M}^{2}\right)\right)\right) \]
            3. --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(0, \left({M}^{2}\right)\right)\right)\right) \]
            4. 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(0, \left(M \cdot M\right)\right)\right)\right) \]
            5. *-lowering-*.f6443.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, \mathsf{*.f64}\left(M, M\right)\right)\right)\right) \]
          5. Simplified43.5%

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

            \[\leadsto \color{blue}{\cos \left(\frac{1}{2} \cdot \left(K \cdot \left(m + n\right)\right)\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 \left(m + n\right)\right)\right)\right) \]
            2. *-lowering-*.f64N/A

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

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

              \[\leadsto \mathsf{cos.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(\left(m + n\right), K\right)\right)\right) \]
            5. +-commutativeN/A

              \[\leadsto \mathsf{cos.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(\left(n + m\right), K\right)\right)\right) \]
            6. +-lowering-+.f646.8%

              \[\leadsto \mathsf{cos.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(\mathsf{+.f64}\left(n, m\right), K\right)\right)\right) \]
          8. Simplified6.8%

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

            \[\leadsto \color{blue}{1} \]
          10. Step-by-step derivation
            1. Simplified7.3%

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

            Reproduce

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