Maksimov and Kolovsky, Equation (32)

Percentage Accurate: 76.2% → 96.8%
Time: 12.2s
Alternatives: 11
Speedup: 1.9×

Specification

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

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

Sampling outcomes in binary64 precision:

Local Percentage Accuracy vs ?

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

Accuracy vs Speed?

Herbie found 11 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.2% accurate, 1.0× speedup?

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

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

Alternative 1: 96.8% accurate, 1.3× speedup?

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

\\
e^{\left(\left(M + -0.5 \cdot \left(n + m\right)\right) \cdot \left(0.5 \cdot \left(n + m\right) - M\right) - \ell\right) + \left|n - m\right|} \cdot \cos M
\end{array}
Derivation
  1. Initial program 78.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \mathsf{*.f64}\left(\mathsf{cos.f64}\left(\mathsf{+.f64}\left(M, \mathsf{/.f64}\left(\mathsf{*.f64}\left(K, \mathsf{+.f64}\left(m, n\right)\right), -2\right)\right)\right), \mathsf{exp.f64}\left(\left(\left(\mathsf{neg}\left({\left(\frac{m + n}{2} - M\right)}^{2}\right)\right) - \left(\ell - \left|m - n\right|\right)\right)\right)\right) \]
  3. Simplified78.2%

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

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

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

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

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

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

Alternative 2: 95.8% accurate, 1.9× speedup?

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

\\
\begin{array}{l}
t_0 := \cos M \cdot e^{0 - M \cdot M}\\
\mathbf{if}\;M \leq -125000:\\
\;\;\;\;t\_0\\

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if M < -125000 or 13500 < M

    1. Initial program 77.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \mathsf{*.f64}\left(\mathsf{cos.f64}\left(\mathsf{+.f64}\left(M, \mathsf{/.f64}\left(\mathsf{*.f64}\left(K, \mathsf{+.f64}\left(m, n\right)\right), -2\right)\right)\right), \mathsf{exp.f64}\left(\left(\left(\mathsf{neg}\left({\left(\frac{m + n}{2} - M\right)}^{2}\right)\right) - \left(\ell - \left|m - n\right|\right)\right)\right)\right) \]
    3. Simplified77.0%

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

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

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

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

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

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

        \[\leadsto \mathsf{*.f64}\left(\mathsf{exp.f64}\left(\left(\mathsf{neg}\left({M}^{2}\right)\right)\right), \mathsf{cos.f64}\left(M\right)\right) \]
      2. neg-sub0N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{exp.f64}\left(\left(0 - {M}^{2}\right)\right), \mathsf{cos.f64}\left(M\right)\right) \]
      3. --lowering--.f64N/A

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

        \[\leadsto \mathsf{*.f64}\left(\mathsf{exp.f64}\left(\mathsf{\_.f64}\left(0, \left(M \cdot M\right)\right)\right), \mathsf{cos.f64}\left(M\right)\right) \]
      5. *-lowering-*.f6498.4%

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

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

    if -125000 < M < 13500

    1. Initial program 79.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \mathsf{*.f64}\left(\mathsf{cos.f64}\left(\mathsf{+.f64}\left(M, \mathsf{/.f64}\left(\mathsf{*.f64}\left(K, \mathsf{+.f64}\left(m, n\right)\right), -2\right)\right)\right), \mathsf{exp.f64}\left(\left(\left(\mathsf{neg}\left({\left(\frac{m + n}{2} - M\right)}^{2}\right)\right) - \left(\ell - \left|m - n\right|\right)\right)\right)\right) \]
    3. Simplified79.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 3: 67.6% accurate, 1.9× speedup?

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

\\
\begin{array}{l}
t_0 := -0.25 \cdot \left(n \cdot n\right)\\
\mathbf{if}\;n \leq -3.6 \cdot 10^{-158}:\\
\;\;\;\;e^{\left|n - m\right| + -0.25 \cdot \left(m \cdot m\right)}\\

\mathbf{elif}\;n \leq 1.45 \cdot 10^{-178}:\\
\;\;\;\;\cos M \cdot t\_0\\

\mathbf{elif}\;n \leq 54:\\
\;\;\;\;\cos M \cdot e^{0 - M \cdot M}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if n < -3.59999999999999991e-158

    1. Initial program 74.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -3.59999999999999991e-158 < n < 1.4499999999999999e-178

    1. Initial program 82.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \mathsf{*.f64}\left(\mathsf{cos.f64}\left(\mathsf{+.f64}\left(M, \mathsf{/.f64}\left(\mathsf{*.f64}\left(K, \mathsf{+.f64}\left(m, n\right)\right), -2\right)\right)\right), \mathsf{exp.f64}\left(\left(\left(\mathsf{neg}\left({\left(\frac{m + n}{2} - M\right)}^{2}\right)\right) - \left(\ell - \left|m - n\right|\right)\right)\right)\right) \]
    3. Simplified82.3%

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\cos M + \frac{-1}{4} \cdot \left({n}^{2} \cdot \cos M\right)} \]
    12. Step-by-step derivation
      1. associate-*r*N/A

        \[\leadsto \cos M + \left(\frac{-1}{4} \cdot {n}^{2}\right) \cdot \color{blue}{\cos M} \]
      2. distribute-rgt1-inN/A

        \[\leadsto \left(\frac{-1}{4} \cdot {n}^{2} + 1\right) \cdot \color{blue}{\cos M} \]
      3. +-commutativeN/A

        \[\leadsto \left(1 + \frac{-1}{4} \cdot {n}^{2}\right) \cdot \cos \color{blue}{M} \]
      4. *-lowering-*.f64N/A

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

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

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

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

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

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(\mathsf{*.f64}\left(\frac{-1}{4}, \mathsf{*.f64}\left(n, n\right)\right), 1\right), \cos M\right) \]
      10. cos-lowering-cos.f648.3%

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(\mathsf{*.f64}\left(\frac{-1}{4}, \mathsf{*.f64}\left(n, n\right)\right), 1\right), \mathsf{cos.f64}\left(M\right)\right) \]
    13. Simplified8.3%

      \[\leadsto \color{blue}{\left(-0.25 \cdot \left(n \cdot n\right) + 1\right) \cdot \cos M} \]
    14. Taylor expanded in n around inf

      \[\leadsto \color{blue}{\frac{-1}{4} \cdot \left({n}^{2} \cdot \cos M\right)} \]
    15. Step-by-step derivation
      1. associate-*r*N/A

        \[\leadsto \left(\frac{-1}{4} \cdot {n}^{2}\right) \cdot \color{blue}{\cos M} \]
      2. *-lowering-*.f64N/A

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

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

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

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

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{-1}{4}, \mathsf{*.f64}\left(n, n\right)\right), \mathsf{cos.f64}\left(M\right)\right) \]
    16. Simplified80.3%

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

    if 1.4499999999999999e-178 < n < 54

    1. Initial program 89.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \mathsf{*.f64}\left(\mathsf{cos.f64}\left(\mathsf{+.f64}\left(M, \mathsf{/.f64}\left(\mathsf{*.f64}\left(K, \mathsf{+.f64}\left(m, n\right)\right), -2\right)\right)\right), \mathsf{exp.f64}\left(\left(\left(\mathsf{neg}\left({\left(\frac{m + n}{2} - M\right)}^{2}\right)\right) - \left(\ell - \left|m - n\right|\right)\right)\right)\right) \]
    3. Simplified89.5%

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

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

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

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

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

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

        \[\leadsto \mathsf{*.f64}\left(\mathsf{exp.f64}\left(\left(\mathsf{neg}\left({M}^{2}\right)\right)\right), \mathsf{cos.f64}\left(M\right)\right) \]
      2. neg-sub0N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{exp.f64}\left(\left(0 - {M}^{2}\right)\right), \mathsf{cos.f64}\left(M\right)\right) \]
      3. --lowering--.f64N/A

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

        \[\leadsto \mathsf{*.f64}\left(\mathsf{exp.f64}\left(\mathsf{\_.f64}\left(0, \left(M \cdot M\right)\right)\right), \mathsf{cos.f64}\left(M\right)\right) \]
      5. *-lowering-*.f6457.4%

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

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

    if 54 < n

    1. Initial program 73.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \mathsf{*.f64}\left(\mathsf{cos.f64}\left(\mathsf{+.f64}\left(M, \mathsf{/.f64}\left(\mathsf{*.f64}\left(K, \mathsf{+.f64}\left(m, n\right)\right), -2\right)\right)\right), \mathsf{exp.f64}\left(\left(\left(\mathsf{neg}\left({\left(\frac{m + n}{2} - M\right)}^{2}\right)\right) - \left(\ell - \left|m - n\right|\right)\right)\right)\right) \]
    3. Simplified73.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;n \leq -3.6 \cdot 10^{-158}:\\ \;\;\;\;e^{\left|n - m\right| + -0.25 \cdot \left(m \cdot m\right)}\\ \mathbf{elif}\;n \leq 1.45 \cdot 10^{-178}:\\ \;\;\;\;\cos M \cdot \left(-0.25 \cdot \left(n \cdot n\right)\right)\\ \mathbf{elif}\;n \leq 54:\\ \;\;\;\;\cos M \cdot e^{0 - M \cdot M}\\ \mathbf{else}:\\ \;\;\;\;e^{-0.25 \cdot \left(n \cdot n\right)}\\ \end{array} \]
  5. Add Preprocessing

Alternative 4: 70.4% accurate, 1.9× speedup?

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

\\
\begin{array}{l}
t_0 := -0.25 \cdot \left(n \cdot n\right)\\
\mathbf{if}\;n \leq -1.02 \cdot 10^{-157}:\\
\;\;\;\;\cos M \cdot e^{-0.25 \cdot \left(m \cdot m\right)}\\

\mathbf{elif}\;n \leq 1.4 \cdot 10^{-178}:\\
\;\;\;\;\cos M \cdot t\_0\\

\mathbf{elif}\;n \leq 54:\\
\;\;\;\;\cos M \cdot e^{0 - M \cdot M}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 4 regimes
  2. if n < -1.0200000000000001e-157

    1. Initial program 74.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -1.0200000000000001e-157 < n < 1.4000000000000001e-178

    1. Initial program 82.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \mathsf{*.f64}\left(\mathsf{cos.f64}\left(\mathsf{+.f64}\left(M, \mathsf{/.f64}\left(\mathsf{*.f64}\left(K, \mathsf{+.f64}\left(m, n\right)\right), -2\right)\right)\right), \mathsf{exp.f64}\left(\left(\left(\mathsf{neg}\left({\left(\frac{m + n}{2} - M\right)}^{2}\right)\right) - \left(\ell - \left|m - n\right|\right)\right)\right)\right) \]
    3. Simplified82.3%

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\cos M + \frac{-1}{4} \cdot \left({n}^{2} \cdot \cos M\right)} \]
    12. Step-by-step derivation
      1. associate-*r*N/A

        \[\leadsto \cos M + \left(\frac{-1}{4} \cdot {n}^{2}\right) \cdot \color{blue}{\cos M} \]
      2. distribute-rgt1-inN/A

        \[\leadsto \left(\frac{-1}{4} \cdot {n}^{2} + 1\right) \cdot \color{blue}{\cos M} \]
      3. +-commutativeN/A

        \[\leadsto \left(1 + \frac{-1}{4} \cdot {n}^{2}\right) \cdot \cos \color{blue}{M} \]
      4. *-lowering-*.f64N/A

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

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

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

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

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

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(\mathsf{*.f64}\left(\frac{-1}{4}, \mathsf{*.f64}\left(n, n\right)\right), 1\right), \cos M\right) \]
      10. cos-lowering-cos.f648.3%

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(\mathsf{*.f64}\left(\frac{-1}{4}, \mathsf{*.f64}\left(n, n\right)\right), 1\right), \mathsf{cos.f64}\left(M\right)\right) \]
    13. Simplified8.3%

      \[\leadsto \color{blue}{\left(-0.25 \cdot \left(n \cdot n\right) + 1\right) \cdot \cos M} \]
    14. Taylor expanded in n around inf

      \[\leadsto \color{blue}{\frac{-1}{4} \cdot \left({n}^{2} \cdot \cos M\right)} \]
    15. Step-by-step derivation
      1. associate-*r*N/A

        \[\leadsto \left(\frac{-1}{4} \cdot {n}^{2}\right) \cdot \color{blue}{\cos M} \]
      2. *-lowering-*.f64N/A

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

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

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

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

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{-1}{4}, \mathsf{*.f64}\left(n, n\right)\right), \mathsf{cos.f64}\left(M\right)\right) \]
    16. Simplified80.3%

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

    if 1.4000000000000001e-178 < n < 54

    1. Initial program 89.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \mathsf{*.f64}\left(\mathsf{cos.f64}\left(\mathsf{+.f64}\left(M, \mathsf{/.f64}\left(\mathsf{*.f64}\left(K, \mathsf{+.f64}\left(m, n\right)\right), -2\right)\right)\right), \mathsf{exp.f64}\left(\left(\left(\mathsf{neg}\left({\left(\frac{m + n}{2} - M\right)}^{2}\right)\right) - \left(\ell - \left|m - n\right|\right)\right)\right)\right) \]
    3. Simplified89.5%

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

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

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

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

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

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

        \[\leadsto \mathsf{*.f64}\left(\mathsf{exp.f64}\left(\left(\mathsf{neg}\left({M}^{2}\right)\right)\right), \mathsf{cos.f64}\left(M\right)\right) \]
      2. neg-sub0N/A

        \[\leadsto \mathsf{*.f64}\left(\mathsf{exp.f64}\left(\left(0 - {M}^{2}\right)\right), \mathsf{cos.f64}\left(M\right)\right) \]
      3. --lowering--.f64N/A

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

        \[\leadsto \mathsf{*.f64}\left(\mathsf{exp.f64}\left(\mathsf{\_.f64}\left(0, \left(M \cdot M\right)\right)\right), \mathsf{cos.f64}\left(M\right)\right) \]
      5. *-lowering-*.f6457.4%

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

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

    if 54 < n

    1. Initial program 73.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \mathsf{*.f64}\left(\mathsf{cos.f64}\left(\mathsf{+.f64}\left(M, \mathsf{/.f64}\left(\mathsf{*.f64}\left(K, \mathsf{+.f64}\left(m, n\right)\right), -2\right)\right)\right), \mathsf{exp.f64}\left(\left(\left(\mathsf{neg}\left({\left(\frac{m + n}{2} - M\right)}^{2}\right)\right) - \left(\ell - \left|m - n\right|\right)\right)\right)\right) \]
    3. Simplified73.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;n \leq -1.02 \cdot 10^{-157}:\\ \;\;\;\;\cos M \cdot e^{-0.25 \cdot \left(m \cdot m\right)}\\ \mathbf{elif}\;n \leq 1.4 \cdot 10^{-178}:\\ \;\;\;\;\cos M \cdot \left(-0.25 \cdot \left(n \cdot n\right)\right)\\ \mathbf{elif}\;n \leq 54:\\ \;\;\;\;\cos M \cdot e^{0 - M \cdot M}\\ \mathbf{else}:\\ \;\;\;\;e^{-0.25 \cdot \left(n \cdot n\right)}\\ \end{array} \]
  5. Add Preprocessing

Alternative 5: 70.3% accurate, 1.9× speedup?

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

\\
\begin{array}{l}
t_0 := -0.25 \cdot \left(n \cdot n\right)\\
t_1 := \cos M \cdot e^{-0.25 \cdot \left(m \cdot m\right)}\\
\mathbf{if}\;n \leq -3.3 \cdot 10^{-158}:\\
\;\;\;\;t\_1\\

\mathbf{elif}\;n \leq 2.25 \cdot 10^{-147}:\\
\;\;\;\;\cos M \cdot t\_0\\

\mathbf{elif}\;n \leq 54:\\
\;\;\;\;t\_1\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if n < -3.3000000000000002e-158 or 2.24999999999999986e-147 < n < 54

    1. Initial program 78.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \mathsf{*.f64}\left(\mathsf{cos.f64}\left(\mathsf{+.f64}\left(M, \mathsf{/.f64}\left(\mathsf{*.f64}\left(K, \mathsf{+.f64}\left(m, n\right)\right), -2\right)\right)\right), \mathsf{exp.f64}\left(\left(\left(\mathsf{neg}\left({\left(\frac{m + n}{2} - M\right)}^{2}\right)\right) - \left(\ell - \left|m - n\right|\right)\right)\right)\right) \]
    3. Simplified78.8%

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

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

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

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

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

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

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

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

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

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

    if -3.3000000000000002e-158 < n < 2.24999999999999986e-147

    1. Initial program 82.4%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \mathsf{*.f64}\left(\mathsf{cos.f64}\left(\mathsf{+.f64}\left(M, \mathsf{/.f64}\left(\mathsf{*.f64}\left(K, \mathsf{+.f64}\left(m, n\right)\right), -2\right)\right)\right), \mathsf{exp.f64}\left(\left(\left(\mathsf{neg}\left({\left(\frac{m + n}{2} - M\right)}^{2}\right)\right) - \left(\ell - \left|m - n\right|\right)\right)\right)\right) \]
    3. Simplified82.4%

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\cos M + \frac{-1}{4} \cdot \left({n}^{2} \cdot \cos M\right)} \]
    12. Step-by-step derivation
      1. associate-*r*N/A

        \[\leadsto \cos M + \left(\frac{-1}{4} \cdot {n}^{2}\right) \cdot \color{blue}{\cos M} \]
      2. distribute-rgt1-inN/A

        \[\leadsto \left(\frac{-1}{4} \cdot {n}^{2} + 1\right) \cdot \color{blue}{\cos M} \]
      3. +-commutativeN/A

        \[\leadsto \left(1 + \frac{-1}{4} \cdot {n}^{2}\right) \cdot \cos \color{blue}{M} \]
      4. *-lowering-*.f64N/A

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

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

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

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

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

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(\mathsf{*.f64}\left(\frac{-1}{4}, \mathsf{*.f64}\left(n, n\right)\right), 1\right), \cos M\right) \]
      10. cos-lowering-cos.f648.1%

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(\mathsf{*.f64}\left(\frac{-1}{4}, \mathsf{*.f64}\left(n, n\right)\right), 1\right), \mathsf{cos.f64}\left(M\right)\right) \]
    13. Simplified8.1%

      \[\leadsto \color{blue}{\left(-0.25 \cdot \left(n \cdot n\right) + 1\right) \cdot \cos M} \]
    14. Taylor expanded in n around inf

      \[\leadsto \color{blue}{\frac{-1}{4} \cdot \left({n}^{2} \cdot \cos M\right)} \]
    15. Step-by-step derivation
      1. associate-*r*N/A

        \[\leadsto \left(\frac{-1}{4} \cdot {n}^{2}\right) \cdot \color{blue}{\cos M} \]
      2. *-lowering-*.f64N/A

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

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

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

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{-1}{4}, \mathsf{*.f64}\left(n, n\right)\right), \cos M\right) \]
      6. cos-lowering-cos.f6478.6%

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{-1}{4}, \mathsf{*.f64}\left(n, n\right)\right), \mathsf{cos.f64}\left(M\right)\right) \]
    16. Simplified78.6%

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

    if 54 < n

    1. Initial program 73.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \mathsf{*.f64}\left(\mathsf{cos.f64}\left(\mathsf{+.f64}\left(M, \mathsf{/.f64}\left(\mathsf{*.f64}\left(K, \mathsf{+.f64}\left(m, n\right)\right), -2\right)\right)\right), \mathsf{exp.f64}\left(\left(\left(\mathsf{neg}\left({\left(\frac{m + n}{2} - M\right)}^{2}\right)\right) - \left(\ell - \left|m - n\right|\right)\right)\right)\right) \]
    3. Simplified73.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 6: 70.2% accurate, 3.5× speedup?

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

\\
\begin{array}{l}
t_0 := -0.25 \cdot \left(n \cdot n\right)\\
t_1 := e^{-0.25 \cdot \left(m \cdot m\right)}\\
\mathbf{if}\;n \leq -5.6 \cdot 10^{-160}:\\
\;\;\;\;t\_1\\

\mathbf{elif}\;n \leq 2.25 \cdot 10^{-147}:\\
\;\;\;\;\cos M \cdot t\_0\\

\mathbf{elif}\;n \leq 54:\\
\;\;\;\;t\_1\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if n < -5.60000000000000032e-160 or 2.24999999999999986e-147 < n < 54

    1. Initial program 79.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \mathsf{*.f64}\left(\mathsf{cos.f64}\left(\mathsf{+.f64}\left(M, \mathsf{/.f64}\left(\mathsf{*.f64}\left(K, \mathsf{+.f64}\left(m, n\right)\right), -2\right)\right)\right), \mathsf{exp.f64}\left(\left(\left(\mathsf{neg}\left({\left(\frac{m + n}{2} - M\right)}^{2}\right)\right) - \left(\ell - \left|m - n\right|\right)\right)\right)\right) \]
    3. Simplified79.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -5.60000000000000032e-160 < n < 2.24999999999999986e-147

    1. Initial program 82.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. Step-by-step derivation
      1. *-lowering-*.f64N/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \mathsf{*.f64}\left(\mathsf{cos.f64}\left(\mathsf{+.f64}\left(M, \mathsf{/.f64}\left(\mathsf{*.f64}\left(K, \mathsf{+.f64}\left(m, n\right)\right), -2\right)\right)\right), \mathsf{exp.f64}\left(\left(\left(\mathsf{neg}\left({\left(\frac{m + n}{2} - M\right)}^{2}\right)\right) - \left(\ell - \left|m - n\right|\right)\right)\right)\right) \]
    3. Simplified82.1%

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\cos M + \frac{-1}{4} \cdot \left({n}^{2} \cdot \cos M\right)} \]
    12. Step-by-step derivation
      1. associate-*r*N/A

        \[\leadsto \cos M + \left(\frac{-1}{4} \cdot {n}^{2}\right) \cdot \color{blue}{\cos M} \]
      2. distribute-rgt1-inN/A

        \[\leadsto \left(\frac{-1}{4} \cdot {n}^{2} + 1\right) \cdot \color{blue}{\cos M} \]
      3. +-commutativeN/A

        \[\leadsto \left(1 + \frac{-1}{4} \cdot {n}^{2}\right) \cdot \cos \color{blue}{M} \]
      4. *-lowering-*.f64N/A

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

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

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

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

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

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(\mathsf{*.f64}\left(\frac{-1}{4}, \mathsf{*.f64}\left(n, n\right)\right), 1\right), \cos M\right) \]
      10. cos-lowering-cos.f648.2%

        \[\leadsto \mathsf{*.f64}\left(\mathsf{+.f64}\left(\mathsf{*.f64}\left(\frac{-1}{4}, \mathsf{*.f64}\left(n, n\right)\right), 1\right), \mathsf{cos.f64}\left(M\right)\right) \]
    13. Simplified8.2%

      \[\leadsto \color{blue}{\left(-0.25 \cdot \left(n \cdot n\right) + 1\right) \cdot \cos M} \]
    14. Taylor expanded in n around inf

      \[\leadsto \color{blue}{\frac{-1}{4} \cdot \left({n}^{2} \cdot \cos M\right)} \]
    15. Step-by-step derivation
      1. associate-*r*N/A

        \[\leadsto \left(\frac{-1}{4} \cdot {n}^{2}\right) \cdot \color{blue}{\cos M} \]
      2. *-lowering-*.f64N/A

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

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

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

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{-1}{4}, \mathsf{*.f64}\left(n, n\right)\right), \cos M\right) \]
      6. cos-lowering-cos.f6478.7%

        \[\leadsto \mathsf{*.f64}\left(\mathsf{*.f64}\left(\frac{-1}{4}, \mathsf{*.f64}\left(n, n\right)\right), \mathsf{cos.f64}\left(M\right)\right) \]
    16. Simplified78.7%

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

    if 54 < n

    1. Initial program 73.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \mathsf{*.f64}\left(\mathsf{cos.f64}\left(\mathsf{+.f64}\left(M, \mathsf{/.f64}\left(\mathsf{*.f64}\left(K, \mathsf{+.f64}\left(m, n\right)\right), -2\right)\right)\right), \mathsf{exp.f64}\left(\left(\left(\mathsf{neg}\left({\left(\frac{m + n}{2} - M\right)}^{2}\right)\right) - \left(\ell - \left|m - n\right|\right)\right)\right)\right) \]
    3. Simplified73.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 7: 66.6% accurate, 3.7× speedup?

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

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

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

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if m < -3.5499999999999998 or 3.29999999999999982e-78 < m

    1. Initial program 73.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \mathsf{*.f64}\left(\mathsf{cos.f64}\left(\mathsf{+.f64}\left(M, \mathsf{/.f64}\left(\mathsf{*.f64}\left(K, \mathsf{+.f64}\left(m, n\right)\right), -2\right)\right)\right), \mathsf{exp.f64}\left(\left(\left(\mathsf{neg}\left({\left(\frac{m + n}{2} - M\right)}^{2}\right)\right) - \left(\ell - \left|m - n\right|\right)\right)\right)\right) \]
    3. Simplified73.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -3.5499999999999998 < m < 3.29999999999999982e-78

    1. Initial program 83.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \mathsf{*.f64}\left(\mathsf{cos.f64}\left(\mathsf{+.f64}\left(M, \mathsf{/.f64}\left(\mathsf{*.f64}\left(K, \mathsf{+.f64}\left(m, n\right)\right), -2\right)\right)\right), \mathsf{exp.f64}\left(\left(\left(\mathsf{neg}\left({\left(\frac{m + n}{2} - M\right)}^{2}\right)\right) - \left(\ell - \left|m - n\right|\right)\right)\right)\right) \]
    3. Simplified83.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 8: 66.2% accurate, 3.9× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;m \leq -0.0106:\\ \;\;\;\;e^{-0.25 \cdot \left(m \cdot m\right)}\\ \mathbf{else}:\\ \;\;\;\;e^{-0.25 \cdot \left(n \cdot n\right)}\\ \end{array} \end{array} \]
(FPCore (K m n M l)
 :precision binary64
 (if (<= m -0.0106) (exp (* -0.25 (* m m))) (exp (* -0.25 (* n n)))))
double code(double K, double m, double n, double M, double l) {
	double tmp;
	if (m <= -0.0106) {
		tmp = exp((-0.25 * (m * m)));
	} else {
		tmp = exp((-0.25 * (n * n)));
	}
	return tmp;
}
real(8) function code(k, m, n, m_1, l)
    real(8), intent (in) :: k
    real(8), intent (in) :: m
    real(8), intent (in) :: n
    real(8), intent (in) :: m_1
    real(8), intent (in) :: l
    real(8) :: tmp
    if (m <= (-0.0106d0)) then
        tmp = exp(((-0.25d0) * (m * m)))
    else
        tmp = exp(((-0.25d0) * (n * n)))
    end if
    code = tmp
end function
public static double code(double K, double m, double n, double M, double l) {
	double tmp;
	if (m <= -0.0106) {
		tmp = Math.exp((-0.25 * (m * m)));
	} else {
		tmp = Math.exp((-0.25 * (n * n)));
	}
	return tmp;
}
def code(K, m, n, M, l):
	tmp = 0
	if m <= -0.0106:
		tmp = math.exp((-0.25 * (m * m)))
	else:
		tmp = math.exp((-0.25 * (n * n)))
	return tmp
function code(K, m, n, M, l)
	tmp = 0.0
	if (m <= -0.0106)
		tmp = exp(Float64(-0.25 * Float64(m * m)));
	else
		tmp = exp(Float64(-0.25 * Float64(n * n)));
	end
	return tmp
end
function tmp_2 = code(K, m, n, M, l)
	tmp = 0.0;
	if (m <= -0.0106)
		tmp = exp((-0.25 * (m * m)));
	else
		tmp = exp((-0.25 * (n * n)));
	end
	tmp_2 = tmp;
end
code[K_, m_, n_, M_, l_] := If[LessEqual[m, -0.0106], N[Exp[N[(-0.25 * N[(m * m), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[Exp[N[(-0.25 * N[(n * n), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}

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

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


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

    1. Initial program 77.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \mathsf{*.f64}\left(\mathsf{cos.f64}\left(\mathsf{+.f64}\left(M, \mathsf{/.f64}\left(\mathsf{*.f64}\left(K, \mathsf{+.f64}\left(m, n\right)\right), -2\right)\right)\right), \mathsf{exp.f64}\left(\left(\left(\mathsf{neg}\left({\left(\frac{m + n}{2} - M\right)}^{2}\right)\right) - \left(\ell - \left|m - n\right|\right)\right)\right)\right) \]
    3. Simplified77.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -0.0106 < m

    1. Initial program 78.5%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \mathsf{*.f64}\left(\mathsf{cos.f64}\left(\mathsf{+.f64}\left(M, \mathsf{/.f64}\left(\mathsf{*.f64}\left(K, \mathsf{+.f64}\left(m, n\right)\right), -2\right)\right)\right), \mathsf{exp.f64}\left(\left(\left(\mathsf{neg}\left({\left(\frac{m + n}{2} - M\right)}^{2}\right)\right) - \left(\ell - \left|m - n\right|\right)\right)\right)\right) \]
    3. Simplified78.5%

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \mathsf{exp.f64}\left(\mathsf{+.f64}\left(\left(\left|m + \left(\mathsf{neg}\left(n\right)\right)\right|\right), \left(\frac{-1}{4} \cdot {\left(m + n\right)}^{2} - \ell\right)\right)\right) \]
      6. mul-1-negN/A

        \[\leadsto \mathsf{exp.f64}\left(\mathsf{+.f64}\left(\left(\left|m + -1 \cdot n\right|\right), \left(\frac{-1}{4} \cdot {\left(m + n\right)}^{2} - \ell\right)\right)\right) \]
      7. fabs-lowering-fabs.f64N/A

        \[\leadsto \mathsf{exp.f64}\left(\mathsf{+.f64}\left(\mathsf{fabs.f64}\left(\left(m + -1 \cdot n\right)\right), \left(\frac{-1}{4} \cdot {\left(m + n\right)}^{2} - \ell\right)\right)\right) \]
      8. mul-1-negN/A

        \[\leadsto \mathsf{exp.f64}\left(\mathsf{+.f64}\left(\mathsf{fabs.f64}\left(\left(m + \left(\mathsf{neg}\left(n\right)\right)\right)\right), \left(\frac{-1}{4} \cdot {\left(m + n\right)}^{2} - \ell\right)\right)\right) \]
      9. sub-negN/A

        \[\leadsto \mathsf{exp.f64}\left(\mathsf{+.f64}\left(\mathsf{fabs.f64}\left(\left(m - n\right)\right), \left(\frac{-1}{4} \cdot {\left(m + n\right)}^{2} - \ell\right)\right)\right) \]
      10. --lowering--.f64N/A

        \[\leadsto \mathsf{exp.f64}\left(\mathsf{+.f64}\left(\mathsf{fabs.f64}\left(\mathsf{\_.f64}\left(m, n\right)\right), \left(\frac{-1}{4} \cdot {\left(m + n\right)}^{2} - \ell\right)\right)\right) \]
      11. --lowering--.f64N/A

        \[\leadsto \mathsf{exp.f64}\left(\mathsf{+.f64}\left(\mathsf{fabs.f64}\left(\mathsf{\_.f64}\left(m, n\right)\right), \mathsf{\_.f64}\left(\left(\frac{-1}{4} \cdot {\left(m + n\right)}^{2}\right), \ell\right)\right)\right) \]
      12. *-lowering-*.f64N/A

        \[\leadsto \mathsf{exp.f64}\left(\mathsf{+.f64}\left(\mathsf{fabs.f64}\left(\mathsf{\_.f64}\left(m, n\right)\right), \mathsf{\_.f64}\left(\mathsf{*.f64}\left(\frac{-1}{4}, \left({\left(m + n\right)}^{2}\right)\right), \ell\right)\right)\right) \]
      13. unpow2N/A

        \[\leadsto \mathsf{exp.f64}\left(\mathsf{+.f64}\left(\mathsf{fabs.f64}\left(\mathsf{\_.f64}\left(m, n\right)\right), \mathsf{\_.f64}\left(\mathsf{*.f64}\left(\frac{-1}{4}, \left(\left(m + n\right) \cdot \left(m + n\right)\right)\right), \ell\right)\right)\right) \]
      14. *-lowering-*.f64N/A

        \[\leadsto \mathsf{exp.f64}\left(\mathsf{+.f64}\left(\mathsf{fabs.f64}\left(\mathsf{\_.f64}\left(m, n\right)\right), \mathsf{\_.f64}\left(\mathsf{*.f64}\left(\frac{-1}{4}, \mathsf{*.f64}\left(\left(m + n\right), \left(m + n\right)\right)\right), \ell\right)\right)\right) \]
      15. +-commutativeN/A

        \[\leadsto \mathsf{exp.f64}\left(\mathsf{+.f64}\left(\mathsf{fabs.f64}\left(\mathsf{\_.f64}\left(m, n\right)\right), \mathsf{\_.f64}\left(\mathsf{*.f64}\left(\frac{-1}{4}, \mathsf{*.f64}\left(\left(n + m\right), \left(m + n\right)\right)\right), \ell\right)\right)\right) \]
      16. +-lowering-+.f64N/A

        \[\leadsto \mathsf{exp.f64}\left(\mathsf{+.f64}\left(\mathsf{fabs.f64}\left(\mathsf{\_.f64}\left(m, n\right)\right), \mathsf{\_.f64}\left(\mathsf{*.f64}\left(\frac{-1}{4}, \mathsf{*.f64}\left(\mathsf{+.f64}\left(n, m\right), \left(m + n\right)\right)\right), \ell\right)\right)\right) \]
      17. +-commutativeN/A

        \[\leadsto \mathsf{exp.f64}\left(\mathsf{+.f64}\left(\mathsf{fabs.f64}\left(\mathsf{\_.f64}\left(m, n\right)\right), \mathsf{\_.f64}\left(\mathsf{*.f64}\left(\frac{-1}{4}, \mathsf{*.f64}\left(\mathsf{+.f64}\left(n, m\right), \left(n + m\right)\right)\right), \ell\right)\right)\right) \]
      18. +-lowering-+.f6485.8%

        \[\leadsto \mathsf{exp.f64}\left(\mathsf{+.f64}\left(\mathsf{fabs.f64}\left(\mathsf{\_.f64}\left(m, n\right)\right), \mathsf{\_.f64}\left(\mathsf{*.f64}\left(\frac{-1}{4}, \mathsf{*.f64}\left(\mathsf{+.f64}\left(n, m\right), \mathsf{+.f64}\left(n, m\right)\right)\right), \ell\right)\right)\right) \]
    10. Simplified85.8%

      \[\leadsto \color{blue}{e^{\left|m - n\right| + \left(-0.25 \cdot \left(\left(n + m\right) \cdot \left(n + m\right)\right) - \ell\right)}} \]
    11. Taylor expanded in n around inf

      \[\leadsto \mathsf{exp.f64}\left(\color{blue}{\left(\frac{-1}{4} \cdot {n}^{2}\right)}\right) \]
    12. Step-by-step derivation
      1. *-lowering-*.f64N/A

        \[\leadsto \mathsf{exp.f64}\left(\mathsf{*.f64}\left(\frac{-1}{4}, \left({n}^{2}\right)\right)\right) \]
      2. unpow2N/A

        \[\leadsto \mathsf{exp.f64}\left(\mathsf{*.f64}\left(\frac{-1}{4}, \left(n \cdot n\right)\right)\right) \]
      3. *-lowering-*.f6458.1%

        \[\leadsto \mathsf{exp.f64}\left(\mathsf{*.f64}\left(\frac{-1}{4}, \mathsf{*.f64}\left(n, n\right)\right)\right) \]
    13. Simplified58.1%

      \[\leadsto e^{\color{blue}{-0.25 \cdot \left(n \cdot n\right)}} \]
  3. Recombined 2 regimes into one program.
  4. Add Preprocessing

Alternative 9: 34.9% accurate, 4.1× speedup?

\[\begin{array}{l} \\ e^{0 - \ell} \end{array} \]
(FPCore (K m n M l) :precision binary64 (exp (- 0.0 l)))
double code(double K, double m, double n, double M, double l) {
	return exp((0.0 - l));
}
real(8) function code(k, m, n, m_1, l)
    real(8), intent (in) :: k
    real(8), intent (in) :: m
    real(8), intent (in) :: n
    real(8), intent (in) :: m_1
    real(8), intent (in) :: l
    code = exp((0.0d0 - l))
end function
public static double code(double K, double m, double n, double M, double l) {
	return Math.exp((0.0 - l));
}
def code(K, m, n, M, l):
	return math.exp((0.0 - l))
function code(K, m, n, M, l)
	return exp(Float64(0.0 - l))
end
function tmp = code(K, m, n, M, l)
	tmp = exp((0.0 - l));
end
code[K_, m_, n_, M_, l_] := N[Exp[N[(0.0 - l), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}

\\
e^{0 - \ell}
\end{array}
Derivation
  1. Initial program 78.2%

    \[\cos \left(\frac{K \cdot \left(m + n\right)}{2} - M\right) \cdot e^{\left(-{\left(\frac{m + n}{2} - M\right)}^{2}\right) - \left(\ell - \left|m - n\right|\right)} \]
  2. Step-by-step derivation
    1. *-lowering-*.f64N/A

      \[\leadsto \mathsf{*.f64}\left(\cos \left(\frac{K \cdot \left(m + n\right)}{2} - M\right), \color{blue}{\left(e^{\left(\mathsf{neg}\left({\left(\frac{m + n}{2} - M\right)}^{2}\right)\right) - \left(\ell - \left|m - n\right|\right)}\right)}\right) \]
    2. sub-negN/A

      \[\leadsto \mathsf{*.f64}\left(\cos \left(\frac{K \cdot \left(m + n\right)}{2} + \left(\mathsf{neg}\left(M\right)\right)\right), \left(e^{\color{blue}{\left(\mathsf{neg}\left({\left(\frac{m + n}{2} - M\right)}^{2}\right)\right)} - \left(\ell - \left|m - n\right|\right)}\right)\right) \]
    3. +-commutativeN/A

      \[\leadsto \mathsf{*.f64}\left(\cos \left(\left(\mathsf{neg}\left(M\right)\right) + \frac{K \cdot \left(m + n\right)}{2}\right), \left(e^{\color{blue}{\left(\mathsf{neg}\left({\left(\frac{m + n}{2} - M\right)}^{2}\right)\right)} - \left(\ell - \left|m - n\right|\right)}\right)\right) \]
    4. neg-sub0N/A

      \[\leadsto \mathsf{*.f64}\left(\cos \left(\left(0 - M\right) + \frac{K \cdot \left(m + n\right)}{2}\right), \left(e^{\left(\mathsf{neg}\left(\color{blue}{{\left(\frac{m + n}{2} - M\right)}^{2}}\right)\right) - \left(\ell - \left|m - n\right|\right)}\right)\right) \]
    5. associate-+l-N/A

      \[\leadsto \mathsf{*.f64}\left(\cos \left(0 - \left(M - \frac{K \cdot \left(m + n\right)}{2}\right)\right), \left(e^{\color{blue}{\left(\mathsf{neg}\left({\left(\frac{m + n}{2} - M\right)}^{2}\right)\right)} - \left(\ell - \left|m - n\right|\right)}\right)\right) \]
    6. sub0-negN/A

      \[\leadsto \mathsf{*.f64}\left(\cos \left(\mathsf{neg}\left(\left(M - \frac{K \cdot \left(m + n\right)}{2}\right)\right)\right), \left(e^{\color{blue}{\left(\mathsf{neg}\left({\left(\frac{m + n}{2} - M\right)}^{2}\right)\right)} - \left(\ell - \left|m - n\right|\right)}\right)\right) \]
    7. cos-negN/A

      \[\leadsto \mathsf{*.f64}\left(\cos \left(M - \frac{K \cdot \left(m + n\right)}{2}\right), \left(e^{\color{blue}{\left(\mathsf{neg}\left({\left(\frac{m + n}{2} - M\right)}^{2}\right)\right) - \left(\ell - \left|m - n\right|\right)}}\right)\right) \]
    8. cos-lowering-cos.f64N/A

      \[\leadsto \mathsf{*.f64}\left(\mathsf{cos.f64}\left(\left(M - \frac{K \cdot \left(m + n\right)}{2}\right)\right), \left(e^{\color{blue}{\left(\mathsf{neg}\left({\left(\frac{m + n}{2} - M\right)}^{2}\right)\right) - \left(\ell - \left|m - n\right|\right)}}\right)\right) \]
    9. sub-negN/A

      \[\leadsto \mathsf{*.f64}\left(\mathsf{cos.f64}\left(\left(M + \left(\mathsf{neg}\left(\frac{K \cdot \left(m + n\right)}{2}\right)\right)\right)\right), \left(e^{\color{blue}{\left(\mathsf{neg}\left({\left(\frac{m + n}{2} - M\right)}^{2}\right)\right)} - \left(\ell - \left|m - n\right|\right)}\right)\right) \]
    10. +-lowering-+.f64N/A

      \[\leadsto \mathsf{*.f64}\left(\mathsf{cos.f64}\left(\mathsf{+.f64}\left(M, \left(\mathsf{neg}\left(\frac{K \cdot \left(m + n\right)}{2}\right)\right)\right)\right), \left(e^{\color{blue}{\left(\mathsf{neg}\left({\left(\frac{m + n}{2} - M\right)}^{2}\right)\right)} - \left(\ell - \left|m - n\right|\right)}\right)\right) \]
    11. distribute-neg-frac2N/A

      \[\leadsto \mathsf{*.f64}\left(\mathsf{cos.f64}\left(\mathsf{+.f64}\left(M, \left(\frac{K \cdot \left(m + n\right)}{\mathsf{neg}\left(2\right)}\right)\right)\right), \left(e^{\left(\mathsf{neg}\left({\left(\frac{m + n}{2} - M\right)}^{2}\right)\right) - \left(\ell - \left|m - n\right|\right)}\right)\right) \]
    12. /-lowering-/.f64N/A

      \[\leadsto \mathsf{*.f64}\left(\mathsf{cos.f64}\left(\mathsf{+.f64}\left(M, \mathsf{/.f64}\left(\left(K \cdot \left(m + n\right)\right), \left(\mathsf{neg}\left(2\right)\right)\right)\right)\right), \left(e^{\left(\mathsf{neg}\left({\left(\frac{m + n}{2} - M\right)}^{2}\right)\right) - \left(\ell - \left|m - n\right|\right)}\right)\right) \]
    13. *-lowering-*.f64N/A

      \[\leadsto \mathsf{*.f64}\left(\mathsf{cos.f64}\left(\mathsf{+.f64}\left(M, \mathsf{/.f64}\left(\mathsf{*.f64}\left(K, \left(m + n\right)\right), \left(\mathsf{neg}\left(2\right)\right)\right)\right)\right), \left(e^{\left(\mathsf{neg}\left({\left(\frac{m + n}{2} - M\right)}^{2}\right)\right) - \left(\ell - \left|m - n\right|\right)}\right)\right) \]
    14. +-lowering-+.f64N/A

      \[\leadsto \mathsf{*.f64}\left(\mathsf{cos.f64}\left(\mathsf{+.f64}\left(M, \mathsf{/.f64}\left(\mathsf{*.f64}\left(K, \mathsf{+.f64}\left(m, n\right)\right), \left(\mathsf{neg}\left(2\right)\right)\right)\right)\right), \left(e^{\left(\mathsf{neg}\left({\left(\frac{m + n}{2} - M\right)}^{2}\right)\right) - \left(\ell - \left|m - n\right|\right)}\right)\right) \]
    15. metadata-evalN/A

      \[\leadsto \mathsf{*.f64}\left(\mathsf{cos.f64}\left(\mathsf{+.f64}\left(M, \mathsf{/.f64}\left(\mathsf{*.f64}\left(K, \mathsf{+.f64}\left(m, n\right)\right), -2\right)\right)\right), \left(e^{\left(\mathsf{neg}\left({\left(\frac{m + n}{2} - M\right)}^{2}\right)\right) - \left(\ell - \left|m - n\right|\right)}\right)\right) \]
    16. exp-lowering-exp.f64N/A

      \[\leadsto \mathsf{*.f64}\left(\mathsf{cos.f64}\left(\mathsf{+.f64}\left(M, \mathsf{/.f64}\left(\mathsf{*.f64}\left(K, \mathsf{+.f64}\left(m, n\right)\right), -2\right)\right)\right), \mathsf{exp.f64}\left(\left(\left(\mathsf{neg}\left({\left(\frac{m + n}{2} - M\right)}^{2}\right)\right) - \left(\ell - \left|m - n\right|\right)\right)\right)\right) \]
  3. Simplified78.2%

    \[\leadsto \color{blue}{\cos \left(M + \frac{K \cdot \left(m + n\right)}{-2}\right) \cdot e^{\left(\frac{m + n}{2} - M\right) \cdot \left(M + \frac{m + n}{-2}\right) + \left(\left|m - n\right| - \ell\right)}} \]
  4. Add Preprocessing
  5. Taylor expanded in K around 0

    \[\leadsto \color{blue}{\cos M \cdot e^{\left(\left|m - n\right| + \left(M + \frac{-1}{2} \cdot \left(m + n\right)\right) \cdot \left(\frac{1}{2} \cdot \left(m + n\right) - M\right)\right) - \ell}} \]
  6. Step-by-step derivation
    1. *-commutativeN/A

      \[\leadsto e^{\left(\left|m - n\right| + \left(M + \frac{-1}{2} \cdot \left(m + n\right)\right) \cdot \left(\frac{1}{2} \cdot \left(m + n\right) - M\right)\right) - \ell} \cdot \color{blue}{\cos M} \]
    2. *-lowering-*.f64N/A

      \[\leadsto \mathsf{*.f64}\left(\left(e^{\left(\left|m - n\right| + \left(M + \frac{-1}{2} \cdot \left(m + n\right)\right) \cdot \left(\frac{1}{2} \cdot \left(m + n\right) - M\right)\right) - \ell}\right), \color{blue}{\cos M}\right) \]
  7. Simplified98.9%

    \[\leadsto \color{blue}{e^{\left|n - m\right| + \left(\left(M + -0.5 \cdot \left(m + n\right)\right) \cdot \left(\left(m + n\right) \cdot 0.5 - M\right) - \ell\right)} \cdot \cos M} \]
  8. Taylor expanded in M around 0

    \[\leadsto \color{blue}{e^{\left(\left|n - m\right| + \frac{-1}{4} \cdot {\left(m + n\right)}^{2}\right) - \ell}} \]
  9. Step-by-step derivation
    1. exp-lowering-exp.f64N/A

      \[\leadsto \mathsf{exp.f64}\left(\left(\left(\left|n - m\right| + \frac{-1}{4} \cdot {\left(m + n\right)}^{2}\right) - \ell\right)\right) \]
    2. associate--l+N/A

      \[\leadsto \mathsf{exp.f64}\left(\left(\left|n - m\right| + \left(\frac{-1}{4} \cdot {\left(m + n\right)}^{2} - \ell\right)\right)\right) \]
    3. +-lowering-+.f64N/A

      \[\leadsto \mathsf{exp.f64}\left(\mathsf{+.f64}\left(\left(\left|n - m\right|\right), \left(\frac{-1}{4} \cdot {\left(m + n\right)}^{2} - \ell\right)\right)\right) \]
    4. fabs-subN/A

      \[\leadsto \mathsf{exp.f64}\left(\mathsf{+.f64}\left(\left(\left|m - n\right|\right), \left(\frac{-1}{4} \cdot {\left(m + n\right)}^{2} - \ell\right)\right)\right) \]
    5. sub-negN/A

      \[\leadsto \mathsf{exp.f64}\left(\mathsf{+.f64}\left(\left(\left|m + \left(\mathsf{neg}\left(n\right)\right)\right|\right), \left(\frac{-1}{4} \cdot {\left(m + n\right)}^{2} - \ell\right)\right)\right) \]
    6. mul-1-negN/A

      \[\leadsto \mathsf{exp.f64}\left(\mathsf{+.f64}\left(\left(\left|m + -1 \cdot n\right|\right), \left(\frac{-1}{4} \cdot {\left(m + n\right)}^{2} - \ell\right)\right)\right) \]
    7. fabs-lowering-fabs.f64N/A

      \[\leadsto \mathsf{exp.f64}\left(\mathsf{+.f64}\left(\mathsf{fabs.f64}\left(\left(m + -1 \cdot n\right)\right), \left(\frac{-1}{4} \cdot {\left(m + n\right)}^{2} - \ell\right)\right)\right) \]
    8. mul-1-negN/A

      \[\leadsto \mathsf{exp.f64}\left(\mathsf{+.f64}\left(\mathsf{fabs.f64}\left(\left(m + \left(\mathsf{neg}\left(n\right)\right)\right)\right), \left(\frac{-1}{4} \cdot {\left(m + n\right)}^{2} - \ell\right)\right)\right) \]
    9. sub-negN/A

      \[\leadsto \mathsf{exp.f64}\left(\mathsf{+.f64}\left(\mathsf{fabs.f64}\left(\left(m - n\right)\right), \left(\frac{-1}{4} \cdot {\left(m + n\right)}^{2} - \ell\right)\right)\right) \]
    10. --lowering--.f64N/A

      \[\leadsto \mathsf{exp.f64}\left(\mathsf{+.f64}\left(\mathsf{fabs.f64}\left(\mathsf{\_.f64}\left(m, n\right)\right), \left(\frac{-1}{4} \cdot {\left(m + n\right)}^{2} - \ell\right)\right)\right) \]
    11. --lowering--.f64N/A

      \[\leadsto \mathsf{exp.f64}\left(\mathsf{+.f64}\left(\mathsf{fabs.f64}\left(\mathsf{\_.f64}\left(m, n\right)\right), \mathsf{\_.f64}\left(\left(\frac{-1}{4} \cdot {\left(m + n\right)}^{2}\right), \ell\right)\right)\right) \]
    12. *-lowering-*.f64N/A

      \[\leadsto \mathsf{exp.f64}\left(\mathsf{+.f64}\left(\mathsf{fabs.f64}\left(\mathsf{\_.f64}\left(m, n\right)\right), \mathsf{\_.f64}\left(\mathsf{*.f64}\left(\frac{-1}{4}, \left({\left(m + n\right)}^{2}\right)\right), \ell\right)\right)\right) \]
    13. unpow2N/A

      \[\leadsto \mathsf{exp.f64}\left(\mathsf{+.f64}\left(\mathsf{fabs.f64}\left(\mathsf{\_.f64}\left(m, n\right)\right), \mathsf{\_.f64}\left(\mathsf{*.f64}\left(\frac{-1}{4}, \left(\left(m + n\right) \cdot \left(m + n\right)\right)\right), \ell\right)\right)\right) \]
    14. *-lowering-*.f64N/A

      \[\leadsto \mathsf{exp.f64}\left(\mathsf{+.f64}\left(\mathsf{fabs.f64}\left(\mathsf{\_.f64}\left(m, n\right)\right), \mathsf{\_.f64}\left(\mathsf{*.f64}\left(\frac{-1}{4}, \mathsf{*.f64}\left(\left(m + n\right), \left(m + n\right)\right)\right), \ell\right)\right)\right) \]
    15. +-commutativeN/A

      \[\leadsto \mathsf{exp.f64}\left(\mathsf{+.f64}\left(\mathsf{fabs.f64}\left(\mathsf{\_.f64}\left(m, n\right)\right), \mathsf{\_.f64}\left(\mathsf{*.f64}\left(\frac{-1}{4}, \mathsf{*.f64}\left(\left(n + m\right), \left(m + n\right)\right)\right), \ell\right)\right)\right) \]
    16. +-lowering-+.f64N/A

      \[\leadsto \mathsf{exp.f64}\left(\mathsf{+.f64}\left(\mathsf{fabs.f64}\left(\mathsf{\_.f64}\left(m, n\right)\right), \mathsf{\_.f64}\left(\mathsf{*.f64}\left(\frac{-1}{4}, \mathsf{*.f64}\left(\mathsf{+.f64}\left(n, m\right), \left(m + n\right)\right)\right), \ell\right)\right)\right) \]
    17. +-commutativeN/A

      \[\leadsto \mathsf{exp.f64}\left(\mathsf{+.f64}\left(\mathsf{fabs.f64}\left(\mathsf{\_.f64}\left(m, n\right)\right), \mathsf{\_.f64}\left(\mathsf{*.f64}\left(\frac{-1}{4}, \mathsf{*.f64}\left(\mathsf{+.f64}\left(n, m\right), \left(n + m\right)\right)\right), \ell\right)\right)\right) \]
    18. +-lowering-+.f6488.3%

      \[\leadsto \mathsf{exp.f64}\left(\mathsf{+.f64}\left(\mathsf{fabs.f64}\left(\mathsf{\_.f64}\left(m, n\right)\right), \mathsf{\_.f64}\left(\mathsf{*.f64}\left(\frac{-1}{4}, \mathsf{*.f64}\left(\mathsf{+.f64}\left(n, m\right), \mathsf{+.f64}\left(n, m\right)\right)\right), \ell\right)\right)\right) \]
  10. Simplified88.3%

    \[\leadsto \color{blue}{e^{\left|m - n\right| + \left(-0.25 \cdot \left(\left(n + m\right) \cdot \left(n + m\right)\right) - \ell\right)}} \]
  11. Taylor expanded in l around inf

    \[\leadsto \mathsf{exp.f64}\left(\color{blue}{\left(-1 \cdot \ell\right)}\right) \]
  12. Step-by-step derivation
    1. neg-mul-1N/A

      \[\leadsto \mathsf{exp.f64}\left(\left(\mathsf{neg}\left(\ell\right)\right)\right) \]
    2. neg-sub0N/A

      \[\leadsto \mathsf{exp.f64}\left(\left(0 - \ell\right)\right) \]
    3. --lowering--.f6435.6%

      \[\leadsto \mathsf{exp.f64}\left(\mathsf{\_.f64}\left(0, \ell\right)\right) \]
  13. Simplified35.6%

    \[\leadsto e^{\color{blue}{0 - \ell}} \]
  14. Add Preprocessing

Alternative 10: 7.0% accurate, 4.2× speedup?

\[\begin{array}{l} \\ \cos M \end{array} \]
(FPCore (K m n M l) :precision binary64 (cos M))
double code(double K, double m, double n, double M, double l) {
	return cos(M);
}
real(8) function code(k, m, n, m_1, l)
    real(8), intent (in) :: k
    real(8), intent (in) :: m
    real(8), intent (in) :: n
    real(8), intent (in) :: m_1
    real(8), intent (in) :: l
    code = cos(m_1)
end function
public static double code(double K, double m, double n, double M, double l) {
	return Math.cos(M);
}
def code(K, m, n, M, l):
	return math.cos(M)
function code(K, m, n, M, l)
	return cos(M)
end
function tmp = code(K, m, n, M, l)
	tmp = cos(M);
end
code[K_, m_, n_, M_, l_] := N[Cos[M], $MachinePrecision]
\begin{array}{l}

\\
\cos M
\end{array}
Derivation
  1. Initial program 78.2%

    \[\cos \left(\frac{K \cdot \left(m + n\right)}{2} - M\right) \cdot e^{\left(-{\left(\frac{m + n}{2} - M\right)}^{2}\right) - \left(\ell - \left|m - n\right|\right)} \]
  2. Step-by-step derivation
    1. *-lowering-*.f64N/A

      \[\leadsto \mathsf{*.f64}\left(\cos \left(\frac{K \cdot \left(m + n\right)}{2} - M\right), \color{blue}{\left(e^{\left(\mathsf{neg}\left({\left(\frac{m + n}{2} - M\right)}^{2}\right)\right) - \left(\ell - \left|m - n\right|\right)}\right)}\right) \]
    2. sub-negN/A

      \[\leadsto \mathsf{*.f64}\left(\cos \left(\frac{K \cdot \left(m + n\right)}{2} + \left(\mathsf{neg}\left(M\right)\right)\right), \left(e^{\color{blue}{\left(\mathsf{neg}\left({\left(\frac{m + n}{2} - M\right)}^{2}\right)\right)} - \left(\ell - \left|m - n\right|\right)}\right)\right) \]
    3. +-commutativeN/A

      \[\leadsto \mathsf{*.f64}\left(\cos \left(\left(\mathsf{neg}\left(M\right)\right) + \frac{K \cdot \left(m + n\right)}{2}\right), \left(e^{\color{blue}{\left(\mathsf{neg}\left({\left(\frac{m + n}{2} - M\right)}^{2}\right)\right)} - \left(\ell - \left|m - n\right|\right)}\right)\right) \]
    4. neg-sub0N/A

      \[\leadsto \mathsf{*.f64}\left(\cos \left(\left(0 - M\right) + \frac{K \cdot \left(m + n\right)}{2}\right), \left(e^{\left(\mathsf{neg}\left(\color{blue}{{\left(\frac{m + n}{2} - M\right)}^{2}}\right)\right) - \left(\ell - \left|m - n\right|\right)}\right)\right) \]
    5. associate-+l-N/A

      \[\leadsto \mathsf{*.f64}\left(\cos \left(0 - \left(M - \frac{K \cdot \left(m + n\right)}{2}\right)\right), \left(e^{\color{blue}{\left(\mathsf{neg}\left({\left(\frac{m + n}{2} - M\right)}^{2}\right)\right)} - \left(\ell - \left|m - n\right|\right)}\right)\right) \]
    6. sub0-negN/A

      \[\leadsto \mathsf{*.f64}\left(\cos \left(\mathsf{neg}\left(\left(M - \frac{K \cdot \left(m + n\right)}{2}\right)\right)\right), \left(e^{\color{blue}{\left(\mathsf{neg}\left({\left(\frac{m + n}{2} - M\right)}^{2}\right)\right)} - \left(\ell - \left|m - n\right|\right)}\right)\right) \]
    7. cos-negN/A

      \[\leadsto \mathsf{*.f64}\left(\cos \left(M - \frac{K \cdot \left(m + n\right)}{2}\right), \left(e^{\color{blue}{\left(\mathsf{neg}\left({\left(\frac{m + n}{2} - M\right)}^{2}\right)\right) - \left(\ell - \left|m - n\right|\right)}}\right)\right) \]
    8. cos-lowering-cos.f64N/A

      \[\leadsto \mathsf{*.f64}\left(\mathsf{cos.f64}\left(\left(M - \frac{K \cdot \left(m + n\right)}{2}\right)\right), \left(e^{\color{blue}{\left(\mathsf{neg}\left({\left(\frac{m + n}{2} - M\right)}^{2}\right)\right) - \left(\ell - \left|m - n\right|\right)}}\right)\right) \]
    9. sub-negN/A

      \[\leadsto \mathsf{*.f64}\left(\mathsf{cos.f64}\left(\left(M + \left(\mathsf{neg}\left(\frac{K \cdot \left(m + n\right)}{2}\right)\right)\right)\right), \left(e^{\color{blue}{\left(\mathsf{neg}\left({\left(\frac{m + n}{2} - M\right)}^{2}\right)\right)} - \left(\ell - \left|m - n\right|\right)}\right)\right) \]
    10. +-lowering-+.f64N/A

      \[\leadsto \mathsf{*.f64}\left(\mathsf{cos.f64}\left(\mathsf{+.f64}\left(M, \left(\mathsf{neg}\left(\frac{K \cdot \left(m + n\right)}{2}\right)\right)\right)\right), \left(e^{\color{blue}{\left(\mathsf{neg}\left({\left(\frac{m + n}{2} - M\right)}^{2}\right)\right)} - \left(\ell - \left|m - n\right|\right)}\right)\right) \]
    11. distribute-neg-frac2N/A

      \[\leadsto \mathsf{*.f64}\left(\mathsf{cos.f64}\left(\mathsf{+.f64}\left(M, \left(\frac{K \cdot \left(m + n\right)}{\mathsf{neg}\left(2\right)}\right)\right)\right), \left(e^{\left(\mathsf{neg}\left({\left(\frac{m + n}{2} - M\right)}^{2}\right)\right) - \left(\ell - \left|m - n\right|\right)}\right)\right) \]
    12. /-lowering-/.f64N/A

      \[\leadsto \mathsf{*.f64}\left(\mathsf{cos.f64}\left(\mathsf{+.f64}\left(M, \mathsf{/.f64}\left(\left(K \cdot \left(m + n\right)\right), \left(\mathsf{neg}\left(2\right)\right)\right)\right)\right), \left(e^{\left(\mathsf{neg}\left({\left(\frac{m + n}{2} - M\right)}^{2}\right)\right) - \left(\ell - \left|m - n\right|\right)}\right)\right) \]
    13. *-lowering-*.f64N/A

      \[\leadsto \mathsf{*.f64}\left(\mathsf{cos.f64}\left(\mathsf{+.f64}\left(M, \mathsf{/.f64}\left(\mathsf{*.f64}\left(K, \left(m + n\right)\right), \left(\mathsf{neg}\left(2\right)\right)\right)\right)\right), \left(e^{\left(\mathsf{neg}\left({\left(\frac{m + n}{2} - M\right)}^{2}\right)\right) - \left(\ell - \left|m - n\right|\right)}\right)\right) \]
    14. +-lowering-+.f64N/A

      \[\leadsto \mathsf{*.f64}\left(\mathsf{cos.f64}\left(\mathsf{+.f64}\left(M, \mathsf{/.f64}\left(\mathsf{*.f64}\left(K, \mathsf{+.f64}\left(m, n\right)\right), \left(\mathsf{neg}\left(2\right)\right)\right)\right)\right), \left(e^{\left(\mathsf{neg}\left({\left(\frac{m + n}{2} - M\right)}^{2}\right)\right) - \left(\ell - \left|m - n\right|\right)}\right)\right) \]
    15. metadata-evalN/A

      \[\leadsto \mathsf{*.f64}\left(\mathsf{cos.f64}\left(\mathsf{+.f64}\left(M, \mathsf{/.f64}\left(\mathsf{*.f64}\left(K, \mathsf{+.f64}\left(m, n\right)\right), -2\right)\right)\right), \left(e^{\left(\mathsf{neg}\left({\left(\frac{m + n}{2} - M\right)}^{2}\right)\right) - \left(\ell - \left|m - n\right|\right)}\right)\right) \]
    16. exp-lowering-exp.f64N/A

      \[\leadsto \mathsf{*.f64}\left(\mathsf{cos.f64}\left(\mathsf{+.f64}\left(M, \mathsf{/.f64}\left(\mathsf{*.f64}\left(K, \mathsf{+.f64}\left(m, n\right)\right), -2\right)\right)\right), \mathsf{exp.f64}\left(\left(\left(\mathsf{neg}\left({\left(\frac{m + n}{2} - M\right)}^{2}\right)\right) - \left(\ell - \left|m - n\right|\right)\right)\right)\right) \]
  3. Simplified78.2%

    \[\leadsto \color{blue}{\cos \left(M + \frac{K \cdot \left(m + n\right)}{-2}\right) \cdot e^{\left(\frac{m + n}{2} - M\right) \cdot \left(M + \frac{m + n}{-2}\right) + \left(\left|m - n\right| - \ell\right)}} \]
  4. Add Preprocessing
  5. Taylor expanded in K around 0

    \[\leadsto \color{blue}{\cos M \cdot e^{\left(\left|m - n\right| + \left(M + \frac{-1}{2} \cdot \left(m + n\right)\right) \cdot \left(\frac{1}{2} \cdot \left(m + n\right) - M\right)\right) - \ell}} \]
  6. Step-by-step derivation
    1. *-commutativeN/A

      \[\leadsto e^{\left(\left|m - n\right| + \left(M + \frac{-1}{2} \cdot \left(m + n\right)\right) \cdot \left(\frac{1}{2} \cdot \left(m + n\right) - M\right)\right) - \ell} \cdot \color{blue}{\cos M} \]
    2. *-lowering-*.f64N/A

      \[\leadsto \mathsf{*.f64}\left(\left(e^{\left(\left|m - n\right| + \left(M + \frac{-1}{2} \cdot \left(m + n\right)\right) \cdot \left(\frac{1}{2} \cdot \left(m + n\right) - M\right)\right) - \ell}\right), \color{blue}{\cos M}\right) \]
  7. Simplified98.9%

    \[\leadsto \color{blue}{e^{\left|n - m\right| + \left(\left(M + -0.5 \cdot \left(m + n\right)\right) \cdot \left(\left(m + n\right) \cdot 0.5 - M\right) - \ell\right)} \cdot \cos M} \]
  8. Taylor expanded in l around inf

    \[\leadsto \mathsf{*.f64}\left(\mathsf{exp.f64}\left(\color{blue}{\left(-1 \cdot \ell\right)}\right), \mathsf{cos.f64}\left(M\right)\right) \]
  9. Step-by-step derivation
    1. mul-1-negN/A

      \[\leadsto \mathsf{*.f64}\left(\mathsf{exp.f64}\left(\left(\mathsf{neg}\left(\ell\right)\right)\right), \mathsf{cos.f64}\left(M\right)\right) \]
    2. neg-sub0N/A

      \[\leadsto \mathsf{*.f64}\left(\mathsf{exp.f64}\left(\left(0 - \ell\right)\right), \mathsf{cos.f64}\left(M\right)\right) \]
    3. --lowering--.f6435.6%

      \[\leadsto \mathsf{*.f64}\left(\mathsf{exp.f64}\left(\mathsf{\_.f64}\left(0, \ell\right)\right), \mathsf{cos.f64}\left(M\right)\right) \]
  10. Simplified35.6%

    \[\leadsto e^{\color{blue}{0 - \ell}} \cdot \cos M \]
  11. Taylor expanded in l around 0

    \[\leadsto \color{blue}{\cos M} \]
  12. Step-by-step derivation
    1. cos-lowering-cos.f646.4%

      \[\leadsto \mathsf{cos.f64}\left(M\right) \]
  13. Simplified6.4%

    \[\leadsto \color{blue}{\cos M} \]
  14. Add Preprocessing

Alternative 11: 7.0% accurate, 425.0× speedup?

\[\begin{array}{l} \\ 1 \end{array} \]
(FPCore (K m n M l) :precision binary64 1.0)
double code(double K, double m, double n, double M, double l) {
	return 1.0;
}
real(8) function code(k, m, n, m_1, l)
    real(8), intent (in) :: k
    real(8), intent (in) :: m
    real(8), intent (in) :: n
    real(8), intent (in) :: m_1
    real(8), intent (in) :: l
    code = 1.0d0
end function
public static double code(double K, double m, double n, double M, double l) {
	return 1.0;
}
def code(K, m, n, M, l):
	return 1.0
function code(K, m, n, M, l)
	return 1.0
end
function tmp = code(K, m, n, M, l)
	tmp = 1.0;
end
code[K_, m_, n_, M_, l_] := 1.0
\begin{array}{l}

\\
1
\end{array}
Derivation
  1. Initial program 78.2%

    \[\cos \left(\frac{K \cdot \left(m + n\right)}{2} - M\right) \cdot e^{\left(-{\left(\frac{m + n}{2} - M\right)}^{2}\right) - \left(\ell - \left|m - n\right|\right)} \]
  2. Step-by-step derivation
    1. *-lowering-*.f64N/A

      \[\leadsto \mathsf{*.f64}\left(\cos \left(\frac{K \cdot \left(m + n\right)}{2} - M\right), \color{blue}{\left(e^{\left(\mathsf{neg}\left({\left(\frac{m + n}{2} - M\right)}^{2}\right)\right) - \left(\ell - \left|m - n\right|\right)}\right)}\right) \]
    2. sub-negN/A

      \[\leadsto \mathsf{*.f64}\left(\cos \left(\frac{K \cdot \left(m + n\right)}{2} + \left(\mathsf{neg}\left(M\right)\right)\right), \left(e^{\color{blue}{\left(\mathsf{neg}\left({\left(\frac{m + n}{2} - M\right)}^{2}\right)\right)} - \left(\ell - \left|m - n\right|\right)}\right)\right) \]
    3. +-commutativeN/A

      \[\leadsto \mathsf{*.f64}\left(\cos \left(\left(\mathsf{neg}\left(M\right)\right) + \frac{K \cdot \left(m + n\right)}{2}\right), \left(e^{\color{blue}{\left(\mathsf{neg}\left({\left(\frac{m + n}{2} - M\right)}^{2}\right)\right)} - \left(\ell - \left|m - n\right|\right)}\right)\right) \]
    4. neg-sub0N/A

      \[\leadsto \mathsf{*.f64}\left(\cos \left(\left(0 - M\right) + \frac{K \cdot \left(m + n\right)}{2}\right), \left(e^{\left(\mathsf{neg}\left(\color{blue}{{\left(\frac{m + n}{2} - M\right)}^{2}}\right)\right) - \left(\ell - \left|m - n\right|\right)}\right)\right) \]
    5. associate-+l-N/A

      \[\leadsto \mathsf{*.f64}\left(\cos \left(0 - \left(M - \frac{K \cdot \left(m + n\right)}{2}\right)\right), \left(e^{\color{blue}{\left(\mathsf{neg}\left({\left(\frac{m + n}{2} - M\right)}^{2}\right)\right)} - \left(\ell - \left|m - n\right|\right)}\right)\right) \]
    6. sub0-negN/A

      \[\leadsto \mathsf{*.f64}\left(\cos \left(\mathsf{neg}\left(\left(M - \frac{K \cdot \left(m + n\right)}{2}\right)\right)\right), \left(e^{\color{blue}{\left(\mathsf{neg}\left({\left(\frac{m + n}{2} - M\right)}^{2}\right)\right)} - \left(\ell - \left|m - n\right|\right)}\right)\right) \]
    7. cos-negN/A

      \[\leadsto \mathsf{*.f64}\left(\cos \left(M - \frac{K \cdot \left(m + n\right)}{2}\right), \left(e^{\color{blue}{\left(\mathsf{neg}\left({\left(\frac{m + n}{2} - M\right)}^{2}\right)\right) - \left(\ell - \left|m - n\right|\right)}}\right)\right) \]
    8. cos-lowering-cos.f64N/A

      \[\leadsto \mathsf{*.f64}\left(\mathsf{cos.f64}\left(\left(M - \frac{K \cdot \left(m + n\right)}{2}\right)\right), \left(e^{\color{blue}{\left(\mathsf{neg}\left({\left(\frac{m + n}{2} - M\right)}^{2}\right)\right) - \left(\ell - \left|m - n\right|\right)}}\right)\right) \]
    9. sub-negN/A

      \[\leadsto \mathsf{*.f64}\left(\mathsf{cos.f64}\left(\left(M + \left(\mathsf{neg}\left(\frac{K \cdot \left(m + n\right)}{2}\right)\right)\right)\right), \left(e^{\color{blue}{\left(\mathsf{neg}\left({\left(\frac{m + n}{2} - M\right)}^{2}\right)\right)} - \left(\ell - \left|m - n\right|\right)}\right)\right) \]
    10. +-lowering-+.f64N/A

      \[\leadsto \mathsf{*.f64}\left(\mathsf{cos.f64}\left(\mathsf{+.f64}\left(M, \left(\mathsf{neg}\left(\frac{K \cdot \left(m + n\right)}{2}\right)\right)\right)\right), \left(e^{\color{blue}{\left(\mathsf{neg}\left({\left(\frac{m + n}{2} - M\right)}^{2}\right)\right)} - \left(\ell - \left|m - n\right|\right)}\right)\right) \]
    11. distribute-neg-frac2N/A

      \[\leadsto \mathsf{*.f64}\left(\mathsf{cos.f64}\left(\mathsf{+.f64}\left(M, \left(\frac{K \cdot \left(m + n\right)}{\mathsf{neg}\left(2\right)}\right)\right)\right), \left(e^{\left(\mathsf{neg}\left({\left(\frac{m + n}{2} - M\right)}^{2}\right)\right) - \left(\ell - \left|m - n\right|\right)}\right)\right) \]
    12. /-lowering-/.f64N/A

      \[\leadsto \mathsf{*.f64}\left(\mathsf{cos.f64}\left(\mathsf{+.f64}\left(M, \mathsf{/.f64}\left(\left(K \cdot \left(m + n\right)\right), \left(\mathsf{neg}\left(2\right)\right)\right)\right)\right), \left(e^{\left(\mathsf{neg}\left({\left(\frac{m + n}{2} - M\right)}^{2}\right)\right) - \left(\ell - \left|m - n\right|\right)}\right)\right) \]
    13. *-lowering-*.f64N/A

      \[\leadsto \mathsf{*.f64}\left(\mathsf{cos.f64}\left(\mathsf{+.f64}\left(M, \mathsf{/.f64}\left(\mathsf{*.f64}\left(K, \left(m + n\right)\right), \left(\mathsf{neg}\left(2\right)\right)\right)\right)\right), \left(e^{\left(\mathsf{neg}\left({\left(\frac{m + n}{2} - M\right)}^{2}\right)\right) - \left(\ell - \left|m - n\right|\right)}\right)\right) \]
    14. +-lowering-+.f64N/A

      \[\leadsto \mathsf{*.f64}\left(\mathsf{cos.f64}\left(\mathsf{+.f64}\left(M, \mathsf{/.f64}\left(\mathsf{*.f64}\left(K, \mathsf{+.f64}\left(m, n\right)\right), \left(\mathsf{neg}\left(2\right)\right)\right)\right)\right), \left(e^{\left(\mathsf{neg}\left({\left(\frac{m + n}{2} - M\right)}^{2}\right)\right) - \left(\ell - \left|m - n\right|\right)}\right)\right) \]
    15. metadata-evalN/A

      \[\leadsto \mathsf{*.f64}\left(\mathsf{cos.f64}\left(\mathsf{+.f64}\left(M, \mathsf{/.f64}\left(\mathsf{*.f64}\left(K, \mathsf{+.f64}\left(m, n\right)\right), -2\right)\right)\right), \left(e^{\left(\mathsf{neg}\left({\left(\frac{m + n}{2} - M\right)}^{2}\right)\right) - \left(\ell - \left|m - n\right|\right)}\right)\right) \]
    16. exp-lowering-exp.f64N/A

      \[\leadsto \mathsf{*.f64}\left(\mathsf{cos.f64}\left(\mathsf{+.f64}\left(M, \mathsf{/.f64}\left(\mathsf{*.f64}\left(K, \mathsf{+.f64}\left(m, n\right)\right), -2\right)\right)\right), \mathsf{exp.f64}\left(\left(\left(\mathsf{neg}\left({\left(\frac{m + n}{2} - M\right)}^{2}\right)\right) - \left(\ell - \left|m - n\right|\right)\right)\right)\right) \]
  3. Simplified78.2%

    \[\leadsto \color{blue}{\cos \left(M + \frac{K \cdot \left(m + n\right)}{-2}\right) \cdot e^{\left(\frac{m + n}{2} - M\right) \cdot \left(M + \frac{m + n}{-2}\right) + \left(\left|m - n\right| - \ell\right)}} \]
  4. Add Preprocessing
  5. Taylor expanded in K around 0

    \[\leadsto \color{blue}{\cos M \cdot e^{\left(\left|m - n\right| + \left(M + \frac{-1}{2} \cdot \left(m + n\right)\right) \cdot \left(\frac{1}{2} \cdot \left(m + n\right) - M\right)\right) - \ell}} \]
  6. Step-by-step derivation
    1. *-commutativeN/A

      \[\leadsto e^{\left(\left|m - n\right| + \left(M + \frac{-1}{2} \cdot \left(m + n\right)\right) \cdot \left(\frac{1}{2} \cdot \left(m + n\right) - M\right)\right) - \ell} \cdot \color{blue}{\cos M} \]
    2. *-lowering-*.f64N/A

      \[\leadsto \mathsf{*.f64}\left(\left(e^{\left(\left|m - n\right| + \left(M + \frac{-1}{2} \cdot \left(m + n\right)\right) \cdot \left(\frac{1}{2} \cdot \left(m + n\right) - M\right)\right) - \ell}\right), \color{blue}{\cos M}\right) \]
  7. Simplified98.9%

    \[\leadsto \color{blue}{e^{\left|n - m\right| + \left(\left(M + -0.5 \cdot \left(m + n\right)\right) \cdot \left(\left(m + n\right) \cdot 0.5 - M\right) - \ell\right)} \cdot \cos M} \]
  8. Taylor expanded in M around 0

    \[\leadsto \color{blue}{e^{\left(\left|n - m\right| + \frac{-1}{4} \cdot {\left(m + n\right)}^{2}\right) - \ell}} \]
  9. Step-by-step derivation
    1. exp-lowering-exp.f64N/A

      \[\leadsto \mathsf{exp.f64}\left(\left(\left(\left|n - m\right| + \frac{-1}{4} \cdot {\left(m + n\right)}^{2}\right) - \ell\right)\right) \]
    2. associate--l+N/A

      \[\leadsto \mathsf{exp.f64}\left(\left(\left|n - m\right| + \left(\frac{-1}{4} \cdot {\left(m + n\right)}^{2} - \ell\right)\right)\right) \]
    3. +-lowering-+.f64N/A

      \[\leadsto \mathsf{exp.f64}\left(\mathsf{+.f64}\left(\left(\left|n - m\right|\right), \left(\frac{-1}{4} \cdot {\left(m + n\right)}^{2} - \ell\right)\right)\right) \]
    4. fabs-subN/A

      \[\leadsto \mathsf{exp.f64}\left(\mathsf{+.f64}\left(\left(\left|m - n\right|\right), \left(\frac{-1}{4} \cdot {\left(m + n\right)}^{2} - \ell\right)\right)\right) \]
    5. sub-negN/A

      \[\leadsto \mathsf{exp.f64}\left(\mathsf{+.f64}\left(\left(\left|m + \left(\mathsf{neg}\left(n\right)\right)\right|\right), \left(\frac{-1}{4} \cdot {\left(m + n\right)}^{2} - \ell\right)\right)\right) \]
    6. mul-1-negN/A

      \[\leadsto \mathsf{exp.f64}\left(\mathsf{+.f64}\left(\left(\left|m + -1 \cdot n\right|\right), \left(\frac{-1}{4} \cdot {\left(m + n\right)}^{2} - \ell\right)\right)\right) \]
    7. fabs-lowering-fabs.f64N/A

      \[\leadsto \mathsf{exp.f64}\left(\mathsf{+.f64}\left(\mathsf{fabs.f64}\left(\left(m + -1 \cdot n\right)\right), \left(\frac{-1}{4} \cdot {\left(m + n\right)}^{2} - \ell\right)\right)\right) \]
    8. mul-1-negN/A

      \[\leadsto \mathsf{exp.f64}\left(\mathsf{+.f64}\left(\mathsf{fabs.f64}\left(\left(m + \left(\mathsf{neg}\left(n\right)\right)\right)\right), \left(\frac{-1}{4} \cdot {\left(m + n\right)}^{2} - \ell\right)\right)\right) \]
    9. sub-negN/A

      \[\leadsto \mathsf{exp.f64}\left(\mathsf{+.f64}\left(\mathsf{fabs.f64}\left(\left(m - n\right)\right), \left(\frac{-1}{4} \cdot {\left(m + n\right)}^{2} - \ell\right)\right)\right) \]
    10. --lowering--.f64N/A

      \[\leadsto \mathsf{exp.f64}\left(\mathsf{+.f64}\left(\mathsf{fabs.f64}\left(\mathsf{\_.f64}\left(m, n\right)\right), \left(\frac{-1}{4} \cdot {\left(m + n\right)}^{2} - \ell\right)\right)\right) \]
    11. --lowering--.f64N/A

      \[\leadsto \mathsf{exp.f64}\left(\mathsf{+.f64}\left(\mathsf{fabs.f64}\left(\mathsf{\_.f64}\left(m, n\right)\right), \mathsf{\_.f64}\left(\left(\frac{-1}{4} \cdot {\left(m + n\right)}^{2}\right), \ell\right)\right)\right) \]
    12. *-lowering-*.f64N/A

      \[\leadsto \mathsf{exp.f64}\left(\mathsf{+.f64}\left(\mathsf{fabs.f64}\left(\mathsf{\_.f64}\left(m, n\right)\right), \mathsf{\_.f64}\left(\mathsf{*.f64}\left(\frac{-1}{4}, \left({\left(m + n\right)}^{2}\right)\right), \ell\right)\right)\right) \]
    13. unpow2N/A

      \[\leadsto \mathsf{exp.f64}\left(\mathsf{+.f64}\left(\mathsf{fabs.f64}\left(\mathsf{\_.f64}\left(m, n\right)\right), \mathsf{\_.f64}\left(\mathsf{*.f64}\left(\frac{-1}{4}, \left(\left(m + n\right) \cdot \left(m + n\right)\right)\right), \ell\right)\right)\right) \]
    14. *-lowering-*.f64N/A

      \[\leadsto \mathsf{exp.f64}\left(\mathsf{+.f64}\left(\mathsf{fabs.f64}\left(\mathsf{\_.f64}\left(m, n\right)\right), \mathsf{\_.f64}\left(\mathsf{*.f64}\left(\frac{-1}{4}, \mathsf{*.f64}\left(\left(m + n\right), \left(m + n\right)\right)\right), \ell\right)\right)\right) \]
    15. +-commutativeN/A

      \[\leadsto \mathsf{exp.f64}\left(\mathsf{+.f64}\left(\mathsf{fabs.f64}\left(\mathsf{\_.f64}\left(m, n\right)\right), \mathsf{\_.f64}\left(\mathsf{*.f64}\left(\frac{-1}{4}, \mathsf{*.f64}\left(\left(n + m\right), \left(m + n\right)\right)\right), \ell\right)\right)\right) \]
    16. +-lowering-+.f64N/A

      \[\leadsto \mathsf{exp.f64}\left(\mathsf{+.f64}\left(\mathsf{fabs.f64}\left(\mathsf{\_.f64}\left(m, n\right)\right), \mathsf{\_.f64}\left(\mathsf{*.f64}\left(\frac{-1}{4}, \mathsf{*.f64}\left(\mathsf{+.f64}\left(n, m\right), \left(m + n\right)\right)\right), \ell\right)\right)\right) \]
    17. +-commutativeN/A

      \[\leadsto \mathsf{exp.f64}\left(\mathsf{+.f64}\left(\mathsf{fabs.f64}\left(\mathsf{\_.f64}\left(m, n\right)\right), \mathsf{\_.f64}\left(\mathsf{*.f64}\left(\frac{-1}{4}, \mathsf{*.f64}\left(\mathsf{+.f64}\left(n, m\right), \left(n + m\right)\right)\right), \ell\right)\right)\right) \]
    18. +-lowering-+.f6488.3%

      \[\leadsto \mathsf{exp.f64}\left(\mathsf{+.f64}\left(\mathsf{fabs.f64}\left(\mathsf{\_.f64}\left(m, n\right)\right), \mathsf{\_.f64}\left(\mathsf{*.f64}\left(\frac{-1}{4}, \mathsf{*.f64}\left(\mathsf{+.f64}\left(n, m\right), \mathsf{+.f64}\left(n, m\right)\right)\right), \ell\right)\right)\right) \]
  10. Simplified88.3%

    \[\leadsto \color{blue}{e^{\left|m - n\right| + \left(-0.25 \cdot \left(\left(n + m\right) \cdot \left(n + m\right)\right) - \ell\right)}} \]
  11. Taylor expanded in n around inf

    \[\leadsto \mathsf{exp.f64}\left(\color{blue}{\left(\frac{-1}{4} \cdot {n}^{2}\right)}\right) \]
  12. Step-by-step derivation
    1. *-lowering-*.f64N/A

      \[\leadsto \mathsf{exp.f64}\left(\mathsf{*.f64}\left(\frac{-1}{4}, \left({n}^{2}\right)\right)\right) \]
    2. unpow2N/A

      \[\leadsto \mathsf{exp.f64}\left(\mathsf{*.f64}\left(\frac{-1}{4}, \left(n \cdot n\right)\right)\right) \]
    3. *-lowering-*.f6457.1%

      \[\leadsto \mathsf{exp.f64}\left(\mathsf{*.f64}\left(\frac{-1}{4}, \mathsf{*.f64}\left(n, n\right)\right)\right) \]
  13. Simplified57.1%

    \[\leadsto e^{\color{blue}{-0.25 \cdot \left(n \cdot n\right)}} \]
  14. Taylor expanded in n around 0

    \[\leadsto \color{blue}{1} \]
  15. Step-by-step derivation
    1. Simplified6.4%

      \[\leadsto \color{blue}{1} \]
    2. Add Preprocessing

    Reproduce

    ?
    herbie shell --seed 2024161 
    (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)))))))