
(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 8 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}
NOTE: K, m, n, M, and l should be sorted in increasing order before calling this function.
(FPCore (K m n M l)
:precision binary64
(if (<= m -8e+15)
(exp (* (pow m 2.0) -0.25))
(*
(cos M)
(exp (- (+ (- n m) (* (- (* n 0.5) M) (- (- M (* n 0.5)) m))) l)))))assert(K < m && m < n && n < M && M < l);
double code(double K, double m, double n, double M, double l) {
double tmp;
if (m <= -8e+15) {
tmp = exp((pow(m, 2.0) * -0.25));
} else {
tmp = cos(M) * exp((((n - m) + (((n * 0.5) - M) * ((M - (n * 0.5)) - m))) - l));
}
return tmp;
}
NOTE: K, m, n, M, and l should be sorted in increasing order before calling this 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 <= (-8d+15)) then
tmp = exp(((m ** 2.0d0) * (-0.25d0)))
else
tmp = cos(m_1) * exp((((n - m) + (((n * 0.5d0) - m_1) * ((m_1 - (n * 0.5d0)) - m))) - l))
end if
code = tmp
end function
assert K < m && m < n && n < M && M < l;
public static double code(double K, double m, double n, double M, double l) {
double tmp;
if (m <= -8e+15) {
tmp = Math.exp((Math.pow(m, 2.0) * -0.25));
} else {
tmp = Math.cos(M) * Math.exp((((n - m) + (((n * 0.5) - M) * ((M - (n * 0.5)) - m))) - l));
}
return tmp;
}
[K, m, n, M, l] = sort([K, m, n, M, l]) def code(K, m, n, M, l): tmp = 0 if m <= -8e+15: tmp = math.exp((math.pow(m, 2.0) * -0.25)) else: tmp = math.cos(M) * math.exp((((n - m) + (((n * 0.5) - M) * ((M - (n * 0.5)) - m))) - l)) return tmp
K, m, n, M, l = sort([K, m, n, M, l]) function code(K, m, n, M, l) tmp = 0.0 if (m <= -8e+15) tmp = exp(Float64((m ^ 2.0) * -0.25)); else tmp = Float64(cos(M) * exp(Float64(Float64(Float64(n - m) + Float64(Float64(Float64(n * 0.5) - M) * Float64(Float64(M - Float64(n * 0.5)) - m))) - l))); end return tmp end
K, m, n, M, l = num2cell(sort([K, m, n, M, l])){:}
function tmp_2 = code(K, m, n, M, l)
tmp = 0.0;
if (m <= -8e+15)
tmp = exp(((m ^ 2.0) * -0.25));
else
tmp = cos(M) * exp((((n - m) + (((n * 0.5) - M) * ((M - (n * 0.5)) - m))) - l));
end
tmp_2 = tmp;
end
NOTE: K, m, n, M, and l should be sorted in increasing order before calling this function. code[K_, m_, n_, M_, l_] := If[LessEqual[m, -8e+15], N[Exp[N[(N[Power[m, 2.0], $MachinePrecision] * -0.25), $MachinePrecision]], $MachinePrecision], N[(N[Cos[M], $MachinePrecision] * N[Exp[N[(N[(N[(n - m), $MachinePrecision] + N[(N[(N[(n * 0.5), $MachinePrecision] - M), $MachinePrecision] * N[(N[(M - N[(n * 0.5), $MachinePrecision]), $MachinePrecision] - m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - l), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[K, m, n, M, l] = \mathsf{sort}([K, m, n, M, l])\\
\\
\begin{array}{l}
\mathbf{if}\;m \leq -8 \cdot 10^{+15}:\\
\;\;\;\;e^{{m}^{2} \cdot -0.25}\\
\mathbf{else}:\\
\;\;\;\;\cos M \cdot e^{\left(\left(n - m\right) + \left(n \cdot 0.5 - M\right) \cdot \left(\left(M - n \cdot 0.5\right) - m\right)\right) - \ell}\\
\end{array}
\end{array}
if m < -8e15Initial program 71.7%
Simplified73.6%
Taylor expanded in K around 0 98.1%
cos-neg98.1%
Simplified98.1%
Taylor expanded in m around inf 98.1%
Taylor expanded in M around 0 98.1%
distribute-lft-neg-in98.1%
metadata-eval98.1%
*-commutative98.1%
Simplified98.1%
if -8e15 < m Initial program 77.8%
Simplified77.8%
Taylor expanded in K around 0 95.8%
cos-neg95.8%
Simplified95.8%
distribute-neg-in95.8%
exp-sum34.8%
div-inv34.8%
fma-neg34.8%
metadata-eval34.8%
add-sqr-sqrt20.2%
fabs-sqr20.2%
add-sqr-sqrt70.2%
Applied egg-rr70.2%
prod-exp95.8%
distribute-neg-in95.8%
+-commutative95.8%
sub-neg95.8%
sub-neg95.8%
mul-1-neg95.8%
+-commutative95.8%
distribute-neg-in95.8%
mul-1-neg95.8%
remove-double-neg95.8%
sub-neg95.8%
associate-+l+95.8%
fma-neg95.8%
*-commutative95.8%
*-commutative95.8%
Simplified95.8%
Taylor expanded in m around 0 89.4%
+-commutative89.4%
unpow289.4%
distribute-rgt-out91.4%
Simplified91.4%
Final simplification92.8%
NOTE: K, m, n, M, and l should be sorted in increasing order before calling this function. (FPCore (K m n M l) :precision binary64 (* (cos M) (exp (- (- (- n m) (pow (- (* (+ m n) 0.5) M) 2.0)) l))))
assert(K < m && m < n && n < M && M < l);
double code(double K, double m, double n, double M, double l) {
return cos(M) * exp((((n - m) - pow((((m + n) * 0.5) - M), 2.0)) - l));
}
NOTE: K, m, n, M, and l should be sorted in increasing order before calling this 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((((n - m) - ((((m + n) * 0.5d0) - m_1) ** 2.0d0)) - l))
end function
assert K < m && m < n && n < M && M < l;
public static double code(double K, double m, double n, double M, double l) {
return Math.cos(M) * Math.exp((((n - m) - Math.pow((((m + n) * 0.5) - M), 2.0)) - l));
}
[K, m, n, M, l] = sort([K, m, n, M, l]) def code(K, m, n, M, l): return math.cos(M) * math.exp((((n - m) - math.pow((((m + n) * 0.5) - M), 2.0)) - l))
K, m, n, M, l = sort([K, m, n, M, l]) function code(K, m, n, M, l) return Float64(cos(M) * exp(Float64(Float64(Float64(n - m) - (Float64(Float64(Float64(m + n) * 0.5) - M) ^ 2.0)) - l))) end
K, m, n, M, l = num2cell(sort([K, m, n, M, l])){:}
function tmp = code(K, m, n, M, l)
tmp = cos(M) * exp((((n - m) - ((((m + n) * 0.5) - M) ^ 2.0)) - l));
end
NOTE: K, m, n, M, and l should be sorted in increasing order before calling this function. code[K_, m_, n_, M_, l_] := N[(N[Cos[M], $MachinePrecision] * N[Exp[N[(N[(N[(n - m), $MachinePrecision] - N[Power[N[(N[(N[(m + n), $MachinePrecision] * 0.5), $MachinePrecision] - M), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] - l), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
[K, m, n, M, l] = \mathsf{sort}([K, m, n, M, l])\\
\\
\cos M \cdot e^{\left(\left(n - m\right) - {\left(\left(m + n\right) \cdot 0.5 - M\right)}^{2}\right) - \ell}
\end{array}
Initial program 76.5%
Simplified76.9%
Taylor expanded in K around 0 96.3%
cos-neg96.3%
Simplified96.3%
distribute-neg-in96.3%
exp-sum29.5%
div-inv29.5%
fma-neg29.5%
metadata-eval29.5%
add-sqr-sqrt18.0%
fabs-sqr18.0%
add-sqr-sqrt59.5%
Applied egg-rr59.5%
prod-exp96.3%
distribute-neg-in96.3%
+-commutative96.3%
sub-neg96.3%
sub-neg96.3%
mul-1-neg96.3%
+-commutative96.3%
distribute-neg-in96.3%
mul-1-neg96.3%
remove-double-neg96.3%
sub-neg96.3%
associate-+l+96.3%
fma-neg96.3%
*-commutative96.3%
*-commutative96.3%
Simplified96.3%
Final simplification96.3%
NOTE: K, m, n, M, and l should be sorted in increasing order before calling this function.
(FPCore (K m n M l)
:precision binary64
(if (<= m -96000000000000.0)
(exp (* (pow m 2.0) -0.25))
(if (<= m 8.5e-218)
(* (cos M) (exp (- (- (* M (- m M)) m) l)))
(* (cos M) (exp (- n (+ (* (* n 0.5) (+ m (* n 0.5))) (+ m l))))))))assert(K < m && m < n && n < M && M < l);
double code(double K, double m, double n, double M, double l) {
double tmp;
if (m <= -96000000000000.0) {
tmp = exp((pow(m, 2.0) * -0.25));
} else if (m <= 8.5e-218) {
tmp = cos(M) * exp((((M * (m - M)) - m) - l));
} else {
tmp = cos(M) * exp((n - (((n * 0.5) * (m + (n * 0.5))) + (m + l))));
}
return tmp;
}
NOTE: K, m, n, M, and l should be sorted in increasing order before calling this 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 <= (-96000000000000.0d0)) then
tmp = exp(((m ** 2.0d0) * (-0.25d0)))
else if (m <= 8.5d-218) then
tmp = cos(m_1) * exp((((m_1 * (m - m_1)) - m) - l))
else
tmp = cos(m_1) * exp((n - (((n * 0.5d0) * (m + (n * 0.5d0))) + (m + l))))
end if
code = tmp
end function
assert K < m && m < n && n < M && M < l;
public static double code(double K, double m, double n, double M, double l) {
double tmp;
if (m <= -96000000000000.0) {
tmp = Math.exp((Math.pow(m, 2.0) * -0.25));
} else if (m <= 8.5e-218) {
tmp = Math.cos(M) * Math.exp((((M * (m - M)) - m) - l));
} else {
tmp = Math.cos(M) * Math.exp((n - (((n * 0.5) * (m + (n * 0.5))) + (m + l))));
}
return tmp;
}
[K, m, n, M, l] = sort([K, m, n, M, l]) def code(K, m, n, M, l): tmp = 0 if m <= -96000000000000.0: tmp = math.exp((math.pow(m, 2.0) * -0.25)) elif m <= 8.5e-218: tmp = math.cos(M) * math.exp((((M * (m - M)) - m) - l)) else: tmp = math.cos(M) * math.exp((n - (((n * 0.5) * (m + (n * 0.5))) + (m + l)))) return tmp
K, m, n, M, l = sort([K, m, n, M, l]) function code(K, m, n, M, l) tmp = 0.0 if (m <= -96000000000000.0) tmp = exp(Float64((m ^ 2.0) * -0.25)); elseif (m <= 8.5e-218) tmp = Float64(cos(M) * exp(Float64(Float64(Float64(M * Float64(m - M)) - m) - l))); else tmp = Float64(cos(M) * exp(Float64(n - Float64(Float64(Float64(n * 0.5) * Float64(m + Float64(n * 0.5))) + Float64(m + l))))); end return tmp end
K, m, n, M, l = num2cell(sort([K, m, n, M, l])){:}
function tmp_2 = code(K, m, n, M, l)
tmp = 0.0;
if (m <= -96000000000000.0)
tmp = exp(((m ^ 2.0) * -0.25));
elseif (m <= 8.5e-218)
tmp = cos(M) * exp((((M * (m - M)) - m) - l));
else
tmp = cos(M) * exp((n - (((n * 0.5) * (m + (n * 0.5))) + (m + l))));
end
tmp_2 = tmp;
end
NOTE: K, m, n, M, and l should be sorted in increasing order before calling this function. code[K_, m_, n_, M_, l_] := If[LessEqual[m, -96000000000000.0], N[Exp[N[(N[Power[m, 2.0], $MachinePrecision] * -0.25), $MachinePrecision]], $MachinePrecision], If[LessEqual[m, 8.5e-218], N[(N[Cos[M], $MachinePrecision] * N[Exp[N[(N[(N[(M * N[(m - M), $MachinePrecision]), $MachinePrecision] - m), $MachinePrecision] - l), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(N[Cos[M], $MachinePrecision] * N[Exp[N[(n - N[(N[(N[(n * 0.5), $MachinePrecision] * N[(m + N[(n * 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(m + l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
[K, m, n, M, l] = \mathsf{sort}([K, m, n, M, l])\\
\\
\begin{array}{l}
\mathbf{if}\;m \leq -96000000000000:\\
\;\;\;\;e^{{m}^{2} \cdot -0.25}\\
\mathbf{elif}\;m \leq 8.5 \cdot 10^{-218}:\\
\;\;\;\;\cos M \cdot e^{\left(M \cdot \left(m - M\right) - m\right) - \ell}\\
\mathbf{else}:\\
\;\;\;\;\cos M \cdot e^{n - \left(\left(n \cdot 0.5\right) \cdot \left(m + n \cdot 0.5\right) + \left(m + \ell\right)\right)}\\
\end{array}
\end{array}
if m < -9.6e13Initial program 70.4%
Simplified72.2%
Taylor expanded in K around 0 98.1%
cos-neg98.1%
Simplified98.1%
Taylor expanded in m around inf 98.2%
Taylor expanded in M around 0 98.2%
distribute-lft-neg-in98.2%
metadata-eval98.2%
*-commutative98.2%
Simplified98.2%
if -9.6e13 < m < 8.5000000000000004e-218Initial program 81.8%
Simplified81.8%
Taylor expanded in K around 0 97.0%
cos-neg97.0%
Simplified97.0%
distribute-neg-in97.0%
exp-sum45.5%
div-inv45.5%
fma-neg45.5%
metadata-eval45.5%
add-sqr-sqrt33.3%
fabs-sqr33.3%
add-sqr-sqrt68.7%
Applied egg-rr68.7%
prod-exp97.0%
distribute-neg-in97.0%
+-commutative97.0%
sub-neg97.0%
sub-neg97.0%
mul-1-neg97.0%
+-commutative97.0%
distribute-neg-in97.0%
mul-1-neg97.0%
remove-double-neg97.0%
sub-neg97.0%
associate-+l+97.0%
fma-neg97.0%
*-commutative97.0%
*-commutative97.0%
Simplified97.0%
Taylor expanded in m around 0 97.0%
+-commutative97.0%
unpow297.0%
distribute-rgt-out97.0%
Simplified97.0%
Taylor expanded in n around 0 81.2%
distribute-neg-in81.2%
unsub-neg81.2%
mul-1-neg81.2%
unsub-neg81.2%
Simplified81.2%
if 8.5000000000000004e-218 < m Initial program 74.6%
Simplified74.6%
Taylor expanded in K around 0 94.7%
cos-neg94.7%
Simplified94.7%
distribute-neg-in94.7%
exp-sum24.8%
div-inv24.8%
fma-neg24.8%
metadata-eval24.8%
add-sqr-sqrt7.8%
fabs-sqr7.8%
add-sqr-sqrt71.3%
Applied egg-rr71.3%
prod-exp94.6%
distribute-neg-in94.6%
+-commutative94.6%
sub-neg94.6%
sub-neg94.6%
mul-1-neg94.6%
+-commutative94.6%
distribute-neg-in94.6%
mul-1-neg94.6%
remove-double-neg94.6%
sub-neg94.6%
associate-+l+94.6%
fma-neg94.6%
*-commutative94.6%
*-commutative94.6%
Simplified94.6%
Taylor expanded in m around 0 82.1%
+-commutative82.1%
unpow282.1%
distribute-rgt-out86.0%
Simplified86.0%
Taylor expanded in M around 0 76.5%
associate-+r+76.5%
associate-*r*76.5%
*-commutative76.5%
*-commutative76.5%
Simplified76.5%
Final simplification82.9%
NOTE: K, m, n, M, and l should be sorted in increasing order before calling this function. (FPCore (K m n M l) :precision binary64 (if (or (<= m -96000000000000.0) (not (<= m 5.2e-30))) (exp (* (pow m 2.0) -0.25)) (* (cos (- (* K (* m 0.5)) M)) (exp (- l)))))
assert(K < m && m < n && n < M && M < l);
double code(double K, double m, double n, double M, double l) {
double tmp;
if ((m <= -96000000000000.0) || !(m <= 5.2e-30)) {
tmp = exp((pow(m, 2.0) * -0.25));
} else {
tmp = cos(((K * (m * 0.5)) - M)) * exp(-l);
}
return tmp;
}
NOTE: K, m, n, M, and l should be sorted in increasing order before calling this 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 <= (-96000000000000.0d0)) .or. (.not. (m <= 5.2d-30))) then
tmp = exp(((m ** 2.0d0) * (-0.25d0)))
else
tmp = cos(((k * (m * 0.5d0)) - m_1)) * exp(-l)
end if
code = tmp
end function
assert K < m && m < n && n < M && M < l;
public static double code(double K, double m, double n, double M, double l) {
double tmp;
if ((m <= -96000000000000.0) || !(m <= 5.2e-30)) {
tmp = Math.exp((Math.pow(m, 2.0) * -0.25));
} else {
tmp = Math.cos(((K * (m * 0.5)) - M)) * Math.exp(-l);
}
return tmp;
}
[K, m, n, M, l] = sort([K, m, n, M, l]) def code(K, m, n, M, l): tmp = 0 if (m <= -96000000000000.0) or not (m <= 5.2e-30): tmp = math.exp((math.pow(m, 2.0) * -0.25)) else: tmp = math.cos(((K * (m * 0.5)) - M)) * math.exp(-l) return tmp
K, m, n, M, l = sort([K, m, n, M, l]) function code(K, m, n, M, l) tmp = 0.0 if ((m <= -96000000000000.0) || !(m <= 5.2e-30)) tmp = exp(Float64((m ^ 2.0) * -0.25)); else tmp = Float64(cos(Float64(Float64(K * Float64(m * 0.5)) - M)) * exp(Float64(-l))); end return tmp end
K, m, n, M, l = num2cell(sort([K, m, n, M, l])){:}
function tmp_2 = code(K, m, n, M, l)
tmp = 0.0;
if ((m <= -96000000000000.0) || ~((m <= 5.2e-30)))
tmp = exp(((m ^ 2.0) * -0.25));
else
tmp = cos(((K * (m * 0.5)) - M)) * exp(-l);
end
tmp_2 = tmp;
end
NOTE: K, m, n, M, and l should be sorted in increasing order before calling this function. code[K_, m_, n_, M_, l_] := If[Or[LessEqual[m, -96000000000000.0], N[Not[LessEqual[m, 5.2e-30]], $MachinePrecision]], N[Exp[N[(N[Power[m, 2.0], $MachinePrecision] * -0.25), $MachinePrecision]], $MachinePrecision], N[(N[Cos[N[(N[(K * N[(m * 0.5), $MachinePrecision]), $MachinePrecision] - M), $MachinePrecision]], $MachinePrecision] * N[Exp[(-l)], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[K, m, n, M, l] = \mathsf{sort}([K, m, n, M, l])\\
\\
\begin{array}{l}
\mathbf{if}\;m \leq -96000000000000 \lor \neg \left(m \leq 5.2 \cdot 10^{-30}\right):\\
\;\;\;\;e^{{m}^{2} \cdot -0.25}\\
\mathbf{else}:\\
\;\;\;\;\cos \left(K \cdot \left(m \cdot 0.5\right) - M\right) \cdot e^{-\ell}\\
\end{array}
\end{array}
if m < -9.6e13 or 5.19999999999999973e-30 < m Initial program 70.1%
Simplified70.9%
Taylor expanded in K around 0 97.1%
cos-neg97.1%
Simplified97.1%
Taylor expanded in m around inf 89.4%
Taylor expanded in M around 0 89.4%
distribute-lft-neg-in89.4%
metadata-eval89.4%
*-commutative89.4%
Simplified89.4%
if -9.6e13 < m < 5.19999999999999973e-30Initial program 82.6%
Simplified82.6%
Taylor expanded in n around 0 97.2%
*-commutative97.2%
associate-*r*97.2%
Simplified97.2%
Taylor expanded in l around inf 49.3%
Final simplification68.9%
NOTE: K, m, n, M, and l should be sorted in increasing order before calling this function. (FPCore (K m n M l) :precision binary64 (if (<= m -96000000000000.0) (exp (* (pow m 2.0) -0.25)) (* (cos M) (exp (- (- (* M (- m M)) m) l)))))
assert(K < m && m < n && n < M && M < l);
double code(double K, double m, double n, double M, double l) {
double tmp;
if (m <= -96000000000000.0) {
tmp = exp((pow(m, 2.0) * -0.25));
} else {
tmp = cos(M) * exp((((M * (m - M)) - m) - l));
}
return tmp;
}
NOTE: K, m, n, M, and l should be sorted in increasing order before calling this 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 <= (-96000000000000.0d0)) then
tmp = exp(((m ** 2.0d0) * (-0.25d0)))
else
tmp = cos(m_1) * exp((((m_1 * (m - m_1)) - m) - l))
end if
code = tmp
end function
assert K < m && m < n && n < M && M < l;
public static double code(double K, double m, double n, double M, double l) {
double tmp;
if (m <= -96000000000000.0) {
tmp = Math.exp((Math.pow(m, 2.0) * -0.25));
} else {
tmp = Math.cos(M) * Math.exp((((M * (m - M)) - m) - l));
}
return tmp;
}
[K, m, n, M, l] = sort([K, m, n, M, l]) def code(K, m, n, M, l): tmp = 0 if m <= -96000000000000.0: tmp = math.exp((math.pow(m, 2.0) * -0.25)) else: tmp = math.cos(M) * math.exp((((M * (m - M)) - m) - l)) return tmp
K, m, n, M, l = sort([K, m, n, M, l]) function code(K, m, n, M, l) tmp = 0.0 if (m <= -96000000000000.0) tmp = exp(Float64((m ^ 2.0) * -0.25)); else tmp = Float64(cos(M) * exp(Float64(Float64(Float64(M * Float64(m - M)) - m) - l))); end return tmp end
K, m, n, M, l = num2cell(sort([K, m, n, M, l])){:}
function tmp_2 = code(K, m, n, M, l)
tmp = 0.0;
if (m <= -96000000000000.0)
tmp = exp(((m ^ 2.0) * -0.25));
else
tmp = cos(M) * exp((((M * (m - M)) - m) - l));
end
tmp_2 = tmp;
end
NOTE: K, m, n, M, and l should be sorted in increasing order before calling this function. code[K_, m_, n_, M_, l_] := If[LessEqual[m, -96000000000000.0], N[Exp[N[(N[Power[m, 2.0], $MachinePrecision] * -0.25), $MachinePrecision]], $MachinePrecision], N[(N[Cos[M], $MachinePrecision] * N[Exp[N[(N[(N[(M * N[(m - M), $MachinePrecision]), $MachinePrecision] - m), $MachinePrecision] - l), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[K, m, n, M, l] = \mathsf{sort}([K, m, n, M, l])\\
\\
\begin{array}{l}
\mathbf{if}\;m \leq -96000000000000:\\
\;\;\;\;e^{{m}^{2} \cdot -0.25}\\
\mathbf{else}:\\
\;\;\;\;\cos M \cdot e^{\left(M \cdot \left(m - M\right) - m\right) - \ell}\\
\end{array}
\end{array}
if m < -9.6e13Initial program 70.4%
Simplified72.2%
Taylor expanded in K around 0 98.1%
cos-neg98.1%
Simplified98.1%
Taylor expanded in m around inf 98.2%
Taylor expanded in M around 0 98.2%
distribute-lft-neg-in98.2%
metadata-eval98.2%
*-commutative98.2%
Simplified98.2%
if -9.6e13 < m Initial program 78.1%
Simplified78.1%
Taylor expanded in K around 0 95.8%
cos-neg95.8%
Simplified95.8%
distribute-neg-in95.8%
exp-sum34.9%
div-inv34.9%
fma-neg34.9%
metadata-eval34.9%
add-sqr-sqrt20.3%
fabs-sqr20.3%
add-sqr-sqrt70.0%
Applied egg-rr70.0%
prod-exp95.8%
distribute-neg-in95.8%
+-commutative95.8%
sub-neg95.8%
sub-neg95.8%
mul-1-neg95.8%
+-commutative95.8%
distribute-neg-in95.8%
mul-1-neg95.8%
remove-double-neg95.8%
sub-neg95.8%
associate-+l+95.8%
fma-neg95.8%
*-commutative95.8%
*-commutative95.8%
Simplified95.8%
Taylor expanded in m around 0 89.4%
+-commutative89.4%
unpow289.4%
distribute-rgt-out91.4%
Simplified91.4%
Taylor expanded in n around 0 81.3%
distribute-neg-in81.3%
unsub-neg81.3%
mul-1-neg81.3%
unsub-neg81.3%
Simplified81.3%
Final simplification84.8%
NOTE: K, m, n, M, and l should be sorted in increasing order before calling this function. (FPCore (K m n M l) :precision binary64 (if (or (<= m -96000000000000.0) (not (<= m 5.2e-30))) (exp (* (pow m 2.0) -0.25)) (* (cos M) (exp (- l)))))
assert(K < m && m < n && n < M && M < l);
double code(double K, double m, double n, double M, double l) {
double tmp;
if ((m <= -96000000000000.0) || !(m <= 5.2e-30)) {
tmp = exp((pow(m, 2.0) * -0.25));
} else {
tmp = cos(M) * exp(-l);
}
return tmp;
}
NOTE: K, m, n, M, and l should be sorted in increasing order before calling this 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 <= (-96000000000000.0d0)) .or. (.not. (m <= 5.2d-30))) then
tmp = exp(((m ** 2.0d0) * (-0.25d0)))
else
tmp = cos(m_1) * exp(-l)
end if
code = tmp
end function
assert K < m && m < n && n < M && M < l;
public static double code(double K, double m, double n, double M, double l) {
double tmp;
if ((m <= -96000000000000.0) || !(m <= 5.2e-30)) {
tmp = Math.exp((Math.pow(m, 2.0) * -0.25));
} else {
tmp = Math.cos(M) * Math.exp(-l);
}
return tmp;
}
[K, m, n, M, l] = sort([K, m, n, M, l]) def code(K, m, n, M, l): tmp = 0 if (m <= -96000000000000.0) or not (m <= 5.2e-30): tmp = math.exp((math.pow(m, 2.0) * -0.25)) else: tmp = math.cos(M) * math.exp(-l) return tmp
K, m, n, M, l = sort([K, m, n, M, l]) function code(K, m, n, M, l) tmp = 0.0 if ((m <= -96000000000000.0) || !(m <= 5.2e-30)) tmp = exp(Float64((m ^ 2.0) * -0.25)); else tmp = Float64(cos(M) * exp(Float64(-l))); end return tmp end
K, m, n, M, l = num2cell(sort([K, m, n, M, l])){:}
function tmp_2 = code(K, m, n, M, l)
tmp = 0.0;
if ((m <= -96000000000000.0) || ~((m <= 5.2e-30)))
tmp = exp(((m ^ 2.0) * -0.25));
else
tmp = cos(M) * exp(-l);
end
tmp_2 = tmp;
end
NOTE: K, m, n, M, and l should be sorted in increasing order before calling this function. code[K_, m_, n_, M_, l_] := If[Or[LessEqual[m, -96000000000000.0], N[Not[LessEqual[m, 5.2e-30]], $MachinePrecision]], N[Exp[N[(N[Power[m, 2.0], $MachinePrecision] * -0.25), $MachinePrecision]], $MachinePrecision], N[(N[Cos[M], $MachinePrecision] * N[Exp[(-l)], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[K, m, n, M, l] = \mathsf{sort}([K, m, n, M, l])\\
\\
\begin{array}{l}
\mathbf{if}\;m \leq -96000000000000 \lor \neg \left(m \leq 5.2 \cdot 10^{-30}\right):\\
\;\;\;\;e^{{m}^{2} \cdot -0.25}\\
\mathbf{else}:\\
\;\;\;\;\cos M \cdot e^{-\ell}\\
\end{array}
\end{array}
if m < -9.6e13 or 5.19999999999999973e-30 < m Initial program 70.1%
Simplified70.9%
Taylor expanded in K around 0 97.1%
cos-neg97.1%
Simplified97.1%
Taylor expanded in m around inf 89.4%
Taylor expanded in M around 0 89.4%
distribute-lft-neg-in89.4%
metadata-eval89.4%
*-commutative89.4%
Simplified89.4%
if -9.6e13 < m < 5.19999999999999973e-30Initial program 82.6%
Simplified82.6%
Taylor expanded in K around 0 95.6%
cos-neg95.6%
Simplified95.6%
Taylor expanded in l around inf 47.6%
Final simplification68.0%
NOTE: K, m, n, M, and l should be sorted in increasing order before calling this function. (FPCore (K m n M l) :precision binary64 (exp (* (pow m 2.0) -0.25)))
assert(K < m && m < n && n < M && M < l);
double code(double K, double m, double n, double M, double l) {
return exp((pow(m, 2.0) * -0.25));
}
NOTE: K, m, n, M, and l should be sorted in increasing order before calling this 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 = exp(((m ** 2.0d0) * (-0.25d0)))
end function
assert K < m && m < n && n < M && M < l;
public static double code(double K, double m, double n, double M, double l) {
return Math.exp((Math.pow(m, 2.0) * -0.25));
}
[K, m, n, M, l] = sort([K, m, n, M, l]) def code(K, m, n, M, l): return math.exp((math.pow(m, 2.0) * -0.25))
K, m, n, M, l = sort([K, m, n, M, l]) function code(K, m, n, M, l) return exp(Float64((m ^ 2.0) * -0.25)) end
K, m, n, M, l = num2cell(sort([K, m, n, M, l])){:}
function tmp = code(K, m, n, M, l)
tmp = exp(((m ^ 2.0) * -0.25));
end
NOTE: K, m, n, M, and l should be sorted in increasing order before calling this function. code[K_, m_, n_, M_, l_] := N[Exp[N[(N[Power[m, 2.0], $MachinePrecision] * -0.25), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
[K, m, n, M, l] = \mathsf{sort}([K, m, n, M, l])\\
\\
e^{{m}^{2} \cdot -0.25}
\end{array}
Initial program 76.5%
Simplified76.9%
Taylor expanded in K around 0 96.3%
cos-neg96.3%
Simplified96.3%
Taylor expanded in m around inf 49.2%
Taylor expanded in M around 0 49.2%
distribute-lft-neg-in49.2%
metadata-eval49.2%
*-commutative49.2%
Simplified49.2%
Final simplification49.2%
NOTE: K, m, n, M, and l should be sorted in increasing order before calling this function. (FPCore (K m n M l) :precision binary64 (cos M))
assert(K < m && m < n && n < M && M < l);
double code(double K, double m, double n, double M, double l) {
return cos(M);
}
NOTE: K, m, n, M, and l should be sorted in increasing order before calling this 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)
end function
assert K < m && m < n && n < M && M < l;
public static double code(double K, double m, double n, double M, double l) {
return Math.cos(M);
}
[K, m, n, M, l] = sort([K, m, n, M, l]) def code(K, m, n, M, l): return math.cos(M)
K, m, n, M, l = sort([K, m, n, M, l]) function code(K, m, n, M, l) return cos(M) end
K, m, n, M, l = num2cell(sort([K, m, n, M, l])){:}
function tmp = code(K, m, n, M, l)
tmp = cos(M);
end
NOTE: K, m, n, M, and l should be sorted in increasing order before calling this function. code[K_, m_, n_, M_, l_] := N[Cos[M], $MachinePrecision]
\begin{array}{l}
[K, m, n, M, l] = \mathsf{sort}([K, m, n, M, l])\\
\\
\cos M
\end{array}
Initial program 76.5%
Simplified76.9%
Taylor expanded in K around 0 96.3%
cos-neg96.3%
Simplified96.3%
Taylor expanded in m around inf 49.2%
Taylor expanded in m around 0 6.8%
Final simplification6.8%
herbie shell --seed 2023337
(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)))))))