
(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 9 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 (- n m)) l) (pow (- (* (+ n m) 0.5) M) 2.0)))))
double code(double K, double m, double n, double M, double l) {
return cos(M) * exp(((fabs((n - m)) - l) - pow((((n + m) * 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(((abs((n - m)) - l) - ((((n + m) * 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(((Math.abs((n - m)) - l) - Math.pow((((n + m) * 0.5) - M), 2.0)));
}
def code(K, m, n, M, l): return math.cos(M) * math.exp(((math.fabs((n - m)) - l) - math.pow((((n + m) * 0.5) - M), 2.0)))
function code(K, m, n, M, l) return Float64(cos(M) * exp(Float64(Float64(abs(Float64(n - m)) - l) - (Float64(Float64(Float64(n + m) * 0.5) - M) ^ 2.0)))) end
function tmp = code(K, m, n, M, l) tmp = cos(M) * exp(((abs((n - m)) - l) - ((((n + m) * 0.5) - M) ^ 2.0))); end
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[(n + m), $MachinePrecision] * 0.5), $MachinePrecision] - M), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\cos M \cdot e^{\left(\left|n - m\right| - \ell\right) - {\left(\left(n + m\right) \cdot 0.5 - M\right)}^{2}}
\end{array}
Initial program 76.1%
associate-/l*75.7%
+-commutative75.7%
fabs-sub75.7%
+-commutative75.7%
Simplified75.7%
Taylor expanded in K around 0 96.7%
cos-neg96.7%
exp-diff23.3%
fabs-sub23.3%
exp-diff96.7%
associate--r+96.7%
*-commutative96.7%
exp-diff27.9%
sub-neg27.9%
fabs-sub27.9%
mul-1-neg27.9%
fabs-sub27.9%
Simplified96.7%
Final simplification96.7%
(FPCore (K m n M l)
:precision binary64
(if (<= n -1e-29)
(* (cos M) (exp (* (pow m 2.0) -0.25)))
(if (<= n 55.0)
(*
(cos (- (/ (* (+ n m) K) 2.0) M))
(exp (- (- m n) (+ l (pow (- (* (+ n m) 0.5) M) 2.0)))))
(* (cos M) (exp (* -0.25 (pow n 2.0)))))))
double code(double K, double m, double n, double M, double l) {
double tmp;
if (n <= -1e-29) {
tmp = cos(M) * exp((pow(m, 2.0) * -0.25));
} else if (n <= 55.0) {
tmp = cos(((((n + m) * K) / 2.0) - M)) * exp(((m - n) - (l + pow((((n + m) * 0.5) - M), 2.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) :: tmp
if (n <= (-1d-29)) then
tmp = cos(m_1) * exp(((m ** 2.0d0) * (-0.25d0)))
else if (n <= 55.0d0) then
tmp = cos(((((n + m) * k) / 2.0d0) - m_1)) * exp(((m - n) - (l + ((((n + m) * 0.5d0) - m_1) ** 2.0d0))))
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 tmp;
if (n <= -1e-29) {
tmp = Math.cos(M) * Math.exp((Math.pow(m, 2.0) * -0.25));
} else if (n <= 55.0) {
tmp = Math.cos(((((n + m) * K) / 2.0) - M)) * Math.exp(((m - n) - (l + Math.pow((((n + m) * 0.5) - M), 2.0))));
} else {
tmp = Math.cos(M) * Math.exp((-0.25 * Math.pow(n, 2.0)));
}
return tmp;
}
def code(K, m, n, M, l): tmp = 0 if n <= -1e-29: tmp = math.cos(M) * math.exp((math.pow(m, 2.0) * -0.25)) elif n <= 55.0: tmp = math.cos(((((n + m) * K) / 2.0) - M)) * math.exp(((m - n) - (l + math.pow((((n + m) * 0.5) - M), 2.0)))) else: tmp = math.cos(M) * math.exp((-0.25 * math.pow(n, 2.0))) return tmp
function code(K, m, n, M, l) tmp = 0.0 if (n <= -1e-29) tmp = Float64(cos(M) * exp(Float64((m ^ 2.0) * -0.25))); elseif (n <= 55.0) tmp = Float64(cos(Float64(Float64(Float64(Float64(n + m) * K) / 2.0) - M)) * exp(Float64(Float64(m - n) - Float64(l + (Float64(Float64(Float64(n + m) * 0.5) - M) ^ 2.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) tmp = 0.0; if (n <= -1e-29) tmp = cos(M) * exp(((m ^ 2.0) * -0.25)); elseif (n <= 55.0) tmp = cos(((((n + m) * K) / 2.0) - M)) * exp(((m - n) - (l + ((((n + m) * 0.5) - M) ^ 2.0)))); else tmp = cos(M) * exp((-0.25 * (n ^ 2.0))); end tmp_2 = tmp; end
code[K_, m_, n_, M_, l_] := If[LessEqual[n, -1e-29], N[(N[Cos[M], $MachinePrecision] * N[Exp[N[(N[Power[m, 2.0], $MachinePrecision] * -0.25), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[n, 55.0], N[(N[Cos[N[(N[(N[(N[(n + m), $MachinePrecision] * K), $MachinePrecision] / 2.0), $MachinePrecision] - M), $MachinePrecision]], $MachinePrecision] * N[Exp[N[(N[(m - n), $MachinePrecision] - N[(l + N[Power[N[(N[(N[(n + m), $MachinePrecision] * 0.5), $MachinePrecision] - M), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(N[Cos[M], $MachinePrecision] * N[Exp[N[(-0.25 * N[Power[n, 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;n \leq -1 \cdot 10^{-29}:\\
\;\;\;\;\cos M \cdot e^{{m}^{2} \cdot -0.25}\\
\mathbf{elif}\;n \leq 55:\\
\;\;\;\;\cos \left(\frac{\left(n + m\right) \cdot K}{2} - M\right) \cdot e^{\left(m - n\right) - \left(\ell + {\left(\left(n + m\right) \cdot 0.5 - M\right)}^{2}\right)}\\
\mathbf{else}:\\
\;\;\;\;\cos M \cdot e^{-0.25 \cdot {n}^{2}}\\
\end{array}
\end{array}
if n < -9.99999999999999943e-30Initial program 67.1%
associate-/l*67.1%
+-commutative67.1%
fabs-sub67.1%
+-commutative67.1%
Simplified67.1%
Taylor expanded in K around 0 98.7%
cos-neg98.7%
exp-diff9.2%
fabs-sub9.2%
exp-diff98.7%
associate--r+98.7%
*-commutative98.7%
exp-diff21.1%
sub-neg21.1%
fabs-sub21.1%
mul-1-neg21.1%
fabs-sub21.1%
Simplified98.7%
Taylor expanded in m around inf 52.8%
*-commutative52.8%
Simplified52.8%
if -9.99999999999999943e-30 < n < 55Initial program 84.5%
sub-neg84.5%
fabs-sub84.5%
distribute-neg-out84.5%
div-inv84.5%
metadata-eval84.5%
fabs-sub84.5%
add-sqr-sqrt37.1%
fabs-sqr37.1%
add-sqr-sqrt84.5%
Applied egg-rr84.5%
neg-sub084.5%
associate-+r-84.5%
*-commutative84.5%
+-commutative84.5%
associate--r-84.5%
Simplified84.5%
if 55 < n Initial program 72.5%
associate-/l*72.5%
+-commutative72.5%
fabs-sub72.5%
+-commutative72.5%
Simplified72.5%
Taylor expanded in K around 0 100.0%
cos-neg100.0%
exp-diff1.4%
fabs-sub1.4%
exp-diff100.0%
associate--r+100.0%
*-commutative100.0%
exp-diff11.6%
sub-neg11.6%
fabs-sub11.6%
mul-1-neg11.6%
fabs-sub11.6%
Simplified100.0%
Taylor expanded in n around inf 98.6%
*-commutative98.6%
Simplified98.6%
Final simplification78.9%
(FPCore (K m n M l)
:precision binary64
(let* ((t_0 (- (- m n) l))
(t_1 (* (cos (- (/ (* (+ n m) K) 2.0) M)) (exp (+ (* M (- M n)) t_0))))
(t_2 (* (cos M) (exp (- (pow M 2.0)))))
(t_3 (- (* m 0.5) M)))
(if (<= M -26.5)
t_2
(if (<= M -1.66e-43)
t_1
(if (<= M -2.45e-83)
(* (cos M) (exp (+ (* t_3 (+ n t_3)) t_0)))
(if (<= M 26.5) t_1 t_2))))))
double code(double K, double m, double n, double M, double l) {
double t_0 = (m - n) - l;
double t_1 = cos(((((n + m) * K) / 2.0) - M)) * exp(((M * (M - n)) + t_0));
double t_2 = cos(M) * exp(-pow(M, 2.0));
double t_3 = (m * 0.5) - M;
double tmp;
if (M <= -26.5) {
tmp = t_2;
} else if (M <= -1.66e-43) {
tmp = t_1;
} else if (M <= -2.45e-83) {
tmp = cos(M) * exp(((t_3 * (n + t_3)) + t_0));
} else if (M <= 26.5) {
tmp = t_1;
} else {
tmp = t_2;
}
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) :: t_1
real(8) :: t_2
real(8) :: t_3
real(8) :: tmp
t_0 = (m - n) - l
t_1 = cos(((((n + m) * k) / 2.0d0) - m_1)) * exp(((m_1 * (m_1 - n)) + t_0))
t_2 = cos(m_1) * exp(-(m_1 ** 2.0d0))
t_3 = (m * 0.5d0) - m_1
if (m_1 <= (-26.5d0)) then
tmp = t_2
else if (m_1 <= (-1.66d-43)) then
tmp = t_1
else if (m_1 <= (-2.45d-83)) then
tmp = cos(m_1) * exp(((t_3 * (n + t_3)) + t_0))
else if (m_1 <= 26.5d0) then
tmp = t_1
else
tmp = t_2
end if
code = tmp
end function
public static double code(double K, double m, double n, double M, double l) {
double t_0 = (m - n) - l;
double t_1 = Math.cos(((((n + m) * K) / 2.0) - M)) * Math.exp(((M * (M - n)) + t_0));
double t_2 = Math.cos(M) * Math.exp(-Math.pow(M, 2.0));
double t_3 = (m * 0.5) - M;
double tmp;
if (M <= -26.5) {
tmp = t_2;
} else if (M <= -1.66e-43) {
tmp = t_1;
} else if (M <= -2.45e-83) {
tmp = Math.cos(M) * Math.exp(((t_3 * (n + t_3)) + t_0));
} else if (M <= 26.5) {
tmp = t_1;
} else {
tmp = t_2;
}
return tmp;
}
def code(K, m, n, M, l): t_0 = (m - n) - l t_1 = math.cos(((((n + m) * K) / 2.0) - M)) * math.exp(((M * (M - n)) + t_0)) t_2 = math.cos(M) * math.exp(-math.pow(M, 2.0)) t_3 = (m * 0.5) - M tmp = 0 if M <= -26.5: tmp = t_2 elif M <= -1.66e-43: tmp = t_1 elif M <= -2.45e-83: tmp = math.cos(M) * math.exp(((t_3 * (n + t_3)) + t_0)) elif M <= 26.5: tmp = t_1 else: tmp = t_2 return tmp
function code(K, m, n, M, l) t_0 = Float64(Float64(m - n) - l) t_1 = Float64(cos(Float64(Float64(Float64(Float64(n + m) * K) / 2.0) - M)) * exp(Float64(Float64(M * Float64(M - n)) + t_0))) t_2 = Float64(cos(M) * exp(Float64(-(M ^ 2.0)))) t_3 = Float64(Float64(m * 0.5) - M) tmp = 0.0 if (M <= -26.5) tmp = t_2; elseif (M <= -1.66e-43) tmp = t_1; elseif (M <= -2.45e-83) tmp = Float64(cos(M) * exp(Float64(Float64(t_3 * Float64(n + t_3)) + t_0))); elseif (M <= 26.5) tmp = t_1; else tmp = t_2; end return tmp end
function tmp_2 = code(K, m, n, M, l) t_0 = (m - n) - l; t_1 = cos(((((n + m) * K) / 2.0) - M)) * exp(((M * (M - n)) + t_0)); t_2 = cos(M) * exp(-(M ^ 2.0)); t_3 = (m * 0.5) - M; tmp = 0.0; if (M <= -26.5) tmp = t_2; elseif (M <= -1.66e-43) tmp = t_1; elseif (M <= -2.45e-83) tmp = cos(M) * exp(((t_3 * (n + t_3)) + t_0)); elseif (M <= 26.5) tmp = t_1; else tmp = t_2; end tmp_2 = tmp; end
code[K_, m_, n_, M_, l_] := Block[{t$95$0 = N[(N[(m - n), $MachinePrecision] - l), $MachinePrecision]}, Block[{t$95$1 = N[(N[Cos[N[(N[(N[(N[(n + m), $MachinePrecision] * K), $MachinePrecision] / 2.0), $MachinePrecision] - M), $MachinePrecision]], $MachinePrecision] * N[Exp[N[(N[(M * N[(M - n), $MachinePrecision]), $MachinePrecision] + t$95$0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(N[Cos[M], $MachinePrecision] * N[Exp[(-N[Power[M, 2.0], $MachinePrecision])], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$3 = N[(N[(m * 0.5), $MachinePrecision] - M), $MachinePrecision]}, If[LessEqual[M, -26.5], t$95$2, If[LessEqual[M, -1.66e-43], t$95$1, If[LessEqual[M, -2.45e-83], N[(N[Cos[M], $MachinePrecision] * N[Exp[N[(N[(t$95$3 * N[(n + t$95$3), $MachinePrecision]), $MachinePrecision] + t$95$0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[M, 26.5], t$95$1, t$95$2]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(m - n\right) - \ell\\
t_1 := \cos \left(\frac{\left(n + m\right) \cdot K}{2} - M\right) \cdot e^{M \cdot \left(M - n\right) + t_0}\\
t_2 := \cos M \cdot e^{-{M}^{2}}\\
t_3 := m \cdot 0.5 - M\\
\mathbf{if}\;M \leq -26.5:\\
\;\;\;\;t_2\\
\mathbf{elif}\;M \leq -1.66 \cdot 10^{-43}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;M \leq -2.45 \cdot 10^{-83}:\\
\;\;\;\;\cos M \cdot e^{t_3 \cdot \left(n + t_3\right) + t_0}\\
\mathbf{elif}\;M \leq 26.5:\\
\;\;\;\;t_1\\
\mathbf{else}:\\
\;\;\;\;t_2\\
\end{array}
\end{array}
if M < -26.5 or 26.5 < M Initial program 75.8%
associate-/l*75.8%
+-commutative75.8%
fabs-sub75.8%
+-commutative75.8%
Simplified75.8%
Taylor expanded in K around 0 99.2%
cos-neg99.2%
exp-diff27.5%
fabs-sub27.5%
exp-diff99.2%
associate--r+99.2%
*-commutative99.2%
exp-diff27.5%
sub-neg27.5%
fabs-sub27.5%
mul-1-neg27.5%
fabs-sub27.5%
Simplified99.2%
Taylor expanded in M around inf 97.5%
mul-1-neg97.5%
Simplified97.5%
if -26.5 < M < -1.66e-43 or -2.45e-83 < M < 26.5Initial program 80.8%
sub-neg80.8%
add-sqr-sqrt2.4%
sqrt-unprod22.2%
sqr-neg22.2%
sqrt-unprod25.3%
add-sqr-sqrt25.3%
div-inv25.3%
metadata-eval25.3%
add-sqr-sqrt16.5%
fabs-sqr16.5%
add-sqr-sqrt25.3%
Applied egg-rr25.3%
unsub-neg25.3%
associate--r-25.3%
sub-neg25.3%
mul-1-neg25.3%
associate-+r+25.3%
+-commutative25.3%
mul-1-neg25.3%
sub-neg25.3%
Simplified25.3%
Taylor expanded in n around 0 35.5%
+-commutative35.5%
unpow235.5%
distribute-rgt-out35.5%
Simplified35.5%
Taylor expanded in m around 0 56.6%
associate-*r*56.6%
neg-mul-156.6%
Simplified56.6%
if -1.66e-43 < M < -2.45e-83Initial program 20.0%
sub-neg20.0%
add-sqr-sqrt0.0%
sqrt-unprod20.0%
sqr-neg20.0%
sqrt-unprod20.0%
add-sqr-sqrt20.0%
div-inv20.0%
metadata-eval20.0%
add-sqr-sqrt20.0%
fabs-sqr20.0%
add-sqr-sqrt20.0%
Applied egg-rr20.0%
unsub-neg20.0%
associate--r-20.0%
sub-neg20.0%
mul-1-neg20.0%
associate-+r+20.0%
+-commutative20.0%
mul-1-neg20.0%
sub-neg20.0%
Simplified20.0%
Taylor expanded in n around 0 20.0%
+-commutative20.0%
unpow220.0%
distribute-rgt-out20.0%
Simplified20.0%
Taylor expanded in K around 0 60.6%
cos-neg41.3%
Simplified60.6%
Final simplification75.9%
(FPCore (K m n M l)
:precision binary64
(if (<= n 3.6e-302)
(* (cos M) (exp (* (pow m 2.0) -0.25)))
(if (<= n 55.0)
(*
(cos (- (/ (* (+ n m) K) 2.0) M))
(exp (+ (* n (- (* m 0.5) M)) (- (- m n) l))))
(* (cos M) (exp (* -0.25 (pow n 2.0)))))))
double code(double K, double m, double n, double M, double l) {
double tmp;
if (n <= 3.6e-302) {
tmp = cos(M) * exp((pow(m, 2.0) * -0.25));
} else if (n <= 55.0) {
tmp = cos(((((n + m) * K) / 2.0) - M)) * exp(((n * ((m * 0.5) - M)) + ((m - n) - l)));
} 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) :: tmp
if (n <= 3.6d-302) then
tmp = cos(m_1) * exp(((m ** 2.0d0) * (-0.25d0)))
else if (n <= 55.0d0) then
tmp = cos(((((n + m) * k) / 2.0d0) - m_1)) * exp(((n * ((m * 0.5d0) - m_1)) + ((m - n) - l)))
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 tmp;
if (n <= 3.6e-302) {
tmp = Math.cos(M) * Math.exp((Math.pow(m, 2.0) * -0.25));
} else if (n <= 55.0) {
tmp = Math.cos(((((n + m) * K) / 2.0) - M)) * Math.exp(((n * ((m * 0.5) - M)) + ((m - n) - l)));
} else {
tmp = Math.cos(M) * Math.exp((-0.25 * Math.pow(n, 2.0)));
}
return tmp;
}
def code(K, m, n, M, l): tmp = 0 if n <= 3.6e-302: tmp = math.cos(M) * math.exp((math.pow(m, 2.0) * -0.25)) elif n <= 55.0: tmp = math.cos(((((n + m) * K) / 2.0) - M)) * math.exp(((n * ((m * 0.5) - M)) + ((m - n) - l))) else: tmp = math.cos(M) * math.exp((-0.25 * math.pow(n, 2.0))) return tmp
function code(K, m, n, M, l) tmp = 0.0 if (n <= 3.6e-302) tmp = Float64(cos(M) * exp(Float64((m ^ 2.0) * -0.25))); elseif (n <= 55.0) tmp = Float64(cos(Float64(Float64(Float64(Float64(n + m) * K) / 2.0) - M)) * exp(Float64(Float64(n * Float64(Float64(m * 0.5) - M)) + Float64(Float64(m - n) - l)))); 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) tmp = 0.0; if (n <= 3.6e-302) tmp = cos(M) * exp(((m ^ 2.0) * -0.25)); elseif (n <= 55.0) tmp = cos(((((n + m) * K) / 2.0) - M)) * exp(((n * ((m * 0.5) - M)) + ((m - n) - l))); else tmp = cos(M) * exp((-0.25 * (n ^ 2.0))); end tmp_2 = tmp; end
code[K_, m_, n_, M_, l_] := If[LessEqual[n, 3.6e-302], N[(N[Cos[M], $MachinePrecision] * N[Exp[N[(N[Power[m, 2.0], $MachinePrecision] * -0.25), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[n, 55.0], N[(N[Cos[N[(N[(N[(N[(n + m), $MachinePrecision] * K), $MachinePrecision] / 2.0), $MachinePrecision] - M), $MachinePrecision]], $MachinePrecision] * N[Exp[N[(N[(n * N[(N[(m * 0.5), $MachinePrecision] - M), $MachinePrecision]), $MachinePrecision] + N[(N[(m - n), $MachinePrecision] - l), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(N[Cos[M], $MachinePrecision] * N[Exp[N[(-0.25 * N[Power[n, 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;n \leq 3.6 \cdot 10^{-302}:\\
\;\;\;\;\cos M \cdot e^{{m}^{2} \cdot -0.25}\\
\mathbf{elif}\;n \leq 55:\\
\;\;\;\;\cos \left(\frac{\left(n + m\right) \cdot K}{2} - M\right) \cdot e^{n \cdot \left(m \cdot 0.5 - M\right) + \left(\left(m - n\right) - \ell\right)}\\
\mathbf{else}:\\
\;\;\;\;\cos M \cdot e^{-0.25 \cdot {n}^{2}}\\
\end{array}
\end{array}
if n < 3.6000000000000001e-302Initial program 74.8%
associate-/l*74.8%
+-commutative74.8%
fabs-sub74.8%
+-commutative74.8%
Simplified74.8%
Taylor expanded in K around 0 97.2%
cos-neg97.2%
exp-diff26.1%
fabs-sub26.1%
exp-diff97.2%
associate--r+97.2%
*-commutative97.2%
exp-diff30.5%
sub-neg30.5%
fabs-sub30.5%
mul-1-neg30.5%
fabs-sub30.5%
Simplified97.2%
Taylor expanded in m around inf 55.7%
*-commutative55.7%
Simplified55.7%
if 3.6000000000000001e-302 < n < 55Initial program 84.2%
sub-neg84.2%
add-sqr-sqrt1.9%
sqrt-unprod27.4%
sqr-neg27.4%
sqrt-unprod27.4%
add-sqr-sqrt27.4%
div-inv27.4%
metadata-eval27.4%
add-sqr-sqrt8.3%
fabs-sqr8.3%
add-sqr-sqrt27.4%
Applied egg-rr27.4%
unsub-neg27.4%
associate--r-27.4%
sub-neg27.4%
mul-1-neg27.4%
associate-+r+27.4%
+-commutative27.4%
mul-1-neg27.4%
sub-neg27.4%
Simplified27.4%
Taylor expanded in n around 0 27.4%
+-commutative27.4%
unpow227.4%
distribute-rgt-out27.4%
Simplified27.4%
Taylor expanded in n around inf 63.4%
*-commutative63.4%
Simplified63.4%
if 55 < n Initial program 72.5%
associate-/l*72.5%
+-commutative72.5%
fabs-sub72.5%
+-commutative72.5%
Simplified72.5%
Taylor expanded in K around 0 100.0%
cos-neg100.0%
exp-diff1.4%
fabs-sub1.4%
exp-diff100.0%
associate--r+100.0%
*-commutative100.0%
exp-diff11.6%
sub-neg11.6%
fabs-sub11.6%
mul-1-neg11.6%
fabs-sub11.6%
Simplified100.0%
Taylor expanded in n around inf 98.6%
*-commutative98.6%
Simplified98.6%
Final simplification68.8%
(FPCore (K m n M l)
:precision binary64
(if (<= n -9e-36)
(* (cos M) (exp (- l)))
(if (<= n 2.9e-17)
(*
(cos (- (/ (* (+ n m) K) 2.0) M))
(exp (+ (* n (- (* m 0.5) M)) (- (- m n) l))))
(* (cos M) (exp (* n (+ (* m 0.5) (- -1.0 M))))))))
double code(double K, double m, double n, double M, double l) {
double tmp;
if (n <= -9e-36) {
tmp = cos(M) * exp(-l);
} else if (n <= 2.9e-17) {
tmp = cos(((((n + m) * K) / 2.0) - M)) * exp(((n * ((m * 0.5) - M)) + ((m - n) - l)));
} else {
tmp = cos(M) * exp((n * ((m * 0.5) + (-1.0 - M))));
}
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 (n <= (-9d-36)) then
tmp = cos(m_1) * exp(-l)
else if (n <= 2.9d-17) then
tmp = cos(((((n + m) * k) / 2.0d0) - m_1)) * exp(((n * ((m * 0.5d0) - m_1)) + ((m - n) - l)))
else
tmp = cos(m_1) * exp((n * ((m * 0.5d0) + ((-1.0d0) - m_1))))
end if
code = tmp
end function
public static double code(double K, double m, double n, double M, double l) {
double tmp;
if (n <= -9e-36) {
tmp = Math.cos(M) * Math.exp(-l);
} else if (n <= 2.9e-17) {
tmp = Math.cos(((((n + m) * K) / 2.0) - M)) * Math.exp(((n * ((m * 0.5) - M)) + ((m - n) - l)));
} else {
tmp = Math.cos(M) * Math.exp((n * ((m * 0.5) + (-1.0 - M))));
}
return tmp;
}
def code(K, m, n, M, l): tmp = 0 if n <= -9e-36: tmp = math.cos(M) * math.exp(-l) elif n <= 2.9e-17: tmp = math.cos(((((n + m) * K) / 2.0) - M)) * math.exp(((n * ((m * 0.5) - M)) + ((m - n) - l))) else: tmp = math.cos(M) * math.exp((n * ((m * 0.5) + (-1.0 - M)))) return tmp
function code(K, m, n, M, l) tmp = 0.0 if (n <= -9e-36) tmp = Float64(cos(M) * exp(Float64(-l))); elseif (n <= 2.9e-17) tmp = Float64(cos(Float64(Float64(Float64(Float64(n + m) * K) / 2.0) - M)) * exp(Float64(Float64(n * Float64(Float64(m * 0.5) - M)) + Float64(Float64(m - n) - l)))); else tmp = Float64(cos(M) * exp(Float64(n * Float64(Float64(m * 0.5) + Float64(-1.0 - M))))); end return tmp end
function tmp_2 = code(K, m, n, M, l) tmp = 0.0; if (n <= -9e-36) tmp = cos(M) * exp(-l); elseif (n <= 2.9e-17) tmp = cos(((((n + m) * K) / 2.0) - M)) * exp(((n * ((m * 0.5) - M)) + ((m - n) - l))); else tmp = cos(M) * exp((n * ((m * 0.5) + (-1.0 - M)))); end tmp_2 = tmp; end
code[K_, m_, n_, M_, l_] := If[LessEqual[n, -9e-36], N[(N[Cos[M], $MachinePrecision] * N[Exp[(-l)], $MachinePrecision]), $MachinePrecision], If[LessEqual[n, 2.9e-17], N[(N[Cos[N[(N[(N[(N[(n + m), $MachinePrecision] * K), $MachinePrecision] / 2.0), $MachinePrecision] - M), $MachinePrecision]], $MachinePrecision] * N[Exp[N[(N[(n * N[(N[(m * 0.5), $MachinePrecision] - M), $MachinePrecision]), $MachinePrecision] + N[(N[(m - n), $MachinePrecision] - l), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(N[Cos[M], $MachinePrecision] * N[Exp[N[(n * N[(N[(m * 0.5), $MachinePrecision] + N[(-1.0 - M), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;n \leq -9 \cdot 10^{-36}:\\
\;\;\;\;\cos M \cdot e^{-\ell}\\
\mathbf{elif}\;n \leq 2.9 \cdot 10^{-17}:\\
\;\;\;\;\cos \left(\frac{\left(n + m\right) \cdot K}{2} - M\right) \cdot e^{n \cdot \left(m \cdot 0.5 - M\right) + \left(\left(m - n\right) - \ell\right)}\\
\mathbf{else}:\\
\;\;\;\;\cos M \cdot e^{n \cdot \left(m \cdot 0.5 + \left(-1 - M\right)\right)}\\
\end{array}
\end{array}
if n < -9.00000000000000047e-36Initial program 67.1%
associate-/l*67.1%
+-commutative67.1%
fabs-sub67.1%
+-commutative67.1%
Simplified67.1%
Taylor expanded in K around 0 98.7%
cos-neg98.7%
exp-diff9.2%
fabs-sub9.2%
exp-diff98.7%
associate--r+98.7%
*-commutative98.7%
exp-diff21.1%
sub-neg21.1%
fabs-sub21.1%
mul-1-neg21.1%
fabs-sub21.1%
Simplified98.7%
Taylor expanded in l around inf 32.1%
mul-1-neg32.1%
Simplified32.1%
if -9.00000000000000047e-36 < n < 2.9000000000000003e-17Initial program 83.9%
sub-neg83.9%
add-sqr-sqrt2.8%
sqrt-unprod25.1%
sqr-neg25.1%
sqrt-unprod25.1%
add-sqr-sqrt25.1%
div-inv25.1%
metadata-eval25.1%
add-sqr-sqrt15.5%
fabs-sqr15.5%
add-sqr-sqrt25.1%
Applied egg-rr25.1%
unsub-neg25.1%
associate--r-25.1%
sub-neg25.1%
mul-1-neg25.1%
associate-+r+25.1%
+-commutative25.1%
mul-1-neg25.1%
sub-neg25.1%
Simplified25.1%
Taylor expanded in n around 0 25.1%
+-commutative25.1%
unpow225.1%
distribute-rgt-out25.1%
Simplified25.1%
Taylor expanded in n around inf 61.0%
*-commutative61.0%
Simplified61.0%
if 2.9000000000000003e-17 < n Initial program 74.0%
sub-neg74.0%
add-sqr-sqrt0.0%
sqrt-unprod3.9%
sqr-neg3.9%
sqrt-unprod5.2%
add-sqr-sqrt5.2%
div-inv5.2%
metadata-eval5.2%
add-sqr-sqrt1.6%
fabs-sqr1.6%
add-sqr-sqrt5.2%
Applied egg-rr5.2%
unsub-neg5.2%
associate--r-5.2%
sub-neg5.2%
mul-1-neg5.2%
associate-+r+5.2%
+-commutative5.2%
mul-1-neg5.2%
sub-neg5.2%
Simplified5.2%
Taylor expanded in n around 0 25.3%
+-commutative25.3%
unpow225.3%
distribute-rgt-out25.4%
Simplified25.4%
Taylor expanded in n around inf 40.3%
*-commutative40.3%
+-commutative40.3%
Simplified40.3%
Taylor expanded in K around 0 58.2%
cos-neg58.2%
Simplified58.2%
Final simplification51.6%
(FPCore (K m n M l)
:precision binary64
(let* ((t_0 (* (cos M) (exp (* n (+ (* m 0.5) (- -1.0 M)))))))
(if (<= l -1.16e+44)
t_0
(if (<= l -3.7e-84)
(*
(cos (- (/ (* (+ n m) K) 2.0) M))
(exp (+ (* M (- M n)) (- (- m n) l))))
(if (<= l 6e-10) t_0 (* (cos M) (exp (- l))))))))
double code(double K, double m, double n, double M, double l) {
double t_0 = cos(M) * exp((n * ((m * 0.5) + (-1.0 - M))));
double tmp;
if (l <= -1.16e+44) {
tmp = t_0;
} else if (l <= -3.7e-84) {
tmp = cos(((((n + m) * K) / 2.0) - M)) * exp(((M * (M - n)) + ((m - n) - l)));
} else if (l <= 6e-10) {
tmp = t_0;
} 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) :: t_0
real(8) :: tmp
t_0 = cos(m_1) * exp((n * ((m * 0.5d0) + ((-1.0d0) - m_1))))
if (l <= (-1.16d+44)) then
tmp = t_0
else if (l <= (-3.7d-84)) then
tmp = cos(((((n + m) * k) / 2.0d0) - m_1)) * exp(((m_1 * (m_1 - n)) + ((m - n) - l)))
else if (l <= 6d-10) then
tmp = t_0
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 t_0 = Math.cos(M) * Math.exp((n * ((m * 0.5) + (-1.0 - M))));
double tmp;
if (l <= -1.16e+44) {
tmp = t_0;
} else if (l <= -3.7e-84) {
tmp = Math.cos(((((n + m) * K) / 2.0) - M)) * Math.exp(((M * (M - n)) + ((m - n) - l)));
} else if (l <= 6e-10) {
tmp = t_0;
} else {
tmp = Math.cos(M) * Math.exp(-l);
}
return tmp;
}
def code(K, m, n, M, l): t_0 = math.cos(M) * math.exp((n * ((m * 0.5) + (-1.0 - M)))) tmp = 0 if l <= -1.16e+44: tmp = t_0 elif l <= -3.7e-84: tmp = math.cos(((((n + m) * K) / 2.0) - M)) * math.exp(((M * (M - n)) + ((m - n) - l))) elif l <= 6e-10: tmp = t_0 else: tmp = math.cos(M) * math.exp(-l) return tmp
function code(K, m, n, M, l) t_0 = Float64(cos(M) * exp(Float64(n * Float64(Float64(m * 0.5) + Float64(-1.0 - M))))) tmp = 0.0 if (l <= -1.16e+44) tmp = t_0; elseif (l <= -3.7e-84) tmp = Float64(cos(Float64(Float64(Float64(Float64(n + m) * K) / 2.0) - M)) * exp(Float64(Float64(M * Float64(M - n)) + Float64(Float64(m - n) - l)))); elseif (l <= 6e-10) tmp = t_0; else tmp = Float64(cos(M) * exp(Float64(-l))); end return tmp end
function tmp_2 = code(K, m, n, M, l) t_0 = cos(M) * exp((n * ((m * 0.5) + (-1.0 - M)))); tmp = 0.0; if (l <= -1.16e+44) tmp = t_0; elseif (l <= -3.7e-84) tmp = cos(((((n + m) * K) / 2.0) - M)) * exp(((M * (M - n)) + ((m - n) - l))); elseif (l <= 6e-10) tmp = t_0; else tmp = cos(M) * exp(-l); end tmp_2 = tmp; end
code[K_, m_, n_, M_, l_] := Block[{t$95$0 = N[(N[Cos[M], $MachinePrecision] * N[Exp[N[(n * N[(N[(m * 0.5), $MachinePrecision] + N[(-1.0 - M), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[l, -1.16e+44], t$95$0, If[LessEqual[l, -3.7e-84], N[(N[Cos[N[(N[(N[(N[(n + m), $MachinePrecision] * K), $MachinePrecision] / 2.0), $MachinePrecision] - M), $MachinePrecision]], $MachinePrecision] * N[Exp[N[(N[(M * N[(M - n), $MachinePrecision]), $MachinePrecision] + N[(N[(m - n), $MachinePrecision] - l), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[l, 6e-10], t$95$0, N[(N[Cos[M], $MachinePrecision] * N[Exp[(-l)], $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos M \cdot e^{n \cdot \left(m \cdot 0.5 + \left(-1 - M\right)\right)}\\
\mathbf{if}\;\ell \leq -1.16 \cdot 10^{+44}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;\ell \leq -3.7 \cdot 10^{-84}:\\
\;\;\;\;\cos \left(\frac{\left(n + m\right) \cdot K}{2} - M\right) \cdot e^{M \cdot \left(M - n\right) + \left(\left(m - n\right) - \ell\right)}\\
\mathbf{elif}\;\ell \leq 6 \cdot 10^{-10}:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;\cos M \cdot e^{-\ell}\\
\end{array}
\end{array}
if l < -1.1600000000000001e44 or -3.6999999999999999e-84 < l < 6e-10Initial program 72.7%
sub-neg72.7%
add-sqr-sqrt0.0%
sqrt-unprod9.9%
sqr-neg9.9%
sqrt-unprod9.9%
add-sqr-sqrt9.9%
div-inv9.9%
metadata-eval9.9%
add-sqr-sqrt5.8%
fabs-sqr5.8%
add-sqr-sqrt9.9%
Applied egg-rr9.9%
unsub-neg9.9%
associate--r-9.9%
sub-neg9.9%
mul-1-neg9.9%
associate-+r+9.9%
+-commutative9.9%
mul-1-neg9.9%
sub-neg9.9%
Simplified9.9%
Taylor expanded in n around 0 17.0%
+-commutative17.0%
unpow217.0%
distribute-rgt-out17.7%
Simplified17.7%
Taylor expanded in n around inf 32.8%
*-commutative32.8%
+-commutative32.8%
Simplified32.8%
Taylor expanded in K around 0 43.3%
cos-neg43.3%
Simplified43.3%
if -1.1600000000000001e44 < l < -3.6999999999999999e-84Initial program 82.8%
sub-neg82.8%
add-sqr-sqrt3.4%
sqrt-unprod21.7%
sqr-neg21.7%
sqrt-unprod21.7%
add-sqr-sqrt21.7%
div-inv21.7%
metadata-eval21.7%
add-sqr-sqrt17.8%
fabs-sqr17.8%
add-sqr-sqrt21.7%
Applied egg-rr21.7%
unsub-neg21.7%
associate--r-21.7%
sub-neg21.7%
mul-1-neg21.7%
associate-+r+21.7%
+-commutative21.7%
mul-1-neg21.7%
sub-neg21.7%
Simplified21.7%
Taylor expanded in n around 0 21.7%
+-commutative21.7%
unpow221.7%
distribute-rgt-out21.7%
Simplified21.7%
Taylor expanded in m around 0 35.3%
associate-*r*35.3%
neg-mul-135.3%
Simplified35.3%
if 6e-10 < l Initial program 80.3%
associate-/l*80.3%
+-commutative80.3%
fabs-sub80.3%
+-commutative80.3%
Simplified80.3%
Taylor expanded in K around 0 97.9%
cos-neg97.9%
exp-diff20.5%
fabs-sub20.5%
exp-diff97.9%
associate--r+97.9%
*-commutative97.9%
exp-diff52.5%
sub-neg52.5%
fabs-sub52.5%
mul-1-neg52.5%
fabs-sub52.5%
Simplified97.9%
Taylor expanded in l around inf 96.6%
mul-1-neg96.6%
Simplified96.6%
Final simplification58.0%
(FPCore (K m n M l) :precision binary64 (if (<= l 6e-10) (* (cos M) (exp (* n (+ (* m 0.5) (- -1.0 M))))) (* (cos M) (exp (- l)))))
double code(double K, double m, double n, double M, double l) {
double tmp;
if (l <= 6e-10) {
tmp = cos(M) * exp((n * ((m * 0.5) + (-1.0 - M))));
} 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 <= 6d-10) then
tmp = cos(m_1) * exp((n * ((m * 0.5d0) + ((-1.0d0) - m_1))))
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 <= 6e-10) {
tmp = Math.cos(M) * Math.exp((n * ((m * 0.5) + (-1.0 - M))));
} else {
tmp = Math.cos(M) * Math.exp(-l);
}
return tmp;
}
def code(K, m, n, M, l): tmp = 0 if l <= 6e-10: tmp = math.cos(M) * math.exp((n * ((m * 0.5) + (-1.0 - M)))) else: tmp = math.cos(M) * math.exp(-l) return tmp
function code(K, m, n, M, l) tmp = 0.0 if (l <= 6e-10) tmp = Float64(cos(M) * exp(Float64(n * Float64(Float64(m * 0.5) + Float64(-1.0 - M))))); 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 <= 6e-10) tmp = cos(M) * exp((n * ((m * 0.5) + (-1.0 - M)))); else tmp = cos(M) * exp(-l); end tmp_2 = tmp; end
code[K_, m_, n_, M_, l_] := If[LessEqual[l, 6e-10], N[(N[Cos[M], $MachinePrecision] * N[Exp[N[(n * N[(N[(m * 0.5), $MachinePrecision] + N[(-1.0 - M), $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 6 \cdot 10^{-10}:\\
\;\;\;\;\cos M \cdot e^{n \cdot \left(m \cdot 0.5 + \left(-1 - M\right)\right)}\\
\mathbf{else}:\\
\;\;\;\;\cos M \cdot e^{-\ell}\\
\end{array}
\end{array}
if l < 6e-10Initial program 74.4%
sub-neg74.4%
add-sqr-sqrt0.6%
sqrt-unprod11.8%
sqr-neg11.8%
sqrt-unprod11.8%
add-sqr-sqrt11.8%
div-inv11.8%
metadata-eval11.8%
add-sqr-sqrt7.7%
fabs-sqr7.7%
add-sqr-sqrt11.8%
Applied egg-rr11.8%
unsub-neg11.8%
associate--r-11.8%
sub-neg11.8%
mul-1-neg11.8%
associate-+r+11.8%
+-commutative11.8%
mul-1-neg11.8%
sub-neg11.8%
Simplified11.8%
Taylor expanded in n around 0 17.7%
+-commutative17.7%
unpow217.7%
distribute-rgt-out18.3%
Simplified18.3%
Taylor expanded in n around inf 32.8%
*-commutative32.8%
+-commutative32.8%
Simplified32.8%
Taylor expanded in K around 0 42.7%
cos-neg42.7%
Simplified42.7%
if 6e-10 < l Initial program 80.3%
associate-/l*80.3%
+-commutative80.3%
fabs-sub80.3%
+-commutative80.3%
Simplified80.3%
Taylor expanded in K around 0 97.9%
cos-neg97.9%
exp-diff20.5%
fabs-sub20.5%
exp-diff97.9%
associate--r+97.9%
*-commutative97.9%
exp-diff52.5%
sub-neg52.5%
fabs-sub52.5%
mul-1-neg52.5%
fabs-sub52.5%
Simplified97.9%
Taylor expanded in l around inf 96.6%
mul-1-neg96.6%
Simplified96.6%
Final simplification58.5%
(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 76.1%
associate-/l*75.7%
+-commutative75.7%
fabs-sub75.7%
+-commutative75.7%
Simplified75.7%
Taylor expanded in K around 0 96.7%
cos-neg96.7%
exp-diff23.3%
fabs-sub23.3%
exp-diff96.7%
associate--r+96.7%
*-commutative96.7%
exp-diff27.9%
sub-neg27.9%
fabs-sub27.9%
mul-1-neg27.9%
fabs-sub27.9%
Simplified96.7%
Taylor expanded in l around inf 37.7%
mul-1-neg37.7%
Simplified37.7%
Final simplification37.7%
(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 76.1%
associate-/l*75.7%
+-commutative75.7%
fabs-sub75.7%
+-commutative75.7%
Simplified75.7%
Taylor expanded in K around 0 96.7%
cos-neg96.7%
exp-diff23.3%
fabs-sub23.3%
exp-diff96.7%
associate--r+96.7%
*-commutative96.7%
exp-diff27.9%
sub-neg27.9%
fabs-sub27.9%
mul-1-neg27.9%
fabs-sub27.9%
Simplified96.7%
Taylor expanded in m around inf 54.7%
*-commutative54.7%
Simplified54.7%
Taylor expanded in m around 0 6.3%
Final simplification6.3%
herbie shell --seed 2023331
(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)))))))