Average Error: 15.4 → 1.3
Time: 10.1s
Precision: binary64
\[\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)} \]
\[\begin{array}{l} t_0 := \sqrt[3]{\mathsf{fma}\left(n + m, 0.5, M\right)}\\ \cos M \cdot e^{\left|n - m\right| - \left(\mathsf{expm1}\left(\sqrt[3]{{\left(\mathsf{log1p}\left({t_0}^{4}\right)\right)}^{3}}\right) \cdot {t_0}^{2} + \ell\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)))))))
(FPCore (K m n M l)
 :precision binary64
 (let* ((t_0 (cbrt (fma (+ n m) 0.5 M))))
   (*
    (cos M)
    (exp
     (-
      (fabs (- n m))
      (+
       (* (expm1 (cbrt (pow (log1p (pow t_0 4.0)) 3.0))) (pow t_0 2.0))
       l))))))
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)))));
}
double code(double K, double m, double n, double M, double l) {
	double t_0 = cbrt(fma((n + m), 0.5, M));
	return cos(M) * exp((fabs((n - m)) - ((expm1(cbrt(pow(log1p(pow(t_0, 4.0)), 3.0))) * pow(t_0, 2.0)) + l)));
}
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 code(K, m, n, M, l)
	t_0 = cbrt(fma(Float64(n + m), 0.5, M))
	return Float64(cos(M) * exp(Float64(abs(Float64(n - m)) - Float64(Float64(expm1(cbrt((log1p((t_0 ^ 4.0)) ^ 3.0))) * (t_0 ^ 2.0)) + l))))
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]
code[K_, m_, n_, M_, l_] := Block[{t$95$0 = N[Power[N[(N[(n + m), $MachinePrecision] * 0.5 + M), $MachinePrecision], 1/3], $MachinePrecision]}, N[(N[Cos[M], $MachinePrecision] * N[Exp[N[(N[Abs[N[(n - m), $MachinePrecision]], $MachinePrecision] - N[(N[(N[(Exp[N[Power[N[Power[N[Log[1 + N[Power[t$95$0, 4.0], $MachinePrecision]], $MachinePrecision], 3.0], $MachinePrecision], 1/3], $MachinePrecision]] - 1), $MachinePrecision] * N[Power[t$95$0, 2.0], $MachinePrecision]), $MachinePrecision] + l), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\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)}
\begin{array}{l}
t_0 := \sqrt[3]{\mathsf{fma}\left(n + m, 0.5, M\right)}\\
\cos M \cdot e^{\left|n - m\right| - \left(\mathsf{expm1}\left(\sqrt[3]{{\left(\mathsf{log1p}\left({t_0}^{4}\right)\right)}^{3}}\right) \cdot {t_0}^{2} + \ell\right)}
\end{array}

Error

Bits error versus K

Bits error versus m

Bits error versus n

Bits error versus M

Bits error versus l

Derivation

  1. Initial program 15.4

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

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

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

    \[\leadsto \color{blue}{\cos M} \cdot e^{\left|n - m\right| - \left({\left(\frac{m + n}{2} - M\right)}^{2} + \ell\right)} \]
  5. Applied egg-rr1.3

    \[\leadsto \cos M \cdot e^{\left|n - m\right| - \left(\color{blue}{\sqrt[3]{{\left(\mathsf{fma}\left(m + n, 0.5, M\right)\right)}^{4}} \cdot {\left(\sqrt[3]{\mathsf{fma}\left(m + n, 0.5, M\right)}\right)}^{2}} + \ell\right)} \]
  6. Applied egg-rr1.3

    \[\leadsto \cos M \cdot e^{\left|n - m\right| - \left(\color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left({\left(\sqrt[3]{\mathsf{fma}\left(m + n, 0.5, M\right)}\right)}^{4}\right)\right)} \cdot {\left(\sqrt[3]{\mathsf{fma}\left(m + n, 0.5, M\right)}\right)}^{2} + \ell\right)} \]
  7. Applied egg-rr1.3

    \[\leadsto \cos M \cdot e^{\left|n - m\right| - \left(\mathsf{expm1}\left(\color{blue}{\sqrt[3]{{\left(\mathsf{log1p}\left({\left(\sqrt[3]{\mathsf{fma}\left(m + n, 0.5, M\right)}\right)}^{4}\right)\right)}^{3}}}\right) \cdot {\left(\sqrt[3]{\mathsf{fma}\left(m + n, 0.5, M\right)}\right)}^{2} + \ell\right)} \]
  8. Final simplification1.3

    \[\leadsto \cos M \cdot e^{\left|n - m\right| - \left(\mathsf{expm1}\left(\sqrt[3]{{\left(\mathsf{log1p}\left({\left(\sqrt[3]{\mathsf{fma}\left(n + m, 0.5, M\right)}\right)}^{4}\right)\right)}^{3}}\right) \cdot {\left(\sqrt[3]{\mathsf{fma}\left(n + m, 0.5, M\right)}\right)}^{2} + \ell\right)} \]

Reproduce

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