
(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 11 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
(let* ((t_0 (- (fabs (- n m)) l))
(t_1 (exp (- t_0 (pow (- (/ (+ m n) 2.0) M) 2.0)))))
(if (<= (* (cos (- (/ (* K (+ m n)) 2.0) M)) t_1) INFINITY)
(* (cos (- (/ K (+ (* -2.0 (/ m (pow n 2.0))) (* 2.0 (/ 1.0 n)))) M)) t_1)
(* (cos M) (exp (- t_0 (pow (log (exp (fma (+ m n) 0.5 M))) 2.0)))))))assert(K < m && m < n && n < M && M < l);
double code(double K, double m, double n, double M, double l) {
double t_0 = fabs((n - m)) - l;
double t_1 = exp((t_0 - pow((((m + n) / 2.0) - M), 2.0)));
double tmp;
if ((cos((((K * (m + n)) / 2.0) - M)) * t_1) <= ((double) INFINITY)) {
tmp = cos(((K / ((-2.0 * (m / pow(n, 2.0))) + (2.0 * (1.0 / n)))) - M)) * t_1;
} else {
tmp = cos(M) * exp((t_0 - pow(log(exp(fma((m + n), 0.5, M))), 2.0)));
}
return tmp;
}
K, m, n, M, l = sort([K, m, n, M, l]) function code(K, m, n, M, l) t_0 = Float64(abs(Float64(n - m)) - l) t_1 = exp(Float64(t_0 - (Float64(Float64(Float64(m + n) / 2.0) - M) ^ 2.0))) tmp = 0.0 if (Float64(cos(Float64(Float64(Float64(K * Float64(m + n)) / 2.0) - M)) * t_1) <= Inf) tmp = Float64(cos(Float64(Float64(K / Float64(Float64(-2.0 * Float64(m / (n ^ 2.0))) + Float64(2.0 * Float64(1.0 / n)))) - M)) * t_1); else tmp = Float64(cos(M) * exp(Float64(t_0 - (log(exp(fma(Float64(m + n), 0.5, M))) ^ 2.0)))); end return 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_] := Block[{t$95$0 = N[(N[Abs[N[(n - m), $MachinePrecision]], $MachinePrecision] - l), $MachinePrecision]}, Block[{t$95$1 = N[Exp[N[(t$95$0 - N[Power[N[(N[(N[(m + n), $MachinePrecision] / 2.0), $MachinePrecision] - M), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[N[(N[Cos[N[(N[(N[(K * N[(m + n), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision] - M), $MachinePrecision]], $MachinePrecision] * t$95$1), $MachinePrecision], Infinity], N[(N[Cos[N[(N[(K / N[(N[(-2.0 * N[(m / N[Power[n, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(2.0 * N[(1.0 / n), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - M), $MachinePrecision]], $MachinePrecision] * t$95$1), $MachinePrecision], N[(N[Cos[M], $MachinePrecision] * N[Exp[N[(t$95$0 - N[Power[N[Log[N[Exp[N[(N[(m + n), $MachinePrecision] * 0.5 + M), $MachinePrecision]], $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
[K, m, n, M, l] = \mathsf{sort}([K, m, n, M, l])\\
\\
\begin{array}{l}
t_0 := \left|n - m\right| - \ell\\
t_1 := e^{t_0 - {\left(\frac{m + n}{2} - M\right)}^{2}}\\
\mathbf{if}\;\cos \left(\frac{K \cdot \left(m + n\right)}{2} - M\right) \cdot t_1 \leq \infty:\\
\;\;\;\;\cos \left(\frac{K}{-2 \cdot \frac{m}{{n}^{2}} + 2 \cdot \frac{1}{n}} - M\right) \cdot t_1\\
\mathbf{else}:\\
\;\;\;\;\cos M \cdot e^{t_0 - {\log \left(e^{\mathsf{fma}\left(m + n, 0.5, M\right)}\right)}^{2}}\\
\end{array}
\end{array}
if (*.f64 (cos.f64 (-.f64 (/.f64 (*.f64 K (+.f64 m n)) 2) M)) (exp.f64 (-.f64 (neg.f64 (pow.f64 (-.f64 (/.f64 (+.f64 m n) 2) M) 2)) (-.f64 l (fabs.f64 (-.f64 m n)))))) < +inf.0Initial program 95.7%
associate-/l*96.0%
+-commutative96.0%
fabs-sub96.0%
+-commutative96.0%
Simplified96.0%
Taylor expanded in m around 0 95.3%
if +inf.0 < (*.f64 (cos.f64 (-.f64 (/.f64 (*.f64 K (+.f64 m n)) 2) M)) (exp.f64 (-.f64 (neg.f64 (pow.f64 (-.f64 (/.f64 (+.f64 m n) 2) M) 2)) (-.f64 l (fabs.f64 (-.f64 m n)))))) Initial program 0.0%
associate-/l*0.0%
+-commutative0.0%
fabs-sub0.0%
+-commutative0.0%
Simplified0.0%
Taylor expanded in K around 0 96.0%
cos-neg96.0%
Simplified96.0%
log1p-expm1-u96.1%
div-inv96.1%
metadata-eval96.1%
fma-neg96.1%
Applied egg-rr96.1%
log1p-expm1-u96.0%
add-sqr-sqrt40.0%
sqrt-prod96.0%
unpow296.0%
add-log-exp96.1%
unpow296.1%
sqrt-prod40.1%
add-sqr-sqrt96.1%
add-sqr-sqrt46.0%
sqrt-unprod96.1%
sqr-neg96.1%
sqrt-unprod50.1%
add-sqr-sqrt96.1%
Applied egg-rr96.1%
Final simplification95.5%
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
(let* ((t_0 (exp (- (- (fabs (- n m)) l) (pow (- (/ (+ m n) 2.0) M) 2.0)))))
(if (<= (* (cos (- (/ (* K (+ m n)) 2.0) M)) t_0) INFINITY)
(* (cos (- (/ K (+ (* -2.0 (/ m (pow n 2.0))) (* 2.0 (/ 1.0 n)))) M)) t_0)
(* t_0 (cos M)))))assert(K < m && m < n && n < M && M < l);
double code(double K, double m, double n, double M, double l) {
double t_0 = exp(((fabs((n - m)) - l) - pow((((m + n) / 2.0) - M), 2.0)));
double tmp;
if ((cos((((K * (m + n)) / 2.0) - M)) * t_0) <= ((double) INFINITY)) {
tmp = cos(((K / ((-2.0 * (m / pow(n, 2.0))) + (2.0 * (1.0 / n)))) - M)) * t_0;
} else {
tmp = t_0 * cos(M);
}
return tmp;
}
assert K < m && m < n && n < M && M < l;
public static double code(double K, double m, double n, double M, double l) {
double t_0 = Math.exp(((Math.abs((n - m)) - l) - Math.pow((((m + n) / 2.0) - M), 2.0)));
double tmp;
if ((Math.cos((((K * (m + n)) / 2.0) - M)) * t_0) <= Double.POSITIVE_INFINITY) {
tmp = Math.cos(((K / ((-2.0 * (m / Math.pow(n, 2.0))) + (2.0 * (1.0 / n)))) - M)) * t_0;
} else {
tmp = t_0 * Math.cos(M);
}
return tmp;
}
[K, m, n, M, l] = sort([K, m, n, M, l]) def code(K, m, n, M, l): t_0 = math.exp(((math.fabs((n - m)) - l) - math.pow((((m + n) / 2.0) - M), 2.0))) tmp = 0 if (math.cos((((K * (m + n)) / 2.0) - M)) * t_0) <= math.inf: tmp = math.cos(((K / ((-2.0 * (m / math.pow(n, 2.0))) + (2.0 * (1.0 / n)))) - M)) * t_0 else: tmp = t_0 * math.cos(M) return tmp
K, m, n, M, l = sort([K, m, n, M, l]) function code(K, m, n, M, l) t_0 = exp(Float64(Float64(abs(Float64(n - m)) - l) - (Float64(Float64(Float64(m + n) / 2.0) - M) ^ 2.0))) tmp = 0.0 if (Float64(cos(Float64(Float64(Float64(K * Float64(m + n)) / 2.0) - M)) * t_0) <= Inf) tmp = Float64(cos(Float64(Float64(K / Float64(Float64(-2.0 * Float64(m / (n ^ 2.0))) + Float64(2.0 * Float64(1.0 / n)))) - M)) * t_0); else tmp = Float64(t_0 * cos(M)); 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)
t_0 = exp(((abs((n - m)) - l) - ((((m + n) / 2.0) - M) ^ 2.0)));
tmp = 0.0;
if ((cos((((K * (m + n)) / 2.0) - M)) * t_0) <= Inf)
tmp = cos(((K / ((-2.0 * (m / (n ^ 2.0))) + (2.0 * (1.0 / n)))) - M)) * t_0;
else
tmp = t_0 * cos(M);
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_] := Block[{t$95$0 = N[Exp[N[(N[(N[Abs[N[(n - m), $MachinePrecision]], $MachinePrecision] - l), $MachinePrecision] - N[Power[N[(N[(N[(m + n), $MachinePrecision] / 2.0), $MachinePrecision] - M), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[N[(N[Cos[N[(N[(N[(K * N[(m + n), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision] - M), $MachinePrecision]], $MachinePrecision] * t$95$0), $MachinePrecision], Infinity], N[(N[Cos[N[(N[(K / N[(N[(-2.0 * N[(m / N[Power[n, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(2.0 * N[(1.0 / n), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - M), $MachinePrecision]], $MachinePrecision] * t$95$0), $MachinePrecision], N[(t$95$0 * N[Cos[M], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
[K, m, n, M, l] = \mathsf{sort}([K, m, n, M, l])\\
\\
\begin{array}{l}
t_0 := e^{\left(\left|n - m\right| - \ell\right) - {\left(\frac{m + n}{2} - M\right)}^{2}}\\
\mathbf{if}\;\cos \left(\frac{K \cdot \left(m + n\right)}{2} - M\right) \cdot t_0 \leq \infty:\\
\;\;\;\;\cos \left(\frac{K}{-2 \cdot \frac{m}{{n}^{2}} + 2 \cdot \frac{1}{n}} - M\right) \cdot t_0\\
\mathbf{else}:\\
\;\;\;\;t_0 \cdot \cos M\\
\end{array}
\end{array}
if (*.f64 (cos.f64 (-.f64 (/.f64 (*.f64 K (+.f64 m n)) 2) M)) (exp.f64 (-.f64 (neg.f64 (pow.f64 (-.f64 (/.f64 (+.f64 m n) 2) M) 2)) (-.f64 l (fabs.f64 (-.f64 m n)))))) < +inf.0Initial program 95.7%
associate-/l*96.0%
+-commutative96.0%
fabs-sub96.0%
+-commutative96.0%
Simplified96.0%
Taylor expanded in m around 0 95.3%
if +inf.0 < (*.f64 (cos.f64 (-.f64 (/.f64 (*.f64 K (+.f64 m n)) 2) M)) (exp.f64 (-.f64 (neg.f64 (pow.f64 (-.f64 (/.f64 (+.f64 m n) 2) M) 2)) (-.f64 l (fabs.f64 (-.f64 m n)))))) Initial program 0.0%
associate-/l*0.0%
+-commutative0.0%
fabs-sub0.0%
+-commutative0.0%
Simplified0.0%
Taylor expanded in K around 0 96.0%
cos-neg96.0%
Simplified96.0%
Final simplification95.5%
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
(let* ((t_0 (- (fabs (- n m)) l))
(t_1 (exp (- t_0 (pow (- (/ (+ m n) 2.0) M) 2.0)))))
(if (<= (* (cos (- (/ (* K (+ m n)) 2.0) M)) t_1) -0.5)
(*
(cos (- (/ K (+ (* -2.0 (/ m (pow n 2.0))) (* 2.0 (/ 1.0 n)))) M))
(exp (+ (* (- (* n 0.5) M) (- (- M (* n 0.5)) m)) t_0)))
(* t_1 (cos M)))))assert(K < m && m < n && n < M && M < l);
double code(double K, double m, double n, double M, double l) {
double t_0 = fabs((n - m)) - l;
double t_1 = exp((t_0 - pow((((m + n) / 2.0) - M), 2.0)));
double tmp;
if ((cos((((K * (m + n)) / 2.0) - M)) * t_1) <= -0.5) {
tmp = cos(((K / ((-2.0 * (m / pow(n, 2.0))) + (2.0 * (1.0 / n)))) - M)) * exp(((((n * 0.5) - M) * ((M - (n * 0.5)) - m)) + t_0));
} else {
tmp = t_1 * cos(M);
}
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) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = abs((n - m)) - l
t_1 = exp((t_0 - ((((m + n) / 2.0d0) - m_1) ** 2.0d0)))
if ((cos((((k * (m + n)) / 2.0d0) - m_1)) * t_1) <= (-0.5d0)) then
tmp = cos(((k / (((-2.0d0) * (m / (n ** 2.0d0))) + (2.0d0 * (1.0d0 / n)))) - m_1)) * exp(((((n * 0.5d0) - m_1) * ((m_1 - (n * 0.5d0)) - m)) + t_0))
else
tmp = t_1 * cos(m_1)
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 t_0 = Math.abs((n - m)) - l;
double t_1 = Math.exp((t_0 - Math.pow((((m + n) / 2.0) - M), 2.0)));
double tmp;
if ((Math.cos((((K * (m + n)) / 2.0) - M)) * t_1) <= -0.5) {
tmp = Math.cos(((K / ((-2.0 * (m / Math.pow(n, 2.0))) + (2.0 * (1.0 / n)))) - M)) * Math.exp(((((n * 0.5) - M) * ((M - (n * 0.5)) - m)) + t_0));
} else {
tmp = t_1 * Math.cos(M);
}
return tmp;
}
[K, m, n, M, l] = sort([K, m, n, M, l]) def code(K, m, n, M, l): t_0 = math.fabs((n - m)) - l t_1 = math.exp((t_0 - math.pow((((m + n) / 2.0) - M), 2.0))) tmp = 0 if (math.cos((((K * (m + n)) / 2.0) - M)) * t_1) <= -0.5: tmp = math.cos(((K / ((-2.0 * (m / math.pow(n, 2.0))) + (2.0 * (1.0 / n)))) - M)) * math.exp(((((n * 0.5) - M) * ((M - (n * 0.5)) - m)) + t_0)) else: tmp = t_1 * math.cos(M) return tmp
K, m, n, M, l = sort([K, m, n, M, l]) function code(K, m, n, M, l) t_0 = Float64(abs(Float64(n - m)) - l) t_1 = exp(Float64(t_0 - (Float64(Float64(Float64(m + n) / 2.0) - M) ^ 2.0))) tmp = 0.0 if (Float64(cos(Float64(Float64(Float64(K * Float64(m + n)) / 2.0) - M)) * t_1) <= -0.5) tmp = Float64(cos(Float64(Float64(K / Float64(Float64(-2.0 * Float64(m / (n ^ 2.0))) + Float64(2.0 * Float64(1.0 / n)))) - M)) * exp(Float64(Float64(Float64(Float64(n * 0.5) - M) * Float64(Float64(M - Float64(n * 0.5)) - m)) + t_0))); else tmp = Float64(t_1 * cos(M)); 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)
t_0 = abs((n - m)) - l;
t_1 = exp((t_0 - ((((m + n) / 2.0) - M) ^ 2.0)));
tmp = 0.0;
if ((cos((((K * (m + n)) / 2.0) - M)) * t_1) <= -0.5)
tmp = cos(((K / ((-2.0 * (m / (n ^ 2.0))) + (2.0 * (1.0 / n)))) - M)) * exp(((((n * 0.5) - M) * ((M - (n * 0.5)) - m)) + t_0));
else
tmp = t_1 * cos(M);
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_] := Block[{t$95$0 = N[(N[Abs[N[(n - m), $MachinePrecision]], $MachinePrecision] - l), $MachinePrecision]}, Block[{t$95$1 = N[Exp[N[(t$95$0 - N[Power[N[(N[(N[(m + n), $MachinePrecision] / 2.0), $MachinePrecision] - M), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[N[(N[Cos[N[(N[(N[(K * N[(m + n), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision] - M), $MachinePrecision]], $MachinePrecision] * t$95$1), $MachinePrecision], -0.5], N[(N[Cos[N[(N[(K / N[(N[(-2.0 * N[(m / N[Power[n, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(2.0 * N[(1.0 / n), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - M), $MachinePrecision]], $MachinePrecision] * N[Exp[N[(N[(N[(N[(n * 0.5), $MachinePrecision] - M), $MachinePrecision] * N[(N[(M - N[(n * 0.5), $MachinePrecision]), $MachinePrecision] - m), $MachinePrecision]), $MachinePrecision] + t$95$0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(t$95$1 * N[Cos[M], $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
[K, m, n, M, l] = \mathsf{sort}([K, m, n, M, l])\\
\\
\begin{array}{l}
t_0 := \left|n - m\right| - \ell\\
t_1 := e^{t_0 - {\left(\frac{m + n}{2} - M\right)}^{2}}\\
\mathbf{if}\;\cos \left(\frac{K \cdot \left(m + n\right)}{2} - M\right) \cdot t_1 \leq -0.5:\\
\;\;\;\;\cos \left(\frac{K}{-2 \cdot \frac{m}{{n}^{2}} + 2 \cdot \frac{1}{n}} - M\right) \cdot e^{\left(n \cdot 0.5 - M\right) \cdot \left(\left(M - n \cdot 0.5\right) - m\right) + t_0}\\
\mathbf{else}:\\
\;\;\;\;t_1 \cdot \cos M\\
\end{array}
\end{array}
if (*.f64 (cos.f64 (-.f64 (/.f64 (*.f64 K (+.f64 m n)) 2) M)) (exp.f64 (-.f64 (neg.f64 (pow.f64 (-.f64 (/.f64 (+.f64 m n) 2) M) 2)) (-.f64 l (fabs.f64 (-.f64 m n)))))) < -0.5Initial program 53.9%
associate-/l*60.1%
+-commutative60.1%
fabs-sub60.1%
+-commutative60.1%
Simplified60.1%
Taylor expanded in m around 0 38.4%
Taylor expanded in m around 0 38.4%
+-commutative9.7%
unpow29.7%
distribute-rgt-out9.7%
*-commutative9.7%
*-commutative9.7%
Simplified38.4%
if -0.5 < (*.f64 (cos.f64 (-.f64 (/.f64 (*.f64 K (+.f64 m n)) 2) M)) (exp.f64 (-.f64 (neg.f64 (pow.f64 (-.f64 (/.f64 (+.f64 m n) 2) M) 2)) (-.f64 l (fabs.f64 (-.f64 m n)))))) Initial program 78.1%
associate-/l*78.1%
+-commutative78.1%
fabs-sub78.1%
+-commutative78.1%
Simplified78.1%
Taylor expanded in K around 0 97.6%
cos-neg97.6%
Simplified97.6%
Final simplification95.1%
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
(let* ((t_0 (- (fabs (- n m)) l))
(t_1 (exp (- t_0 (pow (- (/ (+ m n) 2.0) M) 2.0)))))
(if (<= (* (cos (- (/ (* K (+ m n)) 2.0) M)) t_1) -0.5)
(*
(cos (* 0.5 (* K n)))
(exp (+ (* (- (* m 0.5) M) (- (- M (* m 0.5)) n)) t_0)))
(* t_1 (cos M)))))assert(K < m && m < n && n < M && M < l);
double code(double K, double m, double n, double M, double l) {
double t_0 = fabs((n - m)) - l;
double t_1 = exp((t_0 - pow((((m + n) / 2.0) - M), 2.0)));
double tmp;
if ((cos((((K * (m + n)) / 2.0) - M)) * t_1) <= -0.5) {
tmp = cos((0.5 * (K * n))) * exp(((((m * 0.5) - M) * ((M - (m * 0.5)) - n)) + t_0));
} else {
tmp = t_1 * cos(M);
}
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) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = abs((n - m)) - l
t_1 = exp((t_0 - ((((m + n) / 2.0d0) - m_1) ** 2.0d0)))
if ((cos((((k * (m + n)) / 2.0d0) - m_1)) * t_1) <= (-0.5d0)) then
tmp = cos((0.5d0 * (k * n))) * exp(((((m * 0.5d0) - m_1) * ((m_1 - (m * 0.5d0)) - n)) + t_0))
else
tmp = t_1 * cos(m_1)
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 t_0 = Math.abs((n - m)) - l;
double t_1 = Math.exp((t_0 - Math.pow((((m + n) / 2.0) - M), 2.0)));
double tmp;
if ((Math.cos((((K * (m + n)) / 2.0) - M)) * t_1) <= -0.5) {
tmp = Math.cos((0.5 * (K * n))) * Math.exp(((((m * 0.5) - M) * ((M - (m * 0.5)) - n)) + t_0));
} else {
tmp = t_1 * Math.cos(M);
}
return tmp;
}
[K, m, n, M, l] = sort([K, m, n, M, l]) def code(K, m, n, M, l): t_0 = math.fabs((n - m)) - l t_1 = math.exp((t_0 - math.pow((((m + n) / 2.0) - M), 2.0))) tmp = 0 if (math.cos((((K * (m + n)) / 2.0) - M)) * t_1) <= -0.5: tmp = math.cos((0.5 * (K * n))) * math.exp(((((m * 0.5) - M) * ((M - (m * 0.5)) - n)) + t_0)) else: tmp = t_1 * math.cos(M) return tmp
K, m, n, M, l = sort([K, m, n, M, l]) function code(K, m, n, M, l) t_0 = Float64(abs(Float64(n - m)) - l) t_1 = exp(Float64(t_0 - (Float64(Float64(Float64(m + n) / 2.0) - M) ^ 2.0))) tmp = 0.0 if (Float64(cos(Float64(Float64(Float64(K * Float64(m + n)) / 2.0) - M)) * t_1) <= -0.5) tmp = Float64(cos(Float64(0.5 * Float64(K * n))) * exp(Float64(Float64(Float64(Float64(m * 0.5) - M) * Float64(Float64(M - Float64(m * 0.5)) - n)) + t_0))); else tmp = Float64(t_1 * cos(M)); 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)
t_0 = abs((n - m)) - l;
t_1 = exp((t_0 - ((((m + n) / 2.0) - M) ^ 2.0)));
tmp = 0.0;
if ((cos((((K * (m + n)) / 2.0) - M)) * t_1) <= -0.5)
tmp = cos((0.5 * (K * n))) * exp(((((m * 0.5) - M) * ((M - (m * 0.5)) - n)) + t_0));
else
tmp = t_1 * cos(M);
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_] := Block[{t$95$0 = N[(N[Abs[N[(n - m), $MachinePrecision]], $MachinePrecision] - l), $MachinePrecision]}, Block[{t$95$1 = N[Exp[N[(t$95$0 - N[Power[N[(N[(N[(m + n), $MachinePrecision] / 2.0), $MachinePrecision] - M), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[N[(N[Cos[N[(N[(N[(K * N[(m + n), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision] - M), $MachinePrecision]], $MachinePrecision] * t$95$1), $MachinePrecision], -0.5], N[(N[Cos[N[(0.5 * N[(K * n), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * N[Exp[N[(N[(N[(N[(m * 0.5), $MachinePrecision] - M), $MachinePrecision] * N[(N[(M - N[(m * 0.5), $MachinePrecision]), $MachinePrecision] - n), $MachinePrecision]), $MachinePrecision] + t$95$0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(t$95$1 * N[Cos[M], $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
[K, m, n, M, l] = \mathsf{sort}([K, m, n, M, l])\\
\\
\begin{array}{l}
t_0 := \left|n - m\right| - \ell\\
t_1 := e^{t_0 - {\left(\frac{m + n}{2} - M\right)}^{2}}\\
\mathbf{if}\;\cos \left(\frac{K \cdot \left(m + n\right)}{2} - M\right) \cdot t_1 \leq -0.5:\\
\;\;\;\;\cos \left(0.5 \cdot \left(K \cdot n\right)\right) \cdot e^{\left(m \cdot 0.5 - M\right) \cdot \left(\left(M - m \cdot 0.5\right) - n\right) + t_0}\\
\mathbf{else}:\\
\;\;\;\;t_1 \cdot \cos M\\
\end{array}
\end{array}
if (*.f64 (cos.f64 (-.f64 (/.f64 (*.f64 K (+.f64 m n)) 2) M)) (exp.f64 (-.f64 (neg.f64 (pow.f64 (-.f64 (/.f64 (+.f64 m n) 2) M) 2)) (-.f64 l (fabs.f64 (-.f64 m n)))))) < -0.5Initial program 53.9%
associate-/l*60.1%
+-commutative60.1%
fabs-sub60.1%
+-commutative60.1%
Simplified60.1%
Taylor expanded in n around 0 60.1%
+-commutative9.7%
unpow29.7%
distribute-rgt-out9.7%
*-commutative9.7%
*-commutative9.7%
Simplified60.1%
Taylor expanded in n around inf 47.5%
*-commutative47.5%
Simplified47.5%
if -0.5 < (*.f64 (cos.f64 (-.f64 (/.f64 (*.f64 K (+.f64 m n)) 2) M)) (exp.f64 (-.f64 (neg.f64 (pow.f64 (-.f64 (/.f64 (+.f64 m n) 2) M) 2)) (-.f64 l (fabs.f64 (-.f64 m n)))))) Initial program 78.1%
associate-/l*78.1%
+-commutative78.1%
fabs-sub78.1%
+-commutative78.1%
Simplified78.1%
Taylor expanded in K around 0 97.6%
cos-neg97.6%
Simplified97.6%
Final simplification95.5%
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
(let* ((t_0 (- (fabs (- n m)) l))
(t_1 (* (cos M) (exp (- t_0 (* 0.5 (* m (+ n (* m 0.5)))))))))
(if (<= m -1e+49)
t_1
(if (<= m -1.2e-307)
(* (cos M) (exp (- t_0 (* M (+ (+ m n) M)))))
(if (<= m 4.2e+17)
(* (cos (* (+ m n) (* K 0.5))) (exp (+ (* M (- n M)) t_0)))
t_1)))))assert(K < m && m < n && n < M && M < l);
double code(double K, double m, double n, double M, double l) {
double t_0 = fabs((n - m)) - l;
double t_1 = cos(M) * exp((t_0 - (0.5 * (m * (n + (m * 0.5))))));
double tmp;
if (m <= -1e+49) {
tmp = t_1;
} else if (m <= -1.2e-307) {
tmp = cos(M) * exp((t_0 - (M * ((m + n) + M))));
} else if (m <= 4.2e+17) {
tmp = cos(((m + n) * (K * 0.5))) * exp(((M * (n - M)) + t_0));
} else {
tmp = t_1;
}
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) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = abs((n - m)) - l
t_1 = cos(m_1) * exp((t_0 - (0.5d0 * (m * (n + (m * 0.5d0))))))
if (m <= (-1d+49)) then
tmp = t_1
else if (m <= (-1.2d-307)) then
tmp = cos(m_1) * exp((t_0 - (m_1 * ((m + n) + m_1))))
else if (m <= 4.2d+17) then
tmp = cos(((m + n) * (k * 0.5d0))) * exp(((m_1 * (n - m_1)) + t_0))
else
tmp = t_1
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 t_0 = Math.abs((n - m)) - l;
double t_1 = Math.cos(M) * Math.exp((t_0 - (0.5 * (m * (n + (m * 0.5))))));
double tmp;
if (m <= -1e+49) {
tmp = t_1;
} else if (m <= -1.2e-307) {
tmp = Math.cos(M) * Math.exp((t_0 - (M * ((m + n) + M))));
} else if (m <= 4.2e+17) {
tmp = Math.cos(((m + n) * (K * 0.5))) * Math.exp(((M * (n - M)) + t_0));
} else {
tmp = t_1;
}
return tmp;
}
[K, m, n, M, l] = sort([K, m, n, M, l]) def code(K, m, n, M, l): t_0 = math.fabs((n - m)) - l t_1 = math.cos(M) * math.exp((t_0 - (0.5 * (m * (n + (m * 0.5)))))) tmp = 0 if m <= -1e+49: tmp = t_1 elif m <= -1.2e-307: tmp = math.cos(M) * math.exp((t_0 - (M * ((m + n) + M)))) elif m <= 4.2e+17: tmp = math.cos(((m + n) * (K * 0.5))) * math.exp(((M * (n - M)) + t_0)) else: tmp = t_1 return tmp
K, m, n, M, l = sort([K, m, n, M, l]) function code(K, m, n, M, l) t_0 = Float64(abs(Float64(n - m)) - l) t_1 = Float64(cos(M) * exp(Float64(t_0 - Float64(0.5 * Float64(m * Float64(n + Float64(m * 0.5))))))) tmp = 0.0 if (m <= -1e+49) tmp = t_1; elseif (m <= -1.2e-307) tmp = Float64(cos(M) * exp(Float64(t_0 - Float64(M * Float64(Float64(m + n) + M))))); elseif (m <= 4.2e+17) tmp = Float64(cos(Float64(Float64(m + n) * Float64(K * 0.5))) * exp(Float64(Float64(M * Float64(n - M)) + t_0))); else tmp = t_1; 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)
t_0 = abs((n - m)) - l;
t_1 = cos(M) * exp((t_0 - (0.5 * (m * (n + (m * 0.5))))));
tmp = 0.0;
if (m <= -1e+49)
tmp = t_1;
elseif (m <= -1.2e-307)
tmp = cos(M) * exp((t_0 - (M * ((m + n) + M))));
elseif (m <= 4.2e+17)
tmp = cos(((m + n) * (K * 0.5))) * exp(((M * (n - M)) + t_0));
else
tmp = t_1;
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_] := Block[{t$95$0 = N[(N[Abs[N[(n - m), $MachinePrecision]], $MachinePrecision] - l), $MachinePrecision]}, Block[{t$95$1 = N[(N[Cos[M], $MachinePrecision] * N[Exp[N[(t$95$0 - N[(0.5 * N[(m * N[(n + N[(m * 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[m, -1e+49], t$95$1, If[LessEqual[m, -1.2e-307], N[(N[Cos[M], $MachinePrecision] * N[Exp[N[(t$95$0 - N[(M * N[(N[(m + n), $MachinePrecision] + M), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[m, 4.2e+17], N[(N[Cos[N[(N[(m + n), $MachinePrecision] * N[(K * 0.5), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * N[Exp[N[(N[(M * N[(n - M), $MachinePrecision]), $MachinePrecision] + t$95$0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], t$95$1]]]]]
\begin{array}{l}
[K, m, n, M, l] = \mathsf{sort}([K, m, n, M, l])\\
\\
\begin{array}{l}
t_0 := \left|n - m\right| - \ell\\
t_1 := \cos M \cdot e^{t_0 - 0.5 \cdot \left(m \cdot \left(n + m \cdot 0.5\right)\right)}\\
\mathbf{if}\;m \leq -1 \cdot 10^{+49}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;m \leq -1.2 \cdot 10^{-307}:\\
\;\;\;\;\cos M \cdot e^{t_0 - M \cdot \left(\left(m + n\right) + M\right)}\\
\mathbf{elif}\;m \leq 4.2 \cdot 10^{+17}:\\
\;\;\;\;\cos \left(\left(m + n\right) \cdot \left(K \cdot 0.5\right)\right) \cdot e^{M \cdot \left(n - M\right) + t_0}\\
\mathbf{else}:\\
\;\;\;\;t_1\\
\end{array}
\end{array}
if m < -9.99999999999999946e48 or 4.2e17 < m Initial program 69.2%
associate-/l*70.1%
+-commutative70.1%
fabs-sub70.1%
+-commutative70.1%
Simplified70.1%
Taylor expanded in K around 0 98.1%
cos-neg98.1%
Simplified98.1%
Taylor expanded in n around 0 77.7%
+-commutative77.7%
unpow277.7%
distribute-rgt-out84.3%
*-commutative84.3%
*-commutative84.3%
Simplified84.3%
Taylor expanded in M around 0 84.3%
if -9.99999999999999946e48 < m < -1.20000000000000009e-307Initial program 84.7%
associate-/l*84.7%
+-commutative84.7%
fabs-sub84.7%
+-commutative84.7%
Simplified84.7%
Taylor expanded in K around 0 94.2%
cos-neg94.2%
Simplified94.2%
log1p-expm1-u93.0%
div-inv93.0%
metadata-eval93.0%
fma-neg93.0%
Applied egg-rr93.0%
log1p-expm1-u94.2%
add-sqr-sqrt43.9%
sqrt-prod94.2%
unpow294.2%
add-log-exp93.0%
unpow293.0%
sqrt-prod43.9%
add-sqr-sqrt93.0%
add-sqr-sqrt41.5%
sqrt-unprod93.0%
sqr-neg93.0%
sqrt-unprod51.5%
add-sqr-sqrt93.0%
Applied egg-rr93.0%
Taylor expanded in M around inf 64.1%
unpow264.1%
distribute-lft-out65.3%
+-commutative65.3%
Simplified65.3%
if -1.20000000000000009e-307 < m < 4.2e17Initial program 80.2%
associate-/l*79.7%
+-commutative79.7%
fabs-sub79.7%
+-commutative79.7%
Simplified79.7%
Taylor expanded in n around 0 59.2%
+-commutative55.7%
unpow255.7%
distribute-rgt-out55.8%
*-commutative55.8%
*-commutative55.8%
Simplified59.2%
frac-2neg59.2%
div-inv59.2%
distribute-neg-frac59.2%
metadata-eval59.2%
Applied egg-rr59.2%
Taylor expanded in m around 0 56.3%
mul-1-neg52.8%
*-commutative52.8%
distribute-rgt-neg-in52.8%
Simplified56.3%
Taylor expanded in M around 0 56.7%
associate-*r*56.7%
*-commutative56.7%
+-commutative56.7%
Simplified56.7%
Final simplification71.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
(let* ((t_0 (- (fabs (- n m)) l))
(t_1 (* (cos M) (exp (+ (* M (- n M)) t_0)))))
(if (<= M -1.22e+32)
t_1
(if (<= M 4e-23)
(* (cos M) (exp (+ (* n (- M (* m 0.5))) t_0)))
(if (<= M 4.8e+136)
(* (cos M) (exp (- t_0 (* M (+ (+ m n) M)))))
t_1)))))assert(K < m && m < n && n < M && M < l);
double code(double K, double m, double n, double M, double l) {
double t_0 = fabs((n - m)) - l;
double t_1 = cos(M) * exp(((M * (n - M)) + t_0));
double tmp;
if (M <= -1.22e+32) {
tmp = t_1;
} else if (M <= 4e-23) {
tmp = cos(M) * exp(((n * (M - (m * 0.5))) + t_0));
} else if (M <= 4.8e+136) {
tmp = cos(M) * exp((t_0 - (M * ((m + n) + M))));
} else {
tmp = t_1;
}
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) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = abs((n - m)) - l
t_1 = cos(m_1) * exp(((m_1 * (n - m_1)) + t_0))
if (m_1 <= (-1.22d+32)) then
tmp = t_1
else if (m_1 <= 4d-23) then
tmp = cos(m_1) * exp(((n * (m_1 - (m * 0.5d0))) + t_0))
else if (m_1 <= 4.8d+136) then
tmp = cos(m_1) * exp((t_0 - (m_1 * ((m + n) + m_1))))
else
tmp = t_1
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 t_0 = Math.abs((n - m)) - l;
double t_1 = Math.cos(M) * Math.exp(((M * (n - M)) + t_0));
double tmp;
if (M <= -1.22e+32) {
tmp = t_1;
} else if (M <= 4e-23) {
tmp = Math.cos(M) * Math.exp(((n * (M - (m * 0.5))) + t_0));
} else if (M <= 4.8e+136) {
tmp = Math.cos(M) * Math.exp((t_0 - (M * ((m + n) + M))));
} else {
tmp = t_1;
}
return tmp;
}
[K, m, n, M, l] = sort([K, m, n, M, l]) def code(K, m, n, M, l): t_0 = math.fabs((n - m)) - l t_1 = math.cos(M) * math.exp(((M * (n - M)) + t_0)) tmp = 0 if M <= -1.22e+32: tmp = t_1 elif M <= 4e-23: tmp = math.cos(M) * math.exp(((n * (M - (m * 0.5))) + t_0)) elif M <= 4.8e+136: tmp = math.cos(M) * math.exp((t_0 - (M * ((m + n) + M)))) else: tmp = t_1 return tmp
K, m, n, M, l = sort([K, m, n, M, l]) function code(K, m, n, M, l) t_0 = Float64(abs(Float64(n - m)) - l) t_1 = Float64(cos(M) * exp(Float64(Float64(M * Float64(n - M)) + t_0))) tmp = 0.0 if (M <= -1.22e+32) tmp = t_1; elseif (M <= 4e-23) tmp = Float64(cos(M) * exp(Float64(Float64(n * Float64(M - Float64(m * 0.5))) + t_0))); elseif (M <= 4.8e+136) tmp = Float64(cos(M) * exp(Float64(t_0 - Float64(M * Float64(Float64(m + n) + M))))); else tmp = t_1; 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)
t_0 = abs((n - m)) - l;
t_1 = cos(M) * exp(((M * (n - M)) + t_0));
tmp = 0.0;
if (M <= -1.22e+32)
tmp = t_1;
elseif (M <= 4e-23)
tmp = cos(M) * exp(((n * (M - (m * 0.5))) + t_0));
elseif (M <= 4.8e+136)
tmp = cos(M) * exp((t_0 - (M * ((m + n) + M))));
else
tmp = t_1;
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_] := Block[{t$95$0 = N[(N[Abs[N[(n - m), $MachinePrecision]], $MachinePrecision] - l), $MachinePrecision]}, Block[{t$95$1 = N[(N[Cos[M], $MachinePrecision] * N[Exp[N[(N[(M * N[(n - M), $MachinePrecision]), $MachinePrecision] + t$95$0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[M, -1.22e+32], t$95$1, If[LessEqual[M, 4e-23], N[(N[Cos[M], $MachinePrecision] * N[Exp[N[(N[(n * N[(M - N[(m * 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + t$95$0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[M, 4.8e+136], N[(N[Cos[M], $MachinePrecision] * N[Exp[N[(t$95$0 - N[(M * N[(N[(m + n), $MachinePrecision] + M), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], t$95$1]]]]]
\begin{array}{l}
[K, m, n, M, l] = \mathsf{sort}([K, m, n, M, l])\\
\\
\begin{array}{l}
t_0 := \left|n - m\right| - \ell\\
t_1 := \cos M \cdot e^{M \cdot \left(n - M\right) + t_0}\\
\mathbf{if}\;M \leq -1.22 \cdot 10^{+32}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;M \leq 4 \cdot 10^{-23}:\\
\;\;\;\;\cos M \cdot e^{n \cdot \left(M - m \cdot 0.5\right) + t_0}\\
\mathbf{elif}\;M \leq 4.8 \cdot 10^{+136}:\\
\;\;\;\;\cos M \cdot e^{t_0 - M \cdot \left(\left(m + n\right) + M\right)}\\
\mathbf{else}:\\
\;\;\;\;t_1\\
\end{array}
\end{array}
if M < -1.22000000000000002e32 or 4.8000000000000001e136 < M Initial program 76.5%
associate-/l*76.5%
+-commutative76.5%
fabs-sub76.5%
+-commutative76.5%
Simplified76.5%
Taylor expanded in K around 0 98.8%
cos-neg98.8%
Simplified98.8%
Taylor expanded in n around 0 78.9%
+-commutative78.9%
unpow278.9%
distribute-rgt-out84.9%
*-commutative84.9%
*-commutative84.9%
Simplified84.9%
Taylor expanded in m around 0 80.3%
mul-1-neg80.3%
*-commutative80.3%
distribute-rgt-neg-in80.3%
Simplified80.3%
if -1.22000000000000002e32 < M < 3.99999999999999984e-23Initial program 75.8%
associate-/l*76.3%
+-commutative76.3%
fabs-sub76.3%
+-commutative76.3%
Simplified76.3%
Taylor expanded in K around 0 89.8%
cos-neg89.8%
Simplified89.8%
Taylor expanded in n around 0 58.2%
+-commutative58.2%
unpow258.2%
distribute-rgt-out61.1%
*-commutative61.1%
*-commutative61.1%
Simplified61.1%
Taylor expanded in n around inf 39.2%
if 3.99999999999999984e-23 < M < 4.8000000000000001e136Initial program 85.2%
associate-/l*85.2%
+-commutative85.2%
fabs-sub85.2%
+-commutative85.2%
Simplified85.2%
Taylor expanded in K around 0 100.0%
cos-neg100.0%
Simplified100.0%
log1p-expm1-u96.4%
div-inv96.4%
metadata-eval96.4%
fma-neg96.4%
Applied egg-rr96.4%
log1p-expm1-u100.0%
add-sqr-sqrt37.0%
sqrt-prod100.0%
unpow2100.0%
add-log-exp96.4%
unpow296.4%
sqrt-prod37.0%
add-sqr-sqrt96.4%
add-sqr-sqrt0.0%
sqrt-unprod96.4%
sqr-neg96.4%
sqrt-unprod96.4%
add-sqr-sqrt96.4%
Applied egg-rr96.4%
Taylor expanded in M around inf 81.8%
unpow281.8%
distribute-lft-out81.8%
+-commutative81.8%
Simplified81.8%
Final simplification57.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
(let* ((t_0 (- (fabs (- n m)) l)))
(if (or (<= m -1e+49) (not (<= m 4.2e+17)))
(* (cos M) (exp (- t_0 (* 0.5 (* m (+ n (* m 0.5)))))))
(* (cos M) (exp (- t_0 (* M (+ (+ m n) M))))))))assert(K < m && m < n && n < M && M < l);
double code(double K, double m, double n, double M, double l) {
double t_0 = fabs((n - m)) - l;
double tmp;
if ((m <= -1e+49) || !(m <= 4.2e+17)) {
tmp = cos(M) * exp((t_0 - (0.5 * (m * (n + (m * 0.5))))));
} else {
tmp = cos(M) * exp((t_0 - (M * ((m + n) + M))));
}
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) :: t_0
real(8) :: tmp
t_0 = abs((n - m)) - l
if ((m <= (-1d+49)) .or. (.not. (m <= 4.2d+17))) then
tmp = cos(m_1) * exp((t_0 - (0.5d0 * (m * (n + (m * 0.5d0))))))
else
tmp = cos(m_1) * exp((t_0 - (m_1 * ((m + n) + m_1))))
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 t_0 = Math.abs((n - m)) - l;
double tmp;
if ((m <= -1e+49) || !(m <= 4.2e+17)) {
tmp = Math.cos(M) * Math.exp((t_0 - (0.5 * (m * (n + (m * 0.5))))));
} else {
tmp = Math.cos(M) * Math.exp((t_0 - (M * ((m + n) + M))));
}
return tmp;
}
[K, m, n, M, l] = sort([K, m, n, M, l]) def code(K, m, n, M, l): t_0 = math.fabs((n - m)) - l tmp = 0 if (m <= -1e+49) or not (m <= 4.2e+17): tmp = math.cos(M) * math.exp((t_0 - (0.5 * (m * (n + (m * 0.5)))))) else: tmp = math.cos(M) * math.exp((t_0 - (M * ((m + n) + M)))) return tmp
K, m, n, M, l = sort([K, m, n, M, l]) function code(K, m, n, M, l) t_0 = Float64(abs(Float64(n - m)) - l) tmp = 0.0 if ((m <= -1e+49) || !(m <= 4.2e+17)) tmp = Float64(cos(M) * exp(Float64(t_0 - Float64(0.5 * Float64(m * Float64(n + Float64(m * 0.5))))))); else tmp = Float64(cos(M) * exp(Float64(t_0 - Float64(M * Float64(Float64(m + n) + M))))); 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)
t_0 = abs((n - m)) - l;
tmp = 0.0;
if ((m <= -1e+49) || ~((m <= 4.2e+17)))
tmp = cos(M) * exp((t_0 - (0.5 * (m * (n + (m * 0.5))))));
else
tmp = cos(M) * exp((t_0 - (M * ((m + n) + M))));
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_] := Block[{t$95$0 = N[(N[Abs[N[(n - m), $MachinePrecision]], $MachinePrecision] - l), $MachinePrecision]}, If[Or[LessEqual[m, -1e+49], N[Not[LessEqual[m, 4.2e+17]], $MachinePrecision]], N[(N[Cos[M], $MachinePrecision] * N[Exp[N[(t$95$0 - N[(0.5 * N[(m * N[(n + N[(m * 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(N[Cos[M], $MachinePrecision] * N[Exp[N[(t$95$0 - N[(M * N[(N[(m + n), $MachinePrecision] + M), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
[K, m, n, M, l] = \mathsf{sort}([K, m, n, M, l])\\
\\
\begin{array}{l}
t_0 := \left|n - m\right| - \ell\\
\mathbf{if}\;m \leq -1 \cdot 10^{+49} \lor \neg \left(m \leq 4.2 \cdot 10^{+17}\right):\\
\;\;\;\;\cos M \cdot e^{t_0 - 0.5 \cdot \left(m \cdot \left(n + m \cdot 0.5\right)\right)}\\
\mathbf{else}:\\
\;\;\;\;\cos M \cdot e^{t_0 - M \cdot \left(\left(m + n\right) + M\right)}\\
\end{array}
\end{array}
if m < -9.99999999999999946e48 or 4.2e17 < m Initial program 69.2%
associate-/l*70.1%
+-commutative70.1%
fabs-sub70.1%
+-commutative70.1%
Simplified70.1%
Taylor expanded in K around 0 98.1%
cos-neg98.1%
Simplified98.1%
Taylor expanded in n around 0 77.7%
+-commutative77.7%
unpow277.7%
distribute-rgt-out84.3%
*-commutative84.3%
*-commutative84.3%
Simplified84.3%
Taylor expanded in M around 0 84.3%
if -9.99999999999999946e48 < m < 4.2e17Initial program 82.7%
associate-/l*82.5%
+-commutative82.5%
fabs-sub82.5%
+-commutative82.5%
Simplified82.5%
Taylor expanded in K around 0 90.8%
cos-neg90.8%
Simplified90.8%
log1p-expm1-u88.9%
div-inv88.9%
metadata-eval88.9%
fma-neg88.9%
Applied egg-rr88.9%
log1p-expm1-u90.8%
add-sqr-sqrt41.6%
sqrt-prod90.8%
unpow290.8%
add-log-exp88.9%
unpow288.9%
sqrt-prod41.7%
add-sqr-sqrt88.9%
add-sqr-sqrt40.3%
sqrt-unprod88.9%
sqr-neg88.9%
sqrt-unprod48.5%
add-sqr-sqrt88.9%
Applied egg-rr88.9%
Taylor expanded in M around inf 61.0%
unpow261.0%
distribute-lft-out63.0%
+-commutative63.0%
Simplified63.0%
Final simplification71.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
(let* ((t_0 (- (fabs (- n m)) l)))
(if (<= m -6.5e+43)
(* (cos M) (exp (+ (* (- (* m 0.5) M) (- (- M (* m 0.5)) n)) t_0)))
(* (cos M) (exp (+ (* (- (* n 0.5) M) (- (- M (* n 0.5)) m)) t_0))))))assert(K < m && m < n && n < M && M < l);
double code(double K, double m, double n, double M, double l) {
double t_0 = fabs((n - m)) - l;
double tmp;
if (m <= -6.5e+43) {
tmp = cos(M) * exp(((((m * 0.5) - M) * ((M - (m * 0.5)) - n)) + t_0));
} else {
tmp = cos(M) * exp(((((n * 0.5) - M) * ((M - (n * 0.5)) - m)) + t_0));
}
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) :: t_0
real(8) :: tmp
t_0 = abs((n - m)) - l
if (m <= (-6.5d+43)) then
tmp = cos(m_1) * exp(((((m * 0.5d0) - m_1) * ((m_1 - (m * 0.5d0)) - n)) + t_0))
else
tmp = cos(m_1) * exp(((((n * 0.5d0) - m_1) * ((m_1 - (n * 0.5d0)) - m)) + t_0))
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 t_0 = Math.abs((n - m)) - l;
double tmp;
if (m <= -6.5e+43) {
tmp = Math.cos(M) * Math.exp(((((m * 0.5) - M) * ((M - (m * 0.5)) - n)) + t_0));
} else {
tmp = Math.cos(M) * Math.exp(((((n * 0.5) - M) * ((M - (n * 0.5)) - m)) + t_0));
}
return tmp;
}
[K, m, n, M, l] = sort([K, m, n, M, l]) def code(K, m, n, M, l): t_0 = math.fabs((n - m)) - l tmp = 0 if m <= -6.5e+43: tmp = math.cos(M) * math.exp(((((m * 0.5) - M) * ((M - (m * 0.5)) - n)) + t_0)) else: tmp = math.cos(M) * math.exp(((((n * 0.5) - M) * ((M - (n * 0.5)) - m)) + t_0)) return tmp
K, m, n, M, l = sort([K, m, n, M, l]) function code(K, m, n, M, l) t_0 = Float64(abs(Float64(n - m)) - l) tmp = 0.0 if (m <= -6.5e+43) tmp = Float64(cos(M) * exp(Float64(Float64(Float64(Float64(m * 0.5) - M) * Float64(Float64(M - Float64(m * 0.5)) - n)) + t_0))); else tmp = Float64(cos(M) * exp(Float64(Float64(Float64(Float64(n * 0.5) - M) * Float64(Float64(M - Float64(n * 0.5)) - m)) + t_0))); 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)
t_0 = abs((n - m)) - l;
tmp = 0.0;
if (m <= -6.5e+43)
tmp = cos(M) * exp(((((m * 0.5) - M) * ((M - (m * 0.5)) - n)) + t_0));
else
tmp = cos(M) * exp(((((n * 0.5) - M) * ((M - (n * 0.5)) - m)) + t_0));
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_] := Block[{t$95$0 = N[(N[Abs[N[(n - m), $MachinePrecision]], $MachinePrecision] - l), $MachinePrecision]}, If[LessEqual[m, -6.5e+43], N[(N[Cos[M], $MachinePrecision] * N[Exp[N[(N[(N[(N[(m * 0.5), $MachinePrecision] - M), $MachinePrecision] * N[(N[(M - N[(m * 0.5), $MachinePrecision]), $MachinePrecision] - n), $MachinePrecision]), $MachinePrecision] + t$95$0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(N[Cos[M], $MachinePrecision] * N[Exp[N[(N[(N[(N[(n * 0.5), $MachinePrecision] - M), $MachinePrecision] * N[(N[(M - N[(n * 0.5), $MachinePrecision]), $MachinePrecision] - m), $MachinePrecision]), $MachinePrecision] + t$95$0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
[K, m, n, M, l] = \mathsf{sort}([K, m, n, M, l])\\
\\
\begin{array}{l}
t_0 := \left|n - m\right| - \ell\\
\mathbf{if}\;m \leq -6.5 \cdot 10^{+43}:\\
\;\;\;\;\cos M \cdot e^{\left(m \cdot 0.5 - M\right) \cdot \left(\left(M - m \cdot 0.5\right) - n\right) + t_0}\\
\mathbf{else}:\\
\;\;\;\;\cos M \cdot e^{\left(n \cdot 0.5 - M\right) \cdot \left(\left(M - n \cdot 0.5\right) - m\right) + t_0}\\
\end{array}
\end{array}
if m < -6.4999999999999998e43Initial program 71.4%
associate-/l*71.4%
+-commutative71.4%
fabs-sub71.4%
+-commutative71.4%
Simplified71.4%
Taylor expanded in K around 0 100.0%
cos-neg100.0%
Simplified100.0%
Taylor expanded in n around 0 85.8%
+-commutative85.8%
unpow285.8%
distribute-rgt-out94.0%
*-commutative94.0%
*-commutative94.0%
Simplified94.0%
if -6.4999999999999998e43 < m Initial program 78.3%
associate-/l*78.7%
+-commutative78.7%
fabs-sub78.7%
+-commutative78.7%
Simplified78.7%
Taylor expanded in K around 0 92.4%
cos-neg92.4%
Simplified92.4%
Taylor expanded in m around 0 77.1%
+-commutative77.1%
unpow277.1%
distribute-rgt-out82.4%
*-commutative82.4%
*-commutative82.4%
Simplified82.4%
Final simplification84.6%
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 (+ (* (- (* m 0.5) M) (- (- M (* m 0.5)) n)) (- (fabs (- n m)) 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(((((m * 0.5) - M) * ((M - (m * 0.5)) - n)) + (fabs((n - m)) - 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(((((m * 0.5d0) - m_1) * ((m_1 - (m * 0.5d0)) - n)) + (abs((n - m)) - 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(((((m * 0.5) - M) * ((M - (m * 0.5)) - n)) + (Math.abs((n - m)) - 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(((((m * 0.5) - M) * ((M - (m * 0.5)) - n)) + (math.fabs((n - m)) - 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(Float64(m * 0.5) - M) * Float64(Float64(M - Float64(m * 0.5)) - n)) + Float64(abs(Float64(n - m)) - 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(((((m * 0.5) - M) * ((M - (m * 0.5)) - n)) + (abs((n - m)) - 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 * 0.5), $MachinePrecision] - M), $MachinePrecision] * N[(N[(M - N[(m * 0.5), $MachinePrecision]), $MachinePrecision] - n), $MachinePrecision]), $MachinePrecision] + N[(N[Abs[N[(n - m), $MachinePrecision]], $MachinePrecision] - l), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
[K, m, n, M, l] = \mathsf{sort}([K, m, n, M, l])\\
\\
\cos M \cdot e^{\left(m \cdot 0.5 - M\right) \cdot \left(\left(M - m \cdot 0.5\right) - n\right) + \left(\left|n - m\right| - \ell\right)}
\end{array}
Initial program 77.0%
associate-/l*77.3%
+-commutative77.3%
fabs-sub77.3%
+-commutative77.3%
Simplified77.3%
Taylor expanded in K around 0 93.9%
cos-neg93.9%
Simplified93.9%
Taylor expanded in n around 0 66.4%
+-commutative66.4%
unpow266.4%
distribute-rgt-out70.8%
*-commutative70.8%
*-commutative70.8%
Simplified70.8%
Final simplification70.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
(let* ((t_0 (- (fabs (- n m)) l)))
(if (<= l -8e-20)
(* (cos M) (exp (- t_0 (* M (+ (+ m n) M)))))
(* (cos M) (exp (+ (* M (- n M)) t_0))))))assert(K < m && m < n && n < M && M < l);
double code(double K, double m, double n, double M, double l) {
double t_0 = fabs((n - m)) - l;
double tmp;
if (l <= -8e-20) {
tmp = cos(M) * exp((t_0 - (M * ((m + n) + M))));
} else {
tmp = cos(M) * exp(((M * (n - M)) + t_0));
}
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) :: t_0
real(8) :: tmp
t_0 = abs((n - m)) - l
if (l <= (-8d-20)) then
tmp = cos(m_1) * exp((t_0 - (m_1 * ((m + n) + m_1))))
else
tmp = cos(m_1) * exp(((m_1 * (n - m_1)) + t_0))
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 t_0 = Math.abs((n - m)) - l;
double tmp;
if (l <= -8e-20) {
tmp = Math.cos(M) * Math.exp((t_0 - (M * ((m + n) + M))));
} else {
tmp = Math.cos(M) * Math.exp(((M * (n - M)) + t_0));
}
return tmp;
}
[K, m, n, M, l] = sort([K, m, n, M, l]) def code(K, m, n, M, l): t_0 = math.fabs((n - m)) - l tmp = 0 if l <= -8e-20: tmp = math.cos(M) * math.exp((t_0 - (M * ((m + n) + M)))) else: tmp = math.cos(M) * math.exp(((M * (n - M)) + t_0)) return tmp
K, m, n, M, l = sort([K, m, n, M, l]) function code(K, m, n, M, l) t_0 = Float64(abs(Float64(n - m)) - l) tmp = 0.0 if (l <= -8e-20) tmp = Float64(cos(M) * exp(Float64(t_0 - Float64(M * Float64(Float64(m + n) + M))))); else tmp = Float64(cos(M) * exp(Float64(Float64(M * Float64(n - M)) + t_0))); 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)
t_0 = abs((n - m)) - l;
tmp = 0.0;
if (l <= -8e-20)
tmp = cos(M) * exp((t_0 - (M * ((m + n) + M))));
else
tmp = cos(M) * exp(((M * (n - M)) + t_0));
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_] := Block[{t$95$0 = N[(N[Abs[N[(n - m), $MachinePrecision]], $MachinePrecision] - l), $MachinePrecision]}, If[LessEqual[l, -8e-20], N[(N[Cos[M], $MachinePrecision] * N[Exp[N[(t$95$0 - N[(M * N[(N[(m + n), $MachinePrecision] + M), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(N[Cos[M], $MachinePrecision] * N[Exp[N[(N[(M * N[(n - M), $MachinePrecision]), $MachinePrecision] + t$95$0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
[K, m, n, M, l] = \mathsf{sort}([K, m, n, M, l])\\
\\
\begin{array}{l}
t_0 := \left|n - m\right| - \ell\\
\mathbf{if}\;\ell \leq -8 \cdot 10^{-20}:\\
\;\;\;\;\cos M \cdot e^{t_0 - M \cdot \left(\left(m + n\right) + M\right)}\\
\mathbf{else}:\\
\;\;\;\;\cos M \cdot e^{M \cdot \left(n - M\right) + t_0}\\
\end{array}
\end{array}
if l < -7.99999999999999956e-20Initial program 75.0%
associate-/l*76.6%
+-commutative76.6%
fabs-sub76.6%
+-commutative76.6%
Simplified76.6%
Taylor expanded in K around 0 84.4%
cos-neg84.4%
Simplified84.4%
log1p-expm1-u78.4%
div-inv78.4%
metadata-eval78.4%
fma-neg78.4%
Applied egg-rr78.4%
log1p-expm1-u84.4%
add-sqr-sqrt35.9%
sqrt-prod84.4%
unpow284.4%
add-log-exp78.4%
unpow278.4%
sqrt-prod34.5%
add-sqr-sqrt78.4%
add-sqr-sqrt43.9%
sqrt-unprod78.4%
sqr-neg78.4%
sqrt-unprod34.5%
add-sqr-sqrt78.4%
Applied egg-rr78.4%
Taylor expanded in M around inf 42.8%
unpow242.8%
distribute-lft-out44.4%
+-commutative44.4%
Simplified44.4%
if -7.99999999999999956e-20 < l Initial program 77.7%
associate-/l*77.5%
+-commutative77.5%
fabs-sub77.5%
+-commutative77.5%
Simplified77.5%
Taylor expanded in K around 0 97.0%
cos-neg97.0%
Simplified97.0%
Taylor expanded in n around 0 68.2%
+-commutative68.2%
unpow268.2%
distribute-rgt-out72.9%
*-commutative72.9%
*-commutative72.9%
Simplified72.9%
Taylor expanded in m around 0 55.0%
mul-1-neg55.0%
*-commutative55.0%
distribute-rgt-neg-in55.0%
Simplified55.0%
Final simplification52.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 (* (cos M) (exp (+ (* M (- n M)) (- (fabs (- n m)) 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(((M * (n - M)) + (fabs((n - m)) - 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(((m_1 * (n - m_1)) + (abs((n - m)) - 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(((M * (n - M)) + (Math.abs((n - m)) - 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(((M * (n - M)) + (math.fabs((n - m)) - 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(M * Float64(n - M)) + Float64(abs(Float64(n - m)) - 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(((M * (n - M)) + (abs((n - m)) - 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[(M * N[(n - M), $MachinePrecision]), $MachinePrecision] + N[(N[Abs[N[(n - m), $MachinePrecision]], $MachinePrecision] - l), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
[K, m, n, M, l] = \mathsf{sort}([K, m, n, M, l])\\
\\
\cos M \cdot e^{M \cdot \left(n - M\right) + \left(\left|n - m\right| - \ell\right)}
\end{array}
Initial program 77.0%
associate-/l*77.3%
+-commutative77.3%
fabs-sub77.3%
+-commutative77.3%
Simplified77.3%
Taylor expanded in K around 0 93.9%
cos-neg93.9%
Simplified93.9%
Taylor expanded in n around 0 66.4%
+-commutative66.4%
unpow266.4%
distribute-rgt-out70.8%
*-commutative70.8%
*-commutative70.8%
Simplified70.8%
Taylor expanded in m around 0 50.4%
mul-1-neg50.4%
*-commutative50.4%
distribute-rgt-neg-in50.4%
Simplified50.4%
Final simplification50.4%
herbie shell --seed 2024014
(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)))))))