?

Average Error: 14.8 → 1.2
Time: 16.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 14.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. Simplified14.8

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

    *-commutative [=>]14.8

    \[ \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/ [<=]14.8

    \[ \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- [=>]14.8

    \[ \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 [=>]14.8

    \[ \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 [=>]14.8

    \[ \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 [=>]14.8

    \[ \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 [<=]14.8

    \[ \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 [=>]14.8

    \[ \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- [<=]14.8

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

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

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

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

    cos-neg [=>]1.2

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

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

Alternatives

Alternative 1
Error14.8
Cost14288
\[\begin{array}{l} t_0 := \cos \left(\left(m + n\right) \cdot \frac{K}{2} - M\right) \cdot e^{m - \left(n + \ell\right)}\\ t_1 := \cos M \cdot e^{M \cdot \left(-M\right)}\\ \mathbf{if}\;M \leq -3.2 \cdot 10^{-13}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;M \leq -2.8 \cdot 10^{-243}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;M \leq 1.15 \cdot 10^{-194}:\\ \;\;\;\;\frac{\left(M \cdot M\right) \cdot -0.5}{e^{\ell}}\\ \mathbf{elif}\;M \leq 18:\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 2
Error14.9
Cost14288
\[\begin{array}{l} t_0 := \cos M \cdot e^{M \cdot \left(-M\right)}\\ t_1 := e^{m - \left(n + \ell\right)}\\ \mathbf{if}\;M \leq -3.2 \cdot 10^{-13}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;M \leq -1.1 \cdot 10^{-243}:\\ \;\;\;\;\cos \left(\frac{K}{\frac{2}{m + n}} - M\right) \cdot t_1\\ \mathbf{elif}\;M \leq 1.42 \cdot 10^{-205}:\\ \;\;\;\;\frac{\left(M \cdot M\right) \cdot -0.5}{e^{\ell}}\\ \mathbf{elif}\;M \leq 18:\\ \;\;\;\;\cos \left(\left(m + n\right) \cdot \frac{K}{2} - M\right) \cdot t_1\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 3
Error17.5
Cost14280
\[\begin{array}{l} \mathbf{if}\;m \leq -54:\\ \;\;\;\;{\left(e^{m}\right)}^{\left(m \cdot -0.25\right)}\\ \mathbf{elif}\;m \leq 1.7 \cdot 10^{-121}:\\ \;\;\;\;e^{m - \left(n + \left(\ell + M \cdot M\right)\right)} \cdot \cos \left(\left(m + n\right) \cdot \frac{K}{2} - M\right)\\ \mathbf{else}:\\ \;\;\;\;\cos M \cdot e^{-0.25 \cdot \left(n \cdot n\right)}\\ \end{array} \]
Alternative 4
Error17.5
Cost14280
\[\begin{array}{l} \mathbf{if}\;m \leq -54:\\ \;\;\;\;{\left(e^{m}\right)}^{\left(m \cdot -0.25\right)}\\ \mathbf{elif}\;m \leq 9.2 \cdot 10^{-122}:\\ \;\;\;\;\cos \left(\frac{K}{\frac{2}{m + n}} - M\right) \cdot e^{m - \left(n + \left(\ell + M \cdot M\right)\right)}\\ \mathbf{else}:\\ \;\;\;\;\cos M \cdot e^{-0.25 \cdot \left(n \cdot n\right)}\\ \end{array} \]
Alternative 5
Error11.1
Cost13712
\[\begin{array}{l} t_0 := {\left(e^{m}\right)}^{\left(m \cdot -0.25\right)}\\ t_1 := \cos M \cdot e^{M \cdot \left(-M\right)}\\ \mathbf{if}\;M \leq -27500000000000:\\ \;\;\;\;t_1\\ \mathbf{elif}\;M \leq -1.16 \cdot 10^{-243}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;M \leq 6.4 \cdot 10^{-294}:\\ \;\;\;\;\frac{\left(M \cdot M\right) \cdot -0.5}{e^{\ell}}\\ \mathbf{elif}\;M \leq 27:\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 6
Error11.3
Cost13712
\[\begin{array}{l} t_0 := {\left(e^{m}\right)}^{\left(m \cdot -0.25\right)}\\ t_1 := \cos M \cdot e^{M \cdot \left(-M\right)}\\ \mathbf{if}\;M \leq -27500000000000:\\ \;\;\;\;t_1\\ \mathbf{elif}\;M \leq -3.8 \cdot 10^{-224}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;M \leq 4 \cdot 10^{-295}:\\ \;\;\;\;\cos M \cdot e^{-0.25 \cdot \left(n \cdot n\right)}\\ \mathbf{elif}\;M \leq 27:\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 7
Error11.2
Cost13712
\[\begin{array}{l} t_0 := \cos M \cdot e^{M \cdot \left(-M\right)}\\ \mathbf{if}\;M \leq -27500000000000:\\ \;\;\;\;t_0\\ \mathbf{elif}\;M \leq -1.4 \cdot 10^{-222}:\\ \;\;\;\;\cos M \cdot e^{m \cdot \left(m \cdot -0.25\right)}\\ \mathbf{elif}\;M \leq 4 \cdot 10^{-295}:\\ \;\;\;\;\cos M \cdot e^{-0.25 \cdot \left(n \cdot n\right)}\\ \mathbf{elif}\;M \leq 27:\\ \;\;\;\;{\left(e^{m}\right)}^{\left(m \cdot -0.25\right)}\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 8
Error28.3
Cost13320
\[\begin{array}{l} \mathbf{if}\;\ell \leq -4.8 \cdot 10^{-89}:\\ \;\;\;\;\cos M \cdot e^{\ell}\\ \mathbf{elif}\;\ell \leq 6.4 \cdot 10^{-53}:\\ \;\;\;\;\frac{\left(M \cdot M\right) \cdot -0.5}{e^{\ell}}\\ \mathbf{else}:\\ \;\;\;\;\cos M \cdot e^{-\ell}\\ \end{array} \]
Alternative 9
Error14.8
Cost13320
\[\begin{array}{l} \mathbf{if}\;\ell \leq -720:\\ \;\;\;\;\cos M \cdot e^{\ell}\\ \mathbf{elif}\;\ell \leq 3.2 \cdot 10^{-10}:\\ \;\;\;\;{\left(e^{m}\right)}^{\left(m \cdot -0.25\right)}\\ \mathbf{else}:\\ \;\;\;\;\cos M \cdot e^{-\ell}\\ \end{array} \]
Alternative 10
Error28.3
Cost13124
\[\begin{array}{l} \mathbf{if}\;\ell \leq -3.5 \cdot 10^{-89}:\\ \;\;\;\;\cos M \cdot e^{\ell}\\ \mathbf{elif}\;\ell \leq 2.5 \cdot 10^{-52}:\\ \;\;\;\;\frac{\left(M \cdot M\right) \cdot -0.5}{e^{\ell}}\\ \mathbf{else}:\\ \;\;\;\;e^{-\ell}\\ \end{array} \]
Alternative 11
Error39.4
Cost7113
\[\begin{array}{l} \mathbf{if}\;M \leq -8.8 \cdot 10^{-119} \lor \neg \left(M \leq 0.017\right):\\ \;\;\;\;e^{-\ell}\\ \mathbf{else}:\\ \;\;\;\;\frac{\left(M \cdot M\right) \cdot -0.5}{e^{\ell}}\\ \end{array} \]
Alternative 12
Error43.5
Cost6528
\[e^{-\ell} \]
Alternative 13
Error59.6
Cost6464
\[\cos M \]

Error

Reproduce?

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