
(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 13 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 (- m n)))
(t_1 (exp (- (- t_0 l) (pow (- (/ (+ m n) 2.0) M) 2.0))))
(t_2 (* (+ m n) 0.5)))
(if (<= (* (cos (- (/ (* K (+ m n)) 2.0) M)) t_1) INFINITY)
(* t_1 (cos (- (/ 1.0 (/ (/ 2.0 n) K)) M)))
(* (cos M) (exp (+ t_0 (* (- t_2 M) (- M t_2))))))))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((m - n));
double t_1 = exp(((t_0 - l) - pow((((m + n) / 2.0) - M), 2.0)));
double t_2 = (m + n) * 0.5;
double tmp;
if ((cos((((K * (m + n)) / 2.0) - M)) * t_1) <= ((double) INFINITY)) {
tmp = t_1 * cos(((1.0 / ((2.0 / n) / K)) - M));
} else {
tmp = cos(M) * exp((t_0 + ((t_2 - M) * (M - t_2))));
}
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.abs((m - n));
double t_1 = Math.exp(((t_0 - l) - Math.pow((((m + n) / 2.0) - M), 2.0)));
double t_2 = (m + n) * 0.5;
double tmp;
if ((Math.cos((((K * (m + n)) / 2.0) - M)) * t_1) <= Double.POSITIVE_INFINITY) {
tmp = t_1 * Math.cos(((1.0 / ((2.0 / n) / K)) - M));
} else {
tmp = Math.cos(M) * Math.exp((t_0 + ((t_2 - M) * (M - t_2))));
}
return tmp;
}
[K, m, n, M, l] = sort([K, m, n, M, l]) def code(K, m, n, M, l): t_0 = math.fabs((m - n)) t_1 = math.exp(((t_0 - l) - math.pow((((m + n) / 2.0) - M), 2.0))) t_2 = (m + n) * 0.5 tmp = 0 if (math.cos((((K * (m + n)) / 2.0) - M)) * t_1) <= math.inf: tmp = t_1 * math.cos(((1.0 / ((2.0 / n) / K)) - M)) else: tmp = math.cos(M) * math.exp((t_0 + ((t_2 - M) * (M - t_2)))) return tmp
K, m, n, M, l = sort([K, m, n, M, l]) function code(K, m, n, M, l) t_0 = abs(Float64(m - n)) t_1 = exp(Float64(Float64(t_0 - l) - (Float64(Float64(Float64(m + n) / 2.0) - M) ^ 2.0))) t_2 = Float64(Float64(m + n) * 0.5) tmp = 0.0 if (Float64(cos(Float64(Float64(Float64(K * Float64(m + n)) / 2.0) - M)) * t_1) <= Inf) tmp = Float64(t_1 * cos(Float64(Float64(1.0 / Float64(Float64(2.0 / n) / K)) - M))); else tmp = Float64(cos(M) * exp(Float64(t_0 + Float64(Float64(t_2 - M) * Float64(M - t_2))))); 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((m - n));
t_1 = exp(((t_0 - l) - ((((m + n) / 2.0) - M) ^ 2.0)));
t_2 = (m + n) * 0.5;
tmp = 0.0;
if ((cos((((K * (m + n)) / 2.0) - M)) * t_1) <= Inf)
tmp = t_1 * cos(((1.0 / ((2.0 / n) / K)) - M));
else
tmp = cos(M) * exp((t_0 + ((t_2 - M) * (M - t_2))));
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[Abs[N[(m - n), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[Exp[N[(N[(t$95$0 - l), $MachinePrecision] - N[Power[N[(N[(N[(m + n), $MachinePrecision] / 2.0), $MachinePrecision] - M), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = N[(N[(m + n), $MachinePrecision] * 0.5), $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[(t$95$1 * N[Cos[N[(N[(1.0 / N[(N[(2.0 / n), $MachinePrecision] / K), $MachinePrecision]), $MachinePrecision] - M), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(N[Cos[M], $MachinePrecision] * N[Exp[N[(t$95$0 + N[(N[(t$95$2 - M), $MachinePrecision] * N[(M - t$95$2), $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|m - n\right|\\
t_1 := e^{\left(t\_0 - \ell\right) - {\left(\frac{m + n}{2} - M\right)}^{2}}\\
t_2 := \left(m + n\right) \cdot 0.5\\
\mathbf{if}\;\cos \left(\frac{K \cdot \left(m + n\right)}{2} - M\right) \cdot t\_1 \leq \infty:\\
\;\;\;\;t\_1 \cdot \cos \left(\frac{1}{\frac{\frac{2}{n}}{K}} - M\right)\\
\mathbf{else}:\\
\;\;\;\;\cos M \cdot e^{t\_0 + \left(t\_2 - M\right) \cdot \left(M - t\_2\right)}\\
\end{array}
\end{array}
if (*.f64 (cos.f64 (-.f64 (/.f64 (*.f64 K (+.f64 m n)) #s(literal 2 binary64)) M)) (exp.f64 (-.f64 (neg.f64 (pow.f64 (-.f64 (/.f64 (+.f64 m n) #s(literal 2 binary64)) M) #s(literal 2 binary64))) (-.f64 l (fabs.f64 (-.f64 m n)))))) < +inf.0Initial program 94.0%
Taylor expanded in m around 0 94.9%
clear-num95.4%
inv-pow95.4%
*-commutative95.4%
Applied egg-rr95.4%
unpow-195.4%
associate-/r*95.5%
Simplified95.5%
if +inf.0 < (*.f64 (cos.f64 (-.f64 (/.f64 (*.f64 K (+.f64 m n)) #s(literal 2 binary64)) M)) (exp.f64 (-.f64 (neg.f64 (pow.f64 (-.f64 (/.f64 (+.f64 m n) #s(literal 2 binary64)) M) #s(literal 2 binary64))) (-.f64 l (fabs.f64 (-.f64 m n)))))) Initial program 0.0%
Taylor expanded in K around 0 98.3%
cos-neg98.3%
Simplified98.3%
Taylor expanded in l around 0 98.4%
unpow298.4%
Applied egg-rr98.4%
Final simplification96.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 (* (exp (- (- (fabs (- m n)) l) (pow (- (/ (+ m n) 2.0) M) 2.0))) (cos M)))
assert(K < m && m < n && n < M && M < l);
double code(double K, double m, double n, double M, double l) {
return exp(((fabs((m - n)) - l) - pow((((m + n) / 2.0) - M), 2.0))) * 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 = exp(((abs((m - n)) - l) - ((((m + n) / 2.0d0) - m_1) ** 2.0d0))) * 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.exp(((Math.abs((m - n)) - l) - Math.pow((((m + n) / 2.0) - M), 2.0))) * Math.cos(M);
}
[K, m, n, M, l] = sort([K, m, n, M, l]) def code(K, m, n, M, l): return math.exp(((math.fabs((m - n)) - l) - math.pow((((m + n) / 2.0) - M), 2.0))) * math.cos(M)
K, m, n, M, l = sort([K, m, n, M, l]) function code(K, m, n, M, l) return Float64(exp(Float64(Float64(abs(Float64(m - n)) - l) - (Float64(Float64(Float64(m + n) / 2.0) - M) ^ 2.0))) * cos(M)) end
K, m, n, M, l = num2cell(sort([K, m, n, M, l])){:}
function tmp = code(K, m, n, M, l)
tmp = exp(((abs((m - n)) - l) - ((((m + n) / 2.0) - M) ^ 2.0))) * 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[(N[Exp[N[(N[(N[Abs[N[(m - n), $MachinePrecision]], $MachinePrecision] - l), $MachinePrecision] - N[Power[N[(N[(N[(m + n), $MachinePrecision] / 2.0), $MachinePrecision] - M), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * N[Cos[M], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
[K, m, n, M, l] = \mathsf{sort}([K, m, n, M, l])\\
\\
e^{\left(\left|m - n\right| - \ell\right) - {\left(\frac{m + n}{2} - M\right)}^{2}} \cdot \cos M
\end{array}
Initial program 72.0%
Taylor expanded in K around 0 94.2%
cos-neg94.2%
Simplified94.2%
Final simplification94.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
(let* ((t_0 (cos (- (/ (* K (+ m n)) 2.0) M)))
(t_1 (* (cos M) (exp (- (pow M 2.0)))))
(t_2 (* M (- M n)))
(t_3 (* (cos (- M)) (exp (- t_2 (+ n l))))))
(if (<= M -27.0)
t_1
(if (<= M -7.8e-64)
(* t_0 (exp (+ (- m n) (- t_2 l))))
(if (<= M 3.7e-100)
t_3
(if (<= M 3e-25)
(* t_0 (exp (- (+ m t_2) n)))
(if (<= M 27.0) t_3 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 = cos((((K * (m + n)) / 2.0) - M));
double t_1 = cos(M) * exp(-pow(M, 2.0));
double t_2 = M * (M - n);
double t_3 = cos(-M) * exp((t_2 - (n + l)));
double tmp;
if (M <= -27.0) {
tmp = t_1;
} else if (M <= -7.8e-64) {
tmp = t_0 * exp(((m - n) + (t_2 - l)));
} else if (M <= 3.7e-100) {
tmp = t_3;
} else if (M <= 3e-25) {
tmp = t_0 * exp(((m + t_2) - n));
} else if (M <= 27.0) {
tmp = t_3;
} 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) :: t_2
real(8) :: t_3
real(8) :: tmp
t_0 = cos((((k * (m + n)) / 2.0d0) - m_1))
t_1 = cos(m_1) * exp(-(m_1 ** 2.0d0))
t_2 = m_1 * (m_1 - n)
t_3 = cos(-m_1) * exp((t_2 - (n + l)))
if (m_1 <= (-27.0d0)) then
tmp = t_1
else if (m_1 <= (-7.8d-64)) then
tmp = t_0 * exp(((m - n) + (t_2 - l)))
else if (m_1 <= 3.7d-100) then
tmp = t_3
else if (m_1 <= 3d-25) then
tmp = t_0 * exp(((m + t_2) - n))
else if (m_1 <= 27.0d0) then
tmp = t_3
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.cos((((K * (m + n)) / 2.0) - M));
double t_1 = Math.cos(M) * Math.exp(-Math.pow(M, 2.0));
double t_2 = M * (M - n);
double t_3 = Math.cos(-M) * Math.exp((t_2 - (n + l)));
double tmp;
if (M <= -27.0) {
tmp = t_1;
} else if (M <= -7.8e-64) {
tmp = t_0 * Math.exp(((m - n) + (t_2 - l)));
} else if (M <= 3.7e-100) {
tmp = t_3;
} else if (M <= 3e-25) {
tmp = t_0 * Math.exp(((m + t_2) - n));
} else if (M <= 27.0) {
tmp = t_3;
} 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.cos((((K * (m + n)) / 2.0) - M)) t_1 = math.cos(M) * math.exp(-math.pow(M, 2.0)) t_2 = M * (M - n) t_3 = math.cos(-M) * math.exp((t_2 - (n + l))) tmp = 0 if M <= -27.0: tmp = t_1 elif M <= -7.8e-64: tmp = t_0 * math.exp(((m - n) + (t_2 - l))) elif M <= 3.7e-100: tmp = t_3 elif M <= 3e-25: tmp = t_0 * math.exp(((m + t_2) - n)) elif M <= 27.0: tmp = t_3 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 = cos(Float64(Float64(Float64(K * Float64(m + n)) / 2.0) - M)) t_1 = Float64(cos(M) * exp(Float64(-(M ^ 2.0)))) t_2 = Float64(M * Float64(M - n)) t_3 = Float64(cos(Float64(-M)) * exp(Float64(t_2 - Float64(n + l)))) tmp = 0.0 if (M <= -27.0) tmp = t_1; elseif (M <= -7.8e-64) tmp = Float64(t_0 * exp(Float64(Float64(m - n) + Float64(t_2 - l)))); elseif (M <= 3.7e-100) tmp = t_3; elseif (M <= 3e-25) tmp = Float64(t_0 * exp(Float64(Float64(m + t_2) - n))); elseif (M <= 27.0) tmp = t_3; 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 = cos((((K * (m + n)) / 2.0) - M));
t_1 = cos(M) * exp(-(M ^ 2.0));
t_2 = M * (M - n);
t_3 = cos(-M) * exp((t_2 - (n + l)));
tmp = 0.0;
if (M <= -27.0)
tmp = t_1;
elseif (M <= -7.8e-64)
tmp = t_0 * exp(((m - n) + (t_2 - l)));
elseif (M <= 3.7e-100)
tmp = t_3;
elseif (M <= 3e-25)
tmp = t_0 * exp(((m + t_2) - n));
elseif (M <= 27.0)
tmp = t_3;
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[Cos[N[(N[(N[(K * N[(m + n), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision] - M), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(N[Cos[M], $MachinePrecision] * N[Exp[(-N[Power[M, 2.0], $MachinePrecision])], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(M * N[(M - n), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$3 = N[(N[Cos[(-M)], $MachinePrecision] * N[Exp[N[(t$95$2 - N[(n + l), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[M, -27.0], t$95$1, If[LessEqual[M, -7.8e-64], N[(t$95$0 * N[Exp[N[(N[(m - n), $MachinePrecision] + N[(t$95$2 - l), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[M, 3.7e-100], t$95$3, If[LessEqual[M, 3e-25], N[(t$95$0 * N[Exp[N[(N[(m + t$95$2), $MachinePrecision] - n), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[M, 27.0], t$95$3, t$95$1]]]]]]]]]
\begin{array}{l}
[K, m, n, M, l] = \mathsf{sort}([K, m, n, M, l])\\
\\
\begin{array}{l}
t_0 := \cos \left(\frac{K \cdot \left(m + n\right)}{2} - M\right)\\
t_1 := \cos M \cdot e^{-{M}^{2}}\\
t_2 := M \cdot \left(M - n\right)\\
t_3 := \cos \left(-M\right) \cdot e^{t\_2 - \left(n + \ell\right)}\\
\mathbf{if}\;M \leq -27:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;M \leq -7.8 \cdot 10^{-64}:\\
\;\;\;\;t\_0 \cdot e^{\left(m - n\right) + \left(t\_2 - \ell\right)}\\
\mathbf{elif}\;M \leq 3.7 \cdot 10^{-100}:\\
\;\;\;\;t\_3\\
\mathbf{elif}\;M \leq 3 \cdot 10^{-25}:\\
\;\;\;\;t\_0 \cdot e^{\left(m + t\_2\right) - n}\\
\mathbf{elif}\;M \leq 27:\\
\;\;\;\;t\_3\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if M < -27 or 27 < M Initial program 73.9%
Taylor expanded in K around 0 97.4%
cos-neg97.4%
Simplified97.4%
Taylor expanded in l around 0 94.9%
Taylor expanded in M around inf 94.9%
mul-1-neg94.9%
Simplified94.9%
if -27 < M < -7.7999999999999994e-64Initial program 84.6%
*-un-lft-identity84.6%
*-commutative84.6%
Applied egg-rr31.6%
Taylor expanded in n around 0 31.6%
+-commutative31.6%
unpow231.6%
distribute-rgt-out31.6%
Simplified31.6%
Taylor expanded in m around 0 46.8%
associate-*r*46.8%
neg-mul-146.8%
Simplified46.8%
if -7.7999999999999994e-64 < M < 3.70000000000000018e-100 or 2.9999999999999998e-25 < M < 27Initial program 66.1%
*-un-lft-identity66.1%
*-commutative66.1%
Applied egg-rr32.8%
Taylor expanded in n around 0 35.6%
+-commutative35.6%
unpow235.6%
distribute-rgt-out36.6%
Simplified36.6%
Taylor expanded in m around 0 40.4%
associate-*r*40.4%
neg-mul-140.4%
+-commutative40.4%
Simplified40.4%
Taylor expanded in K around 0 55.0%
if 3.70000000000000018e-100 < M < 2.9999999999999998e-25Initial program 81.1%
*-un-lft-identity81.1%
*-commutative81.1%
Applied egg-rr14.2%
Taylor expanded in n around 0 29.8%
+-commutative29.8%
unpow229.8%
distribute-rgt-out29.9%
Simplified29.9%
Taylor expanded in l around 0 14.3%
Taylor expanded in m around 0 37.8%
mul-1-neg37.8%
distribute-lft-neg-out37.8%
Simplified37.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 (* (+ m n) 0.5)) (t_1 (fabs (- m n))))
(if (<= n 9.5e-102)
(* (cos M) (exp (+ t_1 (* (- t_0 M) (- M t_0)))))
(if (<= n 128000.0)
(* (cos M) (exp (+ t_1 (- (* M (- m M)) l))))
(* (cos M) (exp (* -0.25 (pow n 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 = (m + n) * 0.5;
double t_1 = fabs((m - n));
double tmp;
if (n <= 9.5e-102) {
tmp = cos(M) * exp((t_1 + ((t_0 - M) * (M - t_0))));
} else if (n <= 128000.0) {
tmp = cos(M) * exp((t_1 + ((M * (m - M)) - l)));
} else {
tmp = cos(M) * exp((-0.25 * pow(n, 2.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) :: t_1
real(8) :: tmp
t_0 = (m + n) * 0.5d0
t_1 = abs((m - n))
if (n <= 9.5d-102) then
tmp = cos(m_1) * exp((t_1 + ((t_0 - m_1) * (m_1 - t_0))))
else if (n <= 128000.0d0) then
tmp = cos(m_1) * exp((t_1 + ((m_1 * (m - m_1)) - l)))
else
tmp = cos(m_1) * exp(((-0.25d0) * (n ** 2.0d0)))
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 = (m + n) * 0.5;
double t_1 = Math.abs((m - n));
double tmp;
if (n <= 9.5e-102) {
tmp = Math.cos(M) * Math.exp((t_1 + ((t_0 - M) * (M - t_0))));
} else if (n <= 128000.0) {
tmp = Math.cos(M) * Math.exp((t_1 + ((M * (m - M)) - l)));
} else {
tmp = Math.cos(M) * Math.exp((-0.25 * Math.pow(n, 2.0)));
}
return tmp;
}
[K, m, n, M, l] = sort([K, m, n, M, l]) def code(K, m, n, M, l): t_0 = (m + n) * 0.5 t_1 = math.fabs((m - n)) tmp = 0 if n <= 9.5e-102: tmp = math.cos(M) * math.exp((t_1 + ((t_0 - M) * (M - t_0)))) elif n <= 128000.0: tmp = math.cos(M) * math.exp((t_1 + ((M * (m - M)) - l))) else: tmp = math.cos(M) * math.exp((-0.25 * math.pow(n, 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(Float64(m + n) * 0.5) t_1 = abs(Float64(m - n)) tmp = 0.0 if (n <= 9.5e-102) tmp = Float64(cos(M) * exp(Float64(t_1 + Float64(Float64(t_0 - M) * Float64(M - t_0))))); elseif (n <= 128000.0) tmp = Float64(cos(M) * exp(Float64(t_1 + Float64(Float64(M * Float64(m - M)) - l)))); else tmp = Float64(cos(M) * exp(Float64(-0.25 * (n ^ 2.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 = (m + n) * 0.5;
t_1 = abs((m - n));
tmp = 0.0;
if (n <= 9.5e-102)
tmp = cos(M) * exp((t_1 + ((t_0 - M) * (M - t_0))));
elseif (n <= 128000.0)
tmp = cos(M) * exp((t_1 + ((M * (m - M)) - l)));
else
tmp = cos(M) * exp((-0.25 * (n ^ 2.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[(m + n), $MachinePrecision] * 0.5), $MachinePrecision]}, Block[{t$95$1 = N[Abs[N[(m - n), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[n, 9.5e-102], N[(N[Cos[M], $MachinePrecision] * N[Exp[N[(t$95$1 + N[(N[(t$95$0 - M), $MachinePrecision] * N[(M - t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[n, 128000.0], N[(N[Cos[M], $MachinePrecision] * N[Exp[N[(t$95$1 + N[(N[(M * N[(m - M), $MachinePrecision]), $MachinePrecision] - l), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(N[Cos[M], $MachinePrecision] * N[Exp[N[(-0.25 * N[Power[n, 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(m + n\right) \cdot 0.5\\
t_1 := \left|m - n\right|\\
\mathbf{if}\;n \leq 9.5 \cdot 10^{-102}:\\
\;\;\;\;\cos M \cdot e^{t\_1 + \left(t\_0 - M\right) \cdot \left(M - t\_0\right)}\\
\mathbf{elif}\;n \leq 128000:\\
\;\;\;\;\cos M \cdot e^{t\_1 + \left(M \cdot \left(m - M\right) - \ell\right)}\\
\mathbf{else}:\\
\;\;\;\;\cos M \cdot e^{-0.25 \cdot {n}^{2}}\\
\end{array}
\end{array}
if n < 9.50000000000000025e-102Initial program 75.5%
Taylor expanded in K around 0 92.8%
cos-neg92.8%
Simplified92.8%
Taylor expanded in l around 0 85.8%
unpow285.8%
Applied egg-rr85.8%
if 9.50000000000000025e-102 < n < 128000Initial program 87.1%
Taylor expanded in K around 0 87.9%
cos-neg87.9%
Simplified87.9%
Taylor expanded in m around 0 87.9%
+-commutative87.9%
unpow287.9%
distribute-rgt-out87.9%
*-commutative87.9%
*-commutative87.9%
Simplified87.9%
Taylor expanded in n around 0 87.9%
fabs-sub87.9%
mul-1-neg87.9%
unsub-neg87.9%
Simplified87.9%
if 128000 < n Initial program 58.2%
Taylor expanded in K around 0 100.0%
cos-neg100.0%
Simplified100.0%
Taylor expanded in l around 0 98.5%
Taylor expanded in n around inf 98.5%
Final simplification89.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 (<= n 1.12e+39)
(*
(cos M)
(exp (+ (* (+ n (- (* m 0.5) M)) (- M (* m 0.5))) (- (fabs (- m n)) l))))
(* (cos M) (exp (* -0.25 (pow n 2.0))))))assert(K < m && m < n && n < M && M < l);
double code(double K, double m, double n, double M, double l) {
double tmp;
if (n <= 1.12e+39) {
tmp = cos(M) * exp((((n + ((m * 0.5) - M)) * (M - (m * 0.5))) + (fabs((m - n)) - l)));
} else {
tmp = cos(M) * exp((-0.25 * pow(n, 2.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) :: tmp
if (n <= 1.12d+39) then
tmp = cos(m_1) * exp((((n + ((m * 0.5d0) - m_1)) * (m_1 - (m * 0.5d0))) + (abs((m - n)) - l)))
else
tmp = cos(m_1) * exp(((-0.25d0) * (n ** 2.0d0)))
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 (n <= 1.12e+39) {
tmp = Math.cos(M) * Math.exp((((n + ((m * 0.5) - M)) * (M - (m * 0.5))) + (Math.abs((m - n)) - l)));
} else {
tmp = Math.cos(M) * Math.exp((-0.25 * Math.pow(n, 2.0)));
}
return tmp;
}
[K, m, n, M, l] = sort([K, m, n, M, l]) def code(K, m, n, M, l): tmp = 0 if n <= 1.12e+39: tmp = math.cos(M) * math.exp((((n + ((m * 0.5) - M)) * (M - (m * 0.5))) + (math.fabs((m - n)) - l))) else: tmp = math.cos(M) * math.exp((-0.25 * math.pow(n, 2.0))) return tmp
K, m, n, M, l = sort([K, m, n, M, l]) function code(K, m, n, M, l) tmp = 0.0 if (n <= 1.12e+39) tmp = Float64(cos(M) * exp(Float64(Float64(Float64(n + Float64(Float64(m * 0.5) - M)) * Float64(M - Float64(m * 0.5))) + Float64(abs(Float64(m - n)) - l)))); else tmp = Float64(cos(M) * exp(Float64(-0.25 * (n ^ 2.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)
tmp = 0.0;
if (n <= 1.12e+39)
tmp = cos(M) * exp((((n + ((m * 0.5) - M)) * (M - (m * 0.5))) + (abs((m - n)) - l)));
else
tmp = cos(M) * exp((-0.25 * (n ^ 2.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_] := If[LessEqual[n, 1.12e+39], N[(N[Cos[M], $MachinePrecision] * N[Exp[N[(N[(N[(n + N[(N[(m * 0.5), $MachinePrecision] - M), $MachinePrecision]), $MachinePrecision] * N[(M - N[(m * 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(N[Abs[N[(m - n), $MachinePrecision]], $MachinePrecision] - l), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(N[Cos[M], $MachinePrecision] * N[Exp[N[(-0.25 * N[Power[n, 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[K, m, n, M, l] = \mathsf{sort}([K, m, n, M, l])\\
\\
\begin{array}{l}
\mathbf{if}\;n \leq 1.12 \cdot 10^{+39}:\\
\;\;\;\;\cos M \cdot e^{\left(n + \left(m \cdot 0.5 - M\right)\right) \cdot \left(M - m \cdot 0.5\right) + \left(\left|m - n\right| - \ell\right)}\\
\mathbf{else}:\\
\;\;\;\;\cos M \cdot e^{-0.25 \cdot {n}^{2}}\\
\end{array}
\end{array}
if n < 1.12e39Initial program 76.3%
Taylor expanded in K around 0 92.3%
cos-neg92.3%
Simplified92.3%
Taylor expanded in n around 0 74.4%
+-commutative74.4%
unpow274.4%
distribute-rgt-out79.1%
*-commutative79.1%
*-commutative79.1%
Simplified79.1%
if 1.12e39 < n Initial program 58.7%
Taylor expanded in K around 0 100.0%
cos-neg100.0%
Simplified100.0%
Taylor expanded in l around 0 100.0%
Taylor expanded in n around inf 100.0%
Final simplification84.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
(if (<= n 1.1e-302)
(* (cos M) (exp (* -0.25 (pow m 2.0))))
(if (<= n 140000.0)
(* (cos M) (exp (+ (fabs (- m n)) (- (* M (- m M)) l))))
(* (cos M) (exp (* -0.25 (pow n 2.0)))))))assert(K < m && m < n && n < M && M < l);
double code(double K, double m, double n, double M, double l) {
double tmp;
if (n <= 1.1e-302) {
tmp = cos(M) * exp((-0.25 * pow(m, 2.0)));
} else if (n <= 140000.0) {
tmp = cos(M) * exp((fabs((m - n)) + ((M * (m - M)) - l)));
} else {
tmp = cos(M) * exp((-0.25 * pow(n, 2.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) :: tmp
if (n <= 1.1d-302) then
tmp = cos(m_1) * exp(((-0.25d0) * (m ** 2.0d0)))
else if (n <= 140000.0d0) then
tmp = cos(m_1) * exp((abs((m - n)) + ((m_1 * (m - m_1)) - l)))
else
tmp = cos(m_1) * exp(((-0.25d0) * (n ** 2.0d0)))
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 (n <= 1.1e-302) {
tmp = Math.cos(M) * Math.exp((-0.25 * Math.pow(m, 2.0)));
} else if (n <= 140000.0) {
tmp = Math.cos(M) * Math.exp((Math.abs((m - n)) + ((M * (m - M)) - l)));
} else {
tmp = Math.cos(M) * Math.exp((-0.25 * Math.pow(n, 2.0)));
}
return tmp;
}
[K, m, n, M, l] = sort([K, m, n, M, l]) def code(K, m, n, M, l): tmp = 0 if n <= 1.1e-302: tmp = math.cos(M) * math.exp((-0.25 * math.pow(m, 2.0))) elif n <= 140000.0: tmp = math.cos(M) * math.exp((math.fabs((m - n)) + ((M * (m - M)) - l))) else: tmp = math.cos(M) * math.exp((-0.25 * math.pow(n, 2.0))) return tmp
K, m, n, M, l = sort([K, m, n, M, l]) function code(K, m, n, M, l) tmp = 0.0 if (n <= 1.1e-302) tmp = Float64(cos(M) * exp(Float64(-0.25 * (m ^ 2.0)))); elseif (n <= 140000.0) tmp = Float64(cos(M) * exp(Float64(abs(Float64(m - n)) + Float64(Float64(M * Float64(m - M)) - l)))); else tmp = Float64(cos(M) * exp(Float64(-0.25 * (n ^ 2.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)
tmp = 0.0;
if (n <= 1.1e-302)
tmp = cos(M) * exp((-0.25 * (m ^ 2.0)));
elseif (n <= 140000.0)
tmp = cos(M) * exp((abs((m - n)) + ((M * (m - M)) - l)));
else
tmp = cos(M) * exp((-0.25 * (n ^ 2.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_] := If[LessEqual[n, 1.1e-302], N[(N[Cos[M], $MachinePrecision] * N[Exp[N[(-0.25 * N[Power[m, 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[n, 140000.0], N[(N[Cos[M], $MachinePrecision] * N[Exp[N[(N[Abs[N[(m - n), $MachinePrecision]], $MachinePrecision] + N[(N[(M * N[(m - M), $MachinePrecision]), $MachinePrecision] - l), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(N[Cos[M], $MachinePrecision] * N[Exp[N[(-0.25 * N[Power[n, 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
[K, m, n, M, l] = \mathsf{sort}([K, m, n, M, l])\\
\\
\begin{array}{l}
\mathbf{if}\;n \leq 1.1 \cdot 10^{-302}:\\
\;\;\;\;\cos M \cdot e^{-0.25 \cdot {m}^{2}}\\
\mathbf{elif}\;n \leq 140000:\\
\;\;\;\;\cos M \cdot e^{\left|m - n\right| + \left(M \cdot \left(m - M\right) - \ell\right)}\\
\mathbf{else}:\\
\;\;\;\;\cos M \cdot e^{-0.25 \cdot {n}^{2}}\\
\end{array}
\end{array}
if n < 1.10000000000000004e-302Initial program 72.1%
Taylor expanded in K around 0 95.9%
cos-neg95.9%
Simplified95.9%
Taylor expanded in l around 0 91.4%
Taylor expanded in m around inf 56.5%
if 1.10000000000000004e-302 < n < 1.4e5Initial program 87.0%
Taylor expanded in K around 0 84.3%
cos-neg84.3%
Simplified84.3%
Taylor expanded in m around 0 68.4%
+-commutative68.4%
unpow268.4%
distribute-rgt-out70.1%
*-commutative70.1%
*-commutative70.1%
Simplified70.1%
Taylor expanded in n around 0 70.1%
fabs-sub70.1%
mul-1-neg70.1%
unsub-neg70.1%
Simplified70.1%
if 1.4e5 < n Initial program 58.2%
Taylor expanded in K around 0 100.0%
cos-neg100.0%
Simplified100.0%
Taylor expanded in l around 0 98.5%
Taylor expanded in n around inf 98.5%
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
(if (<= n -2.6e-104)
(* (cos M) (exp (* -0.25 (pow m 2.0))))
(if (<= n 1750000.0)
(*
(cos (- (/ (* K (+ m n)) 2.0) M))
(exp (+ (- m n) (- (* n (- (* m 0.5) M)) l))))
(* (cos M) (exp (* -0.25 (pow n 2.0)))))))assert(K < m && m < n && n < M && M < l);
double code(double K, double m, double n, double M, double l) {
double tmp;
if (n <= -2.6e-104) {
tmp = cos(M) * exp((-0.25 * pow(m, 2.0)));
} else if (n <= 1750000.0) {
tmp = cos((((K * (m + n)) / 2.0) - M)) * exp(((m - n) + ((n * ((m * 0.5) - M)) - l)));
} else {
tmp = cos(M) * exp((-0.25 * pow(n, 2.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) :: tmp
if (n <= (-2.6d-104)) then
tmp = cos(m_1) * exp(((-0.25d0) * (m ** 2.0d0)))
else if (n <= 1750000.0d0) then
tmp = cos((((k * (m + n)) / 2.0d0) - m_1)) * exp(((m - n) + ((n * ((m * 0.5d0) - m_1)) - l)))
else
tmp = cos(m_1) * exp(((-0.25d0) * (n ** 2.0d0)))
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 (n <= -2.6e-104) {
tmp = Math.cos(M) * Math.exp((-0.25 * Math.pow(m, 2.0)));
} else if (n <= 1750000.0) {
tmp = Math.cos((((K * (m + n)) / 2.0) - M)) * Math.exp(((m - n) + ((n * ((m * 0.5) - M)) - l)));
} else {
tmp = Math.cos(M) * Math.exp((-0.25 * Math.pow(n, 2.0)));
}
return tmp;
}
[K, m, n, M, l] = sort([K, m, n, M, l]) def code(K, m, n, M, l): tmp = 0 if n <= -2.6e-104: tmp = math.cos(M) * math.exp((-0.25 * math.pow(m, 2.0))) elif n <= 1750000.0: tmp = math.cos((((K * (m + n)) / 2.0) - M)) * math.exp(((m - n) + ((n * ((m * 0.5) - M)) - l))) else: tmp = math.cos(M) * math.exp((-0.25 * math.pow(n, 2.0))) return tmp
K, m, n, M, l = sort([K, m, n, M, l]) function code(K, m, n, M, l) tmp = 0.0 if (n <= -2.6e-104) tmp = Float64(cos(M) * exp(Float64(-0.25 * (m ^ 2.0)))); elseif (n <= 1750000.0) tmp = Float64(cos(Float64(Float64(Float64(K * Float64(m + n)) / 2.0) - M)) * exp(Float64(Float64(m - n) + Float64(Float64(n * Float64(Float64(m * 0.5) - M)) - l)))); else tmp = Float64(cos(M) * exp(Float64(-0.25 * (n ^ 2.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)
tmp = 0.0;
if (n <= -2.6e-104)
tmp = cos(M) * exp((-0.25 * (m ^ 2.0)));
elseif (n <= 1750000.0)
tmp = cos((((K * (m + n)) / 2.0) - M)) * exp(((m - n) + ((n * ((m * 0.5) - M)) - l)));
else
tmp = cos(M) * exp((-0.25 * (n ^ 2.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_] := If[LessEqual[n, -2.6e-104], N[(N[Cos[M], $MachinePrecision] * N[Exp[N[(-0.25 * N[Power[m, 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[n, 1750000.0], N[(N[Cos[N[(N[(N[(K * N[(m + n), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision] - M), $MachinePrecision]], $MachinePrecision] * N[Exp[N[(N[(m - n), $MachinePrecision] + N[(N[(n * N[(N[(m * 0.5), $MachinePrecision] - M), $MachinePrecision]), $MachinePrecision] - l), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(N[Cos[M], $MachinePrecision] * N[Exp[N[(-0.25 * N[Power[n, 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
[K, m, n, M, l] = \mathsf{sort}([K, m, n, M, l])\\
\\
\begin{array}{l}
\mathbf{if}\;n \leq -2.6 \cdot 10^{-104}:\\
\;\;\;\;\cos M \cdot e^{-0.25 \cdot {m}^{2}}\\
\mathbf{elif}\;n \leq 1750000:\\
\;\;\;\;\cos \left(\frac{K \cdot \left(m + n\right)}{2} - M\right) \cdot e^{\left(m - n\right) + \left(n \cdot \left(m \cdot 0.5 - M\right) - \ell\right)}\\
\mathbf{else}:\\
\;\;\;\;\cos M \cdot e^{-0.25 \cdot {n}^{2}}\\
\end{array}
\end{array}
if n < -2.60000000000000003e-104Initial program 68.5%
Taylor expanded in K around 0 98.9%
cos-neg98.9%
Simplified98.9%
Taylor expanded in l around 0 98.9%
Taylor expanded in m around inf 53.2%
if -2.60000000000000003e-104 < n < 1.75e6Initial program 84.3%
*-un-lft-identity84.3%
*-commutative84.3%
Applied egg-rr41.1%
Taylor expanded in n around 0 41.1%
+-commutative41.1%
unpow241.1%
distribute-rgt-out41.1%
Simplified41.1%
Taylor expanded in n around inf 59.9%
*-commutative59.9%
Simplified59.9%
if 1.75e6 < n Initial program 58.2%
Taylor expanded in K around 0 100.0%
cos-neg100.0%
Simplified100.0%
Taylor expanded in l around 0 98.5%
Taylor expanded in n around inf 98.5%
Final simplification67.7%
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 (* K (+ m n))))
(if (<= n 9.5e+118)
(* (cos (- (/ t_0 2.0) M)) (exp (+ (- m n) (- (* n (- (* m 0.5) M)) l))))
(if (or (<= n 4.8e+207) (not (<= n 1.02e+219)))
(* (cos (- M)) (exp (- (* M (- M n)) (+ n l))))
(*
(cos (* t_0 0.5))
(exp (- (+ m (* 0.5 (* m (+ n (* m 0.5))))) n)))))))assert(K < m && m < n && n < M && M < l);
double code(double K, double m, double n, double M, double l) {
double t_0 = K * (m + n);
double tmp;
if (n <= 9.5e+118) {
tmp = cos(((t_0 / 2.0) - M)) * exp(((m - n) + ((n * ((m * 0.5) - M)) - l)));
} else if ((n <= 4.8e+207) || !(n <= 1.02e+219)) {
tmp = cos(-M) * exp(((M * (M - n)) - (n + l)));
} else {
tmp = cos((t_0 * 0.5)) * exp(((m + (0.5 * (m * (n + (m * 0.5))))) - n));
}
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 = k * (m + n)
if (n <= 9.5d+118) then
tmp = cos(((t_0 / 2.0d0) - m_1)) * exp(((m - n) + ((n * ((m * 0.5d0) - m_1)) - l)))
else if ((n <= 4.8d+207) .or. (.not. (n <= 1.02d+219))) then
tmp = cos(-m_1) * exp(((m_1 * (m_1 - n)) - (n + l)))
else
tmp = cos((t_0 * 0.5d0)) * exp(((m + (0.5d0 * (m * (n + (m * 0.5d0))))) - n))
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 = K * (m + n);
double tmp;
if (n <= 9.5e+118) {
tmp = Math.cos(((t_0 / 2.0) - M)) * Math.exp(((m - n) + ((n * ((m * 0.5) - M)) - l)));
} else if ((n <= 4.8e+207) || !(n <= 1.02e+219)) {
tmp = Math.cos(-M) * Math.exp(((M * (M - n)) - (n + l)));
} else {
tmp = Math.cos((t_0 * 0.5)) * Math.exp(((m + (0.5 * (m * (n + (m * 0.5))))) - n));
}
return tmp;
}
[K, m, n, M, l] = sort([K, m, n, M, l]) def code(K, m, n, M, l): t_0 = K * (m + n) tmp = 0 if n <= 9.5e+118: tmp = math.cos(((t_0 / 2.0) - M)) * math.exp(((m - n) + ((n * ((m * 0.5) - M)) - l))) elif (n <= 4.8e+207) or not (n <= 1.02e+219): tmp = math.cos(-M) * math.exp(((M * (M - n)) - (n + l))) else: tmp = math.cos((t_0 * 0.5)) * math.exp(((m + (0.5 * (m * (n + (m * 0.5))))) - n)) return tmp
K, m, n, M, l = sort([K, m, n, M, l]) function code(K, m, n, M, l) t_0 = Float64(K * Float64(m + n)) tmp = 0.0 if (n <= 9.5e+118) tmp = Float64(cos(Float64(Float64(t_0 / 2.0) - M)) * exp(Float64(Float64(m - n) + Float64(Float64(n * Float64(Float64(m * 0.5) - M)) - l)))); elseif ((n <= 4.8e+207) || !(n <= 1.02e+219)) tmp = Float64(cos(Float64(-M)) * exp(Float64(Float64(M * Float64(M - n)) - Float64(n + l)))); else tmp = Float64(cos(Float64(t_0 * 0.5)) * exp(Float64(Float64(m + Float64(0.5 * Float64(m * Float64(n + Float64(m * 0.5))))) - n))); 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 = K * (m + n);
tmp = 0.0;
if (n <= 9.5e+118)
tmp = cos(((t_0 / 2.0) - M)) * exp(((m - n) + ((n * ((m * 0.5) - M)) - l)));
elseif ((n <= 4.8e+207) || ~((n <= 1.02e+219)))
tmp = cos(-M) * exp(((M * (M - n)) - (n + l)));
else
tmp = cos((t_0 * 0.5)) * exp(((m + (0.5 * (m * (n + (m * 0.5))))) - n));
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[(K * N[(m + n), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[n, 9.5e+118], N[(N[Cos[N[(N[(t$95$0 / 2.0), $MachinePrecision] - M), $MachinePrecision]], $MachinePrecision] * N[Exp[N[(N[(m - n), $MachinePrecision] + N[(N[(n * N[(N[(m * 0.5), $MachinePrecision] - M), $MachinePrecision]), $MachinePrecision] - l), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[Or[LessEqual[n, 4.8e+207], N[Not[LessEqual[n, 1.02e+219]], $MachinePrecision]], N[(N[Cos[(-M)], $MachinePrecision] * N[Exp[N[(N[(M * N[(M - n), $MachinePrecision]), $MachinePrecision] - N[(n + l), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(N[Cos[N[(t$95$0 * 0.5), $MachinePrecision]], $MachinePrecision] * N[Exp[N[(N[(m + N[(0.5 * N[(m * N[(n + N[(m * 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - n), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
[K, m, n, M, l] = \mathsf{sort}([K, m, n, M, l])\\
\\
\begin{array}{l}
t_0 := K \cdot \left(m + n\right)\\
\mathbf{if}\;n \leq 9.5 \cdot 10^{+118}:\\
\;\;\;\;\cos \left(\frac{t\_0}{2} - M\right) \cdot e^{\left(m - n\right) + \left(n \cdot \left(m \cdot 0.5 - M\right) - \ell\right)}\\
\mathbf{elif}\;n \leq 4.8 \cdot 10^{+207} \lor \neg \left(n \leq 1.02 \cdot 10^{+219}\right):\\
\;\;\;\;\cos \left(-M\right) \cdot e^{M \cdot \left(M - n\right) - \left(n + \ell\right)}\\
\mathbf{else}:\\
\;\;\;\;\cos \left(t\_0 \cdot 0.5\right) \cdot e^{\left(m + 0.5 \cdot \left(m \cdot \left(n + m \cdot 0.5\right)\right)\right) - n}\\
\end{array}
\end{array}
if n < 9.49999999999999974e118Initial program 77.2%
*-un-lft-identity77.2%
*-commutative77.2%
Applied egg-rr25.0%
Taylor expanded in n around 0 28.2%
+-commutative28.2%
unpow228.2%
distribute-rgt-out29.2%
Simplified29.2%
Taylor expanded in n around inf 50.0%
*-commutative50.0%
Simplified50.0%
if 9.49999999999999974e118 < n < 4.8000000000000002e207 or 1.02e219 < n Initial program 41.5%
*-un-lft-identity41.5%
*-commutative41.5%
Applied egg-rr0.6%
Taylor expanded in n around 0 14.8%
+-commutative14.8%
unpow214.8%
distribute-rgt-out17.5%
Simplified17.5%
Taylor expanded in m around 0 24.7%
associate-*r*24.7%
neg-mul-124.7%
+-commutative24.7%
Simplified24.7%
Taylor expanded in K around 0 66.4%
if 4.8000000000000002e207 < n < 1.02e219Initial program 100.0%
*-un-lft-identity100.0%
*-commutative100.0%
Applied egg-rr1.6%
Taylor expanded in n around 0 17.7%
+-commutative17.7%
unpow217.7%
distribute-rgt-out18.0%
Simplified18.0%
Taylor expanded in l around 0 18.0%
Taylor expanded in M around 0 100.0%
Final simplification53.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 (cos (- (/ (* K (+ m n)) 2.0) M)))
(t_1 (* t_0 (exp (- (- n) l))))
(t_2 (* M (- M n)))
(t_3 (* (cos (- M)) (exp (- t_2 (+ n l))))))
(if (<= K -6.2e+88)
t_3
(if (<= K 8e-248)
t_1
(if (<= K 1.22e-144)
(* t_0 (exp (- (+ m t_2) n)))
(if (<= K 3.5e+127) t_1 t_3))))))assert(K < m && m < n && n < M && M < l);
double code(double K, double m, double n, double M, double l) {
double t_0 = cos((((K * (m + n)) / 2.0) - M));
double t_1 = t_0 * exp((-n - l));
double t_2 = M * (M - n);
double t_3 = cos(-M) * exp((t_2 - (n + l)));
double tmp;
if (K <= -6.2e+88) {
tmp = t_3;
} else if (K <= 8e-248) {
tmp = t_1;
} else if (K <= 1.22e-144) {
tmp = t_0 * exp(((m + t_2) - n));
} else if (K <= 3.5e+127) {
tmp = t_1;
} else {
tmp = t_3;
}
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) :: t_2
real(8) :: t_3
real(8) :: tmp
t_0 = cos((((k * (m + n)) / 2.0d0) - m_1))
t_1 = t_0 * exp((-n - l))
t_2 = m_1 * (m_1 - n)
t_3 = cos(-m_1) * exp((t_2 - (n + l)))
if (k <= (-6.2d+88)) then
tmp = t_3
else if (k <= 8d-248) then
tmp = t_1
else if (k <= 1.22d-144) then
tmp = t_0 * exp(((m + t_2) - n))
else if (k <= 3.5d+127) then
tmp = t_1
else
tmp = t_3
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.cos((((K * (m + n)) / 2.0) - M));
double t_1 = t_0 * Math.exp((-n - l));
double t_2 = M * (M - n);
double t_3 = Math.cos(-M) * Math.exp((t_2 - (n + l)));
double tmp;
if (K <= -6.2e+88) {
tmp = t_3;
} else if (K <= 8e-248) {
tmp = t_1;
} else if (K <= 1.22e-144) {
tmp = t_0 * Math.exp(((m + t_2) - n));
} else if (K <= 3.5e+127) {
tmp = t_1;
} else {
tmp = t_3;
}
return tmp;
}
[K, m, n, M, l] = sort([K, m, n, M, l]) def code(K, m, n, M, l): t_0 = math.cos((((K * (m + n)) / 2.0) - M)) t_1 = t_0 * math.exp((-n - l)) t_2 = M * (M - n) t_3 = math.cos(-M) * math.exp((t_2 - (n + l))) tmp = 0 if K <= -6.2e+88: tmp = t_3 elif K <= 8e-248: tmp = t_1 elif K <= 1.22e-144: tmp = t_0 * math.exp(((m + t_2) - n)) elif K <= 3.5e+127: tmp = t_1 else: tmp = t_3 return tmp
K, m, n, M, l = sort([K, m, n, M, l]) function code(K, m, n, M, l) t_0 = cos(Float64(Float64(Float64(K * Float64(m + n)) / 2.0) - M)) t_1 = Float64(t_0 * exp(Float64(Float64(-n) - l))) t_2 = Float64(M * Float64(M - n)) t_3 = Float64(cos(Float64(-M)) * exp(Float64(t_2 - Float64(n + l)))) tmp = 0.0 if (K <= -6.2e+88) tmp = t_3; elseif (K <= 8e-248) tmp = t_1; elseif (K <= 1.22e-144) tmp = Float64(t_0 * exp(Float64(Float64(m + t_2) - n))); elseif (K <= 3.5e+127) tmp = t_1; else tmp = t_3; 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 = cos((((K * (m + n)) / 2.0) - M));
t_1 = t_0 * exp((-n - l));
t_2 = M * (M - n);
t_3 = cos(-M) * exp((t_2 - (n + l)));
tmp = 0.0;
if (K <= -6.2e+88)
tmp = t_3;
elseif (K <= 8e-248)
tmp = t_1;
elseif (K <= 1.22e-144)
tmp = t_0 * exp(((m + t_2) - n));
elseif (K <= 3.5e+127)
tmp = t_1;
else
tmp = t_3;
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[Cos[N[(N[(N[(K * N[(m + n), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision] - M), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(t$95$0 * N[Exp[N[((-n) - l), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(M * N[(M - n), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$3 = N[(N[Cos[(-M)], $MachinePrecision] * N[Exp[N[(t$95$2 - N[(n + l), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[K, -6.2e+88], t$95$3, If[LessEqual[K, 8e-248], t$95$1, If[LessEqual[K, 1.22e-144], N[(t$95$0 * N[Exp[N[(N[(m + t$95$2), $MachinePrecision] - n), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[K, 3.5e+127], t$95$1, t$95$3]]]]]]]]
\begin{array}{l}
[K, m, n, M, l] = \mathsf{sort}([K, m, n, M, l])\\
\\
\begin{array}{l}
t_0 := \cos \left(\frac{K \cdot \left(m + n\right)}{2} - M\right)\\
t_1 := t\_0 \cdot e^{\left(-n\right) - \ell}\\
t_2 := M \cdot \left(M - n\right)\\
t_3 := \cos \left(-M\right) \cdot e^{t\_2 - \left(n + \ell\right)}\\
\mathbf{if}\;K \leq -6.2 \cdot 10^{+88}:\\
\;\;\;\;t\_3\\
\mathbf{elif}\;K \leq 8 \cdot 10^{-248}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;K \leq 1.22 \cdot 10^{-144}:\\
\;\;\;\;t\_0 \cdot e^{\left(m + t\_2\right) - n}\\
\mathbf{elif}\;K \leq 3.5 \cdot 10^{+127}:\\
\;\;\;\;t\_1\\
\mathbf{else}:\\
\;\;\;\;t\_3\\
\end{array}
\end{array}
if K < -6.2000000000000003e88 or 3.49999999999999978e127 < K Initial program 30.1%
*-un-lft-identity30.1%
*-commutative30.1%
Applied egg-rr13.4%
Taylor expanded in n around 0 13.4%
+-commutative13.4%
unpow213.4%
distribute-rgt-out13.4%
Simplified13.4%
Taylor expanded in m around 0 16.6%
associate-*r*16.6%
neg-mul-116.6%
+-commutative16.6%
Simplified16.6%
Taylor expanded in K around 0 37.7%
if -6.2000000000000003e88 < K < 7.99999999999999984e-248 or 1.22e-144 < K < 3.49999999999999978e127Initial program 95.8%
*-un-lft-identity95.8%
*-commutative95.8%
Applied egg-rr25.9%
Taylor expanded in n around 0 32.6%
+-commutative32.6%
unpow232.6%
distribute-rgt-out34.9%
Simplified34.9%
Taylor expanded in m around 0 39.7%
associate-*r*39.7%
neg-mul-139.7%
+-commutative39.7%
Simplified39.7%
Taylor expanded in M around 0 50.3%
+-commutative50.3%
distribute-neg-in50.3%
unsub-neg50.3%
Simplified50.3%
if 7.99999999999999984e-248 < K < 1.22e-144Initial program 100.0%
*-un-lft-identity100.0%
*-commutative100.0%
Applied egg-rr16.3%
Taylor expanded in n around 0 35.9%
+-commutative35.9%
unpow235.9%
distribute-rgt-out36.0%
Simplified36.0%
Taylor expanded in l around 0 36.0%
Taylor expanded in m around 0 65.5%
mul-1-neg65.5%
distribute-lft-neg-out65.5%
Simplified65.5%
Final simplification46.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 (cos (- (/ (* K (+ m n)) 2.0) M))))
(if (<= m -1.9e+34)
(* t_0 (exp (- (+ m (* n (- (* m 0.5) M))) n)))
(if (<= m 8e-8)
(* t_0 (exp (- (- n) l)))
(* (cos (- M)) (exp (- (* M (- M n)) (+ n l))))))))assert(K < m && m < n && n < M && M < l);
double code(double K, double m, double n, double M, double l) {
double t_0 = cos((((K * (m + n)) / 2.0) - M));
double tmp;
if (m <= -1.9e+34) {
tmp = t_0 * exp(((m + (n * ((m * 0.5) - M))) - n));
} else if (m <= 8e-8) {
tmp = t_0 * exp((-n - l));
} else {
tmp = cos(-M) * exp(((M * (M - n)) - (n + 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) :: t_0
real(8) :: tmp
t_0 = cos((((k * (m + n)) / 2.0d0) - m_1))
if (m <= (-1.9d+34)) then
tmp = t_0 * exp(((m + (n * ((m * 0.5d0) - m_1))) - n))
else if (m <= 8d-8) then
tmp = t_0 * exp((-n - l))
else
tmp = cos(-m_1) * exp(((m_1 * (m_1 - n)) - (n + 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 t_0 = Math.cos((((K * (m + n)) / 2.0) - M));
double tmp;
if (m <= -1.9e+34) {
tmp = t_0 * Math.exp(((m + (n * ((m * 0.5) - M))) - n));
} else if (m <= 8e-8) {
tmp = t_0 * Math.exp((-n - l));
} else {
tmp = Math.cos(-M) * Math.exp(((M * (M - n)) - (n + l)));
}
return tmp;
}
[K, m, n, M, l] = sort([K, m, n, M, l]) def code(K, m, n, M, l): t_0 = math.cos((((K * (m + n)) / 2.0) - M)) tmp = 0 if m <= -1.9e+34: tmp = t_0 * math.exp(((m + (n * ((m * 0.5) - M))) - n)) elif m <= 8e-8: tmp = t_0 * math.exp((-n - l)) else: tmp = math.cos(-M) * math.exp(((M * (M - n)) - (n + l))) return tmp
K, m, n, M, l = sort([K, m, n, M, l]) function code(K, m, n, M, l) t_0 = cos(Float64(Float64(Float64(K * Float64(m + n)) / 2.0) - M)) tmp = 0.0 if (m <= -1.9e+34) tmp = Float64(t_0 * exp(Float64(Float64(m + Float64(n * Float64(Float64(m * 0.5) - M))) - n))); elseif (m <= 8e-8) tmp = Float64(t_0 * exp(Float64(Float64(-n) - l))); else tmp = Float64(cos(Float64(-M)) * exp(Float64(Float64(M * Float64(M - n)) - Float64(n + 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)
t_0 = cos((((K * (m + n)) / 2.0) - M));
tmp = 0.0;
if (m <= -1.9e+34)
tmp = t_0 * exp(((m + (n * ((m * 0.5) - M))) - n));
elseif (m <= 8e-8)
tmp = t_0 * exp((-n - l));
else
tmp = cos(-M) * exp(((M * (M - n)) - (n + 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_] := Block[{t$95$0 = N[Cos[N[(N[(N[(K * N[(m + n), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision] - M), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[m, -1.9e+34], N[(t$95$0 * N[Exp[N[(N[(m + N[(n * N[(N[(m * 0.5), $MachinePrecision] - M), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - n), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[m, 8e-8], N[(t$95$0 * N[Exp[N[((-n) - l), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(N[Cos[(-M)], $MachinePrecision] * N[Exp[N[(N[(M * N[(M - n), $MachinePrecision]), $MachinePrecision] - N[(n + l), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
[K, m, n, M, l] = \mathsf{sort}([K, m, n, M, l])\\
\\
\begin{array}{l}
t_0 := \cos \left(\frac{K \cdot \left(m + n\right)}{2} - M\right)\\
\mathbf{if}\;m \leq -1.9 \cdot 10^{+34}:\\
\;\;\;\;t\_0 \cdot e^{\left(m + n \cdot \left(m \cdot 0.5 - M\right)\right) - n}\\
\mathbf{elif}\;m \leq 8 \cdot 10^{-8}:\\
\;\;\;\;t\_0 \cdot e^{\left(-n\right) - \ell}\\
\mathbf{else}:\\
\;\;\;\;\cos \left(-M\right) \cdot e^{M \cdot \left(M - n\right) - \left(n + \ell\right)}\\
\end{array}
\end{array}
if m < -1.9000000000000001e34Initial program 66.1%
*-un-lft-identity66.1%
*-commutative66.1%
Applied egg-rr2.8%
Taylor expanded in n around 0 6.1%
+-commutative6.1%
unpow26.1%
distribute-rgt-out9.8%
Simplified9.8%
Taylor expanded in l around 0 8.1%
Taylor expanded in n around inf 48.5%
*-commutative48.5%
Simplified48.5%
if -1.9000000000000001e34 < m < 8.0000000000000002e-8Initial program 73.2%
*-un-lft-identity73.2%
*-commutative73.2%
Applied egg-rr30.2%
Taylor expanded in n around 0 37.4%
+-commutative37.4%
unpow237.4%
distribute-rgt-out37.4%
Simplified37.4%
Taylor expanded in m around 0 37.3%
associate-*r*37.3%
neg-mul-137.3%
+-commutative37.3%
Simplified37.3%
Taylor expanded in M around 0 45.3%
+-commutative45.3%
distribute-neg-in45.3%
unsub-neg45.3%
Simplified45.3%
if 8.0000000000000002e-8 < m Initial program 74.6%
*-un-lft-identity74.6%
*-commutative74.6%
Applied egg-rr15.2%
Taylor expanded in n around 0 18.2%
+-commutative18.2%
unpow218.2%
distribute-rgt-out19.9%
Simplified19.9%
Taylor expanded in m around 0 26.4%
associate-*r*26.4%
neg-mul-126.4%
+-commutative26.4%
Simplified26.4%
Taylor expanded in K around 0 31.4%
Final simplification42.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 (if (or (<= K -1.26e+89) (not (<= K 1.6e+127))) (* (cos (- M)) (exp (- (* M (- M n)) (+ n l)))) (* (cos (- (/ (* K (+ m n)) 2.0) M)) (exp (- (- n) 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 ((K <= -1.26e+89) || !(K <= 1.6e+127)) {
tmp = cos(-M) * exp(((M * (M - n)) - (n + l)));
} else {
tmp = cos((((K * (m + n)) / 2.0) - M)) * exp((-n - 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 ((k <= (-1.26d+89)) .or. (.not. (k <= 1.6d+127))) then
tmp = cos(-m_1) * exp(((m_1 * (m_1 - n)) - (n + l)))
else
tmp = cos((((k * (m + n)) / 2.0d0) - m_1)) * exp((-n - 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 ((K <= -1.26e+89) || !(K <= 1.6e+127)) {
tmp = Math.cos(-M) * Math.exp(((M * (M - n)) - (n + l)));
} else {
tmp = Math.cos((((K * (m + n)) / 2.0) - M)) * Math.exp((-n - l));
}
return tmp;
}
[K, m, n, M, l] = sort([K, m, n, M, l]) def code(K, m, n, M, l): tmp = 0 if (K <= -1.26e+89) or not (K <= 1.6e+127): tmp = math.cos(-M) * math.exp(((M * (M - n)) - (n + l))) else: tmp = math.cos((((K * (m + n)) / 2.0) - M)) * math.exp((-n - 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 ((K <= -1.26e+89) || !(K <= 1.6e+127)) tmp = Float64(cos(Float64(-M)) * exp(Float64(Float64(M * Float64(M - n)) - Float64(n + l)))); else tmp = Float64(cos(Float64(Float64(Float64(K * Float64(m + n)) / 2.0) - M)) * exp(Float64(Float64(-n) - 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 ((K <= -1.26e+89) || ~((K <= 1.6e+127)))
tmp = cos(-M) * exp(((M * (M - n)) - (n + l)));
else
tmp = cos((((K * (m + n)) / 2.0) - M)) * exp((-n - 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[K, -1.26e+89], N[Not[LessEqual[K, 1.6e+127]], $MachinePrecision]], N[(N[Cos[(-M)], $MachinePrecision] * N[Exp[N[(N[(M * N[(M - n), $MachinePrecision]), $MachinePrecision] - N[(n + l), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(N[Cos[N[(N[(N[(K * N[(m + n), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision] - M), $MachinePrecision]], $MachinePrecision] * N[Exp[N[((-n) - l), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[K, m, n, M, l] = \mathsf{sort}([K, m, n, M, l])\\
\\
\begin{array}{l}
\mathbf{if}\;K \leq -1.26 \cdot 10^{+89} \lor \neg \left(K \leq 1.6 \cdot 10^{+127}\right):\\
\;\;\;\;\cos \left(-M\right) \cdot e^{M \cdot \left(M - n\right) - \left(n + \ell\right)}\\
\mathbf{else}:\\
\;\;\;\;\cos \left(\frac{K \cdot \left(m + n\right)}{2} - M\right) \cdot e^{\left(-n\right) - \ell}\\
\end{array}
\end{array}
if K < -1.26e89 or 1.59999999999999988e127 < K Initial program 30.1%
*-un-lft-identity30.1%
*-commutative30.1%
Applied egg-rr13.4%
Taylor expanded in n around 0 13.4%
+-commutative13.4%
unpow213.4%
distribute-rgt-out13.4%
Simplified13.4%
Taylor expanded in m around 0 16.6%
associate-*r*16.6%
neg-mul-116.6%
+-commutative16.6%
Simplified16.6%
Taylor expanded in K around 0 37.7%
if -1.26e89 < K < 1.59999999999999988e127Initial program 96.3%
*-un-lft-identity96.3%
*-commutative96.3%
Applied egg-rr24.7%
Taylor expanded in n around 0 33.1%
+-commutative33.1%
unpow233.1%
distribute-rgt-out35.0%
Simplified35.0%
Taylor expanded in m around 0 39.9%
associate-*r*39.9%
neg-mul-139.9%
+-commutative39.9%
Simplified39.9%
Taylor expanded in M around 0 49.2%
+-commutative49.2%
distribute-neg-in49.2%
unsub-neg49.2%
Simplified49.2%
Final simplification45.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 (if (or (<= K -5e+88) (not (<= K 2.6e+127))) (* (cos (- M)) (exp (- (* M (- M n)) (+ n l)))) (* (exp (- (- n) l)) (cos (* (+ m n) (* K 0.5))))))
assert(K < m && m < n && n < M && M < l);
double code(double K, double m, double n, double M, double l) {
double tmp;
if ((K <= -5e+88) || !(K <= 2.6e+127)) {
tmp = cos(-M) * exp(((M * (M - n)) - (n + l)));
} else {
tmp = exp((-n - l)) * cos(((m + n) * (K * 0.5)));
}
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 ((k <= (-5d+88)) .or. (.not. (k <= 2.6d+127))) then
tmp = cos(-m_1) * exp(((m_1 * (m_1 - n)) - (n + l)))
else
tmp = exp((-n - l)) * cos(((m + n) * (k * 0.5d0)))
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 ((K <= -5e+88) || !(K <= 2.6e+127)) {
tmp = Math.cos(-M) * Math.exp(((M * (M - n)) - (n + l)));
} else {
tmp = Math.exp((-n - l)) * Math.cos(((m + n) * (K * 0.5)));
}
return tmp;
}
[K, m, n, M, l] = sort([K, m, n, M, l]) def code(K, m, n, M, l): tmp = 0 if (K <= -5e+88) or not (K <= 2.6e+127): tmp = math.cos(-M) * math.exp(((M * (M - n)) - (n + l))) else: tmp = math.exp((-n - l)) * math.cos(((m + n) * (K * 0.5))) return tmp
K, m, n, M, l = sort([K, m, n, M, l]) function code(K, m, n, M, l) tmp = 0.0 if ((K <= -5e+88) || !(K <= 2.6e+127)) tmp = Float64(cos(Float64(-M)) * exp(Float64(Float64(M * Float64(M - n)) - Float64(n + l)))); else tmp = Float64(exp(Float64(Float64(-n) - l)) * cos(Float64(Float64(m + n) * Float64(K * 0.5)))); 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 ((K <= -5e+88) || ~((K <= 2.6e+127)))
tmp = cos(-M) * exp(((M * (M - n)) - (n + l)));
else
tmp = exp((-n - l)) * cos(((m + n) * (K * 0.5)));
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[K, -5e+88], N[Not[LessEqual[K, 2.6e+127]], $MachinePrecision]], N[(N[Cos[(-M)], $MachinePrecision] * N[Exp[N[(N[(M * N[(M - n), $MachinePrecision]), $MachinePrecision] - N[(n + l), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(N[Exp[N[((-n) - l), $MachinePrecision]], $MachinePrecision] * N[Cos[N[(N[(m + n), $MachinePrecision] * N[(K * 0.5), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[K, m, n, M, l] = \mathsf{sort}([K, m, n, M, l])\\
\\
\begin{array}{l}
\mathbf{if}\;K \leq -5 \cdot 10^{+88} \lor \neg \left(K \leq 2.6 \cdot 10^{+127}\right):\\
\;\;\;\;\cos \left(-M\right) \cdot e^{M \cdot \left(M - n\right) - \left(n + \ell\right)}\\
\mathbf{else}:\\
\;\;\;\;e^{\left(-n\right) - \ell} \cdot \cos \left(\left(m + n\right) \cdot \left(K \cdot 0.5\right)\right)\\
\end{array}
\end{array}
if K < -4.99999999999999997e88 or 2.6000000000000002e127 < K Initial program 30.1%
*-un-lft-identity30.1%
*-commutative30.1%
Applied egg-rr13.4%
Taylor expanded in n around 0 13.4%
+-commutative13.4%
unpow213.4%
distribute-rgt-out13.4%
Simplified13.4%
Taylor expanded in m around 0 16.6%
associate-*r*16.6%
neg-mul-116.6%
+-commutative16.6%
Simplified16.6%
Taylor expanded in K around 0 37.7%
if -4.99999999999999997e88 < K < 2.6000000000000002e127Initial program 96.3%
*-un-lft-identity96.3%
*-commutative96.3%
Applied egg-rr24.7%
Taylor expanded in n around 0 33.1%
+-commutative33.1%
unpow233.1%
distribute-rgt-out35.0%
Simplified35.0%
Taylor expanded in m around 0 39.9%
associate-*r*39.9%
neg-mul-139.9%
+-commutative39.9%
Simplified39.9%
Taylor expanded in M around 0 48.5%
*-commutative48.5%
+-commutative48.5%
distribute-neg-in48.5%
unsub-neg48.5%
associate-*r*48.5%
Simplified48.5%
Final simplification44.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 (* (exp (- (- n) l)) (cos (* (+ m n) (* K 0.5)))))
assert(K < m && m < n && n < M && M < l);
double code(double K, double m, double n, double M, double l) {
return exp((-n - l)) * cos(((m + n) * (K * 0.5)));
}
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((-n - l)) * cos(((m + n) * (k * 0.5d0)))
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((-n - l)) * Math.cos(((m + n) * (K * 0.5)));
}
[K, m, n, M, l] = sort([K, m, n, M, l]) def code(K, m, n, M, l): return math.exp((-n - l)) * math.cos(((m + n) * (K * 0.5)))
K, m, n, M, l = sort([K, m, n, M, l]) function code(K, m, n, M, l) return Float64(exp(Float64(Float64(-n) - l)) * cos(Float64(Float64(m + n) * Float64(K * 0.5)))) end
K, m, n, M, l = num2cell(sort([K, m, n, M, l])){:}
function tmp = code(K, m, n, M, l)
tmp = exp((-n - l)) * cos(((m + n) * (K * 0.5)));
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[Exp[N[((-n) - l), $MachinePrecision]], $MachinePrecision] * N[Cos[N[(N[(m + n), $MachinePrecision] * N[(K * 0.5), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
[K, m, n, M, l] = \mathsf{sort}([K, m, n, M, l])\\
\\
e^{\left(-n\right) - \ell} \cdot \cos \left(\left(m + n\right) \cdot \left(K \cdot 0.5\right)\right)
\end{array}
Initial program 72.0%
*-un-lft-identity72.0%
*-commutative72.0%
Applied egg-rr20.5%
Taylor expanded in n around 0 25.8%
+-commutative25.8%
unpow225.8%
distribute-rgt-out27.1%
Simplified27.1%
Taylor expanded in m around 0 31.3%
associate-*r*31.3%
neg-mul-131.3%
+-commutative31.3%
Simplified31.3%
Taylor expanded in M around 0 37.2%
*-commutative37.2%
+-commutative37.2%
distribute-neg-in37.2%
unsub-neg37.2%
associate-*r*37.2%
Simplified37.2%
Final simplification37.2%
herbie shell --seed 2024060
(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)))))))