
(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 12 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 (- (* m 0.5) M)))
(if (<= n 8.6e+42)
(* (cos M) (exp (- (fma t_0 (+ n t_0) (- m (- n l))))))
(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 * 0.5) - M;
double tmp;
if (n <= 8.6e+42) {
tmp = cos(M) * exp(-fma(t_0, (n + t_0), (m - (n - l))));
} else {
tmp = exp((-0.25 * 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 * 0.5) - M) tmp = 0.0 if (n <= 8.6e+42) tmp = Float64(cos(M) * exp(Float64(-fma(t_0, Float64(n + t_0), Float64(m - Float64(n - l)))))); else tmp = exp(Float64(-0.25 * (n ^ 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[(m * 0.5), $MachinePrecision] - M), $MachinePrecision]}, If[LessEqual[n, 8.6e+42], N[(N[Cos[M], $MachinePrecision] * N[Exp[(-N[(t$95$0 * N[(n + t$95$0), $MachinePrecision] + N[(m - N[(n - l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision])], $MachinePrecision]), $MachinePrecision], N[Exp[N[(-0.25 * N[Power[n, 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]
\begin{array}{l}
[K, m, n, M, l] = \mathsf{sort}([K, m, n, M, l])\\
\\
\begin{array}{l}
t_0 := m \cdot 0.5 - M\\
\mathbf{if}\;n \leq 8.6 \cdot 10^{+42}:\\
\;\;\;\;\cos M \cdot e^{-\mathsf{fma}\left(t\_0, n + t\_0, m - \left(n - \ell\right)\right)}\\
\mathbf{else}:\\
\;\;\;\;e^{-0.25 \cdot {n}^{2}}\\
\end{array}
\end{array}
if n < 8.5999999999999996e42Initial program 71.9%
Taylor expanded in K around 0 96.8%
cos-neg96.8%
Simplified96.8%
Taylor expanded in n around 0 79.1%
+-commutative79.1%
unpow279.1%
distribute-rgt-out85.3%
*-commutative85.3%
*-commutative85.3%
Simplified85.3%
sub-neg85.3%
exp-sum32.6%
distribute-rgt-neg-in32.6%
exp-prod33.2%
associate-+l-33.2%
fabs-sub33.2%
Applied egg-rr33.2%
Applied egg-rr90.9%
rec-exp90.9%
fma-define90.9%
*-commutative90.9%
associate-+l-90.9%
+-commutative90.9%
*-commutative90.9%
associate--r-90.9%
Simplified90.9%
if 8.5999999999999996e42 < n Initial program 66.0%
Taylor expanded in K around 0 100.0%
cos-neg100.0%
Simplified100.0%
Taylor expanded in n around inf 100.0%
Taylor expanded in M around 0 100.0%
Final simplification92.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 (- (- (fabs (- n m)) l) (pow (- (/ (+ m n) 2.0) M) 2.0)))))
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(((fabs((n - m)) - l) - pow((((m + n) / 2.0) - M), 2.0)));
}
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(((abs((n - m)) - l) - ((((m + n) / 2.0d0) - m_1) ** 2.0d0)))
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(((Math.abs((n - m)) - l) - Math.pow((((m + n) / 2.0) - M), 2.0)));
}
[K, m, n, M, l] = sort([K, m, n, M, l]) def code(K, m, n, M, l): return math.cos(M) * math.exp(((math.fabs((n - m)) - l) - math.pow((((m + n) / 2.0) - M), 2.0)))
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(abs(Float64(n - m)) - l) - (Float64(Float64(Float64(m + n) / 2.0) - M) ^ 2.0)))) 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(((abs((n - m)) - l) - ((((m + n) / 2.0) - M) ^ 2.0)));
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[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]), $MachinePrecision]
\begin{array}{l}
[K, m, n, M, l] = \mathsf{sort}([K, m, n, M, l])\\
\\
\cos M \cdot e^{\left(\left|n - m\right| - \ell\right) - {\left(\frac{m + n}{2} - M\right)}^{2}}
\end{array}
Initial program 70.8%
Taylor expanded in K around 0 97.4%
cos-neg97.4%
Simplified97.4%
Final simplification97.4%
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 5e+41)
(*
(cos M)
(/ 1.0 (exp (+ (* (- (* m 0.5) M) (+ (* m 0.5) (- n M))) (+ l (- m n))))))
(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 <= 5e+41) {
tmp = cos(M) * (1.0 / exp(((((m * 0.5) - M) * ((m * 0.5) + (n - M))) + (l + (m - n)))));
} else {
tmp = 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 <= 5d+41) then
tmp = cos(m_1) * (1.0d0 / exp(((((m * 0.5d0) - m_1) * ((m * 0.5d0) + (n - m_1))) + (l + (m - n)))))
else
tmp = 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 <= 5e+41) {
tmp = Math.cos(M) * (1.0 / Math.exp(((((m * 0.5) - M) * ((m * 0.5) + (n - M))) + (l + (m - n)))));
} else {
tmp = 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 <= 5e+41: tmp = math.cos(M) * (1.0 / math.exp(((((m * 0.5) - M) * ((m * 0.5) + (n - M))) + (l + (m - n))))) else: tmp = 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 <= 5e+41) tmp = Float64(cos(M) * Float64(1.0 / exp(Float64(Float64(Float64(Float64(m * 0.5) - M) * Float64(Float64(m * 0.5) + Float64(n - M))) + Float64(l + Float64(m - n)))))); else tmp = 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 <= 5e+41)
tmp = cos(M) * (1.0 / exp(((((m * 0.5) - M) * ((m * 0.5) + (n - M))) + (l + (m - n)))));
else
tmp = 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, 5e+41], N[(N[Cos[M], $MachinePrecision] * N[(1.0 / N[Exp[N[(N[(N[(N[(m * 0.5), $MachinePrecision] - M), $MachinePrecision] * N[(N[(m * 0.5), $MachinePrecision] + N[(n - M), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(l + N[(m - n), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[Exp[N[(-0.25 * N[Power[n, 2.0], $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 5 \cdot 10^{+41}:\\
\;\;\;\;\cos M \cdot \frac{1}{e^{\left(m \cdot 0.5 - M\right) \cdot \left(m \cdot 0.5 + \left(n - M\right)\right) + \left(\ell + \left(m - n\right)\right)}}\\
\mathbf{else}:\\
\;\;\;\;e^{-0.25 \cdot {n}^{2}}\\
\end{array}
\end{array}
if n < 5.00000000000000022e41Initial program 71.9%
Taylor expanded in K around 0 96.8%
cos-neg96.8%
Simplified96.8%
Taylor expanded in n around 0 79.1%
+-commutative79.1%
unpow279.1%
distribute-rgt-out85.3%
*-commutative85.3%
*-commutative85.3%
Simplified85.3%
sub-neg85.3%
exp-sum32.6%
distribute-rgt-neg-in32.6%
exp-prod33.2%
associate-+l-33.2%
fabs-sub33.2%
Applied egg-rr33.2%
Applied egg-rr90.9%
if 5.00000000000000022e41 < n Initial program 66.0%
Taylor expanded in K around 0 100.0%
cos-neg100.0%
Simplified100.0%
Taylor expanded in n around inf 100.0%
Taylor expanded in M around 0 100.0%
Final simplification92.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
(let* ((t_0 (/ (cos M) (exp l))) (t_1 (exp (* -0.25 (pow n 2.0)))))
(if (<= n -0.0014)
t_1
(if (<= n -1.45e-159)
t_0
(if (<= n 2e-157)
(* (pow n 2.0) (* (cos M) -0.25))
(if (<= n 2.55e-6) 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 = cos(M) / exp(l);
double t_1 = exp((-0.25 * pow(n, 2.0)));
double tmp;
if (n <= -0.0014) {
tmp = t_1;
} else if (n <= -1.45e-159) {
tmp = t_0;
} else if (n <= 2e-157) {
tmp = pow(n, 2.0) * (cos(M) * -0.25);
} else if (n <= 2.55e-6) {
tmp = 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 = cos(m_1) / exp(l)
t_1 = exp(((-0.25d0) * (n ** 2.0d0)))
if (n <= (-0.0014d0)) then
tmp = t_1
else if (n <= (-1.45d-159)) then
tmp = t_0
else if (n <= 2d-157) then
tmp = (n ** 2.0d0) * (cos(m_1) * (-0.25d0))
else if (n <= 2.55d-6) then
tmp = 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.cos(M) / Math.exp(l);
double t_1 = Math.exp((-0.25 * Math.pow(n, 2.0)));
double tmp;
if (n <= -0.0014) {
tmp = t_1;
} else if (n <= -1.45e-159) {
tmp = t_0;
} else if (n <= 2e-157) {
tmp = Math.pow(n, 2.0) * (Math.cos(M) * -0.25);
} else if (n <= 2.55e-6) {
tmp = 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.cos(M) / math.exp(l) t_1 = math.exp((-0.25 * math.pow(n, 2.0))) tmp = 0 if n <= -0.0014: tmp = t_1 elif n <= -1.45e-159: tmp = t_0 elif n <= 2e-157: tmp = math.pow(n, 2.0) * (math.cos(M) * -0.25) elif n <= 2.55e-6: tmp = 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(cos(M) / exp(l)) t_1 = exp(Float64(-0.25 * (n ^ 2.0))) tmp = 0.0 if (n <= -0.0014) tmp = t_1; elseif (n <= -1.45e-159) tmp = t_0; elseif (n <= 2e-157) tmp = Float64((n ^ 2.0) * Float64(cos(M) * -0.25)); elseif (n <= 2.55e-6) tmp = 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 = cos(M) / exp(l);
t_1 = exp((-0.25 * (n ^ 2.0)));
tmp = 0.0;
if (n <= -0.0014)
tmp = t_1;
elseif (n <= -1.45e-159)
tmp = t_0;
elseif (n <= 2e-157)
tmp = (n ^ 2.0) * (cos(M) * -0.25);
elseif (n <= 2.55e-6)
tmp = 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[Cos[M], $MachinePrecision] / N[Exp[l], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[Exp[N[(-0.25 * N[Power[n, 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[n, -0.0014], t$95$1, If[LessEqual[n, -1.45e-159], t$95$0, If[LessEqual[n, 2e-157], N[(N[Power[n, 2.0], $MachinePrecision] * N[(N[Cos[M], $MachinePrecision] * -0.25), $MachinePrecision]), $MachinePrecision], If[LessEqual[n, 2.55e-6], t$95$0, t$95$1]]]]]]
\begin{array}{l}
[K, m, n, M, l] = \mathsf{sort}([K, m, n, M, l])\\
\\
\begin{array}{l}
t_0 := \frac{\cos M}{e^{\ell}}\\
t_1 := e^{-0.25 \cdot {n}^{2}}\\
\mathbf{if}\;n \leq -0.0014:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;n \leq -1.45 \cdot 10^{-159}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;n \leq 2 \cdot 10^{-157}:\\
\;\;\;\;{n}^{2} \cdot \left(\cos M \cdot -0.25\right)\\
\mathbf{elif}\;n \leq 2.55 \cdot 10^{-6}:\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if n < -0.00139999999999999999 or 2.5500000000000001e-6 < n Initial program 64.9%
Taylor expanded in K around 0 99.2%
cos-neg99.2%
Simplified99.2%
Taylor expanded in n around inf 92.8%
Taylor expanded in M around 0 92.8%
if -0.00139999999999999999 < n < -1.44999999999999995e-159 or 1.99999999999999989e-157 < n < 2.5500000000000001e-6Initial program 72.8%
Taylor expanded in K around 0 95.2%
cos-neg95.2%
Simplified95.2%
Taylor expanded in l around inf 44.1%
neg-mul-144.1%
Simplified44.1%
Taylor expanded in l around -inf 44.1%
neg-mul-144.1%
rem-exp-log36.7%
exp-sum36.7%
unsub-neg36.7%
exp-diff36.7%
rem-exp-log44.1%
Simplified44.1%
if -1.44999999999999995e-159 < n < 1.99999999999999989e-157Initial program 80.9%
Taylor expanded in K around 0 95.8%
cos-neg95.8%
Simplified95.8%
Taylor expanded in n around inf 10.0%
Taylor expanded in n around 0 10.0%
associate-*r*10.0%
distribute-rgt1-in10.0%
Simplified10.0%
Taylor expanded in n around inf 80.6%
associate-*r*80.6%
*-commutative80.6%
associate-*l*80.6%
Simplified80.6%
Final simplification78.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
(let* ((t_0 (exp (* -0.25 (pow n 2.0)))))
(if (<= n -1.15e+21)
t_0
(if (<= n -4.2e-157)
(* (cos M) (exp (* n (- M (* m 0.5)))))
(if (<= n 1.04e-158)
(* (pow n 2.0) (* (cos M) -0.25))
(if (<= n 2.55e-6) (/ (cos M) (exp l)) 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 = exp((-0.25 * pow(n, 2.0)));
double tmp;
if (n <= -1.15e+21) {
tmp = t_0;
} else if (n <= -4.2e-157) {
tmp = cos(M) * exp((n * (M - (m * 0.5))));
} else if (n <= 1.04e-158) {
tmp = pow(n, 2.0) * (cos(M) * -0.25);
} else if (n <= 2.55e-6) {
tmp = cos(M) / exp(l);
} else {
tmp = 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 = exp(((-0.25d0) * (n ** 2.0d0)))
if (n <= (-1.15d+21)) then
tmp = t_0
else if (n <= (-4.2d-157)) then
tmp = cos(m_1) * exp((n * (m_1 - (m * 0.5d0))))
else if (n <= 1.04d-158) then
tmp = (n ** 2.0d0) * (cos(m_1) * (-0.25d0))
else if (n <= 2.55d-6) then
tmp = cos(m_1) / exp(l)
else
tmp = 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.exp((-0.25 * Math.pow(n, 2.0)));
double tmp;
if (n <= -1.15e+21) {
tmp = t_0;
} else if (n <= -4.2e-157) {
tmp = Math.cos(M) * Math.exp((n * (M - (m * 0.5))));
} else if (n <= 1.04e-158) {
tmp = Math.pow(n, 2.0) * (Math.cos(M) * -0.25);
} else if (n <= 2.55e-6) {
tmp = Math.cos(M) / Math.exp(l);
} else {
tmp = 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.exp((-0.25 * math.pow(n, 2.0))) tmp = 0 if n <= -1.15e+21: tmp = t_0 elif n <= -4.2e-157: tmp = math.cos(M) * math.exp((n * (M - (m * 0.5)))) elif n <= 1.04e-158: tmp = math.pow(n, 2.0) * (math.cos(M) * -0.25) elif n <= 2.55e-6: tmp = math.cos(M) / math.exp(l) else: tmp = t_0 return tmp
K, m, n, M, l = sort([K, m, n, M, l]) function code(K, m, n, M, l) t_0 = exp(Float64(-0.25 * (n ^ 2.0))) tmp = 0.0 if (n <= -1.15e+21) tmp = t_0; elseif (n <= -4.2e-157) tmp = Float64(cos(M) * exp(Float64(n * Float64(M - Float64(m * 0.5))))); elseif (n <= 1.04e-158) tmp = Float64((n ^ 2.0) * Float64(cos(M) * -0.25)); elseif (n <= 2.55e-6) tmp = Float64(cos(M) / exp(l)); else tmp = 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 = exp((-0.25 * (n ^ 2.0)));
tmp = 0.0;
if (n <= -1.15e+21)
tmp = t_0;
elseif (n <= -4.2e-157)
tmp = cos(M) * exp((n * (M - (m * 0.5))));
elseif (n <= 1.04e-158)
tmp = (n ^ 2.0) * (cos(M) * -0.25);
elseif (n <= 2.55e-6)
tmp = cos(M) / exp(l);
else
tmp = 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[Exp[N[(-0.25 * N[Power[n, 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[n, -1.15e+21], t$95$0, If[LessEqual[n, -4.2e-157], N[(N[Cos[M], $MachinePrecision] * N[Exp[N[(n * N[(M - N[(m * 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[n, 1.04e-158], N[(N[Power[n, 2.0], $MachinePrecision] * N[(N[Cos[M], $MachinePrecision] * -0.25), $MachinePrecision]), $MachinePrecision], If[LessEqual[n, 2.55e-6], N[(N[Cos[M], $MachinePrecision] / N[Exp[l], $MachinePrecision]), $MachinePrecision], t$95$0]]]]]
\begin{array}{l}
[K, m, n, M, l] = \mathsf{sort}([K, m, n, M, l])\\
\\
\begin{array}{l}
t_0 := e^{-0.25 \cdot {n}^{2}}\\
\mathbf{if}\;n \leq -1.15 \cdot 10^{+21}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;n \leq -4.2 \cdot 10^{-157}:\\
\;\;\;\;\cos M \cdot e^{n \cdot \left(M - m \cdot 0.5\right)}\\
\mathbf{elif}\;n \leq 1.04 \cdot 10^{-158}:\\
\;\;\;\;{n}^{2} \cdot \left(\cos M \cdot -0.25\right)\\
\mathbf{elif}\;n \leq 2.55 \cdot 10^{-6}:\\
\;\;\;\;\frac{\cos M}{e^{\ell}}\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if n < -1.15e21 or 2.5500000000000001e-6 < n Initial program 65.3%
Taylor expanded in K around 0 99.2%
cos-neg99.2%
Simplified99.2%
Taylor expanded in n around inf 93.5%
Taylor expanded in M around 0 93.5%
if -1.15e21 < n < -4.2e-157Initial program 74.2%
Taylor expanded in K around 0 94.7%
cos-neg94.7%
Simplified94.7%
Taylor expanded in n around 0 90.6%
+-commutative90.6%
unpow290.6%
distribute-rgt-out90.6%
*-commutative90.6%
*-commutative90.6%
Simplified90.6%
Taylor expanded in n around inf 45.7%
if -4.2e-157 < n < 1.0399999999999999e-158Initial program 80.9%
Taylor expanded in K around 0 95.8%
cos-neg95.8%
Simplified95.8%
Taylor expanded in n around inf 10.0%
Taylor expanded in n around 0 10.0%
associate-*r*10.0%
distribute-rgt1-in10.0%
Simplified10.0%
Taylor expanded in n around inf 80.6%
associate-*r*80.6%
*-commutative80.6%
associate-*l*80.6%
Simplified80.6%
if 1.0399999999999999e-158 < n < 2.5500000000000001e-6Initial program 67.2%
Taylor expanded in K around 0 97.0%
cos-neg97.0%
Simplified97.0%
Taylor expanded in l around inf 36.8%
neg-mul-136.8%
Simplified36.8%
Taylor expanded in l around -inf 36.8%
neg-mul-136.8%
rem-exp-log23.9%
exp-sum23.9%
unsub-neg23.9%
exp-diff23.9%
rem-exp-log36.8%
Simplified36.8%
Final simplification76.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 6.8e+43) (* (cos M) (exp (- (* (- (* m 0.5) M) (- (- M (* m 0.5)) n)) l))) (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 <= 6.8e+43) {
tmp = cos(M) * exp(((((m * 0.5) - M) * ((M - (m * 0.5)) - n)) - l));
} else {
tmp = 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 <= 6.8d+43) then
tmp = cos(m_1) * exp(((((m * 0.5d0) - m_1) * ((m_1 - (m * 0.5d0)) - n)) - l))
else
tmp = 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 <= 6.8e+43) {
tmp = Math.cos(M) * Math.exp(((((m * 0.5) - M) * ((M - (m * 0.5)) - n)) - l));
} else {
tmp = 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 <= 6.8e+43: tmp = math.cos(M) * math.exp(((((m * 0.5) - M) * ((M - (m * 0.5)) - n)) - l)) else: tmp = 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 <= 6.8e+43) tmp = Float64(cos(M) * exp(Float64(Float64(Float64(Float64(m * 0.5) - M) * Float64(Float64(M - Float64(m * 0.5)) - n)) - l))); else tmp = 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 <= 6.8e+43)
tmp = cos(M) * exp(((((m * 0.5) - M) * ((M - (m * 0.5)) - n)) - l));
else
tmp = 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, 6.8e+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] - l), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[Exp[N[(-0.25 * N[Power[n, 2.0], $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 6.8 \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) - \ell}\\
\mathbf{else}:\\
\;\;\;\;e^{-0.25 \cdot {n}^{2}}\\
\end{array}
\end{array}
if n < 6.80000000000000024e43Initial program 71.9%
Taylor expanded in K around 0 96.8%
cos-neg96.8%
Simplified96.8%
Taylor expanded in n around 0 79.1%
+-commutative79.1%
unpow279.1%
distribute-rgt-out85.3%
*-commutative85.3%
*-commutative85.3%
Simplified85.3%
Taylor expanded in l around inf 87.0%
if 6.80000000000000024e43 < n Initial program 66.0%
Taylor expanded in K around 0 100.0%
cos-neg100.0%
Simplified100.0%
Taylor expanded in n around inf 100.0%
Taylor expanded in M around 0 100.0%
Final simplification89.4%
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.65e-272)
(* (cos M) (exp (- (* (* m 0.5) (- (- n) (* m 0.5))) l)))
(if (<= n 1.1e+27)
(* (cos M) (exp (- (* M (- n M)) l)))
(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.65e-272) {
tmp = cos(M) * exp((((m * 0.5) * (-n - (m * 0.5))) - l));
} else if (n <= 1.1e+27) {
tmp = cos(M) * exp(((M * (n - M)) - l));
} else {
tmp = 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.65d-272)) then
tmp = cos(m_1) * exp((((m * 0.5d0) * (-n - (m * 0.5d0))) - l))
else if (n <= 1.1d+27) then
tmp = cos(m_1) * exp(((m_1 * (n - m_1)) - l))
else
tmp = 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.65e-272) {
tmp = Math.cos(M) * Math.exp((((m * 0.5) * (-n - (m * 0.5))) - l));
} else if (n <= 1.1e+27) {
tmp = Math.cos(M) * Math.exp(((M * (n - M)) - l));
} else {
tmp = 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.65e-272: tmp = math.cos(M) * math.exp((((m * 0.5) * (-n - (m * 0.5))) - l)) elif n <= 1.1e+27: tmp = math.cos(M) * math.exp(((M * (n - M)) - l)) else: tmp = 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.65e-272) tmp = Float64(cos(M) * exp(Float64(Float64(Float64(m * 0.5) * Float64(Float64(-n) - Float64(m * 0.5))) - l))); elseif (n <= 1.1e+27) tmp = Float64(cos(M) * exp(Float64(Float64(M * Float64(n - M)) - l))); else tmp = 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.65e-272)
tmp = cos(M) * exp((((m * 0.5) * (-n - (m * 0.5))) - l));
elseif (n <= 1.1e+27)
tmp = cos(M) * exp(((M * (n - M)) - l));
else
tmp = 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.65e-272], N[(N[Cos[M], $MachinePrecision] * N[Exp[N[(N[(N[(m * 0.5), $MachinePrecision] * N[((-n) - N[(m * 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - l), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[n, 1.1e+27], N[(N[Cos[M], $MachinePrecision] * N[Exp[N[(N[(M * N[(n - M), $MachinePrecision]), $MachinePrecision] - l), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[Exp[N[(-0.25 * N[Power[n, 2.0], $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.65 \cdot 10^{-272}:\\
\;\;\;\;\cos M \cdot e^{\left(m \cdot 0.5\right) \cdot \left(\left(-n\right) - m \cdot 0.5\right) - \ell}\\
\mathbf{elif}\;n \leq 1.1 \cdot 10^{+27}:\\
\;\;\;\;\cos M \cdot e^{M \cdot \left(n - M\right) - \ell}\\
\mathbf{else}:\\
\;\;\;\;e^{-0.25 \cdot {n}^{2}}\\
\end{array}
\end{array}
if n < -2.65e-272Initial program 70.9%
Taylor expanded in K around 0 97.9%
cos-neg97.9%
Simplified97.9%
Taylor expanded in n around 0 69.5%
+-commutative69.5%
unpow269.5%
distribute-rgt-out79.0%
*-commutative79.0%
*-commutative79.0%
Simplified79.0%
Taylor expanded in l around inf 82.0%
Taylor expanded in M around 0 69.4%
associate-*r*69.4%
*-commutative69.4%
*-commutative69.4%
Simplified69.4%
if -2.65e-272 < n < 1.0999999999999999e27Initial program 74.5%
Taylor expanded in K around 0 95.1%
cos-neg95.1%
Simplified95.1%
Taylor expanded in n around 0 93.9%
+-commutative93.9%
unpow293.9%
distribute-rgt-out95.1%
*-commutative95.1%
*-commutative95.1%
Simplified95.1%
Taylor expanded in l around inf 94.6%
Taylor expanded in m around 0 77.8%
neg-sub077.8%
+-commutative77.8%
associate--r+77.8%
neg-sub077.8%
mul-1-neg77.8%
remove-double-neg77.8%
Simplified77.8%
if 1.0999999999999999e27 < n Initial program 64.6%
Taylor expanded in K around 0 100.0%
cos-neg100.0%
Simplified100.0%
Taylor expanded in n around inf 100.0%
Taylor expanded in M around 0 100.0%
Final simplification77.8%
NOTE: K, m, n, M, and l should be sorted in increasing order before calling this function. (FPCore (K m n M l) :precision binary64 (if (or (<= n -0.0014) (not (<= n 2.55e-6))) (exp (* -0.25 (pow n 2.0))) (/ (cos M) (exp l))))
assert(K < m && m < n && n < M && M < l);
double code(double K, double m, double n, double M, double l) {
double tmp;
if ((n <= -0.0014) || !(n <= 2.55e-6)) {
tmp = exp((-0.25 * pow(n, 2.0)));
} else {
tmp = cos(M) / exp(l);
}
return tmp;
}
NOTE: K, m, n, M, and l should be sorted in increasing order before calling this function.
real(8) function code(k, m, n, m_1, l)
real(8), intent (in) :: k
real(8), intent (in) :: m
real(8), intent (in) :: n
real(8), intent (in) :: m_1
real(8), intent (in) :: l
real(8) :: tmp
if ((n <= (-0.0014d0)) .or. (.not. (n <= 2.55d-6))) then
tmp = exp(((-0.25d0) * (n ** 2.0d0)))
else
tmp = cos(m_1) / exp(l)
end if
code = tmp
end function
assert K < m && m < n && n < M && M < l;
public static double code(double K, double m, double n, double M, double l) {
double tmp;
if ((n <= -0.0014) || !(n <= 2.55e-6)) {
tmp = Math.exp((-0.25 * Math.pow(n, 2.0)));
} else {
tmp = Math.cos(M) / Math.exp(l);
}
return tmp;
}
[K, m, n, M, l] = sort([K, m, n, M, l]) def code(K, m, n, M, l): tmp = 0 if (n <= -0.0014) or not (n <= 2.55e-6): tmp = math.exp((-0.25 * math.pow(n, 2.0))) else: tmp = math.cos(M) / math.exp(l) return tmp
K, m, n, M, l = sort([K, m, n, M, l]) function code(K, m, n, M, l) tmp = 0.0 if ((n <= -0.0014) || !(n <= 2.55e-6)) tmp = exp(Float64(-0.25 * (n ^ 2.0))); else tmp = Float64(cos(M) / exp(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 ((n <= -0.0014) || ~((n <= 2.55e-6)))
tmp = exp((-0.25 * (n ^ 2.0)));
else
tmp = cos(M) / exp(l);
end
tmp_2 = tmp;
end
NOTE: K, m, n, M, and l should be sorted in increasing order before calling this function. code[K_, m_, n_, M_, l_] := If[Or[LessEqual[n, -0.0014], N[Not[LessEqual[n, 2.55e-6]], $MachinePrecision]], N[Exp[N[(-0.25 * N[Power[n, 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[(N[Cos[M], $MachinePrecision] / N[Exp[l], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[K, m, n, M, l] = \mathsf{sort}([K, m, n, M, l])\\
\\
\begin{array}{l}
\mathbf{if}\;n \leq -0.0014 \lor \neg \left(n \leq 2.55 \cdot 10^{-6}\right):\\
\;\;\;\;e^{-0.25 \cdot {n}^{2}}\\
\mathbf{else}:\\
\;\;\;\;\frac{\cos M}{e^{\ell}}\\
\end{array}
\end{array}
if n < -0.00139999999999999999 or 2.5500000000000001e-6 < n Initial program 64.9%
Taylor expanded in K around 0 99.2%
cos-neg99.2%
Simplified99.2%
Taylor expanded in n around inf 92.8%
Taylor expanded in M around 0 92.8%
if -0.00139999999999999999 < n < 2.5500000000000001e-6Initial program 77.1%
Taylor expanded in K around 0 95.5%
cos-neg95.5%
Simplified95.5%
Taylor expanded in l around inf 42.8%
neg-mul-142.8%
Simplified42.8%
Taylor expanded in l around -inf 42.8%
neg-mul-142.8%
rem-exp-log31.8%
exp-sum31.8%
unsub-neg31.8%
exp-diff31.8%
rem-exp-log42.8%
Simplified42.8%
Final simplification68.4%
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.4e+29) (* (cos M) (exp (- (* M (- n M)) l))) (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.4e+29) {
tmp = cos(M) * exp(((M * (n - M)) - l));
} else {
tmp = 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.4d+29) then
tmp = cos(m_1) * exp(((m_1 * (n - m_1)) - l))
else
tmp = 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.4e+29) {
tmp = Math.cos(M) * Math.exp(((M * (n - M)) - l));
} else {
tmp = 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.4e+29: tmp = math.cos(M) * math.exp(((M * (n - M)) - l)) else: tmp = 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.4e+29) tmp = Float64(cos(M) * exp(Float64(Float64(M * Float64(n - M)) - l))); else tmp = 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.4e+29)
tmp = cos(M) * exp(((M * (n - M)) - l));
else
tmp = 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.4e+29], N[(N[Cos[M], $MachinePrecision] * N[Exp[N[(N[(M * N[(n - M), $MachinePrecision]), $MachinePrecision] - l), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[Exp[N[(-0.25 * N[Power[n, 2.0], $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.4 \cdot 10^{+29}:\\
\;\;\;\;\cos M \cdot e^{M \cdot \left(n - M\right) - \ell}\\
\mathbf{else}:\\
\;\;\;\;e^{-0.25 \cdot {n}^{2}}\\
\end{array}
\end{array}
if n < 2.4000000000000001e29Initial program 72.3%
Taylor expanded in K around 0 96.8%
cos-neg96.8%
Simplified96.8%
Taylor expanded in n around 0 79.0%
+-commutative79.0%
unpow279.0%
distribute-rgt-out85.2%
*-commutative85.2%
*-commutative85.2%
Simplified85.2%
Taylor expanded in l around inf 86.9%
Taylor expanded in m around 0 74.3%
neg-sub074.3%
+-commutative74.3%
associate--r+74.3%
neg-sub074.3%
mul-1-neg74.3%
remove-double-neg74.3%
Simplified74.3%
if 2.4000000000000001e29 < n Initial program 64.6%
Taylor expanded in K around 0 100.0%
cos-neg100.0%
Simplified100.0%
Taylor expanded in n around inf 100.0%
Taylor expanded in M around 0 100.0%
Final simplification79.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 (/ (cos M) (exp l)))
assert(K < m && m < n && n < M && M < l);
double code(double K, double m, double n, double M, double l) {
return cos(M) / exp(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(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(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(l)
K, m, n, M, l = sort([K, m, n, M, l]) function code(K, m, n, M, l) return Float64(cos(M) / exp(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(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[l], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
[K, m, n, M, l] = \mathsf{sort}([K, m, n, M, l])\\
\\
\frac{\cos M}{e^{\ell}}
\end{array}
Initial program 70.8%
Taylor expanded in K around 0 97.4%
cos-neg97.4%
Simplified97.4%
Taylor expanded in l around inf 37.5%
neg-mul-137.5%
Simplified37.5%
Taylor expanded in l around -inf 37.5%
neg-mul-137.5%
rem-exp-log26.8%
exp-sum26.8%
unsub-neg26.8%
exp-diff26.8%
rem-exp-log37.5%
Simplified37.5%
Final simplification37.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 (exp (- l)))
assert(K < m && m < n && n < M && M < l);
double code(double K, double m, double n, double M, double l) {
return exp(-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 = exp(-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.exp(-l);
}
[K, m, n, M, l] = sort([K, m, n, M, l]) def code(K, m, n, M, l): return math.exp(-l)
K, m, n, M, l = sort([K, m, n, M, l]) function code(K, m, n, M, l) return exp(Float64(-l)) end
K, m, n, M, l = num2cell(sort([K, m, n, M, l])){:}
function tmp = code(K, m, n, M, l)
tmp = exp(-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[Exp[(-l)], $MachinePrecision]
\begin{array}{l}
[K, m, n, M, l] = \mathsf{sort}([K, m, n, M, l])\\
\\
e^{-\ell}
\end{array}
Initial program 70.8%
Taylor expanded in K around 0 97.4%
cos-neg97.4%
Simplified97.4%
Taylor expanded in l around inf 37.5%
neg-mul-137.5%
Simplified37.5%
Taylor expanded in M around 0 36.7%
Final simplification36.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 (cos M))
assert(K < m && m < n && n < M && M < l);
double code(double K, double m, double n, double M, double l) {
return cos(M);
}
NOTE: K, m, n, M, and l should be sorted in increasing order before calling this function.
real(8) function code(k, m, n, m_1, l)
real(8), intent (in) :: k
real(8), intent (in) :: m
real(8), intent (in) :: n
real(8), intent (in) :: m_1
real(8), intent (in) :: l
code = cos(m_1)
end function
assert K < m && m < n && n < M && M < l;
public static double code(double K, double m, double n, double M, double l) {
return Math.cos(M);
}
[K, m, n, M, l] = sort([K, m, n, M, l]) def code(K, m, n, M, l): return math.cos(M)
K, m, n, M, l = sort([K, m, n, M, l]) function code(K, m, n, M, l) return cos(M) end
K, m, n, M, l = num2cell(sort([K, m, n, M, l])){:}
function tmp = code(K, m, n, M, l)
tmp = cos(M);
end
NOTE: K, m, n, M, and l should be sorted in increasing order before calling this function. code[K_, m_, n_, M_, l_] := N[Cos[M], $MachinePrecision]
\begin{array}{l}
[K, m, n, M, l] = \mathsf{sort}([K, m, n, M, l])\\
\\
\cos M
\end{array}
Initial program 70.8%
Taylor expanded in K around 0 97.4%
cos-neg97.4%
Simplified97.4%
Taylor expanded in l around inf 37.5%
neg-mul-137.5%
Simplified37.5%
Taylor expanded in l around 0 7.2%
Final simplification7.2%
herbie shell --seed 2024050
(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)))))))