
(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)))))))
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)))));
}
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
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)))));
}
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)))))
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 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
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]
\begin{array}{l}
\\
\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)}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 5 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(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)))))))
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)))));
}
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
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)))));
}
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)))))
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 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
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]
\begin{array}{l}
\\
\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)}
\end{array}
(FPCore (K m n M l) :precision binary64 (* (cos (- (expm1 (* K (+ (* -0.125 (* K (pow (+ m n) 2.0))) (* 0.5 (+ m n))))) M)) (exp (- (fabs (- m n)) (+ (pow (- (/ (+ m n) 2.0) M) 2.0) l)))))
double code(double K, double m, double n, double M, double l) {
return cos((expm1((K * ((-0.125 * (K * pow((m + n), 2.0))) + (0.5 * (m + n))))) - M)) * exp((fabs((m - n)) - (pow((((m + n) / 2.0) - M), 2.0) + l)));
}
public static double code(double K, double m, double n, double M, double l) {
return Math.cos((Math.expm1((K * ((-0.125 * (K * Math.pow((m + n), 2.0))) + (0.5 * (m + n))))) - M)) * Math.exp((Math.abs((m - n)) - (Math.pow((((m + n) / 2.0) - M), 2.0) + l)));
}
def code(K, m, n, M, l): return math.cos((math.expm1((K * ((-0.125 * (K * math.pow((m + n), 2.0))) + (0.5 * (m + n))))) - M)) * math.exp((math.fabs((m - n)) - (math.pow((((m + n) / 2.0) - M), 2.0) + l)))
function code(K, m, n, M, l) return Float64(cos(Float64(expm1(Float64(K * Float64(Float64(-0.125 * Float64(K * (Float64(m + n) ^ 2.0))) + Float64(0.5 * Float64(m + n))))) - M)) * exp(Float64(abs(Float64(m - n)) - Float64((Float64(Float64(Float64(m + n) / 2.0) - M) ^ 2.0) + l)))) end
code[K_, m_, n_, M_, l_] := N[(N[Cos[N[(N[(Exp[N[(K * N[(N[(-0.125 * N[(K * N[Power[N[(m + n), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(0.5 * N[(m + n), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]] - 1), $MachinePrecision] - M), $MachinePrecision]], $MachinePrecision] * N[Exp[N[(N[Abs[N[(m - n), $MachinePrecision]], $MachinePrecision] - N[(N[Power[N[(N[(N[(m + n), $MachinePrecision] / 2.0), $MachinePrecision] - M), $MachinePrecision], 2.0], $MachinePrecision] + l), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\cos \left(\mathsf{expm1}\left(K \cdot \left(-0.125 \cdot \left(K \cdot {\left(m + n\right)}^{2}\right) + 0.5 \cdot \left(m + n\right)\right)\right) - M\right) \cdot e^{\left|m - n\right| - \left({\left(\frac{m + n}{2} - M\right)}^{2} + \ell\right)}
\end{array}
Initial program 72.5%
associate-/l*72.8%
+-commutative72.8%
associate-/l*72.5%
associate-/l*72.8%
+-commutative72.8%
exp-diff22.1%
sub-neg22.1%
exp-sum19.7%
associate-/r*19.7%
exp-diff25.2%
Simplified72.8%
clear-num72.5%
un-div-inv72.5%
Applied egg-rr72.5%
expm1-log1p-u53.6%
div-inv53.6%
clear-num53.6%
div-inv53.6%
metadata-eval53.6%
+-commutative53.6%
Applied egg-rr53.6%
Taylor expanded in K around 0 95.3%
Final simplification95.3%
(FPCore (K m n M l)
:precision binary64
(let* ((t_0 (- (* n 0.5) M)) (t_1 (- (fabs (- m n)) l)))
(if (<= m -1e-27)
(exp (- t_1 (* 0.25 (* (+ m n) (+ m n)))))
(* (cos M) (exp (- t_1 (* t_0 (+ m t_0))))))))
double code(double K, double m, double n, double M, double l) {
double t_0 = (n * 0.5) - M;
double t_1 = fabs((m - n)) - l;
double tmp;
if (m <= -1e-27) {
tmp = exp((t_1 - (0.25 * ((m + n) * (m + n)))));
} else {
tmp = cos(M) * exp((t_1 - (t_0 * (m + t_0))));
}
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
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = (n * 0.5d0) - m_1
t_1 = abs((m - n)) - l
if (m <= (-1d-27)) then
tmp = exp((t_1 - (0.25d0 * ((m + n) * (m + n)))))
else
tmp = cos(m_1) * exp((t_1 - (t_0 * (m + t_0))))
end if
code = tmp
end function
public static double code(double K, double m, double n, double M, double l) {
double t_0 = (n * 0.5) - M;
double t_1 = Math.abs((m - n)) - l;
double tmp;
if (m <= -1e-27) {
tmp = Math.exp((t_1 - (0.25 * ((m + n) * (m + n)))));
} else {
tmp = Math.cos(M) * Math.exp((t_1 - (t_0 * (m + t_0))));
}
return tmp;
}
def code(K, m, n, M, l): t_0 = (n * 0.5) - M t_1 = math.fabs((m - n)) - l tmp = 0 if m <= -1e-27: tmp = math.exp((t_1 - (0.25 * ((m + n) * (m + n))))) else: tmp = math.cos(M) * math.exp((t_1 - (t_0 * (m + t_0)))) return tmp
function code(K, m, n, M, l) t_0 = Float64(Float64(n * 0.5) - M) t_1 = Float64(abs(Float64(m - n)) - l) tmp = 0.0 if (m <= -1e-27) tmp = exp(Float64(t_1 - Float64(0.25 * Float64(Float64(m + n) * Float64(m + n))))); else tmp = Float64(cos(M) * exp(Float64(t_1 - Float64(t_0 * Float64(m + t_0))))); end return tmp end
function tmp_2 = code(K, m, n, M, l) t_0 = (n * 0.5) - M; t_1 = abs((m - n)) - l; tmp = 0.0; if (m <= -1e-27) tmp = exp((t_1 - (0.25 * ((m + n) * (m + n))))); else tmp = cos(M) * exp((t_1 - (t_0 * (m + t_0)))); end tmp_2 = tmp; end
code[K_, m_, n_, M_, l_] := Block[{t$95$0 = N[(N[(n * 0.5), $MachinePrecision] - M), $MachinePrecision]}, Block[{t$95$1 = N[(N[Abs[N[(m - n), $MachinePrecision]], $MachinePrecision] - l), $MachinePrecision]}, If[LessEqual[m, -1e-27], N[Exp[N[(t$95$1 - N[(0.25 * N[(N[(m + n), $MachinePrecision] * N[(m + n), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[(N[Cos[M], $MachinePrecision] * N[Exp[N[(t$95$1 - N[(t$95$0 * N[(m + t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := n \cdot 0.5 - M\\
t_1 := \left|m - n\right| - \ell\\
\mathbf{if}\;m \leq -1 \cdot 10^{-27}:\\
\;\;\;\;e^{t\_1 - 0.25 \cdot \left(\left(m + n\right) \cdot \left(m + n\right)\right)}\\
\mathbf{else}:\\
\;\;\;\;\cos M \cdot e^{t\_1 - t\_0 \cdot \left(m + t\_0\right)}\\
\end{array}
\end{array}
if m < -1e-27Initial program 66.0%
associate-/l*67.4%
+-commutative67.4%
associate-/l*66.0%
associate-/l*67.4%
+-commutative67.4%
exp-diff4.5%
sub-neg4.5%
exp-sum3.1%
associate-/r*3.1%
exp-diff3.1%
Simplified67.4%
Taylor expanded in K around 0 97.4%
cos-neg97.4%
sub-neg97.4%
distribute-neg-in97.4%
mul-1-neg97.4%
associate-+l+97.4%
sub-neg97.4%
mul-1-neg97.4%
sub-neg97.4%
*-commutative97.4%
Simplified97.4%
Taylor expanded in M around 0 97.4%
associate--r+97.4%
+-commutative97.4%
Simplified97.4%
unpow297.4%
Applied egg-rr97.4%
if -1e-27 < m Initial program 74.9%
associate-/l*74.9%
+-commutative74.9%
associate-/l*74.9%
associate-/l*74.9%
+-commutative74.9%
exp-diff28.7%
sub-neg28.7%
exp-sum26.0%
associate-/r*26.0%
exp-diff33.5%
Simplified74.9%
Taylor expanded in K around 0 94.2%
cos-neg94.2%
sub-neg94.2%
distribute-neg-in94.2%
mul-1-neg94.2%
associate-+l+94.2%
sub-neg94.2%
mul-1-neg94.2%
sub-neg94.2%
*-commutative94.2%
Simplified94.2%
metadata-eval94.2%
div-inv94.2%
unpow294.2%
div-inv94.2%
metadata-eval94.2%
+-commutative94.2%
div-inv94.2%
metadata-eval94.2%
+-commutative94.2%
Applied egg-rr94.2%
Taylor expanded in m around 0 75.7%
+-commutative75.7%
unpow275.7%
distribute-rgt-out79.4%
*-commutative79.4%
*-commutative79.4%
Simplified79.4%
Final simplification84.3%
(FPCore (K m n M l)
:precision binary64
(let* ((t_0 (- (* n 0.5) M)) (t_1 (fabs (- m n))))
(if (<= M 3500000000000.0)
(exp (- (- t_1 l) (* 0.25 (* (+ m n) (+ m n)))))
(* (cos M) (exp (- t_1 (* t_0 (+ m t_0))))))))
double code(double K, double m, double n, double M, double l) {
double t_0 = (n * 0.5) - M;
double t_1 = fabs((m - n));
double tmp;
if (M <= 3500000000000.0) {
tmp = exp(((t_1 - l) - (0.25 * ((m + n) * (m + n)))));
} else {
tmp = cos(M) * exp((t_1 - (t_0 * (m + t_0))));
}
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
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = (n * 0.5d0) - m_1
t_1 = abs((m - n))
if (m_1 <= 3500000000000.0d0) then
tmp = exp(((t_1 - l) - (0.25d0 * ((m + n) * (m + n)))))
else
tmp = cos(m_1) * exp((t_1 - (t_0 * (m + t_0))))
end if
code = tmp
end function
public static double code(double K, double m, double n, double M, double l) {
double t_0 = (n * 0.5) - M;
double t_1 = Math.abs((m - n));
double tmp;
if (M <= 3500000000000.0) {
tmp = Math.exp(((t_1 - l) - (0.25 * ((m + n) * (m + n)))));
} else {
tmp = Math.cos(M) * Math.exp((t_1 - (t_0 * (m + t_0))));
}
return tmp;
}
def code(K, m, n, M, l): t_0 = (n * 0.5) - M t_1 = math.fabs((m - n)) tmp = 0 if M <= 3500000000000.0: tmp = math.exp(((t_1 - l) - (0.25 * ((m + n) * (m + n))))) else: tmp = math.cos(M) * math.exp((t_1 - (t_0 * (m + t_0)))) return tmp
function code(K, m, n, M, l) t_0 = Float64(Float64(n * 0.5) - M) t_1 = abs(Float64(m - n)) tmp = 0.0 if (M <= 3500000000000.0) tmp = exp(Float64(Float64(t_1 - l) - Float64(0.25 * Float64(Float64(m + n) * Float64(m + n))))); else tmp = Float64(cos(M) * exp(Float64(t_1 - Float64(t_0 * Float64(m + t_0))))); end return tmp end
function tmp_2 = code(K, m, n, M, l) t_0 = (n * 0.5) - M; t_1 = abs((m - n)); tmp = 0.0; if (M <= 3500000000000.0) tmp = exp(((t_1 - l) - (0.25 * ((m + n) * (m + n))))); else tmp = cos(M) * exp((t_1 - (t_0 * (m + t_0)))); end tmp_2 = tmp; end
code[K_, m_, n_, M_, l_] := Block[{t$95$0 = N[(N[(n * 0.5), $MachinePrecision] - M), $MachinePrecision]}, Block[{t$95$1 = N[Abs[N[(m - n), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[M, 3500000000000.0], N[Exp[N[(N[(t$95$1 - l), $MachinePrecision] - N[(0.25 * N[(N[(m + n), $MachinePrecision] * N[(m + n), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[(N[Cos[M], $MachinePrecision] * N[Exp[N[(t$95$1 - N[(t$95$0 * N[(m + t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := n \cdot 0.5 - M\\
t_1 := \left|m - n\right|\\
\mathbf{if}\;M \leq 3500000000000:\\
\;\;\;\;e^{\left(t\_1 - \ell\right) - 0.25 \cdot \left(\left(m + n\right) \cdot \left(m + n\right)\right)}\\
\mathbf{else}:\\
\;\;\;\;\cos M \cdot e^{t\_1 - t\_0 \cdot \left(m + t\_0\right)}\\
\end{array}
\end{array}
if M < 3.5e12Initial program 72.2%
associate-/l*72.2%
+-commutative72.2%
associate-/l*72.2%
associate-/l*72.2%
+-commutative72.2%
exp-diff21.7%
sub-neg21.7%
exp-sum18.6%
associate-/r*18.6%
exp-diff23.2%
Simplified72.2%
Taylor expanded in K around 0 93.6%
cos-neg93.6%
sub-neg93.6%
distribute-neg-in93.6%
mul-1-neg93.6%
associate-+l+93.6%
sub-neg93.6%
mul-1-neg93.6%
sub-neg93.6%
*-commutative93.6%
Simplified93.6%
Taylor expanded in M around 0 87.7%
associate--r+87.7%
+-commutative87.7%
Simplified87.7%
unpow287.7%
Applied egg-rr87.7%
if 3.5e12 < M Initial program 73.3%
associate-/l*75.0%
+-commutative75.0%
associate-/l*73.3%
associate-/l*75.0%
+-commutative75.0%
exp-diff23.3%
sub-neg23.3%
exp-sum23.3%
associate-/r*23.3%
exp-diff31.7%
Simplified75.0%
Taylor expanded in K around 0 100.0%
cos-neg100.0%
sub-neg100.0%
distribute-neg-in100.0%
mul-1-neg100.0%
associate-+l+100.0%
sub-neg100.0%
mul-1-neg100.0%
sub-neg100.0%
*-commutative100.0%
Simplified100.0%
Taylor expanded in l around 0 100.0%
Taylor expanded in m around 0 81.8%
+-commutative81.8%
unpow281.8%
*-commutative81.8%
distribute-lft-out88.5%
*-commutative88.5%
*-commutative88.5%
Simplified88.5%
Final simplification87.9%
(FPCore (K m n M l) :precision binary64 (let* ((t_0 (* 0.5 (+ m n)))) (* (cos M) (exp (+ (- (fabs (- m n)) l) (* (- t_0 M) (- M t_0)))))))
double code(double K, double m, double n, double M, double l) {
double t_0 = 0.5 * (m + n);
return cos(M) * exp(((fabs((m - n)) - l) + ((t_0 - M) * (M - t_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
real(8) :: t_0
t_0 = 0.5d0 * (m + n)
code = cos(m_1) * exp(((abs((m - n)) - l) + ((t_0 - m_1) * (m_1 - t_0))))
end function
public static double code(double K, double m, double n, double M, double l) {
double t_0 = 0.5 * (m + n);
return Math.cos(M) * Math.exp(((Math.abs((m - n)) - l) + ((t_0 - M) * (M - t_0))));
}
def code(K, m, n, M, l): t_0 = 0.5 * (m + n) return math.cos(M) * math.exp(((math.fabs((m - n)) - l) + ((t_0 - M) * (M - t_0))))
function code(K, m, n, M, l) t_0 = Float64(0.5 * Float64(m + n)) return Float64(cos(M) * exp(Float64(Float64(abs(Float64(m - n)) - l) + Float64(Float64(t_0 - M) * Float64(M - t_0))))) end
function tmp = code(K, m, n, M, l) t_0 = 0.5 * (m + n); tmp = cos(M) * exp(((abs((m - n)) - l) + ((t_0 - M) * (M - t_0)))); end
code[K_, m_, n_, M_, l_] := Block[{t$95$0 = N[(0.5 * N[(m + n), $MachinePrecision]), $MachinePrecision]}, N[(N[Cos[M], $MachinePrecision] * N[Exp[N[(N[(N[Abs[N[(m - n), $MachinePrecision]], $MachinePrecision] - l), $MachinePrecision] + N[(N[(t$95$0 - M), $MachinePrecision] * N[(M - t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 0.5 \cdot \left(m + n\right)\\
\cos M \cdot e^{\left(\left|m - n\right| - \ell\right) + \left(t\_0 - M\right) \cdot \left(M - t\_0\right)}
\end{array}
\end{array}
Initial program 72.5%
associate-/l*72.8%
+-commutative72.8%
associate-/l*72.5%
associate-/l*72.8%
+-commutative72.8%
exp-diff22.1%
sub-neg22.1%
exp-sum19.7%
associate-/r*19.7%
exp-diff25.2%
Simplified72.8%
Taylor expanded in K around 0 95.1%
cos-neg95.1%
sub-neg95.1%
distribute-neg-in95.1%
mul-1-neg95.1%
associate-+l+95.1%
sub-neg95.1%
mul-1-neg95.1%
sub-neg95.1%
*-commutative95.1%
Simplified95.1%
metadata-eval95.1%
div-inv95.1%
unpow295.1%
div-inv95.1%
metadata-eval95.1%
+-commutative95.1%
div-inv95.1%
metadata-eval95.1%
+-commutative95.1%
Applied egg-rr95.1%
Final simplification95.1%
(FPCore (K m n M l) :precision binary64 (exp (- (- (fabs (- m n)) l) (* 0.25 (* (+ m n) (+ m n))))))
double code(double K, double m, double n, double M, double l) {
return exp(((fabs((m - n)) - l) - (0.25 * ((m + n) * (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 = exp(((abs((m - n)) - l) - (0.25d0 * ((m + n) * (m + n)))))
end function
public static double code(double K, double m, double n, double M, double l) {
return Math.exp(((Math.abs((m - n)) - l) - (0.25 * ((m + n) * (m + n)))));
}
def code(K, m, n, M, l): return math.exp(((math.fabs((m - n)) - l) - (0.25 * ((m + n) * (m + n)))))
function code(K, m, n, M, l) return exp(Float64(Float64(abs(Float64(m - n)) - l) - Float64(0.25 * Float64(Float64(m + n) * Float64(m + n))))) end
function tmp = code(K, m, n, M, l) tmp = exp(((abs((m - n)) - l) - (0.25 * ((m + n) * (m + n))))); end
code[K_, m_, n_, M_, l_] := N[Exp[N[(N[(N[Abs[N[(m - n), $MachinePrecision]], $MachinePrecision] - l), $MachinePrecision] - N[(0.25 * N[(N[(m + n), $MachinePrecision] * N[(m + n), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
e^{\left(\left|m - n\right| - \ell\right) - 0.25 \cdot \left(\left(m + n\right) \cdot \left(m + n\right)\right)}
\end{array}
Initial program 72.5%
associate-/l*72.8%
+-commutative72.8%
associate-/l*72.5%
associate-/l*72.8%
+-commutative72.8%
exp-diff22.1%
sub-neg22.1%
exp-sum19.7%
associate-/r*19.7%
exp-diff25.2%
Simplified72.8%
Taylor expanded in K around 0 95.1%
cos-neg95.1%
sub-neg95.1%
distribute-neg-in95.1%
mul-1-neg95.1%
associate-+l+95.1%
sub-neg95.1%
mul-1-neg95.1%
sub-neg95.1%
*-commutative95.1%
Simplified95.1%
Taylor expanded in M around 0 86.3%
associate--r+86.3%
+-commutative86.3%
Simplified86.3%
unpow286.3%
Applied egg-rr86.3%
Final simplification86.3%
herbie shell --seed 2024082
(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)))))))