
(FPCore (K m n M l) :precision binary64 (* (cos (- (/ (* K (+ m n)) 2.0) M)) (exp (- (- (pow (- (/ (+ m n) 2.0) M) 2.0)) (- l (fabs (- m n)))))))
double code(double K, double m, double n, double M, double l) {
return cos((((K * (m + n)) / 2.0) - M)) * exp((-pow((((m + n) / 2.0) - M), 2.0) - (l - fabs((m - n)))));
}
real(8) function code(k, m, n, m_1, l)
real(8), intent (in) :: k
real(8), intent (in) :: m
real(8), intent (in) :: n
real(8), intent (in) :: m_1
real(8), intent (in) :: l
code = cos((((k * (m + n)) / 2.0d0) - m_1)) * exp((-((((m + n) / 2.0d0) - m_1) ** 2.0d0) - (l - abs((m - n)))))
end function
public static double code(double K, double m, double n, double M, double l) {
return Math.cos((((K * (m + n)) / 2.0) - M)) * Math.exp((-Math.pow((((m + n) / 2.0) - M), 2.0) - (l - Math.abs((m - n)))));
}
def code(K, m, n, M, l): return math.cos((((K * (m + n)) / 2.0) - M)) * math.exp((-math.pow((((m + n) / 2.0) - M), 2.0) - (l - math.fabs((m - n)))))
function code(K, m, n, M, l) return Float64(cos(Float64(Float64(Float64(K * Float64(m + n)) / 2.0) - M)) * exp(Float64(Float64(-(Float64(Float64(Float64(m + n) / 2.0) - M) ^ 2.0)) - Float64(l - abs(Float64(m - n)))))) end
function tmp = code(K, m, n, M, l) tmp = cos((((K * (m + n)) / 2.0) - M)) * exp((-((((m + n) / 2.0) - M) ^ 2.0) - (l - abs((m - n))))); end
code[K_, m_, n_, M_, l_] := N[(N[Cos[N[(N[(N[(K * N[(m + n), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision] - M), $MachinePrecision]], $MachinePrecision] * N[Exp[N[((-N[Power[N[(N[(N[(m + n), $MachinePrecision] / 2.0), $MachinePrecision] - M), $MachinePrecision], 2.0], $MachinePrecision]) - N[(l - N[Abs[N[(m - n), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\cos \left(\frac{K \cdot \left(m + n\right)}{2} - M\right) \cdot e^{\left(-{\left(\frac{m + n}{2} - M\right)}^{2}\right) - \left(\ell - \left|m - n\right|\right)}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 11 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (K m n M l) :precision binary64 (* (cos (- (/ (* K (+ m n)) 2.0) M)) (exp (- (- (pow (- (/ (+ m n) 2.0) M) 2.0)) (- l (fabs (- m n)))))))
double code(double K, double m, double n, double M, double l) {
return cos((((K * (m + n)) / 2.0) - M)) * exp((-pow((((m + n) / 2.0) - M), 2.0) - (l - fabs((m - n)))));
}
real(8) function code(k, m, n, m_1, l)
real(8), intent (in) :: k
real(8), intent (in) :: m
real(8), intent (in) :: n
real(8), intent (in) :: m_1
real(8), intent (in) :: l
code = cos((((k * (m + n)) / 2.0d0) - m_1)) * exp((-((((m + n) / 2.0d0) - m_1) ** 2.0d0) - (l - abs((m - n)))))
end function
public static double code(double K, double m, double n, double M, double l) {
return Math.cos((((K * (m + n)) / 2.0) - M)) * Math.exp((-Math.pow((((m + n) / 2.0) - M), 2.0) - (l - Math.abs((m - n)))));
}
def code(K, m, n, M, l): return math.cos((((K * (m + n)) / 2.0) - M)) * math.exp((-math.pow((((m + n) / 2.0) - M), 2.0) - (l - math.fabs((m - n)))))
function code(K, m, n, M, l) return Float64(cos(Float64(Float64(Float64(K * Float64(m + n)) / 2.0) - M)) * exp(Float64(Float64(-(Float64(Float64(Float64(m + n) / 2.0) - M) ^ 2.0)) - Float64(l - abs(Float64(m - n)))))) end
function tmp = code(K, m, n, M, l) tmp = cos((((K * (m + n)) / 2.0) - M)) * exp((-((((m + n) / 2.0) - M) ^ 2.0) - (l - abs((m - n))))); end
code[K_, m_, n_, M_, l_] := N[(N[Cos[N[(N[(N[(K * N[(m + n), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision] - M), $MachinePrecision]], $MachinePrecision] * N[Exp[N[((-N[Power[N[(N[(N[(m + n), $MachinePrecision] / 2.0), $MachinePrecision] - M), $MachinePrecision], 2.0], $MachinePrecision]) - N[(l - N[Abs[N[(m - n), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\cos \left(\frac{K \cdot \left(m + n\right)}{2} - M\right) \cdot e^{\left(-{\left(\frac{m + n}{2} - M\right)}^{2}\right) - \left(\ell - \left|m - n\right|\right)}
\end{array}
NOTE: K, m, n, M, and l should be sorted in increasing order before calling this function.
(FPCore (K m n M l)
:precision binary64
(if (<= m -2.7e+49)
(* (cos M) (exp (* (pow m 2.0) -0.25)))
(*
(cos M)
(exp (+ (* (- (* n 0.5) M) (- (- M (* n 0.5)) m)) (- (fabs (- m 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 (m <= -2.7e+49) {
tmp = cos(M) * exp((pow(m, 2.0) * -0.25));
} else {
tmp = cos(M) * exp(((((n * 0.5) - M) * ((M - (n * 0.5)) - m)) + (fabs((m - 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 (m <= (-2.7d+49)) then
tmp = cos(m_1) * exp(((m ** 2.0d0) * (-0.25d0)))
else
tmp = cos(m_1) * exp(((((n * 0.5d0) - m_1) * ((m_1 - (n * 0.5d0)) - m)) + (abs((m - 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 (m <= -2.7e+49) {
tmp = Math.cos(M) * Math.exp((Math.pow(m, 2.0) * -0.25));
} else {
tmp = Math.cos(M) * Math.exp(((((n * 0.5) - M) * ((M - (n * 0.5)) - m)) + (Math.abs((m - 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 m <= -2.7e+49: tmp = math.cos(M) * math.exp((math.pow(m, 2.0) * -0.25)) else: tmp = math.cos(M) * math.exp(((((n * 0.5) - M) * ((M - (n * 0.5)) - m)) + (math.fabs((m - 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 (m <= -2.7e+49) tmp = Float64(cos(M) * exp(Float64((m ^ 2.0) * -0.25))); else tmp = Float64(cos(M) * exp(Float64(Float64(Float64(Float64(n * 0.5) - M) * Float64(Float64(M - Float64(n * 0.5)) - m)) + Float64(abs(Float64(m - 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 (m <= -2.7e+49)
tmp = cos(M) * exp(((m ^ 2.0) * -0.25));
else
tmp = cos(M) * exp(((((n * 0.5) - M) * ((M - (n * 0.5)) - m)) + (abs((m - 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[LessEqual[m, -2.7e+49], N[(N[Cos[M], $MachinePrecision] * N[Exp[N[(N[Power[m, 2.0], $MachinePrecision] * -0.25), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(N[Cos[M], $MachinePrecision] * N[Exp[N[(N[(N[(N[(n * 0.5), $MachinePrecision] - M), $MachinePrecision] * N[(N[(M - N[(n * 0.5), $MachinePrecision]), $MachinePrecision] - m), $MachinePrecision]), $MachinePrecision] + N[(N[Abs[N[(m - n), $MachinePrecision]], $MachinePrecision] - l), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[K, m, n, M, l] = \mathsf{sort}([K, m, n, M, l])\\
\\
\begin{array}{l}
\mathbf{if}\;m \leq -2.7 \cdot 10^{+49}:\\
\;\;\;\;\cos M \cdot e^{{m}^{2} \cdot -0.25}\\
\mathbf{else}:\\
\;\;\;\;\cos M \cdot e^{\left(n \cdot 0.5 - M\right) \cdot \left(\left(M - n \cdot 0.5\right) - m\right) + \left(\left|m - n\right| - \ell\right)}\\
\end{array}
\end{array}
if m < -2.7000000000000001e49Initial program 67.9%
Taylor expanded in K around 0 100.0%
cos-neg100.0%
Simplified100.0%
Taylor expanded in n around 0 77.4%
+-commutative77.4%
unpow277.4%
distribute-rgt-out88.9%
*-commutative88.9%
*-commutative88.9%
Simplified88.9%
Taylor expanded in m around inf 100.0%
*-commutative100.0%
Simplified100.0%
if -2.7000000000000001e49 < m Initial program 75.5%
Taylor expanded in K around 0 94.6%
cos-neg94.6%
Simplified94.6%
Taylor expanded in m around 0 81.9%
+-commutative81.9%
unpow281.9%
distribute-rgt-out87.4%
*-commutative87.4%
*-commutative87.4%
Simplified87.4%
Final simplification90.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 (* (cos M) (exp (- (- (fabs (- m n)) 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((m - n)) - 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((m - n)) - 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((m - n)) - 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((m - n)) - 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(m - n)) - 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((m - n)) - 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[(m - n), $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|m - n\right| - \ell\right) - {\left(\frac{m + n}{2} - M\right)}^{2}}
\end{array}
Initial program 73.9%
Taylor expanded in K around 0 95.8%
cos-neg95.8%
Simplified95.8%
Final simplification95.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 (<= m -0.3)
(* (cos M) (exp (* (pow m 2.0) -0.25)))
(if (<= m 2.3e-86)
(* (cos M) (exp (+ (* M (- n M)) (- (fabs (- m n)) l))))
(*
(cos M)
(exp (* (pow m 2.0) (- (/ (- (* 0.5 (- M n)) (* M -0.5)) m) 0.25)))))))assert(K < m && m < n && n < M && M < l);
double code(double K, double m, double n, double M, double l) {
double tmp;
if (m <= -0.3) {
tmp = cos(M) * exp((pow(m, 2.0) * -0.25));
} else if (m <= 2.3e-86) {
tmp = cos(M) * exp(((M * (n - M)) + (fabs((m - n)) - l)));
} else {
tmp = cos(M) * exp((pow(m, 2.0) * ((((0.5 * (M - n)) - (M * -0.5)) / m) - 0.25)));
}
return tmp;
}
NOTE: K, m, n, M, and l should be sorted in increasing order before calling this function.
real(8) function code(k, m, n, m_1, l)
real(8), intent (in) :: k
real(8), intent (in) :: m
real(8), intent (in) :: n
real(8), intent (in) :: m_1
real(8), intent (in) :: l
real(8) :: tmp
if (m <= (-0.3d0)) then
tmp = cos(m_1) * exp(((m ** 2.0d0) * (-0.25d0)))
else if (m <= 2.3d-86) then
tmp = cos(m_1) * exp(((m_1 * (n - m_1)) + (abs((m - n)) - l)))
else
tmp = cos(m_1) * exp(((m ** 2.0d0) * ((((0.5d0 * (m_1 - n)) - (m_1 * (-0.5d0))) / m) - 0.25d0)))
end if
code = tmp
end function
assert K < m && m < n && n < M && M < l;
public static double code(double K, double m, double n, double M, double l) {
double tmp;
if (m <= -0.3) {
tmp = Math.cos(M) * Math.exp((Math.pow(m, 2.0) * -0.25));
} else if (m <= 2.3e-86) {
tmp = Math.cos(M) * Math.exp(((M * (n - M)) + (Math.abs((m - n)) - l)));
} else {
tmp = Math.cos(M) * Math.exp((Math.pow(m, 2.0) * ((((0.5 * (M - n)) - (M * -0.5)) / m) - 0.25)));
}
return tmp;
}
[K, m, n, M, l] = sort([K, m, n, M, l]) def code(K, m, n, M, l): tmp = 0 if m <= -0.3: tmp = math.cos(M) * math.exp((math.pow(m, 2.0) * -0.25)) elif m <= 2.3e-86: tmp = math.cos(M) * math.exp(((M * (n - M)) + (math.fabs((m - n)) - l))) else: tmp = math.cos(M) * math.exp((math.pow(m, 2.0) * ((((0.5 * (M - n)) - (M * -0.5)) / m) - 0.25))) return tmp
K, m, n, M, l = sort([K, m, n, M, l]) function code(K, m, n, M, l) tmp = 0.0 if (m <= -0.3) tmp = Float64(cos(M) * exp(Float64((m ^ 2.0) * -0.25))); elseif (m <= 2.3e-86) tmp = Float64(cos(M) * exp(Float64(Float64(M * Float64(n - M)) + Float64(abs(Float64(m - n)) - l)))); else tmp = Float64(cos(M) * exp(Float64((m ^ 2.0) * Float64(Float64(Float64(Float64(0.5 * Float64(M - n)) - Float64(M * -0.5)) / m) - 0.25)))); end return tmp end
K, m, n, M, l = num2cell(sort([K, m, n, M, l])){:}
function tmp_2 = code(K, m, n, M, l)
tmp = 0.0;
if (m <= -0.3)
tmp = cos(M) * exp(((m ^ 2.0) * -0.25));
elseif (m <= 2.3e-86)
tmp = cos(M) * exp(((M * (n - M)) + (abs((m - n)) - l)));
else
tmp = cos(M) * exp(((m ^ 2.0) * ((((0.5 * (M - n)) - (M * -0.5)) / m) - 0.25)));
end
tmp_2 = tmp;
end
NOTE: K, m, n, M, and l should be sorted in increasing order before calling this function. code[K_, m_, n_, M_, l_] := If[LessEqual[m, -0.3], N[(N[Cos[M], $MachinePrecision] * N[Exp[N[(N[Power[m, 2.0], $MachinePrecision] * -0.25), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[m, 2.3e-86], N[(N[Cos[M], $MachinePrecision] * N[Exp[N[(N[(M * N[(n - M), $MachinePrecision]), $MachinePrecision] + N[(N[Abs[N[(m - n), $MachinePrecision]], $MachinePrecision] - l), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(N[Cos[M], $MachinePrecision] * N[Exp[N[(N[Power[m, 2.0], $MachinePrecision] * N[(N[(N[(N[(0.5 * N[(M - n), $MachinePrecision]), $MachinePrecision] - N[(M * -0.5), $MachinePrecision]), $MachinePrecision] / m), $MachinePrecision] - 0.25), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
[K, m, n, M, l] = \mathsf{sort}([K, m, n, M, l])\\
\\
\begin{array}{l}
\mathbf{if}\;m \leq -0.3:\\
\;\;\;\;\cos M \cdot e^{{m}^{2} \cdot -0.25}\\
\mathbf{elif}\;m \leq 2.3 \cdot 10^{-86}:\\
\;\;\;\;\cos M \cdot e^{M \cdot \left(n - M\right) + \left(\left|m - n\right| - \ell\right)}\\
\mathbf{else}:\\
\;\;\;\;\cos M \cdot e^{{m}^{2} \cdot \left(\frac{0.5 \cdot \left(M - n\right) - M \cdot -0.5}{m} - 0.25\right)}\\
\end{array}
\end{array}
if m < -0.299999999999999989Initial program 64.8%
Taylor expanded in K around 0 97.2%
cos-neg97.2%
Simplified97.2%
Taylor expanded in n around 0 72.0%
+-commutative72.0%
unpow272.0%
distribute-rgt-out81.9%
*-commutative81.9%
*-commutative81.9%
Simplified81.9%
Taylor expanded in m around inf 97.2%
*-commutative97.2%
Simplified97.2%
if -0.299999999999999989 < m < 2.29999999999999996e-86Initial program 80.4%
Taylor expanded in K around 0 94.7%
cos-neg94.7%
Simplified94.7%
Taylor expanded in n around 0 65.4%
+-commutative65.4%
unpow265.4%
distribute-rgt-out67.2%
*-commutative67.2%
*-commutative67.2%
Simplified67.2%
Taylor expanded in m around 0 67.2%
associate--r+67.2%
associate-*r*67.2%
neg-mul-167.2%
cancel-sign-sub67.2%
Simplified67.2%
if 2.29999999999999996e-86 < m Initial program 73.0%
Taylor expanded in K around 0 95.9%
cos-neg95.9%
Simplified95.9%
Taylor expanded in n around 0 73.2%
+-commutative73.2%
unpow273.2%
distribute-rgt-out76.0%
*-commutative76.0%
*-commutative76.0%
Simplified76.0%
Taylor expanded in m around inf 60.1%
Final simplification73.5%
NOTE: K, m, n, M, and l should be sorted in increasing order before calling this function.
(FPCore (K m n M l)
:precision binary64
(let* ((t_0 (- M (* m 0.5))))
(if (<= M 1.16e-14)
(* (cos M) (exp (- (- (fabs (- m n)) l) (* t_0 (- t_0 n)))))
(* (cos M) (exp (- (pow M 2.0)))))))assert(K < m && m < n && n < M && M < l);
double code(double K, double m, double n, double M, double l) {
double t_0 = M - (m * 0.5);
double tmp;
if (M <= 1.16e-14) {
tmp = cos(M) * exp(((fabs((m - n)) - l) - (t_0 * (t_0 - n))));
} else {
tmp = cos(M) * exp(-pow(M, 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) :: tmp
t_0 = m_1 - (m * 0.5d0)
if (m_1 <= 1.16d-14) then
tmp = cos(m_1) * exp(((abs((m - n)) - l) - (t_0 * (t_0 - n))))
else
tmp = cos(m_1) * exp(-(m_1 ** 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 - (m * 0.5);
double tmp;
if (M <= 1.16e-14) {
tmp = Math.cos(M) * Math.exp(((Math.abs((m - n)) - l) - (t_0 * (t_0 - n))));
} else {
tmp = Math.cos(M) * Math.exp(-Math.pow(M, 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 - (m * 0.5) tmp = 0 if M <= 1.16e-14: tmp = math.cos(M) * math.exp(((math.fabs((m - n)) - l) - (t_0 * (t_0 - n)))) else: tmp = math.cos(M) * math.exp(-math.pow(M, 2.0)) return tmp
K, m, n, M, l = sort([K, m, n, M, l]) function code(K, m, n, M, l) t_0 = Float64(M - Float64(m * 0.5)) tmp = 0.0 if (M <= 1.16e-14) tmp = Float64(cos(M) * exp(Float64(Float64(abs(Float64(m - n)) - l) - Float64(t_0 * Float64(t_0 - n))))); else tmp = Float64(cos(M) * exp(Float64(-(M ^ 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 - (m * 0.5);
tmp = 0.0;
if (M <= 1.16e-14)
tmp = cos(M) * exp(((abs((m - n)) - l) - (t_0 * (t_0 - n))));
else
tmp = cos(M) * exp(-(M ^ 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[(M - N[(m * 0.5), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[M, 1.16e-14], N[(N[Cos[M], $MachinePrecision] * N[Exp[N[(N[(N[Abs[N[(m - n), $MachinePrecision]], $MachinePrecision] - l), $MachinePrecision] - N[(t$95$0 * N[(t$95$0 - n), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(N[Cos[M], $MachinePrecision] * N[Exp[(-N[Power[M, 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 - m \cdot 0.5\\
\mathbf{if}\;M \leq 1.16 \cdot 10^{-14}:\\
\;\;\;\;\cos M \cdot e^{\left(\left|m - n\right| - \ell\right) - t\_0 \cdot \left(t\_0 - n\right)}\\
\mathbf{else}:\\
\;\;\;\;\cos M \cdot e^{-{M}^{2}}\\
\end{array}
\end{array}
if M < 1.16000000000000007e-14Initial program 71.5%
Taylor expanded in K around 0 94.1%
cos-neg94.1%
Simplified94.1%
Taylor expanded in n around 0 66.3%
+-commutative66.3%
unpow266.3%
distribute-rgt-out70.2%
*-commutative70.2%
*-commutative70.2%
Simplified70.2%
if 1.16000000000000007e-14 < M Initial program 80.3%
Taylor expanded in K around 0 100.0%
cos-neg100.0%
Simplified100.0%
Taylor expanded in n around 0 77.7%
+-commutative77.7%
unpow277.7%
distribute-rgt-out83.4%
*-commutative83.4%
*-commutative83.4%
Simplified83.4%
Taylor expanded in M around inf 98.6%
mul-1-neg98.6%
Simplified98.6%
Final simplification78.1%
NOTE: K, m, n, M, and l should be sorted in increasing order before calling this function.
(FPCore (K m n M l)
:precision binary64
(let* ((t_0 (* (cos M) (exp (- (pow M 2.0))))))
(if (<= m -0.3)
(* (cos M) (exp (* (pow m 2.0) -0.25)))
(if (<= m -1.52e-294)
t_0
(if (<= m 1.15e-244)
(* (cos M) (exp (- l)))
(if (<= m 5.2e-37) t_0 (* (cos M) (exp (* n (- M (* m 0.5)))))))))))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(-pow(M, 2.0));
double tmp;
if (m <= -0.3) {
tmp = cos(M) * exp((pow(m, 2.0) * -0.25));
} else if (m <= -1.52e-294) {
tmp = t_0;
} else if (m <= 1.15e-244) {
tmp = cos(M) * exp(-l);
} else if (m <= 5.2e-37) {
tmp = t_0;
} else {
tmp = cos(M) * exp((n * (M - (m * 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) :: t_0
real(8) :: tmp
t_0 = cos(m_1) * exp(-(m_1 ** 2.0d0))
if (m <= (-0.3d0)) then
tmp = cos(m_1) * exp(((m ** 2.0d0) * (-0.25d0)))
else if (m <= (-1.52d-294)) then
tmp = t_0
else if (m <= 1.15d-244) then
tmp = cos(m_1) * exp(-l)
else if (m <= 5.2d-37) then
tmp = t_0
else
tmp = cos(m_1) * exp((n * (m_1 - (m * 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 t_0 = Math.cos(M) * Math.exp(-Math.pow(M, 2.0));
double tmp;
if (m <= -0.3) {
tmp = Math.cos(M) * Math.exp((Math.pow(m, 2.0) * -0.25));
} else if (m <= -1.52e-294) {
tmp = t_0;
} else if (m <= 1.15e-244) {
tmp = Math.cos(M) * Math.exp(-l);
} else if (m <= 5.2e-37) {
tmp = t_0;
} else {
tmp = Math.cos(M) * Math.exp((n * (M - (m * 0.5))));
}
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(-math.pow(M, 2.0)) tmp = 0 if m <= -0.3: tmp = math.cos(M) * math.exp((math.pow(m, 2.0) * -0.25)) elif m <= -1.52e-294: tmp = t_0 elif m <= 1.15e-244: tmp = math.cos(M) * math.exp(-l) elif m <= 5.2e-37: tmp = t_0 else: tmp = math.cos(M) * math.exp((n * (M - (m * 0.5)))) 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(Float64(-(M ^ 2.0)))) tmp = 0.0 if (m <= -0.3) tmp = Float64(cos(M) * exp(Float64((m ^ 2.0) * -0.25))); elseif (m <= -1.52e-294) tmp = t_0; elseif (m <= 1.15e-244) tmp = Float64(cos(M) * exp(Float64(-l))); elseif (m <= 5.2e-37) tmp = t_0; else tmp = Float64(cos(M) * exp(Float64(n * Float64(M - Float64(m * 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)
t_0 = cos(M) * exp(-(M ^ 2.0));
tmp = 0.0;
if (m <= -0.3)
tmp = cos(M) * exp(((m ^ 2.0) * -0.25));
elseif (m <= -1.52e-294)
tmp = t_0;
elseif (m <= 1.15e-244)
tmp = cos(M) * exp(-l);
elseif (m <= 5.2e-37)
tmp = t_0;
else
tmp = cos(M) * exp((n * (M - (m * 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_] := Block[{t$95$0 = N[(N[Cos[M], $MachinePrecision] * N[Exp[(-N[Power[M, 2.0], $MachinePrecision])], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[m, -0.3], N[(N[Cos[M], $MachinePrecision] * N[Exp[N[(N[Power[m, 2.0], $MachinePrecision] * -0.25), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[m, -1.52e-294], t$95$0, If[LessEqual[m, 1.15e-244], N[(N[Cos[M], $MachinePrecision] * N[Exp[(-l)], $MachinePrecision]), $MachinePrecision], If[LessEqual[m, 5.2e-37], t$95$0, N[(N[Cos[M], $MachinePrecision] * N[Exp[N[(n * N[(M - N[(m * 0.5), $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 := \cos M \cdot e^{-{M}^{2}}\\
\mathbf{if}\;m \leq -0.3:\\
\;\;\;\;\cos M \cdot e^{{m}^{2} \cdot -0.25}\\
\mathbf{elif}\;m \leq -1.52 \cdot 10^{-294}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;m \leq 1.15 \cdot 10^{-244}:\\
\;\;\;\;\cos M \cdot e^{-\ell}\\
\mathbf{elif}\;m \leq 5.2 \cdot 10^{-37}:\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;\cos M \cdot e^{n \cdot \left(M - m \cdot 0.5\right)}\\
\end{array}
\end{array}
if m < -0.299999999999999989Initial program 64.8%
Taylor expanded in K around 0 97.2%
cos-neg97.2%
Simplified97.2%
Taylor expanded in n around 0 72.0%
+-commutative72.0%
unpow272.0%
distribute-rgt-out81.9%
*-commutative81.9%
*-commutative81.9%
Simplified81.9%
Taylor expanded in m around inf 97.2%
*-commutative97.2%
Simplified97.2%
if -0.299999999999999989 < m < -1.52000000000000007e-294 or 1.15e-244 < m < 5.19999999999999959e-37Initial program 83.8%
Taylor expanded in K around 0 95.1%
cos-neg95.1%
Simplified95.1%
Taylor expanded in n around 0 63.2%
+-commutative63.2%
unpow263.2%
distribute-rgt-out65.2%
*-commutative65.2%
*-commutative65.2%
Simplified65.2%
Taylor expanded in M around inf 66.5%
mul-1-neg66.5%
Simplified66.5%
if -1.52000000000000007e-294 < m < 1.15e-244Initial program 73.6%
Taylor expanded in n around 0 64.7%
+-commutative73.2%
unpow273.2%
distribute-rgt-out73.2%
*-commutative73.2%
*-commutative73.2%
Simplified64.7%
Taylor expanded in l around inf 60.4%
mul-1-neg60.4%
Simplified60.4%
Taylor expanded in K around 0 73.4%
cos-neg73.4%
Simplified73.4%
if 5.19999999999999959e-37 < m Initial program 68.8%
Taylor expanded in K around 0 95.3%
cos-neg95.3%
Simplified95.3%
Taylor expanded in n around 0 75.2%
+-commutative75.2%
unpow275.2%
distribute-rgt-out78.4%
*-commutative78.4%
*-commutative78.4%
Simplified78.4%
Taylor expanded in n around inf 44.8%
Final simplification70.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 (<= m -0.3)
(* (cos M) (exp (* (pow m 2.0) -0.25)))
(if (<= m 1.02e-75)
(* (cos M) (exp (+ (* M (- n M)) (- (fabs (- m n)) l))))
(* (cos M) (exp (* n (- M (* m 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 (m <= -0.3) {
tmp = cos(M) * exp((pow(m, 2.0) * -0.25));
} else if (m <= 1.02e-75) {
tmp = cos(M) * exp(((M * (n - M)) + (fabs((m - n)) - l)));
} else {
tmp = cos(M) * exp((n * (M - (m * 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 (m <= (-0.3d0)) then
tmp = cos(m_1) * exp(((m ** 2.0d0) * (-0.25d0)))
else if (m <= 1.02d-75) then
tmp = cos(m_1) * exp(((m_1 * (n - m_1)) + (abs((m - n)) - l)))
else
tmp = cos(m_1) * exp((n * (m_1 - (m * 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 (m <= -0.3) {
tmp = Math.cos(M) * Math.exp((Math.pow(m, 2.0) * -0.25));
} else if (m <= 1.02e-75) {
tmp = Math.cos(M) * Math.exp(((M * (n - M)) + (Math.abs((m - n)) - l)));
} else {
tmp = Math.cos(M) * Math.exp((n * (M - (m * 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 m <= -0.3: tmp = math.cos(M) * math.exp((math.pow(m, 2.0) * -0.25)) elif m <= 1.02e-75: tmp = math.cos(M) * math.exp(((M * (n - M)) + (math.fabs((m - n)) - l))) else: tmp = math.cos(M) * math.exp((n * (M - (m * 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 (m <= -0.3) tmp = Float64(cos(M) * exp(Float64((m ^ 2.0) * -0.25))); elseif (m <= 1.02e-75) tmp = Float64(cos(M) * exp(Float64(Float64(M * Float64(n - M)) + Float64(abs(Float64(m - n)) - l)))); else tmp = Float64(cos(M) * exp(Float64(n * Float64(M - Float64(m * 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 (m <= -0.3)
tmp = cos(M) * exp(((m ^ 2.0) * -0.25));
elseif (m <= 1.02e-75)
tmp = cos(M) * exp(((M * (n - M)) + (abs((m - n)) - l)));
else
tmp = cos(M) * exp((n * (M - (m * 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[LessEqual[m, -0.3], N[(N[Cos[M], $MachinePrecision] * N[Exp[N[(N[Power[m, 2.0], $MachinePrecision] * -0.25), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[m, 1.02e-75], N[(N[Cos[M], $MachinePrecision] * N[Exp[N[(N[(M * N[(n - M), $MachinePrecision]), $MachinePrecision] + N[(N[Abs[N[(m - n), $MachinePrecision]], $MachinePrecision] - l), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(N[Cos[M], $MachinePrecision] * N[Exp[N[(n * N[(M - N[(m * 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
[K, m, n, M, l] = \mathsf{sort}([K, m, n, M, l])\\
\\
\begin{array}{l}
\mathbf{if}\;m \leq -0.3:\\
\;\;\;\;\cos M \cdot e^{{m}^{2} \cdot -0.25}\\
\mathbf{elif}\;m \leq 1.02 \cdot 10^{-75}:\\
\;\;\;\;\cos M \cdot e^{M \cdot \left(n - M\right) + \left(\left|m - n\right| - \ell\right)}\\
\mathbf{else}:\\
\;\;\;\;\cos M \cdot e^{n \cdot \left(M - m \cdot 0.5\right)}\\
\end{array}
\end{array}
if m < -0.299999999999999989Initial program 64.8%
Taylor expanded in K around 0 97.2%
cos-neg97.2%
Simplified97.2%
Taylor expanded in n around 0 72.0%
+-commutative72.0%
unpow272.0%
distribute-rgt-out81.9%
*-commutative81.9%
*-commutative81.9%
Simplified81.9%
Taylor expanded in m around inf 97.2%
*-commutative97.2%
Simplified97.2%
if -0.299999999999999989 < m < 1.01999999999999997e-75Initial program 81.0%
Taylor expanded in K around 0 94.9%
cos-neg94.9%
Simplified94.9%
Taylor expanded in n around 0 65.7%
+-commutative65.7%
unpow265.7%
distribute-rgt-out67.5%
*-commutative67.5%
*-commutative67.5%
Simplified67.5%
Taylor expanded in m around 0 67.5%
associate--r+67.5%
associate-*r*67.5%
neg-mul-167.5%
cancel-sign-sub67.5%
Simplified67.5%
if 1.01999999999999997e-75 < m Initial program 71.4%
Taylor expanded in K around 0 95.7%
cos-neg95.7%
Simplified95.7%
Taylor expanded in n around 0 73.1%
+-commutative73.1%
unpow273.1%
distribute-rgt-out76.0%
*-commutative76.0%
*-commutative76.0%
Simplified76.0%
Taylor expanded in n around inf 46.7%
Final simplification70.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
(if (<= l -0.0004)
(* (cos M) (exp l))
(if (<= l 720.0)
(* (cos M) (exp (- (pow M 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 (l <= -0.0004) {
tmp = cos(M) * exp(l);
} else if (l <= 720.0) {
tmp = cos(M) * exp(-pow(M, 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 (l <= (-0.0004d0)) then
tmp = cos(m_1) * exp(l)
else if (l <= 720.0d0) then
tmp = cos(m_1) * exp(-(m_1 ** 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 (l <= -0.0004) {
tmp = Math.cos(M) * Math.exp(l);
} else if (l <= 720.0) {
tmp = Math.cos(M) * Math.exp(-Math.pow(M, 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 l <= -0.0004: tmp = math.cos(M) * math.exp(l) elif l <= 720.0: tmp = math.cos(M) * math.exp(-math.pow(M, 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 (l <= -0.0004) tmp = Float64(cos(M) * exp(l)); elseif (l <= 720.0) tmp = Float64(cos(M) * exp(Float64(-(M ^ 2.0)))); else tmp = Float64(cos(M) * exp(Float64(-l))); end return tmp end
K, m, n, M, l = num2cell(sort([K, m, n, M, l])){:}
function tmp_2 = code(K, m, n, M, l)
tmp = 0.0;
if (l <= -0.0004)
tmp = cos(M) * exp(l);
elseif (l <= 720.0)
tmp = cos(M) * exp(-(M ^ 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[LessEqual[l, -0.0004], N[(N[Cos[M], $MachinePrecision] * N[Exp[l], $MachinePrecision]), $MachinePrecision], If[LessEqual[l, 720.0], N[(N[Cos[M], $MachinePrecision] * N[Exp[(-N[Power[M, 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}\;\ell \leq -0.0004:\\
\;\;\;\;\cos M \cdot e^{\ell}\\
\mathbf{elif}\;\ell \leq 720:\\
\;\;\;\;\cos M \cdot e^{-{M}^{2}}\\
\mathbf{else}:\\
\;\;\;\;\cos M \cdot e^{-\ell}\\
\end{array}
\end{array}
if l < -4.00000000000000019e-4Initial program 67.6%
Taylor expanded in n around 0 51.6%
+-commutative65.0%
unpow265.0%
distribute-rgt-out69.5%
*-commutative69.5%
*-commutative69.5%
Simplified56.1%
Taylor expanded in l around inf 15.6%
mul-1-neg15.6%
Simplified15.6%
add-cube-cbrt15.6%
pow315.6%
Applied egg-rr50.4%
Taylor expanded in K around 0 75.4%
cos-neg75.4%
Simplified75.4%
if -4.00000000000000019e-4 < l < 720Initial program 76.6%
Taylor expanded in K around 0 96.0%
cos-neg96.0%
Simplified96.0%
Taylor expanded in n around 0 67.9%
+-commutative67.9%
unpow267.9%
distribute-rgt-out72.0%
*-commutative72.0%
*-commutative72.0%
Simplified72.0%
Taylor expanded in M around inf 62.8%
mul-1-neg62.8%
Simplified62.8%
if 720 < l Initial program 75.4%
Taylor expanded in n around 0 64.8%
+-commutative77.2%
unpow277.2%
distribute-rgt-out81.8%
*-commutative81.8%
*-commutative81.8%
Simplified66.3%
Taylor expanded in l around inf 75.4%
mul-1-neg75.4%
Simplified75.4%
Taylor expanded in K around 0 100.0%
cos-neg100.0%
Simplified100.0%
Final simplification75.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 (<= l -0.0004)
(* (cos M) (exp l))
(if (<= l 1.15e-5)
(* (cos M) (exp (* n (- M (* m 0.5)))))
(* (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 (l <= -0.0004) {
tmp = cos(M) * exp(l);
} else if (l <= 1.15e-5) {
tmp = cos(M) * exp((n * (M - (m * 0.5))));
} 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 (l <= (-0.0004d0)) then
tmp = cos(m_1) * exp(l)
else if (l <= 1.15d-5) then
tmp = cos(m_1) * exp((n * (m_1 - (m * 0.5d0))))
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 (l <= -0.0004) {
tmp = Math.cos(M) * Math.exp(l);
} else if (l <= 1.15e-5) {
tmp = Math.cos(M) * Math.exp((n * (M - (m * 0.5))));
} 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 l <= -0.0004: tmp = math.cos(M) * math.exp(l) elif l <= 1.15e-5: tmp = math.cos(M) * math.exp((n * (M - (m * 0.5)))) 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 (l <= -0.0004) tmp = Float64(cos(M) * exp(l)); elseif (l <= 1.15e-5) tmp = Float64(cos(M) * exp(Float64(n * Float64(M - Float64(m * 0.5))))); else tmp = Float64(cos(M) * exp(Float64(-l))); end return tmp end
K, m, n, M, l = num2cell(sort([K, m, n, M, l])){:}
function tmp_2 = code(K, m, n, M, l)
tmp = 0.0;
if (l <= -0.0004)
tmp = cos(M) * exp(l);
elseif (l <= 1.15e-5)
tmp = cos(M) * exp((n * (M - (m * 0.5))));
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[LessEqual[l, -0.0004], N[(N[Cos[M], $MachinePrecision] * N[Exp[l], $MachinePrecision]), $MachinePrecision], If[LessEqual[l, 1.15e-5], N[(N[Cos[M], $MachinePrecision] * N[Exp[N[(n * N[(M - N[(m * 0.5), $MachinePrecision]), $MachinePrecision]), $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}\;\ell \leq -0.0004:\\
\;\;\;\;\cos M \cdot e^{\ell}\\
\mathbf{elif}\;\ell \leq 1.15 \cdot 10^{-5}:\\
\;\;\;\;\cos M \cdot e^{n \cdot \left(M - m \cdot 0.5\right)}\\
\mathbf{else}:\\
\;\;\;\;\cos M \cdot e^{-\ell}\\
\end{array}
\end{array}
if l < -4.00000000000000019e-4Initial program 67.6%
Taylor expanded in n around 0 51.6%
+-commutative65.0%
unpow265.0%
distribute-rgt-out69.5%
*-commutative69.5%
*-commutative69.5%
Simplified56.1%
Taylor expanded in l around inf 15.6%
mul-1-neg15.6%
Simplified15.6%
add-cube-cbrt15.6%
pow315.6%
Applied egg-rr50.4%
Taylor expanded in K around 0 75.4%
cos-neg75.4%
Simplified75.4%
if -4.00000000000000019e-4 < l < 1.15e-5Initial program 76.4%
Taylor expanded in K around 0 96.0%
cos-neg96.0%
Simplified96.0%
Taylor expanded in n around 0 67.6%
+-commutative67.6%
unpow267.6%
distribute-rgt-out71.8%
*-commutative71.8%
*-commutative71.8%
Simplified71.8%
Taylor expanded in n around inf 45.2%
if 1.15e-5 < l Initial program 75.8%
Taylor expanded in n around 0 65.3%
+-commutative77.5%
unpow277.5%
distribute-rgt-out82.1%
*-commutative82.1%
*-commutative82.1%
Simplified66.8%
Taylor expanded in l around inf 74.3%
mul-1-neg74.3%
Simplified74.3%
Taylor expanded in K around 0 98.5%
cos-neg98.5%
Simplified98.5%
Final simplification67.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 (<= l -5e-227) (* (cos M) (exp l)) (* (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 (l <= -5e-227) {
tmp = cos(M) * exp(l);
} 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 (l <= (-5d-227)) then
tmp = cos(m_1) * exp(l)
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 (l <= -5e-227) {
tmp = Math.cos(M) * Math.exp(l);
} 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 l <= -5e-227: tmp = math.cos(M) * math.exp(l) 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 (l <= -5e-227) tmp = Float64(cos(M) * exp(l)); else tmp = Float64(cos(M) * exp(Float64(-l))); end return tmp end
K, m, n, M, l = num2cell(sort([K, m, n, M, l])){:}
function tmp_2 = code(K, m, n, M, l)
tmp = 0.0;
if (l <= -5e-227)
tmp = cos(M) * exp(l);
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[LessEqual[l, -5e-227], N[(N[Cos[M], $MachinePrecision] * N[Exp[l], $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}\;\ell \leq -5 \cdot 10^{-227}:\\
\;\;\;\;\cos M \cdot e^{\ell}\\
\mathbf{else}:\\
\;\;\;\;\cos M \cdot e^{-\ell}\\
\end{array}
\end{array}
if l < -4.99999999999999961e-227Initial program 68.2%
Taylor expanded in n around 0 52.7%
+-commutative66.1%
unpow266.1%
distribute-rgt-out69.7%
*-commutative69.7%
*-commutative69.7%
Simplified56.2%
Taylor expanded in l around inf 13.8%
mul-1-neg13.8%
Simplified13.8%
add-cube-cbrt13.8%
pow313.8%
Applied egg-rr34.4%
Taylor expanded in K around 0 48.9%
cos-neg48.9%
Simplified48.9%
if -4.99999999999999961e-227 < l Initial program 78.6%
Taylor expanded in n around 0 63.1%
+-commutative72.2%
unpow272.2%
distribute-rgt-out77.2%
*-commutative77.2%
*-commutative77.2%
Simplified66.0%
Taylor expanded in l around inf 41.3%
mul-1-neg41.3%
Simplified41.3%
Taylor expanded in K around 0 52.7%
cos-neg52.7%
Simplified52.7%
Final simplification51.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 (* (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])\\
\\
\cos M \cdot e^{\ell}
\end{array}
Initial program 73.9%
Taylor expanded in n around 0 58.4%
+-commutative69.5%
unpow269.5%
distribute-rgt-out73.8%
*-commutative73.8%
*-commutative73.8%
Simplified61.6%
Taylor expanded in l around inf 29.0%
mul-1-neg29.0%
Simplified29.0%
add-cube-cbrt29.0%
pow329.0%
Applied egg-rr19.4%
Taylor expanded in K around 0 26.0%
cos-neg26.0%
Simplified26.0%
Final simplification26.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 (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(Float64(-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 \left(-M\right)
\end{array}
Initial program 73.9%
Taylor expanded in n around 0 58.4%
+-commutative69.5%
unpow269.5%
distribute-rgt-out73.8%
*-commutative73.8%
*-commutative73.8%
Simplified61.6%
Taylor expanded in l around inf 29.0%
mul-1-neg29.0%
Simplified29.0%
Taylor expanded in l around 0 6.9%
associate-*r*6.9%
fma-neg6.9%
+-commutative6.9%
*-lft-identity6.9%
metadata-eval6.9%
cancel-sign-sub-inv6.9%
fma-neg6.9%
associate-*r*6.9%
associate-*r*6.9%
fma-neg6.9%
cancel-sign-sub-inv6.9%
metadata-eval6.9%
*-lft-identity6.9%
+-commutative6.9%
*-lft-identity6.9%
metadata-eval6.9%
cancel-sign-sub-inv6.9%
fma-neg6.9%
Simplified6.9%
Taylor expanded in K around 0 7.1%
neg-mul-17.1%
Simplified7.1%
Final simplification7.1%
herbie shell --seed 2024071
(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)))))))