Maksimov and Kolovsky, Equation (32)

Percentage Accurate: 76.7% → 96.7%
Time: 18.7s
Alternatives: 6
Speedup: 1.3×

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 6 alternatives:

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

Initial Program: 76.7% 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.7% accurate, 1.0× speedup?

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

\\
\cos M \cdot e^{\left(\left|m - n\right| - \ell\right) - {\left(\frac{m + n}{2} - M\right)}^{2}}
\end{array}
Derivation
  1. Initial program 68.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. Taylor expanded in K around 0 97.0%

    \[\leadsto \color{blue}{\cos \left(-M\right)} \cdot e^{\left(-{\left(\frac{m + n}{2} - M\right)}^{2}\right) - \left(\ell - \left|m - n\right|\right)} \]
  3. Step-by-step derivation
    1. cos-neg97.0%

      \[\leadsto \color{blue}{\cos M} \cdot e^{\left(-{\left(\frac{m + n}{2} - M\right)}^{2}\right) - \left(\ell - \left|m - n\right|\right)} \]
  4. Simplified97.0%

    \[\leadsto \color{blue}{\cos M} \cdot e^{\left(-{\left(\frac{m + n}{2} - M\right)}^{2}\right) - \left(\ell - \left|m - n\right|\right)} \]
  5. Final simplification97.0%

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

Alternative 2: 82.3% accurate, 1.3× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;M \leq -0.04 \lor \neg \left(M \leq 27\right):\\ \;\;\;\;\cos M \cdot e^{M \cdot \left(-M\right)}\\ \mathbf{else}:\\ \;\;\;\;\cos M \cdot e^{\left(\left|m - n\right| - \ell\right) - \left(m \cdot m\right) \cdot 0.25}\\ \end{array} \end{array} \]
(FPCore (K m n M l)
 :precision binary64
 (if (or (<= M -0.04) (not (<= M 27.0)))
   (* (cos M) (exp (* M (- M))))
   (* (cos M) (exp (- (- (fabs (- m n)) l) (* (* m m) 0.25))))))
double code(double K, double m, double n, double M, double l) {
	double tmp;
	if ((M <= -0.04) || !(M <= 27.0)) {
		tmp = cos(M) * exp((M * -M));
	} else {
		tmp = cos(M) * exp(((fabs((m - n)) - l) - ((m * m) * 0.25)));
	}
	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_1 <= (-0.04d0)) .or. (.not. (m_1 <= 27.0d0))) then
        tmp = cos(m_1) * exp((m_1 * -m_1))
    else
        tmp = cos(m_1) * exp(((abs((m - n)) - l) - ((m * m) * 0.25d0)))
    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.04) || !(M <= 27.0)) {
		tmp = Math.cos(M) * Math.exp((M * -M));
	} else {
		tmp = Math.cos(M) * Math.exp(((Math.abs((m - n)) - l) - ((m * m) * 0.25)));
	}
	return tmp;
}
def code(K, m, n, M, l):
	tmp = 0
	if (M <= -0.04) or not (M <= 27.0):
		tmp = math.cos(M) * math.exp((M * -M))
	else:
		tmp = math.cos(M) * math.exp(((math.fabs((m - n)) - l) - ((m * m) * 0.25)))
	return tmp
function code(K, m, n, M, l)
	tmp = 0.0
	if ((M <= -0.04) || !(M <= 27.0))
		tmp = Float64(cos(M) * exp(Float64(M * Float64(-M))));
	else
		tmp = Float64(cos(M) * exp(Float64(Float64(abs(Float64(m - n)) - l) - Float64(Float64(m * m) * 0.25))));
	end
	return tmp
end
function tmp_2 = code(K, m, n, M, l)
	tmp = 0.0;
	if ((M <= -0.04) || ~((M <= 27.0)))
		tmp = cos(M) * exp((M * -M));
	else
		tmp = cos(M) * exp(((abs((m - n)) - l) - ((m * m) * 0.25)));
	end
	tmp_2 = tmp;
end
code[K_, m_, n_, M_, l_] := If[Or[LessEqual[M, -0.04], N[Not[LessEqual[M, 27.0]], $MachinePrecision]], N[(N[Cos[M], $MachinePrecision] * N[Exp[N[(M * (-M)), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(N[Cos[M], $MachinePrecision] * N[Exp[N[(N[(N[Abs[N[(m - n), $MachinePrecision]], $MachinePrecision] - l), $MachinePrecision] - N[(N[(m * m), $MachinePrecision] * 0.25), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;M \leq -0.04 \lor \neg \left(M \leq 27\right):\\
\;\;\;\;\cos M \cdot e^{M \cdot \left(-M\right)}\\

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


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

    1. Initial program 68.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. Taylor expanded in M around inf 58.1%

      \[\leadsto \cos \left(\frac{K \cdot \left(m + n\right)}{2} - M\right) \cdot e^{\left(-\color{blue}{{M}^{2}}\right) - \left(\ell - \left|m - n\right|\right)} \]
    3. Step-by-step derivation
      1. unpow258.1%

        \[\leadsto \cos \left(\frac{K \cdot \left(m + n\right)}{2} - M\right) \cdot e^{\left(-\color{blue}{M \cdot M}\right) - \left(\ell - \left|m - n\right|\right)} \]
    4. Simplified58.1%

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

      \[\leadsto \color{blue}{\left(\cos \left(-M\right) + -0.5 \cdot \left(K \cdot \left(\sin \left(-M\right) \cdot \left(n + m\right)\right)\right)\right)} \cdot e^{\left(-M \cdot M\right) - \left(\ell - \left|m - n\right|\right)} \]
    6. Step-by-step derivation
      1. cos-neg59.2%

        \[\leadsto \left(\color{blue}{\cos M} + -0.5 \cdot \left(K \cdot \left(\sin \left(-M\right) \cdot \left(n + m\right)\right)\right)\right) \cdot e^{\left(-M \cdot M\right) - \left(\ell - \left|m - n\right|\right)} \]
      2. +-commutative59.2%

        \[\leadsto \color{blue}{\left(-0.5 \cdot \left(K \cdot \left(\sin \left(-M\right) \cdot \left(n + m\right)\right)\right) + \cos M\right)} \cdot e^{\left(-M \cdot M\right) - \left(\ell - \left|m - n\right|\right)} \]
      3. associate-*r*59.2%

        \[\leadsto \left(-0.5 \cdot \color{blue}{\left(\left(K \cdot \sin \left(-M\right)\right) \cdot \left(n + m\right)\right)} + \cos M\right) \cdot e^{\left(-M \cdot M\right) - \left(\ell - \left|m - n\right|\right)} \]
      4. sin-neg59.2%

        \[\leadsto \left(-0.5 \cdot \left(\left(K \cdot \color{blue}{\left(-\sin M\right)}\right) \cdot \left(n + m\right)\right) + \cos M\right) \cdot e^{\left(-M \cdot M\right) - \left(\ell - \left|m - n\right|\right)} \]
    7. Simplified59.2%

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

      \[\leadsto \color{blue}{e^{\left|m - n\right| - \left(\ell + {M}^{2}\right)} \cdot \cos M} \]
    9. Step-by-step derivation
      1. cos-neg77.0%

        \[\leadsto e^{\left|m - n\right| - \left(\ell + {M}^{2}\right)} \cdot \color{blue}{\cos \left(-M\right)} \]
      2. *-commutative77.0%

        \[\leadsto \color{blue}{\cos \left(-M\right) \cdot e^{\left|m - n\right| - \left(\ell + {M}^{2}\right)}} \]
      3. cos-neg77.0%

        \[\leadsto \color{blue}{\cos M} \cdot e^{\left|m - n\right| - \left(\ell + {M}^{2}\right)} \]
      4. exp-diff27.2%

        \[\leadsto \cos M \cdot \color{blue}{\frac{e^{\left|m - n\right|}}{e^{\ell + {M}^{2}}}} \]
      5. fabs-sub27.2%

        \[\leadsto \cos M \cdot \frac{e^{\color{blue}{\left|n - m\right|}}}{e^{\ell + {M}^{2}}} \]
      6. sub-neg27.2%

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

        \[\leadsto \cos M \cdot \frac{e^{\left|n + \color{blue}{-1 \cdot m}\right|}}{e^{\ell + {M}^{2}}} \]
      8. fabs-neg27.2%

        \[\leadsto \cos M \cdot \frac{e^{\color{blue}{\left|-\left(n + -1 \cdot m\right)\right|}}}{e^{\ell + {M}^{2}}} \]
      9. exp-diff77.0%

        \[\leadsto \cos M \cdot \color{blue}{e^{\left|-\left(n + -1 \cdot m\right)\right| - \left(\ell + {M}^{2}\right)}} \]
      10. fabs-neg77.0%

        \[\leadsto \cos M \cdot e^{\color{blue}{\left|n + -1 \cdot m\right|} - \left(\ell + {M}^{2}\right)} \]
      11. mul-1-neg77.0%

        \[\leadsto \cos M \cdot e^{\left|n + \color{blue}{\left(-m\right)}\right| - \left(\ell + {M}^{2}\right)} \]
      12. sub-neg77.0%

        \[\leadsto \cos M \cdot e^{\left|\color{blue}{n - m}\right| - \left(\ell + {M}^{2}\right)} \]
      13. +-commutative77.0%

        \[\leadsto \cos M \cdot e^{\left|n - m\right| - \color{blue}{\left({M}^{2} + \ell\right)}} \]
      14. unpow277.0%

        \[\leadsto \cos M \cdot e^{\left|n - m\right| - \left(\color{blue}{M \cdot M} + \ell\right)} \]
    10. Simplified77.0%

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

      \[\leadsto \cos M \cdot e^{\color{blue}{-1 \cdot {M}^{2}}} \]
    12. Step-by-step derivation
      1. unpow299.1%

        \[\leadsto \cos M \cdot e^{-1 \cdot \color{blue}{\left(M \cdot M\right)}} \]
      2. mul-1-neg99.1%

        \[\leadsto \cos M \cdot e^{\color{blue}{-M \cdot M}} \]
      3. distribute-rgt-neg-in99.1%

        \[\leadsto \cos M \cdot e^{\color{blue}{M \cdot \left(-M\right)}} \]
    13. Simplified99.1%

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

    if -0.0400000000000000008 < M < 27

    1. Initial program 68.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. Taylor expanded in K around 0 95.5%

      \[\leadsto \color{blue}{\cos \left(-M\right)} \cdot e^{\left(-{\left(\frac{m + n}{2} - M\right)}^{2}\right) - \left(\ell - \left|m - n\right|\right)} \]
    3. Step-by-step derivation
      1. cos-neg95.5%

        \[\leadsto \color{blue}{\cos M} \cdot e^{\left(-{\left(\frac{m + n}{2} - M\right)}^{2}\right) - \left(\ell - \left|m - n\right|\right)} \]
    4. Simplified95.5%

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

      \[\leadsto \cos M \cdot e^{\left(-\color{blue}{0.25 \cdot {m}^{2}}\right) - \left(\ell - \left|m - n\right|\right)} \]
    6. Step-by-step derivation
      1. *-commutative60.5%

        \[\leadsto \cos M \cdot e^{\left(-\color{blue}{{m}^{2} \cdot 0.25}\right) - \left(\ell - \left|m - n\right|\right)} \]
      2. unpow260.5%

        \[\leadsto \cos M \cdot e^{\left(-\color{blue}{\left(m \cdot m\right)} \cdot 0.25\right) - \left(\ell - \left|m - n\right|\right)} \]
    7. Simplified60.5%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;M \leq -0.04 \lor \neg \left(M \leq 27\right):\\ \;\;\;\;\cos M \cdot e^{M \cdot \left(-M\right)}\\ \mathbf{else}:\\ \;\;\;\;\cos M \cdot e^{\left(\left|m - n\right| - \ell\right) - \left(m \cdot m\right) \cdot 0.25}\\ \end{array} \]

Alternative 3: 68.8% accurate, 1.3× speedup?

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

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

\mathbf{elif}\;n \leq 6700000000000:\\
\;\;\;\;\cos \left(n \cdot \left(0.5 \cdot K\right)\right) \cdot e^{M \cdot \left(-M\right)}\\

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


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

    1. Initial program 71.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. Taylor expanded in K around 0 95.7%

      \[\leadsto \color{blue}{\cos \left(-M\right)} \cdot e^{\left(-{\left(\frac{m + n}{2} - M\right)}^{2}\right) - \left(\ell - \left|m - n\right|\right)} \]
    3. Step-by-step derivation
      1. cos-neg95.7%

        \[\leadsto \color{blue}{\cos M} \cdot e^{\left(-{\left(\frac{m + n}{2} - M\right)}^{2}\right) - \left(\ell - \left|m - n\right|\right)} \]
    4. Simplified95.7%

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

      \[\leadsto \cos M \cdot e^{\left(-\color{blue}{0.25 \cdot {m}^{2}}\right) - \left(\ell - \left|m - n\right|\right)} \]
    6. Step-by-step derivation
      1. *-commutative61.3%

        \[\leadsto \cos M \cdot e^{\left(-\color{blue}{{m}^{2} \cdot 0.25}\right) - \left(\ell - \left|m - n\right|\right)} \]
      2. unpow261.3%

        \[\leadsto \cos M \cdot e^{\left(-\color{blue}{\left(m \cdot m\right)} \cdot 0.25\right) - \left(\ell - \left|m - n\right|\right)} \]
    7. Simplified61.3%

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

    if 2.1e-157 < n < 6.7e12

    1. Initial program 69.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. Taylor expanded in M around inf 59.6%

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

        \[\leadsto \cos \left(\frac{K \cdot \left(m + n\right)}{2} - M\right) \cdot e^{\left(-\color{blue}{M \cdot M}\right) - \left(\ell - \left|m - n\right|\right)} \]
    4. Simplified59.6%

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

      \[\leadsto \cos \left(\frac{K \cdot \left(m + n\right)}{2} - M\right) \cdot e^{\color{blue}{-1 \cdot {M}^{2}}} \]
    6. Step-by-step derivation
      1. unpow257.3%

        \[\leadsto \cos \left(\frac{K \cdot \left(m + n\right)}{2} - M\right) \cdot e^{-1 \cdot \color{blue}{\left(M \cdot M\right)}} \]
      2. mul-1-neg57.3%

        \[\leadsto \cos \left(\frac{K \cdot \left(m + n\right)}{2} - M\right) \cdot e^{\color{blue}{-M \cdot M}} \]
      3. distribute-rgt-neg-out57.3%

        \[\leadsto \cos \left(\frac{K \cdot \left(m + n\right)}{2} - M\right) \cdot e^{\color{blue}{M \cdot \left(-M\right)}} \]
    7. Simplified57.3%

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

      \[\leadsto \cos \color{blue}{\left(0.5 \cdot \left(n \cdot K\right)\right)} \cdot e^{M \cdot \left(-M\right)} \]
    9. Step-by-step derivation
      1. *-commutative80.5%

        \[\leadsto \cos \color{blue}{\left(\left(n \cdot K\right) \cdot 0.5\right)} \cdot e^{M \cdot \left(-M\right)} \]
      2. associate-*l*80.5%

        \[\leadsto \cos \color{blue}{\left(n \cdot \left(K \cdot 0.5\right)\right)} \cdot e^{M \cdot \left(-M\right)} \]
      3. *-commutative80.5%

        \[\leadsto \cos \left(n \cdot \color{blue}{\left(0.5 \cdot K\right)}\right) \cdot e^{M \cdot \left(-M\right)} \]
    10. Simplified80.5%

      \[\leadsto \cos \color{blue}{\left(n \cdot \left(0.5 \cdot K\right)\right)} \cdot e^{M \cdot \left(-M\right)} \]

    if 6.7e12 < n

    1. Initial program 60.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. Taylor expanded in K around 0 100.0%

      \[\leadsto \color{blue}{\cos \left(-M\right)} \cdot e^{\left(-{\left(\frac{m + n}{2} - M\right)}^{2}\right) - \left(\ell - \left|m - n\right|\right)} \]
    3. Step-by-step derivation
      1. cos-neg100.0%

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

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

      \[\leadsto \cos M \cdot e^{\left(-\color{blue}{0.25 \cdot {n}^{2}}\right) - \left(\ell - \left|m - n\right|\right)} \]
    6. Step-by-step derivation
      1. *-commutative55.1%

        \[\leadsto \cos \left(\frac{K \cdot \left(m + n\right)}{2} - M\right) \cdot e^{\left(-\color{blue}{{n}^{2} \cdot 0.25}\right) - \left(\ell - \left|m - n\right|\right)} \]
      2. unpow255.1%

        \[\leadsto \cos \left(\frac{K \cdot \left(m + n\right)}{2} - M\right) \cdot e^{\left(-\color{blue}{\left(n \cdot n\right)} \cdot 0.25\right) - \left(\ell - \left|m - n\right|\right)} \]
    7. Simplified88.5%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;n \leq 2.1 \cdot 10^{-157}:\\ \;\;\;\;\cos M \cdot e^{\left(\left|m - n\right| - \ell\right) - \left(m \cdot m\right) \cdot 0.25}\\ \mathbf{elif}\;n \leq 6700000000000:\\ \;\;\;\;\cos \left(n \cdot \left(0.5 \cdot K\right)\right) \cdot e^{M \cdot \left(-M\right)}\\ \mathbf{else}:\\ \;\;\;\;\cos M \cdot e^{\left(\left|m - n\right| - \ell\right) - 0.25 \cdot \left(n \cdot n\right)}\\ \end{array} \]

Alternative 4: 68.3% accurate, 1.9× speedup?

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

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

\mathbf{elif}\;M \leq -2.1 \cdot 10^{-231}:\\
\;\;\;\;\cos \left(\frac{\left(m + n\right) \cdot K}{2} - M\right) \cdot e^{n \cdot \left(n \cdot -0.25\right)}\\

\mathbf{elif}\;M \leq 2.6 \cdot 10^{-26}:\\
\;\;\;\;\cos M \cdot e^{-\ell}\\

\mathbf{else}:\\
\;\;\;\;t_0\\


\end{array}
\end{array}
Derivation
  1. Split input into 3 regimes
  2. if M < -1.25000000000000008e-10 or 2.6000000000000001e-26 < M

    1. Initial program 68.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. Taylor expanded in M around inf 55.9%

      \[\leadsto \cos \left(\frac{K \cdot \left(m + n\right)}{2} - M\right) \cdot e^{\left(-\color{blue}{{M}^{2}}\right) - \left(\ell - \left|m - n\right|\right)} \]
    3. Step-by-step derivation
      1. unpow255.9%

        \[\leadsto \cos \left(\frac{K \cdot \left(m + n\right)}{2} - M\right) \cdot e^{\left(-\color{blue}{M \cdot M}\right) - \left(\ell - \left|m - n\right|\right)} \]
    4. Simplified55.9%

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

      \[\leadsto \color{blue}{\left(\cos \left(-M\right) + -0.5 \cdot \left(K \cdot \left(\sin \left(-M\right) \cdot \left(n + m\right)\right)\right)\right)} \cdot e^{\left(-M \cdot M\right) - \left(\ell - \left|m - n\right|\right)} \]
    6. Step-by-step derivation
      1. cos-neg56.1%

        \[\leadsto \left(\color{blue}{\cos M} + -0.5 \cdot \left(K \cdot \left(\sin \left(-M\right) \cdot \left(n + m\right)\right)\right)\right) \cdot e^{\left(-M \cdot M\right) - \left(\ell - \left|m - n\right|\right)} \]
      2. +-commutative56.1%

        \[\leadsto \color{blue}{\left(-0.5 \cdot \left(K \cdot \left(\sin \left(-M\right) \cdot \left(n + m\right)\right)\right) + \cos M\right)} \cdot e^{\left(-M \cdot M\right) - \left(\ell - \left|m - n\right|\right)} \]
      3. associate-*r*56.1%

        \[\leadsto \left(-0.5 \cdot \color{blue}{\left(\left(K \cdot \sin \left(-M\right)\right) \cdot \left(n + m\right)\right)} + \cos M\right) \cdot e^{\left(-M \cdot M\right) - \left(\ell - \left|m - n\right|\right)} \]
      4. sin-neg56.1%

        \[\leadsto \left(-0.5 \cdot \left(\left(K \cdot \color{blue}{\left(-\sin M\right)}\right) \cdot \left(n + m\right)\right) + \cos M\right) \cdot e^{\left(-M \cdot M\right) - \left(\ell - \left|m - n\right|\right)} \]
    7. Simplified56.1%

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

      \[\leadsto \color{blue}{e^{\left|m - n\right| - \left(\ell + {M}^{2}\right)} \cdot \cos M} \]
    9. Step-by-step derivation
      1. cos-neg72.6%

        \[\leadsto e^{\left|m - n\right| - \left(\ell + {M}^{2}\right)} \cdot \color{blue}{\cos \left(-M\right)} \]
      2. *-commutative72.6%

        \[\leadsto \color{blue}{\cos \left(-M\right) \cdot e^{\left|m - n\right| - \left(\ell + {M}^{2}\right)}} \]
      3. cos-neg72.6%

        \[\leadsto \color{blue}{\cos M} \cdot e^{\left|m - n\right| - \left(\ell + {M}^{2}\right)} \]
      4. exp-diff26.2%

        \[\leadsto \cos M \cdot \color{blue}{\frac{e^{\left|m - n\right|}}{e^{\ell + {M}^{2}}}} \]
      5. fabs-sub26.2%

        \[\leadsto \cos M \cdot \frac{e^{\color{blue}{\left|n - m\right|}}}{e^{\ell + {M}^{2}}} \]
      6. sub-neg26.2%

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

        \[\leadsto \cos M \cdot \frac{e^{\left|n + \color{blue}{-1 \cdot m}\right|}}{e^{\ell + {M}^{2}}} \]
      8. fabs-neg26.2%

        \[\leadsto \cos M \cdot \frac{e^{\color{blue}{\left|-\left(n + -1 \cdot m\right)\right|}}}{e^{\ell + {M}^{2}}} \]
      9. exp-diff72.6%

        \[\leadsto \cos M \cdot \color{blue}{e^{\left|-\left(n + -1 \cdot m\right)\right| - \left(\ell + {M}^{2}\right)}} \]
      10. fabs-neg72.6%

        \[\leadsto \cos M \cdot e^{\color{blue}{\left|n + -1 \cdot m\right|} - \left(\ell + {M}^{2}\right)} \]
      11. mul-1-neg72.6%

        \[\leadsto \cos M \cdot e^{\left|n + \color{blue}{\left(-m\right)}\right| - \left(\ell + {M}^{2}\right)} \]
      12. sub-neg72.6%

        \[\leadsto \cos M \cdot e^{\left|\color{blue}{n - m}\right| - \left(\ell + {M}^{2}\right)} \]
      13. +-commutative72.6%

        \[\leadsto \cos M \cdot e^{\left|n - m\right| - \color{blue}{\left({M}^{2} + \ell\right)}} \]
      14. unpow272.6%

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

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

      \[\leadsto \cos M \cdot e^{\color{blue}{-1 \cdot {M}^{2}}} \]
    12. Step-by-step derivation
      1. unpow293.2%

        \[\leadsto \cos M \cdot e^{-1 \cdot \color{blue}{\left(M \cdot M\right)}} \]
      2. mul-1-neg93.2%

        \[\leadsto \cos M \cdot e^{\color{blue}{-M \cdot M}} \]
      3. distribute-rgt-neg-in93.2%

        \[\leadsto \cos M \cdot e^{\color{blue}{M \cdot \left(-M\right)}} \]
    13. Simplified93.2%

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

    if -1.25000000000000008e-10 < M < -2.09999999999999989e-231

    1. Initial program 63.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. Taylor expanded in n around inf 45.4%

      \[\leadsto \cos \left(\frac{K \cdot \left(m + n\right)}{2} - M\right) \cdot e^{\left(-\color{blue}{0.25 \cdot {n}^{2}}\right) - \left(\ell - \left|m - n\right|\right)} \]
    3. Step-by-step derivation
      1. *-commutative45.4%

        \[\leadsto \cos \left(\frac{K \cdot \left(m + n\right)}{2} - M\right) \cdot e^{\left(-\color{blue}{{n}^{2} \cdot 0.25}\right) - \left(\ell - \left|m - n\right|\right)} \]
      2. unpow245.4%

        \[\leadsto \cos \left(\frac{K \cdot \left(m + n\right)}{2} - M\right) \cdot e^{\left(-\color{blue}{\left(n \cdot n\right)} \cdot 0.25\right) - \left(\ell - \left|m - n\right|\right)} \]
    4. Simplified45.4%

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

      \[\leadsto \cos \left(\frac{K \cdot \left(m + n\right)}{2} - M\right) \cdot e^{\color{blue}{-0.25 \cdot {n}^{2}}} \]
    6. Step-by-step derivation
      1. unpow241.7%

        \[\leadsto \cos \left(\frac{K \cdot \left(m + n\right)}{2} - M\right) \cdot e^{-0.25 \cdot \color{blue}{\left(n \cdot n\right)}} \]
      2. *-commutative41.7%

        \[\leadsto \cos \left(\frac{K \cdot \left(m + n\right)}{2} - M\right) \cdot e^{\color{blue}{\left(n \cdot n\right) \cdot -0.25}} \]
      3. associate-*l*41.7%

        \[\leadsto \cos \left(\frac{K \cdot \left(m + n\right)}{2} - M\right) \cdot e^{\color{blue}{n \cdot \left(n \cdot -0.25\right)}} \]
    7. Simplified41.7%

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

    if -2.09999999999999989e-231 < M < 2.6000000000000001e-26

    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. Taylor expanded in M around inf 35.5%

      \[\leadsto \cos \left(\frac{K \cdot \left(m + n\right)}{2} - M\right) \cdot e^{\left(-\color{blue}{{M}^{2}}\right) - \left(\ell - \left|m - n\right|\right)} \]
    3. Step-by-step derivation
      1. unpow235.5%

        \[\leadsto \cos \left(\frac{K \cdot \left(m + n\right)}{2} - M\right) \cdot e^{\left(-\color{blue}{M \cdot M}\right) - \left(\ell - \left|m - n\right|\right)} \]
    4. Simplified35.5%

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

      \[\leadsto \cos \left(\frac{K \cdot \left(m + n\right)}{2} - M\right) \cdot e^{\color{blue}{-1 \cdot \ell}} \]
    6. Step-by-step derivation
      1. mul-1-neg42.7%

        \[\leadsto \cos \left(\frac{K \cdot \left(m + n\right)}{2} - M\right) \cdot e^{\color{blue}{-\ell}} \]
    7. Simplified42.7%

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

      \[\leadsto \color{blue}{e^{-\ell} \cdot \cos \left(-M\right)} \]
    9. Step-by-step derivation
      1. *-commutative50.8%

        \[\leadsto \color{blue}{\cos \left(-M\right) \cdot e^{-\ell}} \]
      2. cos-neg50.8%

        \[\leadsto \color{blue}{\cos M} \cdot e^{-\ell} \]
    10. Simplified50.8%

      \[\leadsto \color{blue}{\cos M \cdot e^{-\ell}} \]
  3. Recombined 3 regimes into one program.
  4. Final simplification67.9%

    \[\leadsto \begin{array}{l} \mathbf{if}\;M \leq -1.25 \cdot 10^{-10}:\\ \;\;\;\;\cos M \cdot e^{M \cdot \left(-M\right)}\\ \mathbf{elif}\;M \leq -2.1 \cdot 10^{-231}:\\ \;\;\;\;\cos \left(\frac{\left(m + n\right) \cdot K}{2} - M\right) \cdot e^{n \cdot \left(n \cdot -0.25\right)}\\ \mathbf{elif}\;M \leq 2.6 \cdot 10^{-26}:\\ \;\;\;\;\cos M \cdot e^{-\ell}\\ \mathbf{else}:\\ \;\;\;\;\cos M \cdot e^{M \cdot \left(-M\right)}\\ \end{array} \]

Alternative 5: 68.6% accurate, 2.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;M \leq -15 \lor \neg \left(M \leq 2.6 \cdot 10^{-26}\right):\\ \;\;\;\;\cos M \cdot e^{M \cdot \left(-M\right)}\\ \mathbf{else}:\\ \;\;\;\;\cos M \cdot e^{-\ell}\\ \end{array} \end{array} \]
(FPCore (K m n M l)
 :precision binary64
 (if (or (<= M -15.0) (not (<= M 2.6e-26)))
   (* (cos M) (exp (* M (- M))))
   (* (cos M) (exp (- l)))))
double code(double K, double m, double n, double M, double l) {
	double tmp;
	if ((M <= -15.0) || !(M <= 2.6e-26)) {
		tmp = cos(M) * exp((M * -M));
	} else {
		tmp = cos(M) * exp(-l);
	}
	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_1 <= (-15.0d0)) .or. (.not. (m_1 <= 2.6d-26))) then
        tmp = cos(m_1) * exp((m_1 * -m_1))
    else
        tmp = cos(m_1) * exp(-l)
    end if
    code = tmp
end function
public static double code(double K, double m, double n, double M, double l) {
	double tmp;
	if ((M <= -15.0) || !(M <= 2.6e-26)) {
		tmp = Math.cos(M) * Math.exp((M * -M));
	} else {
		tmp = Math.cos(M) * Math.exp(-l);
	}
	return tmp;
}
def code(K, m, n, M, l):
	tmp = 0
	if (M <= -15.0) or not (M <= 2.6e-26):
		tmp = math.cos(M) * math.exp((M * -M))
	else:
		tmp = math.cos(M) * math.exp(-l)
	return tmp
function code(K, m, n, M, l)
	tmp = 0.0
	if ((M <= -15.0) || !(M <= 2.6e-26))
		tmp = Float64(cos(M) * exp(Float64(M * Float64(-M))));
	else
		tmp = Float64(cos(M) * exp(Float64(-l)));
	end
	return tmp
end
function tmp_2 = code(K, m, n, M, l)
	tmp = 0.0;
	if ((M <= -15.0) || ~((M <= 2.6e-26)))
		tmp = cos(M) * exp((M * -M));
	else
		tmp = cos(M) * exp(-l);
	end
	tmp_2 = tmp;
end
code[K_, m_, n_, M_, l_] := If[Or[LessEqual[M, -15.0], N[Not[LessEqual[M, 2.6e-26]], $MachinePrecision]], N[(N[Cos[M], $MachinePrecision] * N[Exp[N[(M * (-M)), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(N[Cos[M], $MachinePrecision] * N[Exp[(-l)], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;M \leq -15 \lor \neg \left(M \leq 2.6 \cdot 10^{-26}\right):\\
\;\;\;\;\cos M \cdot e^{M \cdot \left(-M\right)}\\

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


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if M < -15 or 2.6000000000000001e-26 < M

    1. Initial program 69.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. Taylor expanded in M around inf 56.3%

      \[\leadsto \cos \left(\frac{K \cdot \left(m + n\right)}{2} - M\right) \cdot e^{\left(-\color{blue}{{M}^{2}}\right) - \left(\ell - \left|m - n\right|\right)} \]
    3. Step-by-step derivation
      1. unpow256.3%

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

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

      \[\leadsto \color{blue}{\left(\cos \left(-M\right) + -0.5 \cdot \left(K \cdot \left(\sin \left(-M\right) \cdot \left(n + m\right)\right)\right)\right)} \cdot e^{\left(-M \cdot M\right) - \left(\ell - \left|m - n\right|\right)} \]
    6. Step-by-step derivation
      1. cos-neg56.5%

        \[\leadsto \left(\color{blue}{\cos M} + -0.5 \cdot \left(K \cdot \left(\sin \left(-M\right) \cdot \left(n + m\right)\right)\right)\right) \cdot e^{\left(-M \cdot M\right) - \left(\ell - \left|m - n\right|\right)} \]
      2. +-commutative56.5%

        \[\leadsto \color{blue}{\left(-0.5 \cdot \left(K \cdot \left(\sin \left(-M\right) \cdot \left(n + m\right)\right)\right) + \cos M\right)} \cdot e^{\left(-M \cdot M\right) - \left(\ell - \left|m - n\right|\right)} \]
      3. associate-*r*56.5%

        \[\leadsto \left(-0.5 \cdot \color{blue}{\left(\left(K \cdot \sin \left(-M\right)\right) \cdot \left(n + m\right)\right)} + \cos M\right) \cdot e^{\left(-M \cdot M\right) - \left(\ell - \left|m - n\right|\right)} \]
      4. sin-neg56.5%

        \[\leadsto \left(-0.5 \cdot \left(\left(K \cdot \color{blue}{\left(-\sin M\right)}\right) \cdot \left(n + m\right)\right) + \cos M\right) \cdot e^{\left(-M \cdot M\right) - \left(\ell - \left|m - n\right|\right)} \]
    7. Simplified56.5%

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

      \[\leadsto \color{blue}{e^{\left|m - n\right| - \left(\ell + {M}^{2}\right)} \cdot \cos M} \]
    9. Step-by-step derivation
      1. cos-neg73.2%

        \[\leadsto e^{\left|m - n\right| - \left(\ell + {M}^{2}\right)} \cdot \color{blue}{\cos \left(-M\right)} \]
      2. *-commutative73.2%

        \[\leadsto \color{blue}{\cos \left(-M\right) \cdot e^{\left|m - n\right| - \left(\ell + {M}^{2}\right)}} \]
      3. cos-neg73.2%

        \[\leadsto \color{blue}{\cos M} \cdot e^{\left|m - n\right| - \left(\ell + {M}^{2}\right)} \]
      4. exp-diff26.5%

        \[\leadsto \cos M \cdot \color{blue}{\frac{e^{\left|m - n\right|}}{e^{\ell + {M}^{2}}}} \]
      5. fabs-sub26.5%

        \[\leadsto \cos M \cdot \frac{e^{\color{blue}{\left|n - m\right|}}}{e^{\ell + {M}^{2}}} \]
      6. sub-neg26.5%

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

        \[\leadsto \cos M \cdot \frac{e^{\left|n + \color{blue}{-1 \cdot m}\right|}}{e^{\ell + {M}^{2}}} \]
      8. fabs-neg26.5%

        \[\leadsto \cos M \cdot \frac{e^{\color{blue}{\left|-\left(n + -1 \cdot m\right)\right|}}}{e^{\ell + {M}^{2}}} \]
      9. exp-diff73.2%

        \[\leadsto \cos M \cdot \color{blue}{e^{\left|-\left(n + -1 \cdot m\right)\right| - \left(\ell + {M}^{2}\right)}} \]
      10. fabs-neg73.2%

        \[\leadsto \cos M \cdot e^{\color{blue}{\left|n + -1 \cdot m\right|} - \left(\ell + {M}^{2}\right)} \]
      11. mul-1-neg73.2%

        \[\leadsto \cos M \cdot e^{\left|n + \color{blue}{\left(-m\right)}\right| - \left(\ell + {M}^{2}\right)} \]
      12. sub-neg73.2%

        \[\leadsto \cos M \cdot e^{\left|\color{blue}{n - m}\right| - \left(\ell + {M}^{2}\right)} \]
      13. +-commutative73.2%

        \[\leadsto \cos M \cdot e^{\left|n - m\right| - \color{blue}{\left({M}^{2} + \ell\right)}} \]
      14. unpow273.2%

        \[\leadsto \cos M \cdot e^{\left|n - m\right| - \left(\color{blue}{M \cdot M} + \ell\right)} \]
    10. Simplified73.2%

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

      \[\leadsto \cos M \cdot e^{\color{blue}{-1 \cdot {M}^{2}}} \]
    12. Step-by-step derivation
      1. unpow294.0%

        \[\leadsto \cos M \cdot e^{-1 \cdot \color{blue}{\left(M \cdot M\right)}} \]
      2. mul-1-neg94.0%

        \[\leadsto \cos M \cdot e^{\color{blue}{-M \cdot M}} \]
      3. distribute-rgt-neg-in94.0%

        \[\leadsto \cos M \cdot e^{\color{blue}{M \cdot \left(-M\right)}} \]
    13. Simplified94.0%

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

    if -15 < M < 2.6000000000000001e-26

    1. Initial program 67.5%

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

      \[\leadsto \cos \left(\frac{K \cdot \left(m + n\right)}{2} - M\right) \cdot e^{\left(-\color{blue}{{M}^{2}}\right) - \left(\ell - \left|m - n\right|\right)} \]
    3. Step-by-step derivation
      1. unpow225.9%

        \[\leadsto \cos \left(\frac{K \cdot \left(m + n\right)}{2} - M\right) \cdot e^{\left(-\color{blue}{M \cdot M}\right) - \left(\ell - \left|m - n\right|\right)} \]
    4. Simplified25.9%

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

      \[\leadsto \cos \left(\frac{K \cdot \left(m + n\right)}{2} - M\right) \cdot e^{\color{blue}{-1 \cdot \ell}} \]
    6. Step-by-step derivation
      1. mul-1-neg32.6%

        \[\leadsto \cos \left(\frac{K \cdot \left(m + n\right)}{2} - M\right) \cdot e^{\color{blue}{-\ell}} \]
    7. Simplified32.6%

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

      \[\leadsto \color{blue}{e^{-\ell} \cdot \cos \left(-M\right)} \]
    9. Step-by-step derivation
      1. *-commutative41.2%

        \[\leadsto \color{blue}{\cos \left(-M\right) \cdot e^{-\ell}} \]
      2. cos-neg41.2%

        \[\leadsto \color{blue}{\cos M} \cdot e^{-\ell} \]
    10. Simplified41.2%

      \[\leadsto \color{blue}{\cos M \cdot e^{-\ell}} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification64.7%

    \[\leadsto \begin{array}{l} \mathbf{if}\;M \leq -15 \lor \neg \left(M \leq 2.6 \cdot 10^{-26}\right):\\ \;\;\;\;\cos M \cdot e^{M \cdot \left(-M\right)}\\ \mathbf{else}:\\ \;\;\;\;\cos M \cdot e^{-\ell}\\ \end{array} \]

Alternative 6: 35.0% accurate, 2.1× speedup?

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

\\
\cos M \cdot e^{-\ell}
\end{array}
Derivation
  1. Initial program 68.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. Taylor expanded in M around inf 39.4%

    \[\leadsto \cos \left(\frac{K \cdot \left(m + n\right)}{2} - M\right) \cdot e^{\left(-\color{blue}{{M}^{2}}\right) - \left(\ell - \left|m - n\right|\right)} \]
  3. Step-by-step derivation
    1. unpow239.4%

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

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

    \[\leadsto \cos \left(\frac{K \cdot \left(m + n\right)}{2} - M\right) \cdot e^{\color{blue}{-1 \cdot \ell}} \]
  6. Step-by-step derivation
    1. mul-1-neg23.8%

      \[\leadsto \cos \left(\frac{K \cdot \left(m + n\right)}{2} - M\right) \cdot e^{\color{blue}{-\ell}} \]
  7. Simplified23.8%

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

    \[\leadsto \color{blue}{e^{-\ell} \cdot \cos \left(-M\right)} \]
  9. Step-by-step derivation
    1. *-commutative32.0%

      \[\leadsto \color{blue}{\cos \left(-M\right) \cdot e^{-\ell}} \]
    2. cos-neg32.0%

      \[\leadsto \color{blue}{\cos M} \cdot e^{-\ell} \]
  10. Simplified32.0%

    \[\leadsto \color{blue}{\cos M \cdot e^{-\ell}} \]
  11. Final simplification32.0%

    \[\leadsto \cos M \cdot e^{-\ell} \]

Reproduce

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