Maksimov and Kolovsky, Equation (32)

Percentage Accurate: 76.2% → 97.0%
Time: 12.2s
Alternatives: 12
Speedup: 2.6×

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

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

Initial Program: 76.2% accurate, 1.0× speedup?

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

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

Alternative 1: 97.0% accurate, 1.1× 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 75.9%

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

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

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

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

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

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

Alternative 2: 96.3% accurate, 0.5× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \cos \left(\frac{K \cdot \left(m + n\right)}{2} - M\right)\\ t_1 := \left|m - n\right|\\ t_2 := t\_1 - \ell\\ \mathbf{if}\;e^{t\_2 - {\left(\frac{m + n}{2} - M\right)}^{2}} \cdot t\_0 \leq 0:\\ \;\;\;\;t\_0 \cdot e^{n \cdot \left(n \cdot \left(\frac{\mathsf{fma}\left(\mathsf{fma}\left(0.5, m, 0\right) - M, \frac{\mathsf{fma}\left(m, -0.5, M\right)}{n}, \mathsf{fma}\left(m, -0.5, M\right)\right)}{n} - 0.25\right)\right) + t\_2}\\ \mathbf{else}:\\ \;\;\;\;e^{t\_1 - \mathsf{fma}\left(0.25, \left(m + n\right) \cdot \left(m + n\right), \ell\right)}\\ \end{array} \end{array} \]
(FPCore (K m n M l)
 :precision binary64
 (let* ((t_0 (cos (- (/ (* K (+ m n)) 2.0) M)))
        (t_1 (fabs (- m n)))
        (t_2 (- t_1 l)))
   (if (<= (* (exp (- t_2 (pow (- (/ (+ m n) 2.0) M) 2.0))) t_0) 0.0)
     (*
      t_0
      (exp
       (+
        (*
         n
         (*
          n
          (-
           (/
            (fma (- (fma 0.5 m 0.0) M) (/ (fma m -0.5 M) n) (fma m -0.5 M))
            n)
           0.25)))
        t_2)))
     (exp (- t_1 (fma 0.25 (* (+ m n) (+ m n)) l))))))
double code(double K, double m, double n, double M, double l) {
	double t_0 = cos((((K * (m + n)) / 2.0) - M));
	double t_1 = fabs((m - n));
	double t_2 = t_1 - l;
	double tmp;
	if ((exp((t_2 - pow((((m + n) / 2.0) - M), 2.0))) * t_0) <= 0.0) {
		tmp = t_0 * exp(((n * (n * ((fma((fma(0.5, m, 0.0) - M), (fma(m, -0.5, M) / n), fma(m, -0.5, M)) / n) - 0.25))) + t_2));
	} else {
		tmp = exp((t_1 - fma(0.25, ((m + n) * (m + n)), l)));
	}
	return tmp;
}
function code(K, m, n, M, l)
	t_0 = cos(Float64(Float64(Float64(K * Float64(m + n)) / 2.0) - M))
	t_1 = abs(Float64(m - n))
	t_2 = Float64(t_1 - l)
	tmp = 0.0
	if (Float64(exp(Float64(t_2 - (Float64(Float64(Float64(m + n) / 2.0) - M) ^ 2.0))) * t_0) <= 0.0)
		tmp = Float64(t_0 * exp(Float64(Float64(n * Float64(n * Float64(Float64(fma(Float64(fma(0.5, m, 0.0) - M), Float64(fma(m, -0.5, M) / n), fma(m, -0.5, M)) / n) - 0.25))) + t_2)));
	else
		tmp = exp(Float64(t_1 - fma(0.25, Float64(Float64(m + n) * Float64(m + n)), l)));
	end
	return tmp
end
code[K_, m_, n_, M_, l_] := Block[{t$95$0 = N[Cos[N[(N[(N[(K * N[(m + n), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision] - M), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[Abs[N[(m - n), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = N[(t$95$1 - l), $MachinePrecision]}, If[LessEqual[N[(N[Exp[N[(t$95$2 - N[Power[N[(N[(N[(m + n), $MachinePrecision] / 2.0), $MachinePrecision] - M), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * t$95$0), $MachinePrecision], 0.0], N[(t$95$0 * N[Exp[N[(N[(n * N[(n * N[(N[(N[(N[(N[(0.5 * m + 0.0), $MachinePrecision] - M), $MachinePrecision] * N[(N[(m * -0.5 + M), $MachinePrecision] / n), $MachinePrecision] + N[(m * -0.5 + M), $MachinePrecision]), $MachinePrecision] / n), $MachinePrecision] - 0.25), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + t$95$2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[Exp[N[(t$95$1 - N[(0.25 * N[(N[(m + n), $MachinePrecision] * N[(m + n), $MachinePrecision]), $MachinePrecision] + l), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \cos \left(\frac{K \cdot \left(m + n\right)}{2} - M\right)\\
t_1 := \left|m - n\right|\\
t_2 := t\_1 - \ell\\
\mathbf{if}\;e^{t\_2 - {\left(\frac{m + n}{2} - M\right)}^{2}} \cdot t\_0 \leq 0:\\
\;\;\;\;t\_0 \cdot e^{n \cdot \left(n \cdot \left(\frac{\mathsf{fma}\left(\mathsf{fma}\left(0.5, m, 0\right) - M, \frac{\mathsf{fma}\left(m, -0.5, M\right)}{n}, \mathsf{fma}\left(m, -0.5, M\right)\right)}{n} - 0.25\right)\right) + t\_2}\\

\mathbf{else}:\\
\;\;\;\;e^{t\_1 - \mathsf{fma}\left(0.25, \left(m + n\right) \cdot \left(m + n\right), \ell\right)}\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (*.f64 (cos.f64 (-.f64 (/.f64 (*.f64 K (+.f64 m n)) #s(literal 2 binary64)) M)) (exp.f64 (-.f64 (neg.f64 (pow.f64 (-.f64 (/.f64 (+.f64 m n) #s(literal 2 binary64)) M) #s(literal 2 binary64))) (-.f64 l (fabs.f64 (-.f64 m n)))))) < -0.0

    1. Initial program 98.9%

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

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

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

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

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

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

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

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

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

      \[\leadsto \cos \left(\frac{K \cdot \left(m + n\right)}{2} - M\right) \cdot e^{\left(-\color{blue}{n \cdot \left(n \cdot \left(0.25 - \frac{\mathsf{fma}\left(\mathsf{fma}\left(0.5, m, 0\right) - M, \frac{\mathsf{fma}\left(m, -0.5, M\right)}{n}, \mathsf{fma}\left(m, -0.5, M\right)\right)}{n}\right)\right)}\right) - \left(\ell - \left|m - n\right|\right)} \]

    if -0.0 < (*.f64 (cos.f64 (-.f64 (/.f64 (*.f64 K (+.f64 m n)) #s(literal 2 binary64)) M)) (exp.f64 (-.f64 (neg.f64 (pow.f64 (-.f64 (/.f64 (+.f64 m n) #s(literal 2 binary64)) M) #s(literal 2 binary64))) (-.f64 l (fabs.f64 (-.f64 m n))))))

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

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

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

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

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

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

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

        \[\leadsto e^{\color{blue}{\left|m - n\right| - \left(\ell + \frac{1}{4} \cdot {\left(m + n\right)}^{2}\right)}} \]
      3. fabs-subN/A

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

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

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

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

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

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

        \[\leadsto e^{\left|\color{blue}{n - m}\right| - \left(\ell + \frac{1}{4} \cdot {\left(m + n\right)}^{2}\right)} \]
      10. +-commutativeN/A

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

        \[\leadsto e^{\left|n - m\right| - \color{blue}{\mathsf{fma}\left(\frac{1}{4}, {\left(m + n\right)}^{2}, \ell\right)}} \]
      12. unpow2N/A

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

        \[\leadsto e^{\left|n - m\right| - \mathsf{fma}\left(\frac{1}{4}, \color{blue}{\left(m + n\right) \cdot \left(m + n\right)}, \ell\right)} \]
      14. +-commutativeN/A

        \[\leadsto e^{\left|n - m\right| - \mathsf{fma}\left(\frac{1}{4}, \color{blue}{\left(n + m\right)} \cdot \left(m + n\right), \ell\right)} \]
      15. +-lowering-+.f64N/A

        \[\leadsto e^{\left|n - m\right| - \mathsf{fma}\left(\frac{1}{4}, \color{blue}{\left(n + m\right)} \cdot \left(m + n\right), \ell\right)} \]
      16. +-commutativeN/A

        \[\leadsto e^{\left|n - m\right| - \mathsf{fma}\left(\frac{1}{4}, \left(n + m\right) \cdot \color{blue}{\left(n + m\right)}, \ell\right)} \]
      17. +-lowering-+.f6496.7

        \[\leadsto e^{\left|n - m\right| - \mathsf{fma}\left(0.25, \left(n + m\right) \cdot \color{blue}{\left(n + m\right)}, \ell\right)} \]
    8. Simplified96.7%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;e^{\left(\left|m - n\right| - \ell\right) - {\left(\frac{m + n}{2} - M\right)}^{2}} \cdot \cos \left(\frac{K \cdot \left(m + n\right)}{2} - M\right) \leq 0:\\ \;\;\;\;\cos \left(\frac{K \cdot \left(m + n\right)}{2} - M\right) \cdot e^{n \cdot \left(n \cdot \left(\frac{\mathsf{fma}\left(\mathsf{fma}\left(0.5, m, 0\right) - M, \frac{\mathsf{fma}\left(m, -0.5, M\right)}{n}, \mathsf{fma}\left(m, -0.5, M\right)\right)}{n} - 0.25\right)\right) + \left(\left|m - n\right| - \ell\right)}\\ \mathbf{else}:\\ \;\;\;\;e^{\left|m - n\right| - \mathsf{fma}\left(0.25, \left(m + n\right) \cdot \left(m + n\right), \ell\right)}\\ \end{array} \]
  5. Add Preprocessing

Alternative 3: 95.6% accurate, 2.6× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := e^{0 - M \cdot M}\\ \mathbf{if}\;M \leq -2450:\\ \;\;\;\;t\_0\\ \mathbf{elif}\;M \leq 20:\\ \;\;\;\;e^{\left|m - n\right| - \mathsf{fma}\left(0.25, \left(m + n\right) \cdot \left(m + n\right), \ell\right)}\\ \mathbf{else}:\\ \;\;\;\;t\_0\\ \end{array} \end{array} \]
(FPCore (K m n M l)
 :precision binary64
 (let* ((t_0 (exp (- 0.0 (* M M)))))
   (if (<= M -2450.0)
     t_0
     (if (<= M 20.0)
       (exp (- (fabs (- m n)) (fma 0.25 (* (+ m n) (+ m n)) l)))
       t_0))))
double code(double K, double m, double n, double M, double l) {
	double t_0 = exp((0.0 - (M * M)));
	double tmp;
	if (M <= -2450.0) {
		tmp = t_0;
	} else if (M <= 20.0) {
		tmp = exp((fabs((m - n)) - fma(0.25, ((m + n) * (m + n)), l)));
	} else {
		tmp = t_0;
	}
	return tmp;
}
function code(K, m, n, M, l)
	t_0 = exp(Float64(0.0 - Float64(M * M)))
	tmp = 0.0
	if (M <= -2450.0)
		tmp = t_0;
	elseif (M <= 20.0)
		tmp = exp(Float64(abs(Float64(m - n)) - fma(0.25, Float64(Float64(m + n) * Float64(m + n)), l)));
	else
		tmp = t_0;
	end
	return tmp
end
code[K_, m_, n_, M_, l_] := Block[{t$95$0 = N[Exp[N[(0.0 - N[(M * M), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[M, -2450.0], t$95$0, If[LessEqual[M, 20.0], N[Exp[N[(N[Abs[N[(m - n), $MachinePrecision]], $MachinePrecision] - N[(0.25 * N[(N[(m + n), $MachinePrecision] * N[(m + n), $MachinePrecision]), $MachinePrecision] + l), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], t$95$0]]]
\begin{array}{l}

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

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

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


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

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

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

        \[\leadsto \color{blue}{\cos M} \cdot e^{\left(\mathsf{neg}\left({\left(\frac{m + n}{2} - M\right)}^{2}\right)\right) - \left(\ell - \left|m - n\right|\right)} \]
      2. cos-lowering-cos.f64100.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. 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)} \]
    6. Taylor expanded in M around inf

      \[\leadsto \cos M \cdot e^{\color{blue}{-1 \cdot {M}^{2}}} \]
    7. Step-by-step derivation
      1. mul-1-negN/A

        \[\leadsto \cos M \cdot e^{\color{blue}{\mathsf{neg}\left({M}^{2}\right)}} \]
      2. neg-sub0N/A

        \[\leadsto \cos M \cdot e^{\color{blue}{0 - {M}^{2}}} \]
      3. --lowering--.f64N/A

        \[\leadsto \cos M \cdot e^{\color{blue}{0 - {M}^{2}}} \]
      4. unpow2N/A

        \[\leadsto \cos M \cdot e^{0 - \color{blue}{M \cdot M}} \]
      5. *-lowering-*.f6497.4

        \[\leadsto \cos M \cdot e^{0 - \color{blue}{M \cdot M}} \]
    8. Simplified97.4%

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

      \[\leadsto \color{blue}{1} \cdot e^{0 - M \cdot M} \]
    10. Step-by-step derivation
      1. Simplified97.4%

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

      if -2450 < M < 20

      1. Initial program 77.9%

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

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

          \[\leadsto \color{blue}{\cos M} \cdot e^{\left(\mathsf{neg}\left({\left(\frac{m + n}{2} - M\right)}^{2}\right)\right) - \left(\ell - \left|m - n\right|\right)} \]
        2. cos-lowering-cos.f6496.6

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

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

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

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

          \[\leadsto e^{\color{blue}{\left|m - n\right| - \left(\ell + \frac{1}{4} \cdot {\left(m + n\right)}^{2}\right)}} \]
        3. fabs-subN/A

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

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

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

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

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

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

          \[\leadsto e^{\left|\color{blue}{n - m}\right| - \left(\ell + \frac{1}{4} \cdot {\left(m + n\right)}^{2}\right)} \]
        10. +-commutativeN/A

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

          \[\leadsto e^{\left|n - m\right| - \color{blue}{\mathsf{fma}\left(\frac{1}{4}, {\left(m + n\right)}^{2}, \ell\right)}} \]
        12. unpow2N/A

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

          \[\leadsto e^{\left|n - m\right| - \mathsf{fma}\left(\frac{1}{4}, \color{blue}{\left(m + n\right) \cdot \left(m + n\right)}, \ell\right)} \]
        14. +-commutativeN/A

          \[\leadsto e^{\left|n - m\right| - \mathsf{fma}\left(\frac{1}{4}, \color{blue}{\left(n + m\right)} \cdot \left(m + n\right), \ell\right)} \]
        15. +-lowering-+.f64N/A

          \[\leadsto e^{\left|n - m\right| - \mathsf{fma}\left(\frac{1}{4}, \color{blue}{\left(n + m\right)} \cdot \left(m + n\right), \ell\right)} \]
        16. +-commutativeN/A

          \[\leadsto e^{\left|n - m\right| - \mathsf{fma}\left(\frac{1}{4}, \left(n + m\right) \cdot \color{blue}{\left(n + m\right)}, \ell\right)} \]
        17. +-lowering-+.f6496.6

          \[\leadsto e^{\left|n - m\right| - \mathsf{fma}\left(0.25, \left(n + m\right) \cdot \color{blue}{\left(n + m\right)}, \ell\right)} \]
      8. Simplified96.6%

        \[\leadsto \color{blue}{e^{\left|n - m\right| - \mathsf{fma}\left(0.25, \left(n + m\right) \cdot \left(n + m\right), \ell\right)}} \]
    11. Recombined 2 regimes into one program.
    12. Final simplification97.0%

      \[\leadsto \begin{array}{l} \mathbf{if}\;M \leq -2450:\\ \;\;\;\;e^{0 - M \cdot M}\\ \mathbf{elif}\;M \leq 20:\\ \;\;\;\;e^{\left|m - n\right| - \mathsf{fma}\left(0.25, \left(m + n\right) \cdot \left(m + n\right), \ell\right)}\\ \mathbf{else}:\\ \;\;\;\;e^{0 - M \cdot M}\\ \end{array} \]
    13. Add Preprocessing

    Alternative 4: 62.5% accurate, 2.7× speedup?

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

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

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

          \[\leadsto \color{blue}{\cos M} \cdot e^{\left(\mathsf{neg}\left({\left(\frac{m + n}{2} - M\right)}^{2}\right)\right) - \left(\ell - \left|m - n\right|\right)} \]
        2. cos-lowering-cos.f6498.2

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

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

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

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

          \[\leadsto e^{\color{blue}{\left|m - n\right| - \left(\ell + \frac{1}{4} \cdot {\left(m + n\right)}^{2}\right)}} \]
        3. fabs-subN/A

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

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

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

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

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

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

          \[\leadsto e^{\left|\color{blue}{n - m}\right| - \left(\ell + \frac{1}{4} \cdot {\left(m + n\right)}^{2}\right)} \]
        10. +-commutativeN/A

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

          \[\leadsto e^{\left|n - m\right| - \color{blue}{\mathsf{fma}\left(\frac{1}{4}, {\left(m + n\right)}^{2}, \ell\right)}} \]
        12. unpow2N/A

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

          \[\leadsto e^{\left|n - m\right| - \mathsf{fma}\left(\frac{1}{4}, \color{blue}{\left(m + n\right) \cdot \left(m + n\right)}, \ell\right)} \]
        14. +-commutativeN/A

          \[\leadsto e^{\left|n - m\right| - \mathsf{fma}\left(\frac{1}{4}, \color{blue}{\left(n + m\right)} \cdot \left(m + n\right), \ell\right)} \]
        15. +-lowering-+.f64N/A

          \[\leadsto e^{\left|n - m\right| - \mathsf{fma}\left(\frac{1}{4}, \color{blue}{\left(n + m\right)} \cdot \left(m + n\right), \ell\right)} \]
        16. +-commutativeN/A

          \[\leadsto e^{\left|n - m\right| - \mathsf{fma}\left(\frac{1}{4}, \left(n + m\right) \cdot \color{blue}{\left(n + m\right)}, \ell\right)} \]
        17. +-lowering-+.f6494.6

          \[\leadsto e^{\left|n - m\right| - \mathsf{fma}\left(0.25, \left(n + m\right) \cdot \color{blue}{\left(n + m\right)}, \ell\right)} \]
      8. Simplified94.6%

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

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

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

          \[\leadsto e^{\color{blue}{{m}^{2} \cdot \frac{-1}{4}}} \]
        3. unpow2N/A

          \[\leadsto e^{\color{blue}{\left(m \cdot m\right)} \cdot \frac{-1}{4}} \]
        4. *-lowering-*.f6498.2

          \[\leadsto e^{\color{blue}{\left(m \cdot m\right)} \cdot -0.25} \]
      11. Simplified98.2%

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

      if -70 < m < 1.9999999999999999e-302

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

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

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

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

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

        \[\leadsto \cos M \cdot e^{\color{blue}{-1 \cdot {M}^{2}}} \]
      7. Step-by-step derivation
        1. mul-1-negN/A

          \[\leadsto \cos M \cdot e^{\color{blue}{\mathsf{neg}\left({M}^{2}\right)}} \]
        2. neg-sub0N/A

          \[\leadsto \cos M \cdot e^{\color{blue}{0 - {M}^{2}}} \]
        3. --lowering--.f64N/A

          \[\leadsto \cos M \cdot e^{\color{blue}{0 - {M}^{2}}} \]
        4. unpow2N/A

          \[\leadsto \cos M \cdot e^{0 - \color{blue}{M \cdot M}} \]
        5. *-lowering-*.f6460.5

          \[\leadsto \cos M \cdot e^{0 - \color{blue}{M \cdot M}} \]
      8. Simplified60.5%

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

        \[\leadsto \color{blue}{1} \cdot e^{0 - M \cdot M} \]
      10. Step-by-step derivation
        1. Simplified60.5%

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

        if 1.9999999999999999e-302 < m

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

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

            \[\leadsto \color{blue}{\cos M} \cdot e^{\left(\mathsf{neg}\left({\left(\frac{m + n}{2} - M\right)}^{2}\right)\right) - \left(\ell - \left|m - n\right|\right)} \]
          2. cos-lowering-cos.f6498.6

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

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

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

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

            \[\leadsto e^{\color{blue}{\left|m - n\right| - \left(\ell + \frac{1}{4} \cdot {\left(m + n\right)}^{2}\right)}} \]
          3. fabs-subN/A

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

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

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

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

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

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

            \[\leadsto e^{\left|\color{blue}{n - m}\right| - \left(\ell + \frac{1}{4} \cdot {\left(m + n\right)}^{2}\right)} \]
          10. +-commutativeN/A

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

            \[\leadsto e^{\left|n - m\right| - \color{blue}{\mathsf{fma}\left(\frac{1}{4}, {\left(m + n\right)}^{2}, \ell\right)}} \]
          12. unpow2N/A

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

            \[\leadsto e^{\left|n - m\right| - \mathsf{fma}\left(\frac{1}{4}, \color{blue}{\left(m + n\right) \cdot \left(m + n\right)}, \ell\right)} \]
          14. +-commutativeN/A

            \[\leadsto e^{\left|n - m\right| - \mathsf{fma}\left(\frac{1}{4}, \color{blue}{\left(n + m\right)} \cdot \left(m + n\right), \ell\right)} \]
          15. +-lowering-+.f64N/A

            \[\leadsto e^{\left|n - m\right| - \mathsf{fma}\left(\frac{1}{4}, \color{blue}{\left(n + m\right)} \cdot \left(m + n\right), \ell\right)} \]
          16. +-commutativeN/A

            \[\leadsto e^{\left|n - m\right| - \mathsf{fma}\left(\frac{1}{4}, \left(n + m\right) \cdot \color{blue}{\left(n + m\right)}, \ell\right)} \]
          17. +-lowering-+.f6488.6

            \[\leadsto e^{\left|n - m\right| - \mathsf{fma}\left(0.25, \left(n + m\right) \cdot \color{blue}{\left(n + m\right)}, \ell\right)} \]
        8. Simplified88.6%

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

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

            \[\leadsto e^{\left|n - m\right| - \color{blue}{\frac{1}{4} \cdot {n}^{2}}} \]
          2. unpow2N/A

            \[\leadsto e^{\left|n - m\right| - \frac{1}{4} \cdot \color{blue}{\left(n \cdot n\right)}} \]
          3. *-lowering-*.f6448.6

            \[\leadsto e^{\left|n - m\right| - 0.25 \cdot \color{blue}{\left(n \cdot n\right)}} \]
        11. Simplified48.6%

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

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

      Alternative 5: 65.6% accurate, 2.9× speedup?

      \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;m \leq -70:\\ \;\;\;\;e^{\left(m \cdot m\right) \cdot -0.25}\\ \mathbf{elif}\;m \leq 4 \cdot 10^{-302}:\\ \;\;\;\;e^{0 - M \cdot M}\\ \mathbf{else}:\\ \;\;\;\;e^{n \cdot \left(n \cdot -0.25\right)}\\ \end{array} \end{array} \]
      (FPCore (K m n M l)
       :precision binary64
       (if (<= m -70.0)
         (exp (* (* m m) -0.25))
         (if (<= m 4e-302) (exp (- 0.0 (* M M))) (exp (* n (* n -0.25))))))
      double code(double K, double m, double n, double M, double l) {
      	double tmp;
      	if (m <= -70.0) {
      		tmp = exp(((m * m) * -0.25));
      	} else if (m <= 4e-302) {
      		tmp = exp((0.0 - (M * M)));
      	} else {
      		tmp = exp((n * (n * -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 <= (-70.0d0)) then
              tmp = exp(((m * m) * (-0.25d0)))
          else if (m <= 4d-302) then
              tmp = exp((0.0d0 - (m_1 * m_1)))
          else
              tmp = exp((n * (n * (-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 <= -70.0) {
      		tmp = Math.exp(((m * m) * -0.25));
      	} else if (m <= 4e-302) {
      		tmp = Math.exp((0.0 - (M * M)));
      	} else {
      		tmp = Math.exp((n * (n * -0.25)));
      	}
      	return tmp;
      }
      
      def code(K, m, n, M, l):
      	tmp = 0
      	if m <= -70.0:
      		tmp = math.exp(((m * m) * -0.25))
      	elif m <= 4e-302:
      		tmp = math.exp((0.0 - (M * M)))
      	else:
      		tmp = math.exp((n * (n * -0.25)))
      	return tmp
      
      function code(K, m, n, M, l)
      	tmp = 0.0
      	if (m <= -70.0)
      		tmp = exp(Float64(Float64(m * m) * -0.25));
      	elseif (m <= 4e-302)
      		tmp = exp(Float64(0.0 - Float64(M * M)));
      	else
      		tmp = exp(Float64(n * Float64(n * -0.25)));
      	end
      	return tmp
      end
      
      function tmp_2 = code(K, m, n, M, l)
      	tmp = 0.0;
      	if (m <= -70.0)
      		tmp = exp(((m * m) * -0.25));
      	elseif (m <= 4e-302)
      		tmp = exp((0.0 - (M * M)));
      	else
      		tmp = exp((n * (n * -0.25)));
      	end
      	tmp_2 = tmp;
      end
      
      code[K_, m_, n_, M_, l_] := If[LessEqual[m, -70.0], N[Exp[N[(N[(m * m), $MachinePrecision] * -0.25), $MachinePrecision]], $MachinePrecision], If[LessEqual[m, 4e-302], N[Exp[N[(0.0 - N[(M * M), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[Exp[N[(n * N[(n * -0.25), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]
      
      \begin{array}{l}
      
      \\
      \begin{array}{l}
      \mathbf{if}\;m \leq -70:\\
      \;\;\;\;e^{\left(m \cdot m\right) \cdot -0.25}\\
      
      \mathbf{elif}\;m \leq 4 \cdot 10^{-302}:\\
      \;\;\;\;e^{0 - M \cdot M}\\
      
      \mathbf{else}:\\
      \;\;\;\;e^{n \cdot \left(n \cdot -0.25\right)}\\
      
      
      \end{array}
      \end{array}
      
      Derivation
      1. Split input into 3 regimes
      2. if m < -70

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

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

            \[\leadsto \color{blue}{\cos M} \cdot e^{\left(\mathsf{neg}\left({\left(\frac{m + n}{2} - M\right)}^{2}\right)\right) - \left(\ell - \left|m - n\right|\right)} \]
          2. cos-lowering-cos.f6498.2

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

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

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

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

            \[\leadsto e^{\color{blue}{\left|m - n\right| - \left(\ell + \frac{1}{4} \cdot {\left(m + n\right)}^{2}\right)}} \]
          3. fabs-subN/A

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

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

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

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

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

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

            \[\leadsto e^{\left|\color{blue}{n - m}\right| - \left(\ell + \frac{1}{4} \cdot {\left(m + n\right)}^{2}\right)} \]
          10. +-commutativeN/A

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

            \[\leadsto e^{\left|n - m\right| - \color{blue}{\mathsf{fma}\left(\frac{1}{4}, {\left(m + n\right)}^{2}, \ell\right)}} \]
          12. unpow2N/A

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

            \[\leadsto e^{\left|n - m\right| - \mathsf{fma}\left(\frac{1}{4}, \color{blue}{\left(m + n\right) \cdot \left(m + n\right)}, \ell\right)} \]
          14. +-commutativeN/A

            \[\leadsto e^{\left|n - m\right| - \mathsf{fma}\left(\frac{1}{4}, \color{blue}{\left(n + m\right)} \cdot \left(m + n\right), \ell\right)} \]
          15. +-lowering-+.f64N/A

            \[\leadsto e^{\left|n - m\right| - \mathsf{fma}\left(\frac{1}{4}, \color{blue}{\left(n + m\right)} \cdot \left(m + n\right), \ell\right)} \]
          16. +-commutativeN/A

            \[\leadsto e^{\left|n - m\right| - \mathsf{fma}\left(\frac{1}{4}, \left(n + m\right) \cdot \color{blue}{\left(n + m\right)}, \ell\right)} \]
          17. +-lowering-+.f6494.6

            \[\leadsto e^{\left|n - m\right| - \mathsf{fma}\left(0.25, \left(n + m\right) \cdot \color{blue}{\left(n + m\right)}, \ell\right)} \]
        8. Simplified94.6%

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

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

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

            \[\leadsto e^{\color{blue}{{m}^{2} \cdot \frac{-1}{4}}} \]
          3. unpow2N/A

            \[\leadsto e^{\color{blue}{\left(m \cdot m\right)} \cdot \frac{-1}{4}} \]
          4. *-lowering-*.f6498.2

            \[\leadsto e^{\color{blue}{\left(m \cdot m\right)} \cdot -0.25} \]
        11. Simplified98.2%

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

        if -70 < m < 3.9999999999999999e-302

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

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

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

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

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

          \[\leadsto \cos M \cdot e^{\color{blue}{-1 \cdot {M}^{2}}} \]
        7. Step-by-step derivation
          1. mul-1-negN/A

            \[\leadsto \cos M \cdot e^{\color{blue}{\mathsf{neg}\left({M}^{2}\right)}} \]
          2. neg-sub0N/A

            \[\leadsto \cos M \cdot e^{\color{blue}{0 - {M}^{2}}} \]
          3. --lowering--.f64N/A

            \[\leadsto \cos M \cdot e^{\color{blue}{0 - {M}^{2}}} \]
          4. unpow2N/A

            \[\leadsto \cos M \cdot e^{0 - \color{blue}{M \cdot M}} \]
          5. *-lowering-*.f6460.5

            \[\leadsto \cos M \cdot e^{0 - \color{blue}{M \cdot M}} \]
        8. Simplified60.5%

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

          \[\leadsto \color{blue}{1} \cdot e^{0 - M \cdot M} \]
        10. Step-by-step derivation
          1. Simplified60.5%

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

          if 3.9999999999999999e-302 < m

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

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

              \[\leadsto \color{blue}{\cos M} \cdot e^{\left(\mathsf{neg}\left({\left(\frac{m + n}{2} - M\right)}^{2}\right)\right) - \left(\ell - \left|m - n\right|\right)} \]
            2. cos-lowering-cos.f6498.6

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

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

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

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

              \[\leadsto e^{\color{blue}{\left|m - n\right| - \left(\ell + \frac{1}{4} \cdot {\left(m + n\right)}^{2}\right)}} \]
            3. fabs-subN/A

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

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

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

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

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

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

              \[\leadsto e^{\left|\color{blue}{n - m}\right| - \left(\ell + \frac{1}{4} \cdot {\left(m + n\right)}^{2}\right)} \]
            10. +-commutativeN/A

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

              \[\leadsto e^{\left|n - m\right| - \color{blue}{\mathsf{fma}\left(\frac{1}{4}, {\left(m + n\right)}^{2}, \ell\right)}} \]
            12. unpow2N/A

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

              \[\leadsto e^{\left|n - m\right| - \mathsf{fma}\left(\frac{1}{4}, \color{blue}{\left(m + n\right) \cdot \left(m + n\right)}, \ell\right)} \]
            14. +-commutativeN/A

              \[\leadsto e^{\left|n - m\right| - \mathsf{fma}\left(\frac{1}{4}, \color{blue}{\left(n + m\right)} \cdot \left(m + n\right), \ell\right)} \]
            15. +-lowering-+.f64N/A

              \[\leadsto e^{\left|n - m\right| - \mathsf{fma}\left(\frac{1}{4}, \color{blue}{\left(n + m\right)} \cdot \left(m + n\right), \ell\right)} \]
            16. +-commutativeN/A

              \[\leadsto e^{\left|n - m\right| - \mathsf{fma}\left(\frac{1}{4}, \left(n + m\right) \cdot \color{blue}{\left(n + m\right)}, \ell\right)} \]
            17. +-lowering-+.f6488.6

              \[\leadsto e^{\left|n - m\right| - \mathsf{fma}\left(0.25, \left(n + m\right) \cdot \color{blue}{\left(n + m\right)}, \ell\right)} \]
          8. Simplified88.6%

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

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

              \[\leadsto e^{\color{blue}{{n}^{2} \cdot \frac{-1}{4}}} \]
            2. unpow2N/A

              \[\leadsto e^{\color{blue}{\left(n \cdot n\right)} \cdot \frac{-1}{4}} \]
            3. associate-*l*N/A

              \[\leadsto e^{\color{blue}{n \cdot \left(n \cdot \frac{-1}{4}\right)}} \]
            4. *-commutativeN/A

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

              \[\leadsto e^{\color{blue}{n \cdot \left(\frac{-1}{4} \cdot n\right)}} \]
            6. *-commutativeN/A

              \[\leadsto e^{n \cdot \color{blue}{\left(n \cdot \frac{-1}{4}\right)}} \]
            7. *-lowering-*.f6455.7

              \[\leadsto e^{n \cdot \color{blue}{\left(n \cdot -0.25\right)}} \]
          11. Simplified55.7%

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

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

        Alternative 6: 71.5% accurate, 2.9× speedup?

        \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;\ell \leq -6.1 \cdot 10^{+32}:\\ \;\;\;\;e^{\ell}\\ \mathbf{elif}\;\ell \leq 7 \cdot 10^{-17}:\\ \;\;\;\;e^{n \cdot \left(n \cdot -0.25\right)}\\ \mathbf{else}:\\ \;\;\;\;e^{0 - \ell}\\ \end{array} \end{array} \]
        (FPCore (K m n M l)
         :precision binary64
         (if (<= l -6.1e+32)
           (exp l)
           (if (<= l 7e-17) (exp (* n (* n -0.25))) (exp (- 0.0 l)))))
        double code(double K, double m, double n, double M, double l) {
        	double tmp;
        	if (l <= -6.1e+32) {
        		tmp = exp(l);
        	} else if (l <= 7e-17) {
        		tmp = exp((n * (n * -0.25)));
        	} else {
        		tmp = exp((0.0 - 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 (l <= (-6.1d+32)) then
                tmp = exp(l)
            else if (l <= 7d-17) then
                tmp = exp((n * (n * (-0.25d0))))
            else
                tmp = exp((0.0d0 - l))
            end if
            code = tmp
        end function
        
        public static double code(double K, double m, double n, double M, double l) {
        	double tmp;
        	if (l <= -6.1e+32) {
        		tmp = Math.exp(l);
        	} else if (l <= 7e-17) {
        		tmp = Math.exp((n * (n * -0.25)));
        	} else {
        		tmp = Math.exp((0.0 - l));
        	}
        	return tmp;
        }
        
        def code(K, m, n, M, l):
        	tmp = 0
        	if l <= -6.1e+32:
        		tmp = math.exp(l)
        	elif l <= 7e-17:
        		tmp = math.exp((n * (n * -0.25)))
        	else:
        		tmp = math.exp((0.0 - l))
        	return tmp
        
        function code(K, m, n, M, l)
        	tmp = 0.0
        	if (l <= -6.1e+32)
        		tmp = exp(l);
        	elseif (l <= 7e-17)
        		tmp = exp(Float64(n * Float64(n * -0.25)));
        	else
        		tmp = exp(Float64(0.0 - l));
        	end
        	return tmp
        end
        
        function tmp_2 = code(K, m, n, M, l)
        	tmp = 0.0;
        	if (l <= -6.1e+32)
        		tmp = exp(l);
        	elseif (l <= 7e-17)
        		tmp = exp((n * (n * -0.25)));
        	else
        		tmp = exp((0.0 - l));
        	end
        	tmp_2 = tmp;
        end
        
        code[K_, m_, n_, M_, l_] := If[LessEqual[l, -6.1e+32], N[Exp[l], $MachinePrecision], If[LessEqual[l, 7e-17], N[Exp[N[(n * N[(n * -0.25), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[Exp[N[(0.0 - l), $MachinePrecision]], $MachinePrecision]]]
        
        \begin{array}{l}
        
        \\
        \begin{array}{l}
        \mathbf{if}\;\ell \leq -6.1 \cdot 10^{+32}:\\
        \;\;\;\;e^{\ell}\\
        
        \mathbf{elif}\;\ell \leq 7 \cdot 10^{-17}:\\
        \;\;\;\;e^{n \cdot \left(n \cdot -0.25\right)}\\
        
        \mathbf{else}:\\
        \;\;\;\;e^{0 - \ell}\\
        
        
        \end{array}
        \end{array}
        
        Derivation
        1. Split input into 3 regimes
        2. if l < -6.10000000000000027e32

          1. Initial program 73.3%

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

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

              \[\leadsto \color{blue}{\cos M} \cdot e^{\left(\mathsf{neg}\left({\left(\frac{m + n}{2} - M\right)}^{2}\right)\right) - \left(\ell - \left|m - n\right|\right)} \]
            2. cos-lowering-cos.f6495.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. Simplified95.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)} \]
          6. Taylor expanded in M around 0

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

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

              \[\leadsto e^{\color{blue}{\left|m - n\right| - \left(\ell + \frac{1}{4} \cdot {\left(m + n\right)}^{2}\right)}} \]
            3. fabs-subN/A

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

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

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

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

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

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

              \[\leadsto e^{\left|\color{blue}{n - m}\right| - \left(\ell + \frac{1}{4} \cdot {\left(m + n\right)}^{2}\right)} \]
            10. +-commutativeN/A

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

              \[\leadsto e^{\left|n - m\right| - \color{blue}{\mathsf{fma}\left(\frac{1}{4}, {\left(m + n\right)}^{2}, \ell\right)}} \]
            12. unpow2N/A

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

              \[\leadsto e^{\left|n - m\right| - \mathsf{fma}\left(\frac{1}{4}, \color{blue}{\left(m + n\right) \cdot \left(m + n\right)}, \ell\right)} \]
            14. +-commutativeN/A

              \[\leadsto e^{\left|n - m\right| - \mathsf{fma}\left(\frac{1}{4}, \color{blue}{\left(n + m\right)} \cdot \left(m + n\right), \ell\right)} \]
            15. +-lowering-+.f64N/A

              \[\leadsto e^{\left|n - m\right| - \mathsf{fma}\left(\frac{1}{4}, \color{blue}{\left(n + m\right)} \cdot \left(m + n\right), \ell\right)} \]
            16. +-commutativeN/A

              \[\leadsto e^{\left|n - m\right| - \mathsf{fma}\left(\frac{1}{4}, \left(n + m\right) \cdot \color{blue}{\left(n + m\right)}, \ell\right)} \]
            17. +-lowering-+.f6478.5

              \[\leadsto e^{\left|n - m\right| - \mathsf{fma}\left(0.25, \left(n + m\right) \cdot \color{blue}{\left(n + m\right)}, \ell\right)} \]
          8. Simplified78.5%

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

            \[\leadsto e^{\color{blue}{-1 \cdot \ell}} \]
          10. Step-by-step derivation
            1. neg-mul-1N/A

              \[\leadsto e^{\color{blue}{\mathsf{neg}\left(\ell\right)}} \]
            2. neg-sub0N/A

              \[\leadsto e^{\color{blue}{0 - \ell}} \]
            3. --lowering--.f6414.6

              \[\leadsto e^{\color{blue}{0 - \ell}} \]
          11. Simplified14.6%

            \[\leadsto e^{\color{blue}{0 - \ell}} \]
          12. Step-by-step derivation
            1. flip3--N/A

              \[\leadsto e^{\color{blue}{\frac{{0}^{3} - {\ell}^{3}}{0 \cdot 0 + \left(\ell \cdot \ell + 0 \cdot \ell\right)}}} \]
            2. div-invN/A

              \[\leadsto e^{\color{blue}{\left({0}^{3} - {\ell}^{3}\right) \cdot \frac{1}{0 \cdot 0 + \left(\ell \cdot \ell + 0 \cdot \ell\right)}}} \]
            3. metadata-evalN/A

              \[\leadsto e^{\left(\color{blue}{0} - {\ell}^{3}\right) \cdot \frac{1}{0 \cdot 0 + \left(\ell \cdot \ell + 0 \cdot \ell\right)}} \]
            4. sub0-negN/A

              \[\leadsto e^{\color{blue}{\left(\mathsf{neg}\left({\ell}^{3}\right)\right)} \cdot \frac{1}{0 \cdot 0 + \left(\ell \cdot \ell + 0 \cdot \ell\right)}} \]
            5. sqr-powN/A

              \[\leadsto e^{\left(\mathsf{neg}\left(\color{blue}{{\ell}^{\left(\frac{3}{2}\right)} \cdot {\ell}^{\left(\frac{3}{2}\right)}}\right)\right) \cdot \frac{1}{0 \cdot 0 + \left(\ell \cdot \ell + 0 \cdot \ell\right)}} \]
            6. pow-prod-downN/A

              \[\leadsto e^{\left(\mathsf{neg}\left(\color{blue}{{\left(\ell \cdot \ell\right)}^{\left(\frac{3}{2}\right)}}\right)\right) \cdot \frac{1}{0 \cdot 0 + \left(\ell \cdot \ell + 0 \cdot \ell\right)}} \]
            7. sqr-negN/A

              \[\leadsto e^{\left(\mathsf{neg}\left({\color{blue}{\left(\left(\mathsf{neg}\left(\ell\right)\right) \cdot \left(\mathsf{neg}\left(\ell\right)\right)\right)}}^{\left(\frac{3}{2}\right)}\right)\right) \cdot \frac{1}{0 \cdot 0 + \left(\ell \cdot \ell + 0 \cdot \ell\right)}} \]
            8. sub0-negN/A

              \[\leadsto e^{\left(\mathsf{neg}\left({\left(\color{blue}{\left(0 - \ell\right)} \cdot \left(\mathsf{neg}\left(\ell\right)\right)\right)}^{\left(\frac{3}{2}\right)}\right)\right) \cdot \frac{1}{0 \cdot 0 + \left(\ell \cdot \ell + 0 \cdot \ell\right)}} \]
            9. sub0-negN/A

              \[\leadsto e^{\left(\mathsf{neg}\left({\left(\left(0 - \ell\right) \cdot \color{blue}{\left(0 - \ell\right)}\right)}^{\left(\frac{3}{2}\right)}\right)\right) \cdot \frac{1}{0 \cdot 0 + \left(\ell \cdot \ell + 0 \cdot \ell\right)}} \]
            10. pow-prod-downN/A

              \[\leadsto e^{\left(\mathsf{neg}\left(\color{blue}{{\left(0 - \ell\right)}^{\left(\frac{3}{2}\right)} \cdot {\left(0 - \ell\right)}^{\left(\frac{3}{2}\right)}}\right)\right) \cdot \frac{1}{0 \cdot 0 + \left(\ell \cdot \ell + 0 \cdot \ell\right)}} \]
            11. sqr-powN/A

              \[\leadsto e^{\left(\mathsf{neg}\left(\color{blue}{{\left(0 - \ell\right)}^{3}}\right)\right) \cdot \frac{1}{0 \cdot 0 + \left(\ell \cdot \ell + 0 \cdot \ell\right)}} \]
            12. sub0-negN/A

              \[\leadsto e^{\left(\mathsf{neg}\left({\color{blue}{\left(\mathsf{neg}\left(\ell\right)\right)}}^{3}\right)\right) \cdot \frac{1}{0 \cdot 0 + \left(\ell \cdot \ell + 0 \cdot \ell\right)}} \]
            13. cube-negN/A

              \[\leadsto e^{\left(\mathsf{neg}\left(\color{blue}{\left(\mathsf{neg}\left({\ell}^{3}\right)\right)}\right)\right) \cdot \frac{1}{0 \cdot 0 + \left(\ell \cdot \ell + 0 \cdot \ell\right)}} \]
            14. sub0-negN/A

              \[\leadsto e^{\left(\mathsf{neg}\left(\color{blue}{\left(0 - {\ell}^{3}\right)}\right)\right) \cdot \frac{1}{0 \cdot 0 + \left(\ell \cdot \ell + 0 \cdot \ell\right)}} \]
            15. metadata-evalN/A

              \[\leadsto e^{\left(\mathsf{neg}\left(\left(\color{blue}{{0}^{3}} - {\ell}^{3}\right)\right)\right) \cdot \frac{1}{0 \cdot 0 + \left(\ell \cdot \ell + 0 \cdot \ell\right)}} \]
            16. distribute-lft-neg-inN/A

              \[\leadsto e^{\color{blue}{\mathsf{neg}\left(\left({0}^{3} - {\ell}^{3}\right) \cdot \frac{1}{0 \cdot 0 + \left(\ell \cdot \ell + 0 \cdot \ell\right)}\right)}} \]
            17. div-invN/A

              \[\leadsto e^{\mathsf{neg}\left(\color{blue}{\frac{{0}^{3} - {\ell}^{3}}{0 \cdot 0 + \left(\ell \cdot \ell + 0 \cdot \ell\right)}}\right)} \]
            18. flip3--N/A

              \[\leadsto e^{\mathsf{neg}\left(\color{blue}{\left(0 - \ell\right)}\right)} \]
            19. sub0-negN/A

              \[\leadsto e^{\mathsf{neg}\left(\color{blue}{\left(\mathsf{neg}\left(\ell\right)\right)}\right)} \]
          13. Applied egg-rr78.7%

            \[\leadsto \color{blue}{e^{\ell}} \]

          if -6.10000000000000027e32 < l < 7.0000000000000003e-17

          1. Initial program 78.6%

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

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

              \[\leadsto \color{blue}{\cos M} \cdot e^{\left(\mathsf{neg}\left({\left(\frac{m + n}{2} - M\right)}^{2}\right)\right) - \left(\ell - \left|m - n\right|\right)} \]
            2. cos-lowering-cos.f6498.6

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

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

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

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

              \[\leadsto e^{\color{blue}{\left|m - n\right| - \left(\ell + \frac{1}{4} \cdot {\left(m + n\right)}^{2}\right)}} \]
            3. fabs-subN/A

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

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

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

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

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

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

              \[\leadsto e^{\left|\color{blue}{n - m}\right| - \left(\ell + \frac{1}{4} \cdot {\left(m + n\right)}^{2}\right)} \]
            10. +-commutativeN/A

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

              \[\leadsto e^{\left|n - m\right| - \color{blue}{\mathsf{fma}\left(\frac{1}{4}, {\left(m + n\right)}^{2}, \ell\right)}} \]
            12. unpow2N/A

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

              \[\leadsto e^{\left|n - m\right| - \mathsf{fma}\left(\frac{1}{4}, \color{blue}{\left(m + n\right) \cdot \left(m + n\right)}, \ell\right)} \]
            14. +-commutativeN/A

              \[\leadsto e^{\left|n - m\right| - \mathsf{fma}\left(\frac{1}{4}, \color{blue}{\left(n + m\right)} \cdot \left(m + n\right), \ell\right)} \]
            15. +-lowering-+.f64N/A

              \[\leadsto e^{\left|n - m\right| - \mathsf{fma}\left(\frac{1}{4}, \color{blue}{\left(n + m\right)} \cdot \left(m + n\right), \ell\right)} \]
            16. +-commutativeN/A

              \[\leadsto e^{\left|n - m\right| - \mathsf{fma}\left(\frac{1}{4}, \left(n + m\right) \cdot \color{blue}{\left(n + m\right)}, \ell\right)} \]
            17. +-lowering-+.f6485.8

              \[\leadsto e^{\left|n - m\right| - \mathsf{fma}\left(0.25, \left(n + m\right) \cdot \color{blue}{\left(n + m\right)}, \ell\right)} \]
          8. Simplified85.8%

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

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

              \[\leadsto e^{\color{blue}{{n}^{2} \cdot \frac{-1}{4}}} \]
            2. unpow2N/A

              \[\leadsto e^{\color{blue}{\left(n \cdot n\right)} \cdot \frac{-1}{4}} \]
            3. associate-*l*N/A

              \[\leadsto e^{\color{blue}{n \cdot \left(n \cdot \frac{-1}{4}\right)}} \]
            4. *-commutativeN/A

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

              \[\leadsto e^{\color{blue}{n \cdot \left(\frac{-1}{4} \cdot n\right)}} \]
            6. *-commutativeN/A

              \[\leadsto e^{n \cdot \color{blue}{\left(n \cdot \frac{-1}{4}\right)}} \]
            7. *-lowering-*.f6460.5

              \[\leadsto e^{n \cdot \color{blue}{\left(n \cdot -0.25\right)}} \]
          11. Simplified60.5%

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

          if 7.0000000000000003e-17 < l

          1. Initial program 73.1%

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

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

              \[\leadsto \color{blue}{\cos M} \cdot e^{\left(\mathsf{neg}\left({\left(\frac{m + n}{2} - M\right)}^{2}\right)\right) - \left(\ell - \left|m - n\right|\right)} \]
            2. cos-lowering-cos.f64100.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. 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)} \]
          6. Taylor expanded in M around 0

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

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

              \[\leadsto e^{\color{blue}{\left|m - n\right| - \left(\ell + \frac{1}{4} \cdot {\left(m + n\right)}^{2}\right)}} \]
            3. fabs-subN/A

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

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

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

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

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

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

              \[\leadsto e^{\left|\color{blue}{n - m}\right| - \left(\ell + \frac{1}{4} \cdot {\left(m + n\right)}^{2}\right)} \]
            10. +-commutativeN/A

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

              \[\leadsto e^{\left|n - m\right| - \color{blue}{\mathsf{fma}\left(\frac{1}{4}, {\left(m + n\right)}^{2}, \ell\right)}} \]
            12. unpow2N/A

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

              \[\leadsto e^{\left|n - m\right| - \mathsf{fma}\left(\frac{1}{4}, \color{blue}{\left(m + n\right) \cdot \left(m + n\right)}, \ell\right)} \]
            14. +-commutativeN/A

              \[\leadsto e^{\left|n - m\right| - \mathsf{fma}\left(\frac{1}{4}, \color{blue}{\left(n + m\right)} \cdot \left(m + n\right), \ell\right)} \]
            15. +-lowering-+.f64N/A

              \[\leadsto e^{\left|n - m\right| - \mathsf{fma}\left(\frac{1}{4}, \color{blue}{\left(n + m\right)} \cdot \left(m + n\right), \ell\right)} \]
            16. +-commutativeN/A

              \[\leadsto e^{\left|n - m\right| - \mathsf{fma}\left(\frac{1}{4}, \left(n + m\right) \cdot \color{blue}{\left(n + m\right)}, \ell\right)} \]
            17. +-lowering-+.f64100.0

              \[\leadsto e^{\left|n - m\right| - \mathsf{fma}\left(0.25, \left(n + m\right) \cdot \color{blue}{\left(n + m\right)}, \ell\right)} \]
          8. Simplified100.0%

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

            \[\leadsto e^{\color{blue}{-1 \cdot \ell}} \]
          10. Step-by-step derivation
            1. neg-mul-1N/A

              \[\leadsto e^{\color{blue}{\mathsf{neg}\left(\ell\right)}} \]
            2. neg-sub0N/A

              \[\leadsto e^{\color{blue}{0 - \ell}} \]
            3. --lowering--.f6496.2

              \[\leadsto e^{\color{blue}{0 - \ell}} \]
          11. Simplified96.2%

            \[\leadsto e^{\color{blue}{0 - \ell}} \]
          12. Step-by-step derivation
            1. sub0-negN/A

              \[\leadsto e^{\color{blue}{\mathsf{neg}\left(\ell\right)}} \]
            2. neg-lowering-neg.f6496.2

              \[\leadsto e^{\color{blue}{-\ell}} \]
          13. Applied egg-rr96.2%

            \[\leadsto e^{\color{blue}{-\ell}} \]
        3. Recombined 3 regimes into one program.
        4. Final simplification74.1%

          \[\leadsto \begin{array}{l} \mathbf{if}\;\ell \leq -6.1 \cdot 10^{+32}:\\ \;\;\;\;e^{\ell}\\ \mathbf{elif}\;\ell \leq 7 \cdot 10^{-17}:\\ \;\;\;\;e^{n \cdot \left(n \cdot -0.25\right)}\\ \mathbf{else}:\\ \;\;\;\;e^{0 - \ell}\\ \end{array} \]
        5. Add Preprocessing

        Alternative 7: 65.1% accurate, 3.1× speedup?

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

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

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

              \[\leadsto \color{blue}{\cos M} \cdot e^{\left(\mathsf{neg}\left({\left(\frac{m + n}{2} - M\right)}^{2}\right)\right) - \left(\ell - \left|m - n\right|\right)} \]
            2. cos-lowering-cos.f6498.2

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

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

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

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

              \[\leadsto e^{\color{blue}{\left|m - n\right| - \left(\ell + \frac{1}{4} \cdot {\left(m + n\right)}^{2}\right)}} \]
            3. fabs-subN/A

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

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

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

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

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

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

              \[\leadsto e^{\left|\color{blue}{n - m}\right| - \left(\ell + \frac{1}{4} \cdot {\left(m + n\right)}^{2}\right)} \]
            10. +-commutativeN/A

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

              \[\leadsto e^{\left|n - m\right| - \color{blue}{\mathsf{fma}\left(\frac{1}{4}, {\left(m + n\right)}^{2}, \ell\right)}} \]
            12. unpow2N/A

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

              \[\leadsto e^{\left|n - m\right| - \mathsf{fma}\left(\frac{1}{4}, \color{blue}{\left(m + n\right) \cdot \left(m + n\right)}, \ell\right)} \]
            14. +-commutativeN/A

              \[\leadsto e^{\left|n - m\right| - \mathsf{fma}\left(\frac{1}{4}, \color{blue}{\left(n + m\right)} \cdot \left(m + n\right), \ell\right)} \]
            15. +-lowering-+.f64N/A

              \[\leadsto e^{\left|n - m\right| - \mathsf{fma}\left(\frac{1}{4}, \color{blue}{\left(n + m\right)} \cdot \left(m + n\right), \ell\right)} \]
            16. +-commutativeN/A

              \[\leadsto e^{\left|n - m\right| - \mathsf{fma}\left(\frac{1}{4}, \left(n + m\right) \cdot \color{blue}{\left(n + m\right)}, \ell\right)} \]
            17. +-lowering-+.f6494.7

              \[\leadsto e^{\left|n - m\right| - \mathsf{fma}\left(0.25, \left(n + m\right) \cdot \color{blue}{\left(n + m\right)}, \ell\right)} \]
          8. Simplified94.7%

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

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

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

              \[\leadsto e^{\color{blue}{{m}^{2} \cdot \frac{-1}{4}}} \]
            3. unpow2N/A

              \[\leadsto e^{\color{blue}{\left(m \cdot m\right)} \cdot \frac{-1}{4}} \]
            4. *-lowering-*.f6498.2

              \[\leadsto e^{\color{blue}{\left(m \cdot m\right)} \cdot -0.25} \]
          11. Simplified98.2%

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

          if -55 < m

          1. Initial program 79.7%

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

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

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

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

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

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

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

              \[\leadsto e^{\color{blue}{\left|m - n\right| - \left(\ell + \frac{1}{4} \cdot {\left(m + n\right)}^{2}\right)}} \]
            3. fabs-subN/A

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

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

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

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

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

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

              \[\leadsto e^{\left|\color{blue}{n - m}\right| - \left(\ell + \frac{1}{4} \cdot {\left(m + n\right)}^{2}\right)} \]
            10. +-commutativeN/A

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

              \[\leadsto e^{\left|n - m\right| - \color{blue}{\mathsf{fma}\left(\frac{1}{4}, {\left(m + n\right)}^{2}, \ell\right)}} \]
            12. unpow2N/A

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

              \[\leadsto e^{\left|n - m\right| - \mathsf{fma}\left(\frac{1}{4}, \color{blue}{\left(m + n\right) \cdot \left(m + n\right)}, \ell\right)} \]
            14. +-commutativeN/A

              \[\leadsto e^{\left|n - m\right| - \mathsf{fma}\left(\frac{1}{4}, \color{blue}{\left(n + m\right)} \cdot \left(m + n\right), \ell\right)} \]
            15. +-lowering-+.f64N/A

              \[\leadsto e^{\left|n - m\right| - \mathsf{fma}\left(\frac{1}{4}, \color{blue}{\left(n + m\right)} \cdot \left(m + n\right), \ell\right)} \]
            16. +-commutativeN/A

              \[\leadsto e^{\left|n - m\right| - \mathsf{fma}\left(\frac{1}{4}, \left(n + m\right) \cdot \color{blue}{\left(n + m\right)}, \ell\right)} \]
            17. +-lowering-+.f6485.9

              \[\leadsto e^{\left|n - m\right| - \mathsf{fma}\left(0.25, \left(n + m\right) \cdot \color{blue}{\left(n + m\right)}, \ell\right)} \]
          8. Simplified85.9%

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

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

              \[\leadsto e^{\color{blue}{{n}^{2} \cdot \frac{-1}{4}}} \]
            2. unpow2N/A

              \[\leadsto e^{\color{blue}{\left(n \cdot n\right)} \cdot \frac{-1}{4}} \]
            3. associate-*l*N/A

              \[\leadsto e^{\color{blue}{n \cdot \left(n \cdot \frac{-1}{4}\right)}} \]
            4. *-commutativeN/A

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

              \[\leadsto e^{\color{blue}{n \cdot \left(\frac{-1}{4} \cdot n\right)}} \]
            6. *-commutativeN/A

              \[\leadsto e^{n \cdot \color{blue}{\left(n \cdot \frac{-1}{4}\right)}} \]
            7. *-lowering-*.f6457.5

              \[\leadsto e^{n \cdot \color{blue}{\left(n \cdot -0.25\right)}} \]
          11. Simplified57.5%

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

        Alternative 8: 49.2% accurate, 3.3× speedup?

        \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;\ell \leq 10^{-16}:\\ \;\;\;\;e^{\ell}\\ \mathbf{else}:\\ \;\;\;\;e^{0 - \ell}\\ \end{array} \end{array} \]
        (FPCore (K m n M l)
         :precision binary64
         (if (<= l 1e-16) (exp l) (exp (- 0.0 l))))
        double code(double K, double m, double n, double M, double l) {
        	double tmp;
        	if (l <= 1e-16) {
        		tmp = exp(l);
        	} else {
        		tmp = exp((0.0 - 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 (l <= 1d-16) then
                tmp = exp(l)
            else
                tmp = exp((0.0d0 - l))
            end if
            code = tmp
        end function
        
        public static double code(double K, double m, double n, double M, double l) {
        	double tmp;
        	if (l <= 1e-16) {
        		tmp = Math.exp(l);
        	} else {
        		tmp = Math.exp((0.0 - l));
        	}
        	return tmp;
        }
        
        def code(K, m, n, M, l):
        	tmp = 0
        	if l <= 1e-16:
        		tmp = math.exp(l)
        	else:
        		tmp = math.exp((0.0 - l))
        	return tmp
        
        function code(K, m, n, M, l)
        	tmp = 0.0
        	if (l <= 1e-16)
        		tmp = exp(l);
        	else
        		tmp = exp(Float64(0.0 - l));
        	end
        	return tmp
        end
        
        function tmp_2 = code(K, m, n, M, l)
        	tmp = 0.0;
        	if (l <= 1e-16)
        		tmp = exp(l);
        	else
        		tmp = exp((0.0 - l));
        	end
        	tmp_2 = tmp;
        end
        
        code[K_, m_, n_, M_, l_] := If[LessEqual[l, 1e-16], N[Exp[l], $MachinePrecision], N[Exp[N[(0.0 - l), $MachinePrecision]], $MachinePrecision]]
        
        \begin{array}{l}
        
        \\
        \begin{array}{l}
        \mathbf{if}\;\ell \leq 10^{-16}:\\
        \;\;\;\;e^{\ell}\\
        
        \mathbf{else}:\\
        \;\;\;\;e^{0 - \ell}\\
        
        
        \end{array}
        \end{array}
        
        Derivation
        1. Split input into 2 regimes
        2. if l < 9.9999999999999998e-17

          1. Initial program 77.0%

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

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

              \[\leadsto \color{blue}{\cos M} \cdot e^{\left(\mathsf{neg}\left({\left(\frac{m + n}{2} - M\right)}^{2}\right)\right) - \left(\ell - \left|m - n\right|\right)} \]
            2. cos-lowering-cos.f6497.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. Simplified97.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)} \]
          6. Taylor expanded in M around 0

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

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

              \[\leadsto e^{\color{blue}{\left|m - n\right| - \left(\ell + \frac{1}{4} \cdot {\left(m + n\right)}^{2}\right)}} \]
            3. fabs-subN/A

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

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

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

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

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

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

              \[\leadsto e^{\left|\color{blue}{n - m}\right| - \left(\ell + \frac{1}{4} \cdot {\left(m + n\right)}^{2}\right)} \]
            10. +-commutativeN/A

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

              \[\leadsto e^{\left|n - m\right| - \color{blue}{\mathsf{fma}\left(\frac{1}{4}, {\left(m + n\right)}^{2}, \ell\right)}} \]
            12. unpow2N/A

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

              \[\leadsto e^{\left|n - m\right| - \mathsf{fma}\left(\frac{1}{4}, \color{blue}{\left(m + n\right) \cdot \left(m + n\right)}, \ell\right)} \]
            14. +-commutativeN/A

              \[\leadsto e^{\left|n - m\right| - \mathsf{fma}\left(\frac{1}{4}, \color{blue}{\left(n + m\right)} \cdot \left(m + n\right), \ell\right)} \]
            15. +-lowering-+.f64N/A

              \[\leadsto e^{\left|n - m\right| - \mathsf{fma}\left(\frac{1}{4}, \color{blue}{\left(n + m\right)} \cdot \left(m + n\right), \ell\right)} \]
            16. +-commutativeN/A

              \[\leadsto e^{\left|n - m\right| - \mathsf{fma}\left(\frac{1}{4}, \left(n + m\right) \cdot \color{blue}{\left(n + m\right)}, \ell\right)} \]
            17. +-lowering-+.f6483.6

              \[\leadsto e^{\left|n - m\right| - \mathsf{fma}\left(0.25, \left(n + m\right) \cdot \color{blue}{\left(n + m\right)}, \ell\right)} \]
          8. Simplified83.6%

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

            \[\leadsto e^{\color{blue}{-1 \cdot \ell}} \]
          10. Step-by-step derivation
            1. neg-mul-1N/A

              \[\leadsto e^{\color{blue}{\mathsf{neg}\left(\ell\right)}} \]
            2. neg-sub0N/A

              \[\leadsto e^{\color{blue}{0 - \ell}} \]
            3. --lowering--.f6414.7

              \[\leadsto e^{\color{blue}{0 - \ell}} \]
          11. Simplified14.7%

            \[\leadsto e^{\color{blue}{0 - \ell}} \]
          12. Step-by-step derivation
            1. flip3--N/A

              \[\leadsto e^{\color{blue}{\frac{{0}^{3} - {\ell}^{3}}{0 \cdot 0 + \left(\ell \cdot \ell + 0 \cdot \ell\right)}}} \]
            2. div-invN/A

              \[\leadsto e^{\color{blue}{\left({0}^{3} - {\ell}^{3}\right) \cdot \frac{1}{0 \cdot 0 + \left(\ell \cdot \ell + 0 \cdot \ell\right)}}} \]
            3. metadata-evalN/A

              \[\leadsto e^{\left(\color{blue}{0} - {\ell}^{3}\right) \cdot \frac{1}{0 \cdot 0 + \left(\ell \cdot \ell + 0 \cdot \ell\right)}} \]
            4. sub0-negN/A

              \[\leadsto e^{\color{blue}{\left(\mathsf{neg}\left({\ell}^{3}\right)\right)} \cdot \frac{1}{0 \cdot 0 + \left(\ell \cdot \ell + 0 \cdot \ell\right)}} \]
            5. sqr-powN/A

              \[\leadsto e^{\left(\mathsf{neg}\left(\color{blue}{{\ell}^{\left(\frac{3}{2}\right)} \cdot {\ell}^{\left(\frac{3}{2}\right)}}\right)\right) \cdot \frac{1}{0 \cdot 0 + \left(\ell \cdot \ell + 0 \cdot \ell\right)}} \]
            6. pow-prod-downN/A

              \[\leadsto e^{\left(\mathsf{neg}\left(\color{blue}{{\left(\ell \cdot \ell\right)}^{\left(\frac{3}{2}\right)}}\right)\right) \cdot \frac{1}{0 \cdot 0 + \left(\ell \cdot \ell + 0 \cdot \ell\right)}} \]
            7. sqr-negN/A

              \[\leadsto e^{\left(\mathsf{neg}\left({\color{blue}{\left(\left(\mathsf{neg}\left(\ell\right)\right) \cdot \left(\mathsf{neg}\left(\ell\right)\right)\right)}}^{\left(\frac{3}{2}\right)}\right)\right) \cdot \frac{1}{0 \cdot 0 + \left(\ell \cdot \ell + 0 \cdot \ell\right)}} \]
            8. sub0-negN/A

              \[\leadsto e^{\left(\mathsf{neg}\left({\left(\color{blue}{\left(0 - \ell\right)} \cdot \left(\mathsf{neg}\left(\ell\right)\right)\right)}^{\left(\frac{3}{2}\right)}\right)\right) \cdot \frac{1}{0 \cdot 0 + \left(\ell \cdot \ell + 0 \cdot \ell\right)}} \]
            9. sub0-negN/A

              \[\leadsto e^{\left(\mathsf{neg}\left({\left(\left(0 - \ell\right) \cdot \color{blue}{\left(0 - \ell\right)}\right)}^{\left(\frac{3}{2}\right)}\right)\right) \cdot \frac{1}{0 \cdot 0 + \left(\ell \cdot \ell + 0 \cdot \ell\right)}} \]
            10. pow-prod-downN/A

              \[\leadsto e^{\left(\mathsf{neg}\left(\color{blue}{{\left(0 - \ell\right)}^{\left(\frac{3}{2}\right)} \cdot {\left(0 - \ell\right)}^{\left(\frac{3}{2}\right)}}\right)\right) \cdot \frac{1}{0 \cdot 0 + \left(\ell \cdot \ell + 0 \cdot \ell\right)}} \]
            11. sqr-powN/A

              \[\leadsto e^{\left(\mathsf{neg}\left(\color{blue}{{\left(0 - \ell\right)}^{3}}\right)\right) \cdot \frac{1}{0 \cdot 0 + \left(\ell \cdot \ell + 0 \cdot \ell\right)}} \]
            12. sub0-negN/A

              \[\leadsto e^{\left(\mathsf{neg}\left({\color{blue}{\left(\mathsf{neg}\left(\ell\right)\right)}}^{3}\right)\right) \cdot \frac{1}{0 \cdot 0 + \left(\ell \cdot \ell + 0 \cdot \ell\right)}} \]
            13. cube-negN/A

              \[\leadsto e^{\left(\mathsf{neg}\left(\color{blue}{\left(\mathsf{neg}\left({\ell}^{3}\right)\right)}\right)\right) \cdot \frac{1}{0 \cdot 0 + \left(\ell \cdot \ell + 0 \cdot \ell\right)}} \]
            14. sub0-negN/A

              \[\leadsto e^{\left(\mathsf{neg}\left(\color{blue}{\left(0 - {\ell}^{3}\right)}\right)\right) \cdot \frac{1}{0 \cdot 0 + \left(\ell \cdot \ell + 0 \cdot \ell\right)}} \]
            15. metadata-evalN/A

              \[\leadsto e^{\left(\mathsf{neg}\left(\left(\color{blue}{{0}^{3}} - {\ell}^{3}\right)\right)\right) \cdot \frac{1}{0 \cdot 0 + \left(\ell \cdot \ell + 0 \cdot \ell\right)}} \]
            16. distribute-lft-neg-inN/A

              \[\leadsto e^{\color{blue}{\mathsf{neg}\left(\left({0}^{3} - {\ell}^{3}\right) \cdot \frac{1}{0 \cdot 0 + \left(\ell \cdot \ell + 0 \cdot \ell\right)}\right)}} \]
            17. div-invN/A

              \[\leadsto e^{\mathsf{neg}\left(\color{blue}{\frac{{0}^{3} - {\ell}^{3}}{0 \cdot 0 + \left(\ell \cdot \ell + 0 \cdot \ell\right)}}\right)} \]
            18. flip3--N/A

              \[\leadsto e^{\mathsf{neg}\left(\color{blue}{\left(0 - \ell\right)}\right)} \]
            19. sub0-negN/A

              \[\leadsto e^{\mathsf{neg}\left(\color{blue}{\left(\mathsf{neg}\left(\ell\right)\right)}\right)} \]
          13. Applied egg-rr36.5%

            \[\leadsto \color{blue}{e^{\ell}} \]

          if 9.9999999999999998e-17 < l

          1. Initial program 72.7%

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

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

              \[\leadsto \color{blue}{\cos M} \cdot e^{\left(\mathsf{neg}\left({\left(\frac{m + n}{2} - M\right)}^{2}\right)\right) - \left(\ell - \left|m - n\right|\right)} \]
            2. cos-lowering-cos.f64100.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. 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)} \]
          6. Taylor expanded in M around 0

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

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

              \[\leadsto e^{\color{blue}{\left|m - n\right| - \left(\ell + \frac{1}{4} \cdot {\left(m + n\right)}^{2}\right)}} \]
            3. fabs-subN/A

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

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

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

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

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

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

              \[\leadsto e^{\left|\color{blue}{n - m}\right| - \left(\ell + \frac{1}{4} \cdot {\left(m + n\right)}^{2}\right)} \]
            10. +-commutativeN/A

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

              \[\leadsto e^{\left|n - m\right| - \color{blue}{\mathsf{fma}\left(\frac{1}{4}, {\left(m + n\right)}^{2}, \ell\right)}} \]
            12. unpow2N/A

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

              \[\leadsto e^{\left|n - m\right| - \mathsf{fma}\left(\frac{1}{4}, \color{blue}{\left(m + n\right) \cdot \left(m + n\right)}, \ell\right)} \]
            14. +-commutativeN/A

              \[\leadsto e^{\left|n - m\right| - \mathsf{fma}\left(\frac{1}{4}, \color{blue}{\left(n + m\right)} \cdot \left(m + n\right), \ell\right)} \]
            15. +-lowering-+.f64N/A

              \[\leadsto e^{\left|n - m\right| - \mathsf{fma}\left(\frac{1}{4}, \color{blue}{\left(n + m\right)} \cdot \left(m + n\right), \ell\right)} \]
            16. +-commutativeN/A

              \[\leadsto e^{\left|n - m\right| - \mathsf{fma}\left(\frac{1}{4}, \left(n + m\right) \cdot \color{blue}{\left(n + m\right)}, \ell\right)} \]
            17. +-lowering-+.f64100.0

              \[\leadsto e^{\left|n - m\right| - \mathsf{fma}\left(0.25, \left(n + m\right) \cdot \color{blue}{\left(n + m\right)}, \ell\right)} \]
          8. Simplified100.0%

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

            \[\leadsto e^{\color{blue}{-1 \cdot \ell}} \]
          10. Step-by-step derivation
            1. neg-mul-1N/A

              \[\leadsto e^{\color{blue}{\mathsf{neg}\left(\ell\right)}} \]
            2. neg-sub0N/A

              \[\leadsto e^{\color{blue}{0 - \ell}} \]
            3. --lowering--.f6497.1

              \[\leadsto e^{\color{blue}{0 - \ell}} \]
          11. Simplified97.1%

            \[\leadsto e^{\color{blue}{0 - \ell}} \]
          12. Step-by-step derivation
            1. sub0-negN/A

              \[\leadsto e^{\color{blue}{\mathsf{neg}\left(\ell\right)}} \]
            2. neg-lowering-neg.f6497.1

              \[\leadsto e^{\color{blue}{-\ell}} \]
          13. Applied egg-rr97.1%

            \[\leadsto e^{\color{blue}{-\ell}} \]
        3. Recombined 2 regimes into one program.
        4. Final simplification52.1%

          \[\leadsto \begin{array}{l} \mathbf{if}\;\ell \leq 10^{-16}:\\ \;\;\;\;e^{\ell}\\ \mathbf{else}:\\ \;\;\;\;e^{0 - \ell}\\ \end{array} \]
        5. Add Preprocessing

        Alternative 9: 24.8% accurate, 3.6× speedup?

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

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

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

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

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

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

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

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

            \[\leadsto e^{\color{blue}{\left|m - n\right| - \left(\ell + \frac{1}{4} \cdot {\left(m + n\right)}^{2}\right)}} \]
          3. fabs-subN/A

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

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

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

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

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

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

            \[\leadsto e^{\left|\color{blue}{n - m}\right| - \left(\ell + \frac{1}{4} \cdot {\left(m + n\right)}^{2}\right)} \]
          10. +-commutativeN/A

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

            \[\leadsto e^{\left|n - m\right| - \color{blue}{\mathsf{fma}\left(\frac{1}{4}, {\left(m + n\right)}^{2}, \ell\right)}} \]
          12. unpow2N/A

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

            \[\leadsto e^{\left|n - m\right| - \mathsf{fma}\left(\frac{1}{4}, \color{blue}{\left(m + n\right) \cdot \left(m + n\right)}, \ell\right)} \]
          14. +-commutativeN/A

            \[\leadsto e^{\left|n - m\right| - \mathsf{fma}\left(\frac{1}{4}, \color{blue}{\left(n + m\right)} \cdot \left(m + n\right), \ell\right)} \]
          15. +-lowering-+.f64N/A

            \[\leadsto e^{\left|n - m\right| - \mathsf{fma}\left(\frac{1}{4}, \color{blue}{\left(n + m\right)} \cdot \left(m + n\right), \ell\right)} \]
          16. +-commutativeN/A

            \[\leadsto e^{\left|n - m\right| - \mathsf{fma}\left(\frac{1}{4}, \left(n + m\right) \cdot \color{blue}{\left(n + m\right)}, \ell\right)} \]
          17. +-lowering-+.f6487.8

            \[\leadsto e^{\left|n - m\right| - \mathsf{fma}\left(0.25, \left(n + m\right) \cdot \color{blue}{\left(n + m\right)}, \ell\right)} \]
        8. Simplified87.8%

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

          \[\leadsto e^{\color{blue}{-1 \cdot \ell}} \]
        10. Step-by-step derivation
          1. neg-mul-1N/A

            \[\leadsto e^{\color{blue}{\mathsf{neg}\left(\ell\right)}} \]
          2. neg-sub0N/A

            \[\leadsto e^{\color{blue}{0 - \ell}} \]
          3. --lowering--.f6436.0

            \[\leadsto e^{\color{blue}{0 - \ell}} \]
        11. Simplified36.0%

          \[\leadsto e^{\color{blue}{0 - \ell}} \]
        12. Step-by-step derivation
          1. flip3--N/A

            \[\leadsto e^{\color{blue}{\frac{{0}^{3} - {\ell}^{3}}{0 \cdot 0 + \left(\ell \cdot \ell + 0 \cdot \ell\right)}}} \]
          2. div-invN/A

            \[\leadsto e^{\color{blue}{\left({0}^{3} - {\ell}^{3}\right) \cdot \frac{1}{0 \cdot 0 + \left(\ell \cdot \ell + 0 \cdot \ell\right)}}} \]
          3. metadata-evalN/A

            \[\leadsto e^{\left(\color{blue}{0} - {\ell}^{3}\right) \cdot \frac{1}{0 \cdot 0 + \left(\ell \cdot \ell + 0 \cdot \ell\right)}} \]
          4. sub0-negN/A

            \[\leadsto e^{\color{blue}{\left(\mathsf{neg}\left({\ell}^{3}\right)\right)} \cdot \frac{1}{0 \cdot 0 + \left(\ell \cdot \ell + 0 \cdot \ell\right)}} \]
          5. sqr-powN/A

            \[\leadsto e^{\left(\mathsf{neg}\left(\color{blue}{{\ell}^{\left(\frac{3}{2}\right)} \cdot {\ell}^{\left(\frac{3}{2}\right)}}\right)\right) \cdot \frac{1}{0 \cdot 0 + \left(\ell \cdot \ell + 0 \cdot \ell\right)}} \]
          6. pow-prod-downN/A

            \[\leadsto e^{\left(\mathsf{neg}\left(\color{blue}{{\left(\ell \cdot \ell\right)}^{\left(\frac{3}{2}\right)}}\right)\right) \cdot \frac{1}{0 \cdot 0 + \left(\ell \cdot \ell + 0 \cdot \ell\right)}} \]
          7. sqr-negN/A

            \[\leadsto e^{\left(\mathsf{neg}\left({\color{blue}{\left(\left(\mathsf{neg}\left(\ell\right)\right) \cdot \left(\mathsf{neg}\left(\ell\right)\right)\right)}}^{\left(\frac{3}{2}\right)}\right)\right) \cdot \frac{1}{0 \cdot 0 + \left(\ell \cdot \ell + 0 \cdot \ell\right)}} \]
          8. sub0-negN/A

            \[\leadsto e^{\left(\mathsf{neg}\left({\left(\color{blue}{\left(0 - \ell\right)} \cdot \left(\mathsf{neg}\left(\ell\right)\right)\right)}^{\left(\frac{3}{2}\right)}\right)\right) \cdot \frac{1}{0 \cdot 0 + \left(\ell \cdot \ell + 0 \cdot \ell\right)}} \]
          9. sub0-negN/A

            \[\leadsto e^{\left(\mathsf{neg}\left({\left(\left(0 - \ell\right) \cdot \color{blue}{\left(0 - \ell\right)}\right)}^{\left(\frac{3}{2}\right)}\right)\right) \cdot \frac{1}{0 \cdot 0 + \left(\ell \cdot \ell + 0 \cdot \ell\right)}} \]
          10. pow-prod-downN/A

            \[\leadsto e^{\left(\mathsf{neg}\left(\color{blue}{{\left(0 - \ell\right)}^{\left(\frac{3}{2}\right)} \cdot {\left(0 - \ell\right)}^{\left(\frac{3}{2}\right)}}\right)\right) \cdot \frac{1}{0 \cdot 0 + \left(\ell \cdot \ell + 0 \cdot \ell\right)}} \]
          11. sqr-powN/A

            \[\leadsto e^{\left(\mathsf{neg}\left(\color{blue}{{\left(0 - \ell\right)}^{3}}\right)\right) \cdot \frac{1}{0 \cdot 0 + \left(\ell \cdot \ell + 0 \cdot \ell\right)}} \]
          12. sub0-negN/A

            \[\leadsto e^{\left(\mathsf{neg}\left({\color{blue}{\left(\mathsf{neg}\left(\ell\right)\right)}}^{3}\right)\right) \cdot \frac{1}{0 \cdot 0 + \left(\ell \cdot \ell + 0 \cdot \ell\right)}} \]
          13. cube-negN/A

            \[\leadsto e^{\left(\mathsf{neg}\left(\color{blue}{\left(\mathsf{neg}\left({\ell}^{3}\right)\right)}\right)\right) \cdot \frac{1}{0 \cdot 0 + \left(\ell \cdot \ell + 0 \cdot \ell\right)}} \]
          14. sub0-negN/A

            \[\leadsto e^{\left(\mathsf{neg}\left(\color{blue}{\left(0 - {\ell}^{3}\right)}\right)\right) \cdot \frac{1}{0 \cdot 0 + \left(\ell \cdot \ell + 0 \cdot \ell\right)}} \]
          15. metadata-evalN/A

            \[\leadsto e^{\left(\mathsf{neg}\left(\left(\color{blue}{{0}^{3}} - {\ell}^{3}\right)\right)\right) \cdot \frac{1}{0 \cdot 0 + \left(\ell \cdot \ell + 0 \cdot \ell\right)}} \]
          16. distribute-lft-neg-inN/A

            \[\leadsto e^{\color{blue}{\mathsf{neg}\left(\left({0}^{3} - {\ell}^{3}\right) \cdot \frac{1}{0 \cdot 0 + \left(\ell \cdot \ell + 0 \cdot \ell\right)}\right)}} \]
          17. div-invN/A

            \[\leadsto e^{\mathsf{neg}\left(\color{blue}{\frac{{0}^{3} - {\ell}^{3}}{0 \cdot 0 + \left(\ell \cdot \ell + 0 \cdot \ell\right)}}\right)} \]
          18. flip3--N/A

            \[\leadsto e^{\mathsf{neg}\left(\color{blue}{\left(0 - \ell\right)}\right)} \]
          19. sub0-negN/A

            \[\leadsto e^{\mathsf{neg}\left(\color{blue}{\left(\mathsf{neg}\left(\ell\right)\right)}\right)} \]
        13. Applied egg-rr27.8%

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

        Alternative 10: 10.3% accurate, 18.9× speedup?

        \[\begin{array}{l} \\ \mathsf{fma}\left(\ell, \mathsf{fma}\left(\ell, \mathsf{fma}\left(\ell, -0.16666666666666666, 0.5\right), -1\right), 1\right) \end{array} \]
        (FPCore (K m n M l)
         :precision binary64
         (fma l (fma l (fma l -0.16666666666666666 0.5) -1.0) 1.0))
        double code(double K, double m, double n, double M, double l) {
        	return fma(l, fma(l, fma(l, -0.16666666666666666, 0.5), -1.0), 1.0);
        }
        
        function code(K, m, n, M, l)
        	return fma(l, fma(l, fma(l, -0.16666666666666666, 0.5), -1.0), 1.0)
        end
        
        code[K_, m_, n_, M_, l_] := N[(l * N[(l * N[(l * -0.16666666666666666 + 0.5), $MachinePrecision] + -1.0), $MachinePrecision] + 1.0), $MachinePrecision]
        
        \begin{array}{l}
        
        \\
        \mathsf{fma}\left(\ell, \mathsf{fma}\left(\ell, \mathsf{fma}\left(\ell, -0.16666666666666666, 0.5\right), -1\right), 1\right)
        \end{array}
        
        Derivation
        1. Initial program 75.9%

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

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

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

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

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

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

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

            \[\leadsto e^{\color{blue}{\left|m - n\right| - \left(\ell + \frac{1}{4} \cdot {\left(m + n\right)}^{2}\right)}} \]
          3. fabs-subN/A

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

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

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

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

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

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

            \[\leadsto e^{\left|\color{blue}{n - m}\right| - \left(\ell + \frac{1}{4} \cdot {\left(m + n\right)}^{2}\right)} \]
          10. +-commutativeN/A

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

            \[\leadsto e^{\left|n - m\right| - \color{blue}{\mathsf{fma}\left(\frac{1}{4}, {\left(m + n\right)}^{2}, \ell\right)}} \]
          12. unpow2N/A

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

            \[\leadsto e^{\left|n - m\right| - \mathsf{fma}\left(\frac{1}{4}, \color{blue}{\left(m + n\right) \cdot \left(m + n\right)}, \ell\right)} \]
          14. +-commutativeN/A

            \[\leadsto e^{\left|n - m\right| - \mathsf{fma}\left(\frac{1}{4}, \color{blue}{\left(n + m\right)} \cdot \left(m + n\right), \ell\right)} \]
          15. +-lowering-+.f64N/A

            \[\leadsto e^{\left|n - m\right| - \mathsf{fma}\left(\frac{1}{4}, \color{blue}{\left(n + m\right)} \cdot \left(m + n\right), \ell\right)} \]
          16. +-commutativeN/A

            \[\leadsto e^{\left|n - m\right| - \mathsf{fma}\left(\frac{1}{4}, \left(n + m\right) \cdot \color{blue}{\left(n + m\right)}, \ell\right)} \]
          17. +-lowering-+.f6487.8

            \[\leadsto e^{\left|n - m\right| - \mathsf{fma}\left(0.25, \left(n + m\right) \cdot \color{blue}{\left(n + m\right)}, \ell\right)} \]
        8. Simplified87.8%

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

          \[\leadsto e^{\color{blue}{-1 \cdot \ell}} \]
        10. Step-by-step derivation
          1. neg-mul-1N/A

            \[\leadsto e^{\color{blue}{\mathsf{neg}\left(\ell\right)}} \]
          2. neg-sub0N/A

            \[\leadsto e^{\color{blue}{0 - \ell}} \]
          3. --lowering--.f6436.0

            \[\leadsto e^{\color{blue}{0 - \ell}} \]
        11. Simplified36.0%

          \[\leadsto e^{\color{blue}{0 - \ell}} \]
        12. Taylor expanded in l around 0

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

            \[\leadsto \color{blue}{\ell \cdot \left(\ell \cdot \left(\frac{1}{2} + \frac{-1}{6} \cdot \ell\right) - 1\right) + 1} \]
          2. accelerator-lowering-fma.f64N/A

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

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

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

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

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

            \[\leadsto \mathsf{fma}\left(\ell, \mathsf{fma}\left(\ell, \color{blue}{\ell \cdot \frac{-1}{6}} + \frac{1}{2}, -1\right), 1\right) \]
          8. accelerator-lowering-fma.f6411.1

            \[\leadsto \mathsf{fma}\left(\ell, \mathsf{fma}\left(\ell, \color{blue}{\mathsf{fma}\left(\ell, -0.16666666666666666, 0.5\right)}, -1\right), 1\right) \]
        14. Simplified11.1%

          \[\leadsto \color{blue}{\mathsf{fma}\left(\ell, \mathsf{fma}\left(\ell, \mathsf{fma}\left(\ell, -0.16666666666666666, 0.5\right), -1\right), 1\right)} \]
        15. Add Preprocessing

        Alternative 11: 9.5% accurate, 27.6× speedup?

        \[\begin{array}{l} \\ \mathsf{fma}\left(\ell, \mathsf{fma}\left(\ell, 0.5, -1\right), 1\right) \end{array} \]
        (FPCore (K m n M l) :precision binary64 (fma l (fma l 0.5 -1.0) 1.0))
        double code(double K, double m, double n, double M, double l) {
        	return fma(l, fma(l, 0.5, -1.0), 1.0);
        }
        
        function code(K, m, n, M, l)
        	return fma(l, fma(l, 0.5, -1.0), 1.0)
        end
        
        code[K_, m_, n_, M_, l_] := N[(l * N[(l * 0.5 + -1.0), $MachinePrecision] + 1.0), $MachinePrecision]
        
        \begin{array}{l}
        
        \\
        \mathsf{fma}\left(\ell, \mathsf{fma}\left(\ell, 0.5, -1\right), 1\right)
        \end{array}
        
        Derivation
        1. Initial program 75.9%

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

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

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

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

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

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

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

            \[\leadsto e^{\color{blue}{\left|m - n\right| - \left(\ell + \frac{1}{4} \cdot {\left(m + n\right)}^{2}\right)}} \]
          3. fabs-subN/A

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

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

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

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

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

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

            \[\leadsto e^{\left|\color{blue}{n - m}\right| - \left(\ell + \frac{1}{4} \cdot {\left(m + n\right)}^{2}\right)} \]
          10. +-commutativeN/A

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

            \[\leadsto e^{\left|n - m\right| - \color{blue}{\mathsf{fma}\left(\frac{1}{4}, {\left(m + n\right)}^{2}, \ell\right)}} \]
          12. unpow2N/A

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

            \[\leadsto e^{\left|n - m\right| - \mathsf{fma}\left(\frac{1}{4}, \color{blue}{\left(m + n\right) \cdot \left(m + n\right)}, \ell\right)} \]
          14. +-commutativeN/A

            \[\leadsto e^{\left|n - m\right| - \mathsf{fma}\left(\frac{1}{4}, \color{blue}{\left(n + m\right)} \cdot \left(m + n\right), \ell\right)} \]
          15. +-lowering-+.f64N/A

            \[\leadsto e^{\left|n - m\right| - \mathsf{fma}\left(\frac{1}{4}, \color{blue}{\left(n + m\right)} \cdot \left(m + n\right), \ell\right)} \]
          16. +-commutativeN/A

            \[\leadsto e^{\left|n - m\right| - \mathsf{fma}\left(\frac{1}{4}, \left(n + m\right) \cdot \color{blue}{\left(n + m\right)}, \ell\right)} \]
          17. +-lowering-+.f6487.8

            \[\leadsto e^{\left|n - m\right| - \mathsf{fma}\left(0.25, \left(n + m\right) \cdot \color{blue}{\left(n + m\right)}, \ell\right)} \]
        8. Simplified87.8%

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

          \[\leadsto e^{\color{blue}{-1 \cdot \ell}} \]
        10. Step-by-step derivation
          1. neg-mul-1N/A

            \[\leadsto e^{\color{blue}{\mathsf{neg}\left(\ell\right)}} \]
          2. neg-sub0N/A

            \[\leadsto e^{\color{blue}{0 - \ell}} \]
          3. --lowering--.f6436.0

            \[\leadsto e^{\color{blue}{0 - \ell}} \]
        11. Simplified36.0%

          \[\leadsto e^{\color{blue}{0 - \ell}} \]
        12. Taylor expanded in l around 0

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

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

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

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

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

            \[\leadsto \mathsf{fma}\left(\ell, \ell \cdot \frac{1}{2} + \color{blue}{-1}, 1\right) \]
          6. accelerator-lowering-fma.f6410.8

            \[\leadsto \mathsf{fma}\left(\ell, \color{blue}{\mathsf{fma}\left(\ell, 0.5, -1\right)}, 1\right) \]
        14. Simplified10.8%

          \[\leadsto \color{blue}{\mathsf{fma}\left(\ell, \mathsf{fma}\left(\ell, 0.5, -1\right), 1\right)} \]
        15. Add Preprocessing

        Alternative 12: 7.2% accurate, 359.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.9%

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

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

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

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

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

          \[\leadsto \cos M \cdot e^{\color{blue}{-1 \cdot {M}^{2}}} \]
        7. Step-by-step derivation
          1. mul-1-negN/A

            \[\leadsto \cos M \cdot e^{\color{blue}{\mathsf{neg}\left({M}^{2}\right)}} \]
          2. neg-sub0N/A

            \[\leadsto \cos M \cdot e^{\color{blue}{0 - {M}^{2}}} \]
          3. --lowering--.f64N/A

            \[\leadsto \cos M \cdot e^{\color{blue}{0 - {M}^{2}}} \]
          4. unpow2N/A

            \[\leadsto \cos M \cdot e^{0 - \color{blue}{M \cdot M}} \]
          5. *-lowering-*.f6450.9

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

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

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

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

          Reproduce

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