?

Average Error: 15.4 → 1.2
Time: 24.8s
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.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(K \cdot \frac{m + n}{2} - M\right) \cdot e^{\left(\left|m - n\right| - \ell\right) - {\left(\frac{m + n}{2} - M\right)}^{2}}} \]
    Proof

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

    trig.json-simplify-24 [=>]15.4

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

    trig.json-simplify-24 [=>]15.4

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

    rational.json-simplify-10 [=>]15.4

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

    rational.json-simplify-10 [=>]15.4

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

    rational.json-simplify-47 [=>]15.4

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

    metadata-eval [=>]15.4

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

    rational.json-simplify-7 [=>]15.4

    \[ \cos \color{blue}{\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)} \]

    rational.json-simplify-2 [=>]15.4

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

    rational.json-simplify-49 [=>]15.4

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

    rational.json-simplify-12 [=>]15.4

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

    rational.json-simplify-42 [=>]15.4

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

    rational.json-simplify-45 [=>]15.4

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

    rational.json-simplify-5 [=>]15.4

    \[ \cos \left(K \cdot \frac{m + n}{2} - M\right) \cdot e^{\left(\left|m - n\right| - \color{blue}{\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}} \]

    trig.json-simplify-23 [=>]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
Error12.9
Cost19984
\[\begin{array}{l} t_0 := e^{-0.25 \cdot {n}^{2}}\\ t_1 := \frac{\cos M}{e^{{M}^{2}}}\\ \mathbf{if}\;M \leq -26.5:\\ \;\;\;\;t_1\\ \mathbf{elif}\;M \leq -3.5 \cdot 10^{-163}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;M \leq -2.5 \cdot 10^{-219}:\\ \;\;\;\;\cos M \cdot e^{-\ell}\\ \mathbf{elif}\;M \leq 2.05 \cdot 10^{-8}:\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 2
Error19.3
Cost19848
\[\begin{array}{l} \mathbf{if}\;m \leq -165000:\\ \;\;\;\;\cos M \cdot e^{-0.25 \cdot {m}^{2}}\\ \mathbf{elif}\;m \leq 6 \cdot 10^{-300}:\\ \;\;\;\;\frac{\cos M}{e^{{M}^{2}}}\\ \mathbf{else}:\\ \;\;\;\;\cos M \cdot e^{-0.25 \cdot {n}^{2}}\\ \end{array} \]
Alternative 3
Error19.3
Cost19720
\[\begin{array}{l} \mathbf{if}\;m \leq -165000:\\ \;\;\;\;\cos M \cdot e^{-0.25 \cdot {m}^{2}}\\ \mathbf{elif}\;m \leq 2 \cdot 10^{-299}:\\ \;\;\;\;\frac{\cos M}{e^{{M}^{2}}}\\ \mathbf{else}:\\ \;\;\;\;e^{-0.25 \cdot {n}^{2}}\\ \end{array} \]
Alternative 4
Error19.5
Cost13188
\[\begin{array}{l} \mathbf{if}\;\ell \leq 2.8 \cdot 10^{-15}:\\ \;\;\;\;e^{-0.25 \cdot {n}^{2}}\\ \mathbf{else}:\\ \;\;\;\;\cos M \cdot e^{-\ell}\\ \end{array} \]
Alternative 5
Error27.6
Cost13056
\[e^{-0.25 \cdot {n}^{2}} \]
Alternative 6
Error59.3
Cost6464
\[\cos M \]

Error

Reproduce?

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