?

Average Accuracy: 75.7% → 97.5%
Time: 19.1s
Precision: binary64
Cost: 14153

?

\[\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} \mathbf{if}\;M \leq -0.106 \lor \neg \left(M \leq 4.6 \cdot 10^{-5}\right):\\ \;\;\;\;\cos M \cdot e^{M \cdot \left(-M\right)}\\ \mathbf{else}:\\ \;\;\;\;e^{\left|m - n\right| + \left(\frac{m + n}{\frac{1}{m + n}} \cdot -0.25 - \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
 (if (or (<= M -0.106) (not (<= M 4.6e-5)))
   (* (cos M) (exp (* M (- M))))
   (exp (+ (fabs (- m n)) (- (* (/ (+ m n) (/ 1.0 (+ m n))) -0.25) 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 tmp;
	if ((M <= -0.106) || !(M <= 4.6e-5)) {
		tmp = cos(M) * exp((M * -M));
	} else {
		tmp = exp((fabs((m - n)) + ((((m + n) / (1.0 / (m + n))) * -0.25) - l)));
	}
	return tmp;
}
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) :: tmp
    if ((m_1 <= (-0.106d0)) .or. (.not. (m_1 <= 4.6d-5))) then
        tmp = cos(m_1) * exp((m_1 * -m_1))
    else
        tmp = exp((abs((m - n)) + ((((m + n) / (1.0d0 / (m + n))) * (-0.25d0)) - l)))
    end if
    code = tmp
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 tmp;
	if ((M <= -0.106) || !(M <= 4.6e-5)) {
		tmp = Math.cos(M) * Math.exp((M * -M));
	} else {
		tmp = Math.exp((Math.abs((m - n)) + ((((m + n) / (1.0 / (m + n))) * -0.25) - l)));
	}
	return tmp;
}
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):
	tmp = 0
	if (M <= -0.106) or not (M <= 4.6e-5):
		tmp = math.cos(M) * math.exp((M * -M))
	else:
		tmp = math.exp((math.fabs((m - n)) + ((((m + n) / (1.0 / (m + n))) * -0.25) - l)))
	return tmp
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)
	tmp = 0.0
	if ((M <= -0.106) || !(M <= 4.6e-5))
		tmp = Float64(cos(M) * exp(Float64(M * Float64(-M))));
	else
		tmp = exp(Float64(abs(Float64(m - n)) + Float64(Float64(Float64(Float64(m + n) / Float64(1.0 / Float64(m + n))) * -0.25) - l)));
	end
	return tmp
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_2 = code(K, m, n, M, l)
	tmp = 0.0;
	if ((M <= -0.106) || ~((M <= 4.6e-5)))
		tmp = cos(M) * exp((M * -M));
	else
		tmp = exp((abs((m - n)) + ((((m + n) / (1.0 / (m + n))) * -0.25) - l)));
	end
	tmp_2 = tmp;
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_] := If[Or[LessEqual[M, -0.106], N[Not[LessEqual[M, 4.6e-5]], $MachinePrecision]], N[(N[Cos[M], $MachinePrecision] * N[Exp[N[(M * (-M)), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[Exp[N[(N[Abs[N[(m - n), $MachinePrecision]], $MachinePrecision] + N[(N[(N[(N[(m + n), $MachinePrecision] / N[(1.0 / N[(m + n), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * -0.25), $MachinePrecision] - l), $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}
\mathbf{if}\;M \leq -0.106 \lor \neg \left(M \leq 4.6 \cdot 10^{-5}\right):\\
\;\;\;\;\cos M \cdot e^{M \cdot \left(-M\right)}\\

\mathbf{else}:\\
\;\;\;\;e^{\left|m - n\right| + \left(\frac{m + n}{\frac{1}{m + n}} \cdot -0.25 - \ell\right)}\\


\end{array}

Error?

Try it out?

Your Program's Arguments

Results

Enter valid numbers for all inputs

Derivation?

  1. Split input into 2 regimes
  2. if M < -0.105999999999999997 or 4.6e-5 < M

    1. Initial program 77.5%

      \[\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. Simplified77.6%

      \[\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]77.5

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

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

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

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

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

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

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

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

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

      \[ \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 99.9%

      \[\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. Simplified99.9%

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

      [Start]99.9

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

      cos-neg [=>]99.9

      \[ \color{blue}{\cos M} \cdot e^{\left(\left|m - n\right| - \ell\right) - {\left(\frac{m + n}{2} - M\right)}^{2}} \]
    5. Taylor expanded in M around inf 99.0%

      \[\leadsto \cos M \cdot e^{\color{blue}{-1 \cdot {M}^{2}}} \]
    6. Simplified99.0%

      \[\leadsto \cos M \cdot e^{\color{blue}{M \cdot \left(-M\right)}} \]
      Proof

      [Start]99.0

      \[ \cos M \cdot e^{-1 \cdot {M}^{2}} \]

      mul-1-neg [=>]99.0

      \[ \cos M \cdot e^{\color{blue}{-{M}^{2}}} \]

      unpow2 [=>]99.0

      \[ \cos M \cdot e^{-\color{blue}{M \cdot M}} \]

      distribute-rgt-neg-in [=>]99.0

      \[ \cos M \cdot e^{\color{blue}{M \cdot \left(-M\right)}} \]

    if -0.105999999999999997 < M < 4.6e-5

    1. Initial program 73.6%

      \[\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. Simplified73.7%

      \[\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]73.6

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

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

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

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

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

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

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

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

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

      \[ \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 95.9%

      \[\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. Simplified95.9%

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

      [Start]95.9

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

      cos-neg [=>]95.9

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

      \[\leadsto \color{blue}{e^{\left|m - n\right| - \left(\ell + 0.25 \cdot {\left(n + m\right)}^{2}\right)}} \]
    6. Applied egg-rr95.8%

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

      [Start]95.8

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

      unpow2 [=>]95.8

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

      flip-+ [=>]88.6

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

      associate-*r/ [=>]88.6

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

      associate-/l* [=>]88.6

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

      +-commutative [=>]88.6

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

      *-un-lft-identity [=>]88.6

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

      associate-/l* [=>]88.6

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

      flip-+ [<=]95.8

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

      +-commutative [=>]95.8

      \[ e^{\left|m - n\right| - \left(\ell + 0.25 \cdot \frac{m + n}{\frac{1}{\color{blue}{m + n}}}\right)} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification97.5%

    \[\leadsto \begin{array}{l} \mathbf{if}\;M \leq -0.106 \lor \neg \left(M \leq 4.6 \cdot 10^{-5}\right):\\ \;\;\;\;\cos M \cdot e^{M \cdot \left(-M\right)}\\ \mathbf{else}:\\ \;\;\;\;e^{\left|m - n\right| + \left(\frac{m + n}{\frac{1}{m + n}} \cdot -0.25 - \ell\right)}\\ \end{array} \]

Alternatives

Alternative 1
Accuracy98.0%
Cost26624
\[\cos M \cdot e^{\left(\left|m - n\right| - \ell\right) - {\left(\frac{m + n}{2} - M\right)}^{2}} \]
Alternative 2
Accuracy97.4%
Cost13449
\[\begin{array}{l} \mathbf{if}\;M \leq -0.106 \lor \neg \left(M \leq 4.6 \cdot 10^{-5}\right):\\ \;\;\;\;\cos M \cdot e^{M \cdot \left(-M\right)}\\ \mathbf{else}:\\ \;\;\;\;e^{\left(m - \left(n + \ell\right)\right) + \left(\left(m + n\right) \cdot 0.5\right) \cdot \left(\left(m + n\right) \cdot -0.5\right)}\\ \end{array} \]
Alternative 3
Accuracy90.8%
Cost13124
\[\begin{array}{l} \mathbf{if}\;\ell \leq -55:\\ \;\;\;\;\cos M \cdot e^{\ell}\\ \mathbf{else}:\\ \;\;\;\;e^{\left(m - \left(n + \ell\right)\right) + \left(\left(m + n\right) \cdot 0.5\right) \cdot \left(\left(m + n\right) \cdot -0.5\right)}\\ \end{array} \]
Alternative 4
Accuracy84.8%
Cost7620
\[\begin{array}{l} \mathbf{if}\;\ell \leq -0.21:\\ \;\;\;\;e^{\left(m - n\right) + \left(n \cdot n\right) \cdot -0.25}\\ \mathbf{else}:\\ \;\;\;\;e^{\left(m - \left(n + \ell\right)\right) + \left(\left(m + n\right) \cdot 0.5\right) \cdot \left(\left(m + n\right) \cdot -0.5\right)}\\ \end{array} \]
Alternative 5
Accuracy76.6%
Cost7108
\[\begin{array}{l} \mathbf{if}\;\ell \leq 720:\\ \;\;\;\;e^{\left(m - n\right) + \left(n \cdot n\right) \cdot -0.25}\\ \mathbf{else}:\\ \;\;\;\;e^{-\ell}\\ \end{array} \]
Alternative 6
Accuracy69.7%
Cost6852
\[\begin{array}{l} \mathbf{if}\;\ell \leq 720:\\ \;\;\;\;e^{n \cdot \left(n \cdot -0.25\right)}\\ \mathbf{else}:\\ \;\;\;\;e^{-\ell}\\ \end{array} \]
Alternative 7
Accuracy69.1%
Cost6852
\[\begin{array}{l} \mathbf{if}\;n \leq 1.1 \cdot 10^{-7}:\\ \;\;\;\;e^{-0.25 \cdot \left(m \cdot m\right)}\\ \mathbf{else}:\\ \;\;\;\;e^{n \cdot \left(n \cdot -0.25\right)}\\ \end{array} \]
Alternative 8
Accuracy32.6%
Cost6528
\[e^{-\ell} \]
Alternative 9
Accuracy7.2%
Cost6464
\[\cos M \]

Error

Reproduce?

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