?

Average Error: 15.1 → 1.1
Time: 15.6s
Precision: binary64
Cost: 26624

?

\[\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)} \]
\[\cos M \cdot e^{\left(\left|m - n\right| - \ell\right) - {\left(\frac{m + n}{2} - M\right)}^{2}} \]
(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
 (* (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((((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(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((((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
    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((((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) {
	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((((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):
	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(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)
	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((((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)
	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[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_] := 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]
\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)}
\cos M \cdot e^{\left(\left|m - n\right| - \ell\right) - {\left(\frac{m + n}{2} - M\right)}^{2}}

Error?

Try it out?

Your Program's Arguments

Results

Enter valid numbers for all inputs

Derivation?

  1. Initial program 15.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. Simplified15.0

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

    [Start]15.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)} \]

    *-commutative [=>]15.1

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

    associate-*r/ [<=]15.0

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

    associate--r- [=>]15.0

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

    +-commutative [=>]15.0

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

    sub-neg [=>]15.0

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

    distribute-neg-out [=>]15.0

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

    sub-neg [<=]15.0

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

    +-commutative [=>]15.0

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

    associate--l- [<=]15.0

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

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

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

    [Start]1.1

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

    cos-neg [=>]1.1

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

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

Alternatives

Alternative 1
Error18.8
Cost20944
\[\begin{array}{l} \mathbf{if}\;n \leq -1.45 \cdot 10^{-259}:\\ \;\;\;\;\cos M \cdot e^{\left(m \cdot m\right) \cdot -0.25}\\ \mathbf{elif}\;n \leq 5 \cdot 10^{-240}:\\ \;\;\;\;\cos M \cdot e^{M \cdot \left(-M\right)}\\ \mathbf{elif}\;n \leq 4 \cdot 10^{-227}:\\ \;\;\;\;{\left(e^{m \cdot m}\right)}^{-0.25}\\ \mathbf{elif}\;n \leq 54:\\ \;\;\;\;\cos \left(\frac{K}{\frac{2}{m + n}} - M\right) \cdot e^{\left|m - n\right| - \left(\ell + M \cdot M\right)}\\ \mathbf{else}:\\ \;\;\;\;\cos M \cdot e^{-0.25 \cdot \left(n \cdot n\right)}\\ \end{array} \]
Alternative 2
Error19.0
Cost14224
\[\begin{array}{l} t_0 := e^{M \cdot \left(-M\right)}\\ t_1 := \cos M \cdot t_0\\ t_2 := \cos M \cdot e^{\left(m \cdot m\right) \cdot -0.25}\\ \mathbf{if}\;n \leq -2.2 \cdot 10^{-260}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;n \leq 1.75 \cdot 10^{-239}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;n \leq 2.9 \cdot 10^{-136}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;n \leq 2.7 \cdot 10^{-43}:\\ \;\;\;\;t_0 \cdot \cos \left(\left(m + n\right) \cdot \frac{K}{2} - M\right)\\ \mathbf{elif}\;n \leq 54:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;\cos M \cdot e^{-0.25 \cdot \left(n \cdot n\right)}\\ \end{array} \]
Alternative 3
Error11.0
Cost13844
\[\begin{array}{l} t_0 := \cos M \cdot e^{-0.25 \cdot \left(n \cdot n\right)}\\ t_1 := \cos M \cdot e^{M \cdot \left(-M\right)}\\ t_2 := {\left(e^{m \cdot m}\right)}^{-0.25}\\ \mathbf{if}\;M \leq -27.5:\\ \;\;\;\;t_1\\ \mathbf{elif}\;M \leq -5 \cdot 10^{-243}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;M \leq 6 \cdot 10^{-230}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;M \leq 5 \cdot 10^{-146}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;M \leq 8.5 \cdot 10^{-5}:\\ \;\;\;\;t_2\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 4
Error11.3
Cost13449
\[\begin{array}{l} \mathbf{if}\;M \leq -8.8 \cdot 10^{-10} \lor \neg \left(M \leq 8.5 \cdot 10^{-5}\right):\\ \;\;\;\;\cos M \cdot e^{M \cdot \left(-M\right)}\\ \mathbf{else}:\\ \;\;\;\;{\left(e^{m \cdot m}\right)}^{-0.25}\\ \end{array} \]
Alternative 5
Error18.5
Cost13188
\[\begin{array}{l} \mathbf{if}\;\ell \leq 0.0017:\\ \;\;\;\;{\left(e^{m \cdot m}\right)}^{-0.25}\\ \mathbf{else}:\\ \;\;\;\;\frac{\cos M}{e^{\ell}}\\ \end{array} \]
Alternative 6
Error42.5
Cost12992
\[\frac{\cos M}{e^{\ell}} \]
Alternative 7
Error42.5
Cost6528
\[e^{-\ell} \]
Alternative 8
Error59.3
Cost6464
\[\cos M \]
Alternative 9
Error59.3
Cost64
\[1 \]

Error

Reproduce?

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