Maksimov and Kolovsky, Equation (32)

Percentage Accurate: 75.9% → 96.6%
Time: 14.8s
Alternatives: 9
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 9 alternatives:

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

Initial Program: 75.9% accurate, 1.0× speedup?

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

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

Alternative 1: 96.6% accurate, 1.3× speedup?

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

\\
\begin{array}{l}
t_0 := \frac{m + n}{2} - M\\
\frac{\cos M}{e^{t\_0 \cdot t\_0 + \left(\ell - \left|m - n\right|\right)}}
\end{array}
\end{array}
Derivation
  1. Initial program 75.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 2: 85.1% accurate, 1.9× speedup?

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

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

\mathbf{elif}\;M \leq 1.2 \cdot 10^{-12}:\\
\;\;\;\;\frac{-0.001388888888888889 \cdot {M}^{6}}{e^{0.25 \cdot \left(m \cdot m\right)}}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if M < -27 or 1.19999999999999994e-12 < M

    1. Initial program 80.2%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -27 < M < 1.19999999999999994e-12

    1. Initial program 71.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \mathsf{/.f64}\left(\mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\left({M}^{2}\right), \left({M}^{2} \cdot \left(\frac{1}{24} + \frac{-1}{720} \cdot {M}^{2}\right) - \frac{1}{2}\right)\right)\right), \mathsf{exp.f64}\left(\mathsf{*.f64}\left(\frac{1}{4}, \color{blue}{\mathsf{*.f64}\left(m, m\right)}\right)\right)\right) \]
      3. unpow2N/A

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

        \[\leadsto \mathsf{/.f64}\left(\mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\mathsf{*.f64}\left(M, M\right), \left({M}^{2} \cdot \left(\frac{1}{24} + \frac{-1}{720} \cdot {M}^{2}\right) - \frac{1}{2}\right)\right)\right), \mathsf{exp.f64}\left(\mathsf{*.f64}\left(\frac{1}{4}, \mathsf{*.f64}\left(\color{blue}{m}, m\right)\right)\right)\right) \]
      5. sub-negN/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\mathsf{*.f64}\left(M, M\right), \left({M}^{2} \cdot \left(\frac{1}{24} + \frac{-1}{720} \cdot {M}^{2}\right) + \left(\mathsf{neg}\left(\frac{1}{2}\right)\right)\right)\right)\right), \mathsf{exp.f64}\left(\mathsf{*.f64}\left(\frac{1}{4}, \mathsf{*.f64}\left(m, \color{blue}{m}\right)\right)\right)\right) \]
      6. metadata-evalN/A

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

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

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

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

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

        \[\leadsto \mathsf{/.f64}\left(\mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\mathsf{*.f64}\left(M, M\right), \mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{*.f64}\left(M, M\right), \mathsf{+.f64}\left(\frac{1}{24}, \left(\frac{-1}{720} \cdot {M}^{2}\right)\right)\right), \frac{-1}{2}\right)\right)\right), \mathsf{exp.f64}\left(\mathsf{*.f64}\left(\frac{1}{4}, \mathsf{*.f64}\left(m, m\right)\right)\right)\right) \]
      12. *-commutativeN/A

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

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

        \[\leadsto \mathsf{/.f64}\left(\mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\mathsf{*.f64}\left(M, M\right), \mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{*.f64}\left(M, M\right), \mathsf{+.f64}\left(\frac{1}{24}, \mathsf{*.f64}\left(\left(M \cdot M\right), \frac{-1}{720}\right)\right)\right), \frac{-1}{2}\right)\right)\right), \mathsf{exp.f64}\left(\mathsf{*.f64}\left(\frac{1}{4}, \mathsf{*.f64}\left(m, m\right)\right)\right)\right) \]
      15. *-lowering-*.f6462.2%

        \[\leadsto \mathsf{/.f64}\left(\mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\mathsf{*.f64}\left(M, M\right), \mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{*.f64}\left(M, M\right), \mathsf{+.f64}\left(\frac{1}{24}, \mathsf{*.f64}\left(\mathsf{*.f64}\left(M, M\right), \frac{-1}{720}\right)\right)\right), \frac{-1}{2}\right)\right)\right), \mathsf{exp.f64}\left(\mathsf{*.f64}\left(\frac{1}{4}, \mathsf{*.f64}\left(m, m\right)\right)\right)\right) \]
    13. Simplified62.2%

      \[\leadsto \frac{\color{blue}{1 + \left(M \cdot M\right) \cdot \left(\left(M \cdot M\right) \cdot \left(0.041666666666666664 + \left(M \cdot M\right) \cdot -0.001388888888888889\right) + -0.5\right)}}{e^{0.25 \cdot \left(m \cdot m\right)}} \]
    14. Taylor expanded in M around inf

      \[\leadsto \color{blue}{\frac{-1}{720} \cdot \frac{{M}^{6}}{e^{\frac{1}{4} \cdot {m}^{2}}}} \]
    15. Step-by-step derivation
      1. associate-*r/N/A

        \[\leadsto \frac{\frac{-1}{720} \cdot {M}^{6}}{\color{blue}{e^{\frac{1}{4} \cdot {m}^{2}}}} \]
      2. /-lowering-/.f64N/A

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

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

        \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(\frac{-1}{720}, \mathsf{pow.f64}\left(M, 6\right)\right), \left(e^{\frac{1}{4} \cdot \color{blue}{{m}^{2}}}\right)\right) \]
      5. exp-lowering-exp.f64N/A

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

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

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

        \[\leadsto \mathsf{/.f64}\left(\mathsf{*.f64}\left(\frac{-1}{720}, \mathsf{pow.f64}\left(M, 6\right)\right), \mathsf{exp.f64}\left(\mathsf{*.f64}\left(\frac{1}{4}, \mathsf{*.f64}\left(m, m\right)\right)\right)\right) \]
    16. Simplified81.3%

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

Alternative 3: 64.6% accurate, 2.0× speedup?

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

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

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

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


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

    1. Initial program 68.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \mathsf{/.f64}\left(\mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\left({M}^{2}\right), \left({M}^{2} \cdot \left(\frac{1}{24} + \frac{-1}{720} \cdot {M}^{2}\right) - \frac{1}{2}\right)\right)\right), \mathsf{exp.f64}\left(\mathsf{*.f64}\left(\frac{1}{4}, \color{blue}{\mathsf{*.f64}\left(m, m\right)}\right)\right)\right) \]
      3. unpow2N/A

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

        \[\leadsto \mathsf{/.f64}\left(\mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\mathsf{*.f64}\left(M, M\right), \left({M}^{2} \cdot \left(\frac{1}{24} + \frac{-1}{720} \cdot {M}^{2}\right) - \frac{1}{2}\right)\right)\right), \mathsf{exp.f64}\left(\mathsf{*.f64}\left(\frac{1}{4}, \mathsf{*.f64}\left(\color{blue}{m}, m\right)\right)\right)\right) \]
      5. sub-negN/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\mathsf{*.f64}\left(M, M\right), \left({M}^{2} \cdot \left(\frac{1}{24} + \frac{-1}{720} \cdot {M}^{2}\right) + \left(\mathsf{neg}\left(\frac{1}{2}\right)\right)\right)\right)\right), \mathsf{exp.f64}\left(\mathsf{*.f64}\left(\frac{1}{4}, \mathsf{*.f64}\left(m, \color{blue}{m}\right)\right)\right)\right) \]
      6. metadata-evalN/A

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

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

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

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

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

        \[\leadsto \mathsf{/.f64}\left(\mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\mathsf{*.f64}\left(M, M\right), \mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{*.f64}\left(M, M\right), \mathsf{+.f64}\left(\frac{1}{24}, \left(\frac{-1}{720} \cdot {M}^{2}\right)\right)\right), \frac{-1}{2}\right)\right)\right), \mathsf{exp.f64}\left(\mathsf{*.f64}\left(\frac{1}{4}, \mathsf{*.f64}\left(m, m\right)\right)\right)\right) \]
      12. *-commutativeN/A

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

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

        \[\leadsto \mathsf{/.f64}\left(\mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\mathsf{*.f64}\left(M, M\right), \mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{*.f64}\left(M, M\right), \mathsf{+.f64}\left(\frac{1}{24}, \mathsf{*.f64}\left(\left(M \cdot M\right), \frac{-1}{720}\right)\right)\right), \frac{-1}{2}\right)\right)\right), \mathsf{exp.f64}\left(\mathsf{*.f64}\left(\frac{1}{4}, \mathsf{*.f64}\left(m, m\right)\right)\right)\right) \]
      15. *-lowering-*.f6455.8%

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

      \[\leadsto \frac{\color{blue}{1 + \left(M \cdot M\right) \cdot \left(\left(M \cdot M\right) \cdot \left(0.041666666666666664 + \left(M \cdot M\right) \cdot -0.001388888888888889\right) + -0.5\right)}}{e^{0.25 \cdot \left(m \cdot m\right)}} \]
    14. Taylor expanded in M around 0

      \[\leadsto \color{blue}{\frac{1}{e^{\frac{1}{4} \cdot {m}^{2}}}} \]
    15. Step-by-step derivation
      1. rec-expN/A

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

        \[\leadsto \mathsf{exp.f64}\left(\left(\mathsf{neg}\left(\frac{1}{4} \cdot {m}^{2}\right)\right)\right) \]
      3. distribute-lft-neg-inN/A

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

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

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

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

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

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

    if -0.880000000000000004 < m < -6.6000000000000006e-266

    1. Initial program 72.1%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -6.6000000000000006e-266 < m

    1. Initial program 80.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. neg-sub0N/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 4: 64.6% accurate, 2.0× speedup?

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

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

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

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


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

    1. Initial program 68.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \mathsf{/.f64}\left(\mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\left({M}^{2}\right), \left({M}^{2} \cdot \left(\frac{1}{24} + \frac{-1}{720} \cdot {M}^{2}\right) - \frac{1}{2}\right)\right)\right), \mathsf{exp.f64}\left(\mathsf{*.f64}\left(\frac{1}{4}, \color{blue}{\mathsf{*.f64}\left(m, m\right)}\right)\right)\right) \]
      3. unpow2N/A

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

        \[\leadsto \mathsf{/.f64}\left(\mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\mathsf{*.f64}\left(M, M\right), \left({M}^{2} \cdot \left(\frac{1}{24} + \frac{-1}{720} \cdot {M}^{2}\right) - \frac{1}{2}\right)\right)\right), \mathsf{exp.f64}\left(\mathsf{*.f64}\left(\frac{1}{4}, \mathsf{*.f64}\left(\color{blue}{m}, m\right)\right)\right)\right) \]
      5. sub-negN/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\mathsf{*.f64}\left(M, M\right), \left({M}^{2} \cdot \left(\frac{1}{24} + \frac{-1}{720} \cdot {M}^{2}\right) + \left(\mathsf{neg}\left(\frac{1}{2}\right)\right)\right)\right)\right), \mathsf{exp.f64}\left(\mathsf{*.f64}\left(\frac{1}{4}, \mathsf{*.f64}\left(m, \color{blue}{m}\right)\right)\right)\right) \]
      6. metadata-evalN/A

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

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

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

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

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

        \[\leadsto \mathsf{/.f64}\left(\mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\mathsf{*.f64}\left(M, M\right), \mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{*.f64}\left(M, M\right), \mathsf{+.f64}\left(\frac{1}{24}, \left(\frac{-1}{720} \cdot {M}^{2}\right)\right)\right), \frac{-1}{2}\right)\right)\right), \mathsf{exp.f64}\left(\mathsf{*.f64}\left(\frac{1}{4}, \mathsf{*.f64}\left(m, m\right)\right)\right)\right) \]
      12. *-commutativeN/A

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

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

        \[\leadsto \mathsf{/.f64}\left(\mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\mathsf{*.f64}\left(M, M\right), \mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{*.f64}\left(M, M\right), \mathsf{+.f64}\left(\frac{1}{24}, \mathsf{*.f64}\left(\left(M \cdot M\right), \frac{-1}{720}\right)\right)\right), \frac{-1}{2}\right)\right)\right), \mathsf{exp.f64}\left(\mathsf{*.f64}\left(\frac{1}{4}, \mathsf{*.f64}\left(m, m\right)\right)\right)\right) \]
      15. *-lowering-*.f6455.8%

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

      \[\leadsto \frac{\color{blue}{1 + \left(M \cdot M\right) \cdot \left(\left(M \cdot M\right) \cdot \left(0.041666666666666664 + \left(M \cdot M\right) \cdot -0.001388888888888889\right) + -0.5\right)}}{e^{0.25 \cdot \left(m \cdot m\right)}} \]
    14. Taylor expanded in M around 0

      \[\leadsto \color{blue}{\frac{1}{e^{\frac{1}{4} \cdot {m}^{2}}}} \]
    15. Step-by-step derivation
      1. rec-expN/A

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

        \[\leadsto \mathsf{exp.f64}\left(\left(\mathsf{neg}\left(\frac{1}{4} \cdot {m}^{2}\right)\right)\right) \]
      3. distribute-lft-neg-inN/A

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

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

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

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

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

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

    if -0.880000000000000004 < m < -3.9999999999999999e-266

    1. Initial program 72.1%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    if -3.9999999999999999e-266 < m

    1. Initial program 80.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. neg-sub0N/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{1}{e^{\frac{1}{4} \cdot {n}^{2}}}} \]
    12. Step-by-step derivation
      1. rec-expN/A

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

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

        \[\leadsto \mathsf{exp.f64}\left(\left(\mathsf{neg}\left({n}^{2} \cdot \frac{1}{4}\right)\right)\right) \]
      4. distribute-rgt-neg-inN/A

        \[\leadsto \mathsf{exp.f64}\left(\left({n}^{2} \cdot \left(\mathsf{neg}\left(\frac{1}{4}\right)\right)\right)\right) \]
      5. metadata-evalN/A

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

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

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

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

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

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

Alternative 5: 61.9% accurate, 2.0× speedup?

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

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

\mathbf{elif}\;n \leq 2.5 \cdot 10^{-5}:\\
\;\;\;\;\frac{\cos M}{e^{\ell}}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if n < 1e-281

    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. neg-sub0N/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \mathsf{/.f64}\left(\mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\left({M}^{2}\right), \left({M}^{2} \cdot \left(\frac{1}{24} + \frac{-1}{720} \cdot {M}^{2}\right) - \frac{1}{2}\right)\right)\right), \mathsf{exp.f64}\left(\mathsf{*.f64}\left(\frac{1}{4}, \color{blue}{\mathsf{*.f64}\left(m, m\right)}\right)\right)\right) \]
      3. unpow2N/A

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

        \[\leadsto \mathsf{/.f64}\left(\mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\mathsf{*.f64}\left(M, M\right), \left({M}^{2} \cdot \left(\frac{1}{24} + \frac{-1}{720} \cdot {M}^{2}\right) - \frac{1}{2}\right)\right)\right), \mathsf{exp.f64}\left(\mathsf{*.f64}\left(\frac{1}{4}, \mathsf{*.f64}\left(\color{blue}{m}, m\right)\right)\right)\right) \]
      5. sub-negN/A

        \[\leadsto \mathsf{/.f64}\left(\mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\mathsf{*.f64}\left(M, M\right), \left({M}^{2} \cdot \left(\frac{1}{24} + \frac{-1}{720} \cdot {M}^{2}\right) + \left(\mathsf{neg}\left(\frac{1}{2}\right)\right)\right)\right)\right), \mathsf{exp.f64}\left(\mathsf{*.f64}\left(\frac{1}{4}, \mathsf{*.f64}\left(m, \color{blue}{m}\right)\right)\right)\right) \]
      6. metadata-evalN/A

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

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

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

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

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

        \[\leadsto \mathsf{/.f64}\left(\mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\mathsf{*.f64}\left(M, M\right), \mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{*.f64}\left(M, M\right), \mathsf{+.f64}\left(\frac{1}{24}, \left(\frac{-1}{720} \cdot {M}^{2}\right)\right)\right), \frac{-1}{2}\right)\right)\right), \mathsf{exp.f64}\left(\mathsf{*.f64}\left(\frac{1}{4}, \mathsf{*.f64}\left(m, m\right)\right)\right)\right) \]
      12. *-commutativeN/A

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

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

        \[\leadsto \mathsf{/.f64}\left(\mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\mathsf{*.f64}\left(M, M\right), \mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{*.f64}\left(M, M\right), \mathsf{+.f64}\left(\frac{1}{24}, \mathsf{*.f64}\left(\left(M \cdot M\right), \frac{-1}{720}\right)\right)\right), \frac{-1}{2}\right)\right)\right), \mathsf{exp.f64}\left(\mathsf{*.f64}\left(\frac{1}{4}, \mathsf{*.f64}\left(m, m\right)\right)\right)\right) \]
      15. *-lowering-*.f6439.4%

        \[\leadsto \mathsf{/.f64}\left(\mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\mathsf{*.f64}\left(M, M\right), \mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{*.f64}\left(M, M\right), \mathsf{+.f64}\left(\frac{1}{24}, \mathsf{*.f64}\left(\mathsf{*.f64}\left(M, M\right), \frac{-1}{720}\right)\right)\right), \frac{-1}{2}\right)\right)\right), \mathsf{exp.f64}\left(\mathsf{*.f64}\left(\frac{1}{4}, \mathsf{*.f64}\left(m, m\right)\right)\right)\right) \]
    13. Simplified39.4%

      \[\leadsto \frac{\color{blue}{1 + \left(M \cdot M\right) \cdot \left(\left(M \cdot M\right) \cdot \left(0.041666666666666664 + \left(M \cdot M\right) \cdot -0.001388888888888889\right) + -0.5\right)}}{e^{0.25 \cdot \left(m \cdot m\right)}} \]
    14. Taylor expanded in M around 0

      \[\leadsto \color{blue}{\frac{1}{e^{\frac{1}{4} \cdot {m}^{2}}}} \]
    15. Step-by-step derivation
      1. rec-expN/A

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

        \[\leadsto \mathsf{exp.f64}\left(\left(\mathsf{neg}\left(\frac{1}{4} \cdot {m}^{2}\right)\right)\right) \]
      3. distribute-lft-neg-inN/A

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

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

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

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

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

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

    if 1e-281 < n < 2.50000000000000012e-5

    1. Initial program 84.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      if 2.50000000000000012e-5 < n

      1. Initial program 70.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{\frac{1}{e^{\frac{1}{4} \cdot {n}^{2}}}} \]
      12. Step-by-step derivation
        1. rec-expN/A

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

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

          \[\leadsto \mathsf{exp.f64}\left(\left(\mathsf{neg}\left({n}^{2} \cdot \frac{1}{4}\right)\right)\right) \]
        4. distribute-rgt-neg-inN/A

          \[\leadsto \mathsf{exp.f64}\left(\left({n}^{2} \cdot \left(\mathsf{neg}\left(\frac{1}{4}\right)\right)\right)\right) \]
        5. metadata-evalN/A

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

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

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

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

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

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

    Alternative 6: 66.7% accurate, 3.7× speedup?

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

      1. Initial program 72.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

          \[\leadsto \mathsf{/.f64}\left(\mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\left({M}^{2}\right), \left({M}^{2} \cdot \left(\frac{1}{24} + \frac{-1}{720} \cdot {M}^{2}\right) - \frac{1}{2}\right)\right)\right), \mathsf{exp.f64}\left(\mathsf{*.f64}\left(\frac{1}{4}, \color{blue}{\mathsf{*.f64}\left(m, m\right)}\right)\right)\right) \]
        3. unpow2N/A

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

          \[\leadsto \mathsf{/.f64}\left(\mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\mathsf{*.f64}\left(M, M\right), \left({M}^{2} \cdot \left(\frac{1}{24} + \frac{-1}{720} \cdot {M}^{2}\right) - \frac{1}{2}\right)\right)\right), \mathsf{exp.f64}\left(\mathsf{*.f64}\left(\frac{1}{4}, \mathsf{*.f64}\left(\color{blue}{m}, m\right)\right)\right)\right) \]
        5. sub-negN/A

          \[\leadsto \mathsf{/.f64}\left(\mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\mathsf{*.f64}\left(M, M\right), \left({M}^{2} \cdot \left(\frac{1}{24} + \frac{-1}{720} \cdot {M}^{2}\right) + \left(\mathsf{neg}\left(\frac{1}{2}\right)\right)\right)\right)\right), \mathsf{exp.f64}\left(\mathsf{*.f64}\left(\frac{1}{4}, \mathsf{*.f64}\left(m, \color{blue}{m}\right)\right)\right)\right) \]
        6. metadata-evalN/A

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

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

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

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

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

          \[\leadsto \mathsf{/.f64}\left(\mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\mathsf{*.f64}\left(M, M\right), \mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{*.f64}\left(M, M\right), \mathsf{+.f64}\left(\frac{1}{24}, \left(\frac{-1}{720} \cdot {M}^{2}\right)\right)\right), \frac{-1}{2}\right)\right)\right), \mathsf{exp.f64}\left(\mathsf{*.f64}\left(\frac{1}{4}, \mathsf{*.f64}\left(m, m\right)\right)\right)\right) \]
        12. *-commutativeN/A

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

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

          \[\leadsto \mathsf{/.f64}\left(\mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\mathsf{*.f64}\left(M, M\right), \mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{*.f64}\left(M, M\right), \mathsf{+.f64}\left(\frac{1}{24}, \mathsf{*.f64}\left(\left(M \cdot M\right), \frac{-1}{720}\right)\right)\right), \frac{-1}{2}\right)\right)\right), \mathsf{exp.f64}\left(\mathsf{*.f64}\left(\frac{1}{4}, \mathsf{*.f64}\left(m, m\right)\right)\right)\right) \]
        15. *-lowering-*.f6458.9%

          \[\leadsto \mathsf{/.f64}\left(\mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\mathsf{*.f64}\left(M, M\right), \mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{*.f64}\left(M, M\right), \mathsf{+.f64}\left(\frac{1}{24}, \mathsf{*.f64}\left(\mathsf{*.f64}\left(M, M\right), \frac{-1}{720}\right)\right)\right), \frac{-1}{2}\right)\right)\right), \mathsf{exp.f64}\left(\mathsf{*.f64}\left(\frac{1}{4}, \mathsf{*.f64}\left(m, m\right)\right)\right)\right) \]
      13. Simplified58.9%

        \[\leadsto \frac{\color{blue}{1 + \left(M \cdot M\right) \cdot \left(\left(M \cdot M\right) \cdot \left(0.041666666666666664 + \left(M \cdot M\right) \cdot -0.001388888888888889\right) + -0.5\right)}}{e^{0.25 \cdot \left(m \cdot m\right)}} \]
      14. Taylor expanded in M around 0

        \[\leadsto \color{blue}{\frac{1}{e^{\frac{1}{4} \cdot {m}^{2}}}} \]
      15. Step-by-step derivation
        1. rec-expN/A

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

          \[\leadsto \mathsf{exp.f64}\left(\left(\mathsf{neg}\left(\frac{1}{4} \cdot {m}^{2}\right)\right)\right) \]
        3. distribute-lft-neg-inN/A

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

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

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

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

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

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

      if -0.880000000000000004 < m < 54

      1. Initial program 79.8%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

            \[\leadsto \mathsf{/.f64}\left(\mathsf{cos.f64}\left(M\right), \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\ell, \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\ell, \mathsf{+.f64}\left(\frac{1}{2}, \left(\ell \cdot \color{blue}{\frac{1}{6}}\right)\right)\right)\right)\right)\right)\right) \]
          10. *-lowering-*.f6435.6%

            \[\leadsto \mathsf{/.f64}\left(\mathsf{cos.f64}\left(M\right), \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\ell, \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\ell, \mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(\ell, \color{blue}{\frac{1}{6}}\right)\right)\right)\right)\right)\right)\right) \]
        7. Simplified35.6%

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

          \[\leadsto \mathsf{/.f64}\left(\color{blue}{1}, \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\ell, \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\ell, \mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(\ell, \frac{1}{6}\right)\right)\right)\right)\right)\right)\right) \]
        9. Step-by-step derivation
          1. Simplified35.6%

            \[\leadsto \frac{\color{blue}{1}}{1 + \ell \cdot \left(1 + \ell \cdot \left(0.5 + \ell \cdot 0.16666666666666666\right)\right)} \]
        10. Recombined 2 regimes into one program.
        11. Final simplification69.9%

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

        Alternative 7: 64.3% accurate, 3.9× speedup?

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

          1. Initial program 69.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

              \[\leadsto \mathsf{/.f64}\left(\mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\left({M}^{2}\right), \left({M}^{2} \cdot \left(\frac{1}{24} + \frac{-1}{720} \cdot {M}^{2}\right) - \frac{1}{2}\right)\right)\right), \mathsf{exp.f64}\left(\mathsf{*.f64}\left(\frac{1}{4}, \color{blue}{\mathsf{*.f64}\left(m, m\right)}\right)\right)\right) \]
            3. unpow2N/A

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

              \[\leadsto \mathsf{/.f64}\left(\mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\mathsf{*.f64}\left(M, M\right), \left({M}^{2} \cdot \left(\frac{1}{24} + \frac{-1}{720} \cdot {M}^{2}\right) - \frac{1}{2}\right)\right)\right), \mathsf{exp.f64}\left(\mathsf{*.f64}\left(\frac{1}{4}, \mathsf{*.f64}\left(\color{blue}{m}, m\right)\right)\right)\right) \]
            5. sub-negN/A

              \[\leadsto \mathsf{/.f64}\left(\mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\mathsf{*.f64}\left(M, M\right), \left({M}^{2} \cdot \left(\frac{1}{24} + \frac{-1}{720} \cdot {M}^{2}\right) + \left(\mathsf{neg}\left(\frac{1}{2}\right)\right)\right)\right)\right), \mathsf{exp.f64}\left(\mathsf{*.f64}\left(\frac{1}{4}, \mathsf{*.f64}\left(m, \color{blue}{m}\right)\right)\right)\right) \]
            6. metadata-evalN/A

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

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

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

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

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

              \[\leadsto \mathsf{/.f64}\left(\mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\mathsf{*.f64}\left(M, M\right), \mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{*.f64}\left(M, M\right), \mathsf{+.f64}\left(\frac{1}{24}, \left(\frac{-1}{720} \cdot {M}^{2}\right)\right)\right), \frac{-1}{2}\right)\right)\right), \mathsf{exp.f64}\left(\mathsf{*.f64}\left(\frac{1}{4}, \mathsf{*.f64}\left(m, m\right)\right)\right)\right) \]
            12. *-commutativeN/A

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

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

              \[\leadsto \mathsf{/.f64}\left(\mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\mathsf{*.f64}\left(M, M\right), \mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{*.f64}\left(M, M\right), \mathsf{+.f64}\left(\frac{1}{24}, \mathsf{*.f64}\left(\left(M \cdot M\right), \frac{-1}{720}\right)\right)\right), \frac{-1}{2}\right)\right)\right), \mathsf{exp.f64}\left(\mathsf{*.f64}\left(\frac{1}{4}, \mathsf{*.f64}\left(m, m\right)\right)\right)\right) \]
            15. *-lowering-*.f6455.0%

              \[\leadsto \mathsf{/.f64}\left(\mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\mathsf{*.f64}\left(M, M\right), \mathsf{+.f64}\left(\mathsf{*.f64}\left(\mathsf{*.f64}\left(M, M\right), \mathsf{+.f64}\left(\frac{1}{24}, \mathsf{*.f64}\left(\mathsf{*.f64}\left(M, M\right), \frac{-1}{720}\right)\right)\right), \frac{-1}{2}\right)\right)\right), \mathsf{exp.f64}\left(\mathsf{*.f64}\left(\frac{1}{4}, \mathsf{*.f64}\left(m, m\right)\right)\right)\right) \]
          13. Simplified55.0%

            \[\leadsto \frac{\color{blue}{1 + \left(M \cdot M\right) \cdot \left(\left(M \cdot M\right) \cdot \left(0.041666666666666664 + \left(M \cdot M\right) \cdot -0.001388888888888889\right) + -0.5\right)}}{e^{0.25 \cdot \left(m \cdot m\right)}} \]
          14. Taylor expanded in M around 0

            \[\leadsto \color{blue}{\frac{1}{e^{\frac{1}{4} \cdot {m}^{2}}}} \]
          15. Step-by-step derivation
            1. rec-expN/A

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

              \[\leadsto \mathsf{exp.f64}\left(\left(\mathsf{neg}\left(\frac{1}{4} \cdot {m}^{2}\right)\right)\right) \]
            3. distribute-lft-neg-inN/A

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

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

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

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

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

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

          if -0.095000000000000001 < m

          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. neg-sub0N/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

            \[\leadsto \color{blue}{\frac{1}{e^{\frac{1}{4} \cdot {n}^{2}}}} \]
          12. Step-by-step derivation
            1. rec-expN/A

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

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

              \[\leadsto \mathsf{exp.f64}\left(\left(\mathsf{neg}\left({n}^{2} \cdot \frac{1}{4}\right)\right)\right) \]
            4. distribute-rgt-neg-inN/A

              \[\leadsto \mathsf{exp.f64}\left(\left({n}^{2} \cdot \left(\mathsf{neg}\left(\frac{1}{4}\right)\right)\right)\right) \]
            5. metadata-evalN/A

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

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

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

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

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

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

        Alternative 8: 34.0% accurate, 28.3× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

              \[\leadsto \mathsf{/.f64}\left(\mathsf{cos.f64}\left(M\right), \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\ell, \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\ell, \mathsf{+.f64}\left(\frac{1}{2}, \left(\ell \cdot \color{blue}{\frac{1}{6}}\right)\right)\right)\right)\right)\right)\right) \]
            10. *-lowering-*.f6433.1%

              \[\leadsto \mathsf{/.f64}\left(\mathsf{cos.f64}\left(M\right), \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\ell, \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\ell, \mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(\ell, \color{blue}{\frac{1}{6}}\right)\right)\right)\right)\right)\right)\right) \]
          7. Simplified33.1%

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

            \[\leadsto \mathsf{/.f64}\left(\color{blue}{1}, \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\ell, \mathsf{+.f64}\left(1, \mathsf{*.f64}\left(\ell, \mathsf{+.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(\ell, \frac{1}{6}\right)\right)\right)\right)\right)\right)\right) \]
          9. Step-by-step derivation
            1. Simplified33.1%

              \[\leadsto \frac{\color{blue}{1}}{1 + \ell \cdot \left(1 + \ell \cdot \left(0.5 + \ell \cdot 0.16666666666666666\right)\right)} \]
            2. Add Preprocessing

            Alternative 9: 6.8% 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 75.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                \[\leadsto \mathsf{cos.f64}\left(\mathsf{\_.f64}\left(\mathsf{*.f64}\left(\frac{1}{2}, \mathsf{*.f64}\left(n, K\right)\right), M\right)\right) \]
            10. Simplified5.0%

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

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

                \[\leadsto \cos M \]
              2. cos-lowering-cos.f645.5%

                \[\leadsto \mathsf{cos.f64}\left(M\right) \]
            13. Simplified5.5%

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

              \[\leadsto \color{blue}{1} \]
            15. Step-by-step derivation
              1. Simplified5.5%

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

              Reproduce

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