Average Error: 15.4 → 1.4
Time: 26.1s
Precision: binary64
Cost: 14336
\[\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 := M + \left(m + n\right) \cdot -0.5\\ 1 \cdot e^{\left(-t_0 \cdot t_0\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)))))))
(FPCore (K m n M l)
 :precision binary64
 (let* ((t_0 (+ M (* (+ m n) -0.5))))
   (* 1.0 (exp (- (- (* t_0 t_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)))));
}
double code(double K, double m, double n, double M, double l) {
	double t_0 = M + ((m + n) * -0.5);
	return 1.0 * exp((-(t_0 * t_0) - (l - fabs((m - n)))));
}
real(8) function code(k, m, n, m_1, l)
    real(8), intent (in) :: k
    real(8), intent (in) :: m
    real(8), intent (in) :: n
    real(8), intent (in) :: m_1
    real(8), intent (in) :: l
    code = cos((((k * (m + n)) / 2.0d0) - m_1)) * exp((-((((m + n) / 2.0d0) - m_1) ** 2.0d0) - (l - abs((m - n)))))
end function
real(8) function code(k, m, n, m_1, l)
    real(8), intent (in) :: k
    real(8), intent (in) :: m
    real(8), intent (in) :: n
    real(8), intent (in) :: m_1
    real(8), intent (in) :: l
    real(8) :: t_0
    t_0 = m_1 + ((m + n) * (-0.5d0))
    code = 1.0d0 * exp((-(t_0 * t_0) - (l - abs((m - n)))))
end function
public static double code(double K, double m, double n, double M, double l) {
	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)))));
}
public static double code(double K, double m, double n, double M, double l) {
	double t_0 = M + ((m + n) * -0.5);
	return 1.0 * Math.exp((-(t_0 * t_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)))))
def code(K, m, n, M, l):
	t_0 = M + ((m + n) * -0.5)
	return 1.0 * math.exp((-(t_0 * t_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 code(K, m, n, M, l)
	t_0 = Float64(M + Float64(Float64(m + n) * -0.5))
	return Float64(1.0 * exp(Float64(Float64(-Float64(t_0 * t_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
function tmp = code(K, m, n, M, l)
	t_0 = M + ((m + n) * -0.5);
	tmp = 1.0 * exp((-(t_0 * t_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]
code[K_, m_, n_, M_, l_] := Block[{t$95$0 = N[(M + N[(N[(m + n), $MachinePrecision] * -0.5), $MachinePrecision]), $MachinePrecision]}, N[(1.0 * N[Exp[N[((-N[(t$95$0 * t$95$0), $MachinePrecision]) - N[(l - N[Abs[N[(m - n), $MachinePrecision]], $MachinePrecision]), $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 := M + \left(m + n\right) \cdot -0.5\\
1 \cdot e^{\left(-t_0 \cdot t_0\right) - \left(\ell - \left|m - n\right|\right)}
\end{array}

Error

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

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. Taylor expanded in K around 0 1.3

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

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

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

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

Alternatives

Alternative 1
Error11.8
Cost13576
\[\begin{array}{l} t_0 := 1 \cdot e^{-0.25 \cdot {\left(\frac{1}{m}\right)}^{-2}}\\ \mathbf{if}\;m \leq -7.4 \cdot 10^{-13}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;m \leq 13:\\ \;\;\;\;1 \cdot e^{-{\left(\frac{1}{M}\right)}^{-2}}\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 2
Error18.8
Cost13380
\[\begin{array}{l} \mathbf{if}\;\ell \leq 720:\\ \;\;\;\;1 \cdot e^{-{\left(\frac{1}{M}\right)}^{-2}}\\ \mathbf{else}:\\ \;\;\;\;e^{-\ell}\\ \end{array} \]
Alternative 3
Error42.7
Cost12992
\[\frac{\cos M}{e^{\ell}} \]
Alternative 4
Error42.7
Cost6528
\[e^{-\ell} \]
Alternative 5
Error59.2
Cost6464
\[\cos M \]
Alternative 6
Error59.2
Cost64
\[1 \]

Error

Reproduce

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