
(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 10 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}
(FPCore (K m n M l) :precision binary64 (* (cos M) (exp (- (- (fabs (- m n)) l) (pow (- (/ (+ m n) 2.0) M) 2.0)))))
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)));
}
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
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)));
}
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)))
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
function tmp = code(K, m, n, M, l) tmp = cos(M) * exp(((abs((m - n)) - l) - ((((m + n) / 2.0) - M) ^ 2.0))); end
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}
\\
\cos M \cdot e^{\left(\left|m - n\right| - \ell\right) - {\left(\frac{m + n}{2} - M\right)}^{2}}
\end{array}
Initial program 77.9%
Taylor expanded in K around 0 95.6%
cos-neg95.6%
Simplified95.6%
Final simplification95.6%
(FPCore (K m n M l)
:precision binary64
(let* ((t_0 (* (cos M) (exp (+ (* M (- m M)) (- (fabs (- m n)) l))))))
(if (<= m -18000.0)
(* (cos M) (exp (* (pow m 2.0) -0.25)))
(if (<= m -2.3e-189)
t_0
(if (<= m -6e-253)
(* (cos (* 0.5 (* m K))) (exp (- (- m n) l)))
(if (<= m 1.26e-247) t_0 (* (cos M) (exp (* -0.25 (pow n 2.0))))))))))
double code(double K, double m, double n, double M, double l) {
double t_0 = cos(M) * exp(((M * (m - M)) + (fabs((m - n)) - l)));
double tmp;
if (m <= -18000.0) {
tmp = cos(M) * exp((pow(m, 2.0) * -0.25));
} else if (m <= -2.3e-189) {
tmp = t_0;
} else if (m <= -6e-253) {
tmp = cos((0.5 * (m * K))) * exp(((m - n) - l));
} else if (m <= 1.26e-247) {
tmp = t_0;
} else {
tmp = cos(M) * exp((-0.25 * pow(n, 2.0)));
}
return tmp;
}
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 * (m - m_1)) + (abs((m - n)) - l)))
if (m <= (-18000.0d0)) then
tmp = cos(m_1) * exp(((m ** 2.0d0) * (-0.25d0)))
else if (m <= (-2.3d-189)) then
tmp = t_0
else if (m <= (-6d-253)) then
tmp = cos((0.5d0 * (m * k))) * exp(((m - n) - l))
else if (m <= 1.26d-247) then
tmp = t_0
else
tmp = cos(m_1) * exp(((-0.25d0) * (n ** 2.0d0)))
end if
code = tmp
end function
public static double code(double K, double m, double n, double M, double l) {
double t_0 = Math.cos(M) * Math.exp(((M * (m - M)) + (Math.abs((m - n)) - l)));
double tmp;
if (m <= -18000.0) {
tmp = Math.cos(M) * Math.exp((Math.pow(m, 2.0) * -0.25));
} else if (m <= -2.3e-189) {
tmp = t_0;
} else if (m <= -6e-253) {
tmp = Math.cos((0.5 * (m * K))) * Math.exp(((m - n) - l));
} else if (m <= 1.26e-247) {
tmp = t_0;
} else {
tmp = Math.cos(M) * Math.exp((-0.25 * Math.pow(n, 2.0)));
}
return tmp;
}
def code(K, m, n, M, l): t_0 = math.cos(M) * math.exp(((M * (m - M)) + (math.fabs((m - n)) - l))) tmp = 0 if m <= -18000.0: tmp = math.cos(M) * math.exp((math.pow(m, 2.0) * -0.25)) elif m <= -2.3e-189: tmp = t_0 elif m <= -6e-253: tmp = math.cos((0.5 * (m * K))) * math.exp(((m - n) - l)) elif m <= 1.26e-247: tmp = t_0 else: tmp = math.cos(M) * math.exp((-0.25 * math.pow(n, 2.0))) return tmp
function code(K, m, n, M, l) t_0 = Float64(cos(M) * exp(Float64(Float64(M * Float64(m - M)) + Float64(abs(Float64(m - n)) - l)))) tmp = 0.0 if (m <= -18000.0) tmp = Float64(cos(M) * exp(Float64((m ^ 2.0) * -0.25))); elseif (m <= -2.3e-189) tmp = t_0; elseif (m <= -6e-253) tmp = Float64(cos(Float64(0.5 * Float64(m * K))) * exp(Float64(Float64(m - n) - l))); elseif (m <= 1.26e-247) tmp = t_0; else tmp = Float64(cos(M) * exp(Float64(-0.25 * (n ^ 2.0)))); end return tmp end
function tmp_2 = code(K, m, n, M, l) t_0 = cos(M) * exp(((M * (m - M)) + (abs((m - n)) - l))); tmp = 0.0; if (m <= -18000.0) tmp = cos(M) * exp(((m ^ 2.0) * -0.25)); elseif (m <= -2.3e-189) tmp = t_0; elseif (m <= -6e-253) tmp = cos((0.5 * (m * K))) * exp(((m - n) - l)); elseif (m <= 1.26e-247) tmp = t_0; else tmp = cos(M) * exp((-0.25 * (n ^ 2.0))); end tmp_2 = tmp; end
code[K_, m_, n_, M_, l_] := Block[{t$95$0 = N[(N[Cos[M], $MachinePrecision] * N[Exp[N[(N[(M * N[(m - M), $MachinePrecision]), $MachinePrecision] + N[(N[Abs[N[(m - n), $MachinePrecision]], $MachinePrecision] - l), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[m, -18000.0], N[(N[Cos[M], $MachinePrecision] * N[Exp[N[(N[Power[m, 2.0], $MachinePrecision] * -0.25), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[m, -2.3e-189], t$95$0, If[LessEqual[m, -6e-253], N[(N[Cos[N[(0.5 * N[(m * K), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * N[Exp[N[(N[(m - n), $MachinePrecision] - l), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[m, 1.26e-247], t$95$0, N[(N[Cos[M], $MachinePrecision] * N[Exp[N[(-0.25 * N[Power[n, 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos M \cdot e^{M \cdot \left(m - M\right) + \left(\left|m - n\right| - \ell\right)}\\
\mathbf{if}\;m \leq -18000:\\
\;\;\;\;\cos M \cdot e^{{m}^{2} \cdot -0.25}\\
\mathbf{elif}\;m \leq -2.3 \cdot 10^{-189}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;m \leq -6 \cdot 10^{-253}:\\
\;\;\;\;\cos \left(0.5 \cdot \left(m \cdot K\right)\right) \cdot e^{\left(m - n\right) - \ell}\\
\mathbf{elif}\;m \leq 1.26 \cdot 10^{-247}:\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;\cos M \cdot e^{-0.25 \cdot {n}^{2}}\\
\end{array}
\end{array}
if m < -18000Initial program 73.2%
Taylor expanded in K around 0 98.2%
cos-neg98.2%
Simplified98.2%
Taylor expanded in m around inf 96.5%
*-commutative96.5%
Simplified96.5%
if -18000 < m < -2.2999999999999998e-189 or -6.0000000000000004e-253 < m < 1.25999999999999999e-247Initial program 87.4%
Taylor expanded in K around 0 94.8%
cos-neg94.8%
Simplified94.8%
Taylor expanded in m around 0 94.8%
+-commutative94.8%
unpow294.8%
distribute-rgt-out94.8%
*-commutative94.8%
*-commutative94.8%
Simplified94.8%
Taylor expanded in n around 0 78.4%
associate--r+78.4%
associate-*r*78.4%
neg-mul-178.4%
cancel-sign-sub78.4%
fabs-sub78.4%
Simplified78.4%
if -2.2999999999999998e-189 < m < -6.0000000000000004e-253Initial program 90.9%
associate--r-90.9%
add-sqr-sqrt0.0%
sqrt-unprod19.3%
sqr-neg19.3%
sqrt-unprod19.3%
add-sqr-sqrt19.3%
div-inv19.3%
metadata-eval19.3%
add-sqr-sqrt0.3%
fabs-sqr0.3%
add-sqr-sqrt19.3%
Applied egg-rr19.3%
Taylor expanded in m around inf 19.5%
*-commutative19.5%
Simplified19.5%
Taylor expanded in l around inf 91.1%
neg-mul-191.1%
Simplified91.1%
if 1.25999999999999999e-247 < m Initial program 73.1%
Taylor expanded in K around 0 94.4%
cos-neg94.4%
Simplified94.4%
Taylor expanded in n around inf 52.9%
*-commutative52.9%
Simplified52.9%
Final simplification71.2%
(FPCore (K m n M l) :precision binary64 (* (cos M) (exp (- (- (- m n) l) (pow (- (* (+ m n) 0.5) M) 2.0)))))
double code(double K, double m, double n, double M, double l) {
return cos(M) * exp((((m - n) - l) - pow((((m + n) * 0.5) - M), 2.0)));
}
real(8) function code(k, m, n, m_1, l)
real(8), intent (in) :: k
real(8), intent (in) :: m
real(8), intent (in) :: n
real(8), intent (in) :: m_1
real(8), intent (in) :: l
code = cos(m_1) * exp((((m - n) - l) - ((((m + n) * 0.5d0) - m_1) ** 2.0d0)))
end function
public static double code(double K, double m, double n, double M, double l) {
return Math.cos(M) * Math.exp((((m - n) - l) - Math.pow((((m + n) * 0.5) - M), 2.0)));
}
def code(K, m, n, M, l): return math.cos(M) * math.exp((((m - n) - l) - math.pow((((m + n) * 0.5) - M), 2.0)))
function code(K, m, n, M, l) return Float64(cos(M) * exp(Float64(Float64(Float64(m - n) - l) - (Float64(Float64(Float64(m + n) * 0.5) - M) ^ 2.0)))) end
function tmp = code(K, m, n, M, l) tmp = cos(M) * exp((((m - n) - l) - ((((m + n) * 0.5) - M) ^ 2.0))); end
code[K_, m_, n_, M_, l_] := N[(N[Cos[M], $MachinePrecision] * N[Exp[N[(N[(N[(m - n), $MachinePrecision] - l), $MachinePrecision] - N[Power[N[(N[(N[(m + n), $MachinePrecision] * 0.5), $MachinePrecision] - M), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\cos M \cdot e^{\left(\left(m - n\right) - \ell\right) - {\left(\left(m + n\right) \cdot 0.5 - M\right)}^{2}}
\end{array}
Initial program 77.9%
Taylor expanded in K around 0 95.6%
cos-neg95.6%
Simplified95.6%
sub-neg95.6%
distribute-neg-out95.6%
div-inv95.6%
metadata-eval95.6%
add-sqr-sqrt51.4%
fabs-sqr51.4%
add-sqr-sqrt95.6%
Applied egg-rr95.6%
+-commutative95.6%
distribute-neg-in95.6%
sub-neg95.6%
neg-sub095.6%
associate--r-95.6%
neg-sub095.6%
Simplified95.6%
Final simplification95.6%
(FPCore (K m n M l) :precision binary64 (if (or (<= M -16.0) (not (<= M 27.0))) (* (cos M) (exp (- (pow M 2.0)))) (* (cos (* 0.5 (* m K))) (exp (- (- m n) l)))))
double code(double K, double m, double n, double M, double l) {
double tmp;
if ((M <= -16.0) || !(M <= 27.0)) {
tmp = cos(M) * exp(-pow(M, 2.0));
} else {
tmp = cos((0.5 * (m * K))) * exp(((m - n) - l));
}
return tmp;
}
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_1 <= (-16.0d0)) .or. (.not. (m_1 <= 27.0d0))) then
tmp = cos(m_1) * exp(-(m_1 ** 2.0d0))
else
tmp = cos((0.5d0 * (m * k))) * exp(((m - n) - l))
end if
code = tmp
end function
public static double code(double K, double m, double n, double M, double l) {
double tmp;
if ((M <= -16.0) || !(M <= 27.0)) {
tmp = Math.cos(M) * Math.exp(-Math.pow(M, 2.0));
} else {
tmp = Math.cos((0.5 * (m * K))) * Math.exp(((m - n) - l));
}
return tmp;
}
def code(K, m, n, M, l): tmp = 0 if (M <= -16.0) or not (M <= 27.0): tmp = math.cos(M) * math.exp(-math.pow(M, 2.0)) else: tmp = math.cos((0.5 * (m * K))) * math.exp(((m - n) - l)) return tmp
function code(K, m, n, M, l) tmp = 0.0 if ((M <= -16.0) || !(M <= 27.0)) tmp = Float64(cos(M) * exp(Float64(-(M ^ 2.0)))); else tmp = Float64(cos(Float64(0.5 * Float64(m * K))) * exp(Float64(Float64(m - n) - l))); end return tmp end
function tmp_2 = code(K, m, n, M, l) tmp = 0.0; if ((M <= -16.0) || ~((M <= 27.0))) tmp = cos(M) * exp(-(M ^ 2.0)); else tmp = cos((0.5 * (m * K))) * exp(((m - n) - l)); end tmp_2 = tmp; end
code[K_, m_, n_, M_, l_] := If[Or[LessEqual[M, -16.0], N[Not[LessEqual[M, 27.0]], $MachinePrecision]], N[(N[Cos[M], $MachinePrecision] * N[Exp[(-N[Power[M, 2.0], $MachinePrecision])], $MachinePrecision]), $MachinePrecision], N[(N[Cos[N[(0.5 * N[(m * K), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * N[Exp[N[(N[(m - n), $MachinePrecision] - l), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;M \leq -16 \lor \neg \left(M \leq 27\right):\\
\;\;\;\;\cos M \cdot e^{-{M}^{2}}\\
\mathbf{else}:\\
\;\;\;\;\cos \left(0.5 \cdot \left(m \cdot K\right)\right) \cdot e^{\left(m - n\right) - \ell}\\
\end{array}
\end{array}
if M < -16 or 27 < M Initial program 78.2%
Taylor expanded in K around 0 100.0%
cos-neg100.0%
Simplified100.0%
Taylor expanded in M around inf 98.4%
mul-1-neg98.4%
Simplified98.4%
if -16 < M < 27Initial program 77.7%
associate--r-77.7%
add-sqr-sqrt1.5%
sqrt-unprod28.9%
sqr-neg28.9%
sqrt-unprod28.9%
add-sqr-sqrt28.9%
div-inv28.9%
metadata-eval28.9%
add-sqr-sqrt8.1%
fabs-sqr8.1%
add-sqr-sqrt28.9%
Applied egg-rr28.9%
Taylor expanded in m around inf 28.1%
*-commutative28.1%
Simplified28.1%
Taylor expanded in l around inf 56.1%
neg-mul-156.1%
Simplified56.1%
Final simplification75.7%
(FPCore (K m n M l)
:precision binary64
(if (<= l -4.1e+102)
(* (cos M) (exp (* m (- M (* n 0.5)))))
(if (<= l 200.0)
(* (cos (* 0.5 (* m K))) (exp (- (- m n) l)))
(* (cos M) (exp (- l))))))
double code(double K, double m, double n, double M, double l) {
double tmp;
if (l <= -4.1e+102) {
tmp = cos(M) * exp((m * (M - (n * 0.5))));
} else if (l <= 200.0) {
tmp = cos((0.5 * (m * K))) * exp(((m - n) - l));
} else {
tmp = cos(M) * exp(-l);
}
return tmp;
}
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 <= (-4.1d+102)) then
tmp = cos(m_1) * exp((m * (m_1 - (n * 0.5d0))))
else if (l <= 200.0d0) then
tmp = cos((0.5d0 * (m * k))) * exp(((m - n) - l))
else
tmp = cos(m_1) * exp(-l)
end if
code = tmp
end function
public static double code(double K, double m, double n, double M, double l) {
double tmp;
if (l <= -4.1e+102) {
tmp = Math.cos(M) * Math.exp((m * (M - (n * 0.5))));
} else if (l <= 200.0) {
tmp = Math.cos((0.5 * (m * K))) * Math.exp(((m - n) - l));
} else {
tmp = Math.cos(M) * Math.exp(-l);
}
return tmp;
}
def code(K, m, n, M, l): tmp = 0 if l <= -4.1e+102: tmp = math.cos(M) * math.exp((m * (M - (n * 0.5)))) elif l <= 200.0: tmp = math.cos((0.5 * (m * K))) * math.exp(((m - n) - l)) else: tmp = math.cos(M) * math.exp(-l) return tmp
function code(K, m, n, M, l) tmp = 0.0 if (l <= -4.1e+102) tmp = Float64(cos(M) * exp(Float64(m * Float64(M - Float64(n * 0.5))))); elseif (l <= 200.0) tmp = Float64(cos(Float64(0.5 * Float64(m * K))) * exp(Float64(Float64(m - n) - l))); else tmp = Float64(cos(M) * exp(Float64(-l))); end return tmp end
function tmp_2 = code(K, m, n, M, l) tmp = 0.0; if (l <= -4.1e+102) tmp = cos(M) * exp((m * (M - (n * 0.5)))); elseif (l <= 200.0) tmp = cos((0.5 * (m * K))) * exp(((m - n) - l)); else tmp = cos(M) * exp(-l); end tmp_2 = tmp; end
code[K_, m_, n_, M_, l_] := If[LessEqual[l, -4.1e+102], N[(N[Cos[M], $MachinePrecision] * N[Exp[N[(m * N[(M - N[(n * 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[l, 200.0], N[(N[Cos[N[(0.5 * N[(m * K), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * N[Exp[N[(N[(m - n), $MachinePrecision] - l), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(N[Cos[M], $MachinePrecision] * N[Exp[(-l)], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\ell \leq -4.1 \cdot 10^{+102}:\\
\;\;\;\;\cos M \cdot e^{m \cdot \left(M - n \cdot 0.5\right)}\\
\mathbf{elif}\;\ell \leq 200:\\
\;\;\;\;\cos \left(0.5 \cdot \left(m \cdot K\right)\right) \cdot e^{\left(m - n\right) - \ell}\\
\mathbf{else}:\\
\;\;\;\;\cos M \cdot e^{-\ell}\\
\end{array}
\end{array}
if l < -4.1e102Initial program 63.4%
Taylor expanded in K around 0 92.7%
cos-neg92.7%
Simplified92.7%
Taylor expanded in m around 0 73.3%
+-commutative73.3%
unpow273.3%
distribute-rgt-out78.3%
*-commutative78.3%
*-commutative78.3%
Simplified78.3%
Taylor expanded in m around inf 45.1%
if -4.1e102 < l < 200Initial program 78.6%
associate--r-78.6%
add-sqr-sqrt0.0%
sqrt-unprod12.9%
sqr-neg12.9%
sqrt-unprod12.9%
add-sqr-sqrt12.9%
div-inv12.9%
metadata-eval12.9%
add-sqr-sqrt3.1%
fabs-sqr3.1%
add-sqr-sqrt12.9%
Applied egg-rr12.9%
Taylor expanded in m around inf 12.2%
*-commutative12.2%
Simplified12.2%
Taylor expanded in l around inf 37.8%
neg-mul-137.8%
Simplified37.8%
if 200 < l Initial program 85.3%
Taylor expanded in l around inf 85.3%
mul-1-neg85.3%
Simplified85.3%
Taylor expanded in K around 0 100.0%
cos-neg100.0%
Simplified100.0%
Final simplification55.5%
(FPCore (K m n M l) :precision binary64 (if (<= l 150.0) (* (cos M) (exp (* m (- M (* n 0.5))))) (* (cos M) (exp (- l)))))
double code(double K, double m, double n, double M, double l) {
double tmp;
if (l <= 150.0) {
tmp = cos(M) * exp((m * (M - (n * 0.5))));
} else {
tmp = cos(M) * exp(-l);
}
return tmp;
}
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 <= 150.0d0) then
tmp = cos(m_1) * exp((m * (m_1 - (n * 0.5d0))))
else
tmp = cos(m_1) * exp(-l)
end if
code = tmp
end function
public static double code(double K, double m, double n, double M, double l) {
double tmp;
if (l <= 150.0) {
tmp = Math.cos(M) * Math.exp((m * (M - (n * 0.5))));
} else {
tmp = Math.cos(M) * Math.exp(-l);
}
return tmp;
}
def code(K, m, n, M, l): tmp = 0 if l <= 150.0: tmp = math.cos(M) * math.exp((m * (M - (n * 0.5)))) else: tmp = math.cos(M) * math.exp(-l) return tmp
function code(K, m, n, M, l) tmp = 0.0 if (l <= 150.0) tmp = Float64(cos(M) * exp(Float64(m * Float64(M - Float64(n * 0.5))))); else tmp = Float64(cos(M) * exp(Float64(-l))); end return tmp end
function tmp_2 = code(K, m, n, M, l) tmp = 0.0; if (l <= 150.0) tmp = cos(M) * exp((m * (M - (n * 0.5)))); else tmp = cos(M) * exp(-l); end tmp_2 = tmp; end
code[K_, m_, n_, M_, l_] := If[LessEqual[l, 150.0], N[(N[Cos[M], $MachinePrecision] * N[Exp[N[(m * N[(M - N[(n * 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(N[Cos[M], $MachinePrecision] * N[Exp[(-l)], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\ell \leq 150:\\
\;\;\;\;\cos M \cdot e^{m \cdot \left(M - n \cdot 0.5\right)}\\
\mathbf{else}:\\
\;\;\;\;\cos M \cdot e^{-\ell}\\
\end{array}
\end{array}
if l < 150Initial program 75.1%
Taylor expanded in K around 0 94.0%
cos-neg94.0%
Simplified94.0%
Taylor expanded in m around 0 72.3%
+-commutative72.3%
unpow272.3%
distribute-rgt-out77.1%
*-commutative77.1%
*-commutative77.1%
Simplified77.1%
Taylor expanded in m around inf 42.7%
if 150 < l Initial program 85.5%
Taylor expanded in l around inf 84.1%
mul-1-neg84.1%
Simplified84.1%
Taylor expanded in K around 0 98.6%
cos-neg98.6%
Simplified98.6%
Final simplification57.8%
(FPCore (K m n M l) :precision binary64 (* (cos M) (exp (- l))))
double code(double K, double m, double n, double M, double l) {
return cos(M) * exp(-l);
}
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
public static double code(double K, double m, double n, double M, double l) {
return Math.cos(M) * Math.exp(-l);
}
def code(K, m, n, M, l): return math.cos(M) * math.exp(-l)
function code(K, m, n, M, l) return Float64(cos(M) * exp(Float64(-l))) end
function tmp = code(K, m, n, M, l) tmp = cos(M) * exp(-l); end
code[K_, m_, n_, M_, l_] := N[(N[Cos[M], $MachinePrecision] * N[Exp[(-l)], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\cos M \cdot e^{-\ell}
\end{array}
Initial program 77.9%
Taylor expanded in l around inf 33.0%
mul-1-neg33.0%
Simplified33.0%
Taylor expanded in K around 0 37.8%
cos-neg37.8%
Simplified37.8%
(FPCore (K m n M l) :precision binary64 (cos (- (* m (* 0.5 K)) M)))
double code(double K, double m, double n, double M, double l) {
return cos(((m * (0.5 * K)) - M));
}
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 * (0.5d0 * k)) - m_1))
end function
public static double code(double K, double m, double n, double M, double l) {
return Math.cos(((m * (0.5 * K)) - M));
}
def code(K, m, n, M, l): return math.cos(((m * (0.5 * K)) - M))
function code(K, m, n, M, l) return cos(Float64(Float64(m * Float64(0.5 * K)) - M)) end
function tmp = code(K, m, n, M, l) tmp = cos(((m * (0.5 * K)) - M)); end
code[K_, m_, n_, M_, l_] := N[Cos[N[(N[(m * N[(0.5 * K), $MachinePrecision]), $MachinePrecision] - M), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\cos \left(m \cdot \left(0.5 \cdot K\right) - M\right)
\end{array}
Initial program 77.9%
Taylor expanded in l around inf 33.0%
mul-1-neg33.0%
Simplified33.0%
Taylor expanded in l around 0 7.9%
Taylor expanded in n around 0 8.0%
associate-*r*8.0%
*-commutative8.0%
Simplified8.0%
Final simplification8.0%
(FPCore (K m n M l) :precision binary64 (cos (* m (* 0.5 K))))
double code(double K, double m, double n, double M, double l) {
return cos((m * (0.5 * K)));
}
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 * (0.5d0 * k)))
end function
public static double code(double K, double m, double n, double M, double l) {
return Math.cos((m * (0.5 * K)));
}
def code(K, m, n, M, l): return math.cos((m * (0.5 * K)))
function code(K, m, n, M, l) return cos(Float64(m * Float64(0.5 * K))) end
function tmp = code(K, m, n, M, l) tmp = cos((m * (0.5 * K))); end
code[K_, m_, n_, M_, l_] := N[Cos[N[(m * N[(0.5 * K), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
\cos \left(m \cdot \left(0.5 \cdot K\right)\right)
\end{array}
Initial program 77.9%
Taylor expanded in l around inf 33.0%
mul-1-neg33.0%
Simplified33.0%
Taylor expanded in l around 0 7.9%
Taylor expanded in m around inf 8.0%
associate-*r*8.0%
*-commutative8.0%
Simplified8.0%
Final simplification8.0%
(FPCore (K m n M l) :precision binary64 (cos M))
double code(double K, double m, double n, double M, double l) {
return cos(M);
}
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
public static double code(double K, double m, double n, double M, double l) {
return Math.cos(M);
}
def code(K, m, n, M, l): return math.cos(M)
function code(K, m, n, M, l) return cos(M) end
function tmp = code(K, m, n, M, l) tmp = cos(M); end
code[K_, m_, n_, M_, l_] := N[Cos[M], $MachinePrecision]
\begin{array}{l}
\\
\cos M
\end{array}
Initial program 77.9%
Taylor expanded in l around inf 33.0%
mul-1-neg33.0%
Simplified33.0%
Taylor expanded in l around 0 7.9%
Taylor expanded in K around 0 8.1%
cos-neg8.1%
Simplified8.1%
herbie shell --seed 2024092
(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)))))))