
(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}
(FPCore (K m n M l) :precision binary64 (/ (cos M) (exp (+ (pow (- (/ (+ m n) 2.0) M) 2.0) (- l (fabs (- n m)))))))
double code(double K, double m, double n, double M, double l) {
return cos(M) / exp((pow((((m + n) / 2.0) - M), 2.0) + (l - fabs((n - 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) / exp((((((m + n) / 2.0d0) - m_1) ** 2.0d0) + (l - abs((n - m)))))
end function
public static double code(double K, double m, double n, double M, double l) {
return Math.cos(M) / Math.exp((Math.pow((((m + n) / 2.0) - M), 2.0) + (l - Math.abs((n - m)))));
}
def code(K, m, n, M, l): return math.cos(M) / math.exp((math.pow((((m + n) / 2.0) - M), 2.0) + (l - math.fabs((n - m)))))
function code(K, m, n, M, l) return Float64(cos(M) / exp(Float64((Float64(Float64(Float64(m + n) / 2.0) - M) ^ 2.0) + Float64(l - abs(Float64(n - m)))))) end
function tmp = code(K, m, n, M, l) tmp = cos(M) / exp((((((m + n) / 2.0) - M) ^ 2.0) + (l - abs((n - m))))); end
code[K_, m_, n_, M_, l_] := N[(N[Cos[M], $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[(n - m), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\cos M}{e^{{\left(\frac{m + n}{2} - M\right)}^{2} + \left(\ell - \left|n - m\right|\right)}}
\end{array}
Initial program 76.6%
Simplified76.6%
Taylor expanded in K around 0 96.4%
cos-neg96.4%
Simplified96.4%
Final simplification96.4%
(FPCore (K m n M l) :precision binary64 (/ (cos M) (exp (fabs (- (+ (+ m l) (pow (- (* 0.5 (+ m n)) M) 2.0)) n)))))
double code(double K, double m, double n, double M, double l) {
return cos(M) / exp(fabs((((m + l) + pow(((0.5 * (m + n)) - M), 2.0)) - 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(m_1) / exp(abs((((m + l) + (((0.5d0 * (m + n)) - m_1) ** 2.0d0)) - n)))
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 + l) + Math.pow(((0.5 * (m + n)) - M), 2.0)) - n)));
}
def code(K, m, n, M, l): return math.cos(M) / math.exp(math.fabs((((m + l) + math.pow(((0.5 * (m + n)) - M), 2.0)) - n)))
function code(K, m, n, M, l) return Float64(cos(M) / exp(abs(Float64(Float64(Float64(m + l) + (Float64(Float64(0.5 * Float64(m + n)) - M) ^ 2.0)) - n)))) end
function tmp = code(K, m, n, M, l) tmp = cos(M) / exp(abs((((m + l) + (((0.5 * (m + n)) - M) ^ 2.0)) - n))); end
code[K_, m_, n_, M_, l_] := N[(N[Cos[M], $MachinePrecision] / N[Exp[N[Abs[N[(N[(N[(m + l), $MachinePrecision] + N[Power[N[(N[(0.5 * N[(m + n), $MachinePrecision]), $MachinePrecision] - M), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] - n), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\cos M}{e^{\left|\left(\left(m + \ell\right) + {\left(0.5 \cdot \left(m + n\right) - M\right)}^{2}\right) - n\right|}}
\end{array}
Initial program 76.6%
Simplified76.6%
add-sqr-sqrt68.0%
sqrt-unprod72.2%
pow272.2%
Applied egg-rr72.2%
unpow272.2%
rem-sqrt-square72.2%
associate-+r-72.2%
sub-neg72.2%
+-commutative72.2%
associate-+l+72.2%
+-commutative72.2%
sub-neg72.2%
mul-1-neg72.2%
+-commutative72.2%
distribute-neg-in72.2%
mul-1-neg72.2%
remove-double-neg72.2%
sub-neg72.2%
Simplified72.2%
Taylor expanded in K around 0 91.4%
cos-neg91.4%
fabs-sub91.4%
associate--r+91.4%
unsub-neg91.4%
mul-1-neg91.4%
+-commutative91.4%
fabs-sub91.4%
associate--r+91.4%
fabs-sub91.4%
cancel-sign-sub-inv91.4%
metadata-eval91.4%
*-lft-identity91.4%
Simplified91.4%
Final simplification91.4%
(FPCore (K m n M l)
:precision binary64
(if (<= m -54.0)
(/ (cos M) (exp (fabs (- n (* 0.25 (* m m))))))
(if (<= m 8.5e-253)
(/ (cos M) (exp (fabs (- (* M M) n))))
(/ (cos M) (exp (+ (- l (fabs (- n m))) (* 0.25 (* n n))))))))
double code(double K, double m, double n, double M, double l) {
double tmp;
if (m <= -54.0) {
tmp = cos(M) / exp(fabs((n - (0.25 * (m * m)))));
} else if (m <= 8.5e-253) {
tmp = cos(M) / exp(fabs(((M * M) - n)));
} else {
tmp = cos(M) / exp(((l - fabs((n - m))) + (0.25 * (n * n))));
}
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 <= (-54.0d0)) then
tmp = cos(m_1) / exp(abs((n - (0.25d0 * (m * m)))))
else if (m <= 8.5d-253) then
tmp = cos(m_1) / exp(abs(((m_1 * m_1) - n)))
else
tmp = cos(m_1) / exp(((l - abs((n - m))) + (0.25d0 * (n * n))))
end if
code = tmp
end function
public static double code(double K, double m, double n, double M, double l) {
double tmp;
if (m <= -54.0) {
tmp = Math.cos(M) / Math.exp(Math.abs((n - (0.25 * (m * m)))));
} else if (m <= 8.5e-253) {
tmp = Math.cos(M) / Math.exp(Math.abs(((M * M) - n)));
} else {
tmp = Math.cos(M) / Math.exp(((l - Math.abs((n - m))) + (0.25 * (n * n))));
}
return tmp;
}
def code(K, m, n, M, l): tmp = 0 if m <= -54.0: tmp = math.cos(M) / math.exp(math.fabs((n - (0.25 * (m * m))))) elif m <= 8.5e-253: tmp = math.cos(M) / math.exp(math.fabs(((M * M) - n))) else: tmp = math.cos(M) / math.exp(((l - math.fabs((n - m))) + (0.25 * (n * n)))) return tmp
function code(K, m, n, M, l) tmp = 0.0 if (m <= -54.0) tmp = Float64(cos(M) / exp(abs(Float64(n - Float64(0.25 * Float64(m * m)))))); elseif (m <= 8.5e-253) tmp = Float64(cos(M) / exp(abs(Float64(Float64(M * M) - n)))); else tmp = Float64(cos(M) / exp(Float64(Float64(l - abs(Float64(n - m))) + Float64(0.25 * Float64(n * n))))); end return tmp end
function tmp_2 = code(K, m, n, M, l) tmp = 0.0; if (m <= -54.0) tmp = cos(M) / exp(abs((n - (0.25 * (m * m))))); elseif (m <= 8.5e-253) tmp = cos(M) / exp(abs(((M * M) - n))); else tmp = cos(M) / exp(((l - abs((n - m))) + (0.25 * (n * n)))); end tmp_2 = tmp; end
code[K_, m_, n_, M_, l_] := If[LessEqual[m, -54.0], N[(N[Cos[M], $MachinePrecision] / N[Exp[N[Abs[N[(n - N[(0.25 * N[(m * m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[m, 8.5e-253], N[(N[Cos[M], $MachinePrecision] / N[Exp[N[Abs[N[(N[(M * M), $MachinePrecision] - n), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(N[Cos[M], $MachinePrecision] / N[Exp[N[(N[(l - N[Abs[N[(n - m), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] + N[(0.25 * N[(n * n), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;m \leq -54:\\
\;\;\;\;\frac{\cos M}{e^{\left|n - 0.25 \cdot \left(m \cdot m\right)\right|}}\\
\mathbf{elif}\;m \leq 8.5 \cdot 10^{-253}:\\
\;\;\;\;\frac{\cos M}{e^{\left|M \cdot M - n\right|}}\\
\mathbf{else}:\\
\;\;\;\;\frac{\cos M}{e^{\left(\ell - \left|n - m\right|\right) + 0.25 \cdot \left(n \cdot n\right)}}\\
\end{array}
\end{array}
if m < -54Initial program 70.5%
Simplified70.5%
add-sqr-sqrt67.2%
sqrt-unprod67.3%
pow267.3%
Applied egg-rr67.3%
unpow267.3%
rem-sqrt-square67.3%
associate-+r-67.3%
sub-neg67.3%
+-commutative67.3%
associate-+l+67.3%
+-commutative67.3%
sub-neg67.3%
mul-1-neg67.3%
+-commutative67.3%
distribute-neg-in67.3%
mul-1-neg67.3%
remove-double-neg67.3%
sub-neg67.3%
Simplified67.3%
Taylor expanded in K around 0 96.8%
cos-neg96.8%
fabs-sub96.8%
associate--r+96.8%
unsub-neg96.8%
mul-1-neg96.8%
+-commutative96.8%
fabs-sub96.8%
associate--r+96.8%
fabs-sub96.8%
cancel-sign-sub-inv96.8%
metadata-eval96.8%
*-lft-identity96.8%
Simplified96.8%
Taylor expanded in m around inf 96.8%
unpow296.8%
Simplified96.8%
if -54 < m < 8.4999999999999999e-253Initial program 81.8%
Simplified81.8%
add-sqr-sqrt64.8%
sqrt-unprod74.9%
pow274.9%
Applied egg-rr74.9%
unpow274.9%
rem-sqrt-square74.9%
associate-+r-74.9%
sub-neg74.9%
+-commutative74.9%
associate-+l+74.9%
+-commutative74.9%
sub-neg74.9%
mul-1-neg74.9%
+-commutative74.9%
distribute-neg-in74.9%
mul-1-neg74.9%
remove-double-neg74.9%
sub-neg74.9%
Simplified74.9%
Taylor expanded in K around 0 85.0%
cos-neg85.0%
fabs-sub85.0%
associate--r+85.0%
unsub-neg85.0%
mul-1-neg85.0%
+-commutative85.0%
fabs-sub85.0%
associate--r+85.0%
fabs-sub85.0%
cancel-sign-sub-inv85.0%
metadata-eval85.0%
*-lft-identity85.0%
Simplified85.0%
Taylor expanded in M around inf 83.8%
unpow283.8%
Simplified83.8%
if 8.4999999999999999e-253 < m Initial program 76.7%
Simplified76.7%
Taylor expanded in K around 0 97.1%
cos-neg97.1%
Simplified97.1%
Taylor expanded in n around inf 59.9%
*-commutative48.7%
unpow248.7%
Simplified59.9%
Final simplification75.3%
(FPCore (K m n M l) :precision binary64 (if (or (<= M -1.35e-14) (not (<= M 26.5))) (/ (cos M) (exp (fabs (- (* M M) n)))) (/ (cos M) (exp (fabs (- n l))))))
double code(double K, double m, double n, double M, double l) {
double tmp;
if ((M <= -1.35e-14) || !(M <= 26.5)) {
tmp = cos(M) / exp(fabs(((M * M) - n)));
} else {
tmp = cos(M) / exp(fabs((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 <= (-1.35d-14)) .or. (.not. (m_1 <= 26.5d0))) then
tmp = cos(m_1) / exp(abs(((m_1 * m_1) - n)))
else
tmp = cos(m_1) / exp(abs((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 <= -1.35e-14) || !(M <= 26.5)) {
tmp = Math.cos(M) / Math.exp(Math.abs(((M * M) - n)));
} else {
tmp = Math.cos(M) / Math.exp(Math.abs((n - l)));
}
return tmp;
}
def code(K, m, n, M, l): tmp = 0 if (M <= -1.35e-14) or not (M <= 26.5): tmp = math.cos(M) / math.exp(math.fabs(((M * M) - n))) else: tmp = math.cos(M) / math.exp(math.fabs((n - l))) return tmp
function code(K, m, n, M, l) tmp = 0.0 if ((M <= -1.35e-14) || !(M <= 26.5)) tmp = Float64(cos(M) / exp(abs(Float64(Float64(M * M) - n)))); else tmp = Float64(cos(M) / exp(abs(Float64(n - l)))); end return tmp end
function tmp_2 = code(K, m, n, M, l) tmp = 0.0; if ((M <= -1.35e-14) || ~((M <= 26.5))) tmp = cos(M) / exp(abs(((M * M) - n))); else tmp = cos(M) / exp(abs((n - l))); end tmp_2 = tmp; end
code[K_, m_, n_, M_, l_] := If[Or[LessEqual[M, -1.35e-14], N[Not[LessEqual[M, 26.5]], $MachinePrecision]], N[(N[Cos[M], $MachinePrecision] / N[Exp[N[Abs[N[(N[(M * M), $MachinePrecision] - n), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(N[Cos[M], $MachinePrecision] / N[Exp[N[Abs[N[(n - l), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;M \leq -1.35 \cdot 10^{-14} \lor \neg \left(M \leq 26.5\right):\\
\;\;\;\;\frac{\cos M}{e^{\left|M \cdot M - n\right|}}\\
\mathbf{else}:\\
\;\;\;\;\frac{\cos M}{e^{\left|n - \ell\right|}}\\
\end{array}
\end{array}
if M < -1.3499999999999999e-14 or 26.5 < M Initial program 78.4%
Simplified78.4%
add-sqr-sqrt77.6%
sqrt-unprod77.7%
pow277.7%
Applied egg-rr77.7%
unpow277.7%
rem-sqrt-square77.7%
associate-+r-77.7%
sub-neg77.7%
+-commutative77.7%
associate-+l+77.7%
+-commutative77.7%
sub-neg77.7%
mul-1-neg77.7%
+-commutative77.7%
distribute-neg-in77.7%
mul-1-neg77.7%
remove-double-neg77.7%
sub-neg77.7%
Simplified77.7%
Taylor expanded in K around 0 96.3%
cos-neg96.3%
fabs-sub96.3%
associate--r+96.3%
unsub-neg96.3%
mul-1-neg96.3%
+-commutative96.3%
fabs-sub96.3%
associate--r+96.3%
fabs-sub96.3%
cancel-sign-sub-inv96.3%
metadata-eval96.3%
*-lft-identity96.3%
Simplified96.3%
Taylor expanded in M around inf 96.3%
unpow296.3%
Simplified96.3%
if -1.3499999999999999e-14 < M < 26.5Initial program 74.7%
Simplified74.7%
add-sqr-sqrt57.4%
sqrt-unprod66.2%
pow266.2%
Applied egg-rr66.2%
unpow266.2%
rem-sqrt-square66.2%
associate-+r-66.2%
sub-neg66.2%
+-commutative66.2%
associate-+l+66.2%
+-commutative66.2%
sub-neg66.2%
mul-1-neg66.2%
+-commutative66.2%
distribute-neg-in66.2%
mul-1-neg66.2%
remove-double-neg66.2%
sub-neg66.2%
Simplified66.2%
Taylor expanded in K around 0 85.9%
cos-neg85.9%
fabs-sub85.9%
associate--r+85.9%
unsub-neg85.9%
mul-1-neg85.9%
+-commutative85.9%
fabs-sub85.9%
associate--r+85.9%
fabs-sub85.9%
cancel-sign-sub-inv85.9%
metadata-eval85.9%
*-lft-identity85.9%
Simplified85.9%
Taylor expanded in l around inf 70.8%
Final simplification84.2%
(FPCore (K m n M l) :precision binary64 (if (<= m -54.0) (/ (cos M) (exp (fabs (- n (* 0.25 (* m m)))))) (/ (cos M) (exp (fabs (- (* M M) n))))))
double code(double K, double m, double n, double M, double l) {
double tmp;
if (m <= -54.0) {
tmp = cos(M) / exp(fabs((n - (0.25 * (m * m)))));
} else {
tmp = cos(M) / exp(fabs(((M * M) - n)));
}
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 <= (-54.0d0)) then
tmp = cos(m_1) / exp(abs((n - (0.25d0 * (m * m)))))
else
tmp = cos(m_1) / exp(abs(((m_1 * m_1) - n)))
end if
code = tmp
end function
public static double code(double K, double m, double n, double M, double l) {
double tmp;
if (m <= -54.0) {
tmp = Math.cos(M) / Math.exp(Math.abs((n - (0.25 * (m * m)))));
} else {
tmp = Math.cos(M) / Math.exp(Math.abs(((M * M) - n)));
}
return tmp;
}
def code(K, m, n, M, l): tmp = 0 if m <= -54.0: tmp = math.cos(M) / math.exp(math.fabs((n - (0.25 * (m * m))))) else: tmp = math.cos(M) / math.exp(math.fabs(((M * M) - n))) return tmp
function code(K, m, n, M, l) tmp = 0.0 if (m <= -54.0) tmp = Float64(cos(M) / exp(abs(Float64(n - Float64(0.25 * Float64(m * m)))))); else tmp = Float64(cos(M) / exp(abs(Float64(Float64(M * M) - n)))); end return tmp end
function tmp_2 = code(K, m, n, M, l) tmp = 0.0; if (m <= -54.0) tmp = cos(M) / exp(abs((n - (0.25 * (m * m))))); else tmp = cos(M) / exp(abs(((M * M) - n))); end tmp_2 = tmp; end
code[K_, m_, n_, M_, l_] := If[LessEqual[m, -54.0], N[(N[Cos[M], $MachinePrecision] / N[Exp[N[Abs[N[(n - N[(0.25 * N[(m * m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(N[Cos[M], $MachinePrecision] / N[Exp[N[Abs[N[(N[(M * M), $MachinePrecision] - n), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;m \leq -54:\\
\;\;\;\;\frac{\cos M}{e^{\left|n - 0.25 \cdot \left(m \cdot m\right)\right|}}\\
\mathbf{else}:\\
\;\;\;\;\frac{\cos M}{e^{\left|M \cdot M - n\right|}}\\
\end{array}
\end{array}
if m < -54Initial program 70.5%
Simplified70.5%
add-sqr-sqrt67.2%
sqrt-unprod67.3%
pow267.3%
Applied egg-rr67.3%
unpow267.3%
rem-sqrt-square67.3%
associate-+r-67.3%
sub-neg67.3%
+-commutative67.3%
associate-+l+67.3%
+-commutative67.3%
sub-neg67.3%
mul-1-neg67.3%
+-commutative67.3%
distribute-neg-in67.3%
mul-1-neg67.3%
remove-double-neg67.3%
sub-neg67.3%
Simplified67.3%
Taylor expanded in K around 0 96.8%
cos-neg96.8%
fabs-sub96.8%
associate--r+96.8%
unsub-neg96.8%
mul-1-neg96.8%
+-commutative96.8%
fabs-sub96.8%
associate--r+96.8%
fabs-sub96.8%
cancel-sign-sub-inv96.8%
metadata-eval96.8%
*-lft-identity96.8%
Simplified96.8%
Taylor expanded in m around inf 96.8%
unpow296.8%
Simplified96.8%
if -54 < m Initial program 78.6%
Simplified78.6%
add-sqr-sqrt68.2%
sqrt-unprod73.7%
pow273.7%
Applied egg-rr73.7%
unpow273.7%
rem-sqrt-square73.7%
associate-+r-73.7%
sub-neg73.7%
+-commutative73.7%
associate-+l+73.7%
+-commutative73.7%
sub-neg73.7%
mul-1-neg73.7%
+-commutative73.7%
distribute-neg-in73.7%
mul-1-neg73.7%
remove-double-neg73.7%
sub-neg73.7%
Simplified73.7%
Taylor expanded in K around 0 89.7%
cos-neg89.7%
fabs-sub89.7%
associate--r+89.7%
unsub-neg89.7%
mul-1-neg89.7%
+-commutative89.7%
fabs-sub89.7%
associate--r+89.7%
fabs-sub89.7%
cancel-sign-sub-inv89.7%
metadata-eval89.7%
*-lft-identity89.7%
Simplified89.7%
Taylor expanded in M around inf 80.8%
unpow280.8%
Simplified80.8%
Final simplification84.6%
(FPCore (K m n M l) :precision binary64 (/ (cos M) (exp (fabs (- n l)))))
double code(double K, double m, double n, double M, double l) {
return cos(M) / exp(fabs((n - 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(abs((n - l)))
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 - l)));
}
def code(K, m, n, M, l): return math.cos(M) / math.exp(math.fabs((n - l)))
function code(K, m, n, M, l) return Float64(cos(M) / exp(abs(Float64(n - l)))) end
function tmp = code(K, m, n, M, l) tmp = cos(M) / exp(abs((n - l))); end
code[K_, m_, n_, M_, l_] := N[(N[Cos[M], $MachinePrecision] / N[Exp[N[Abs[N[(n - l), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\cos M}{e^{\left|n - \ell\right|}}
\end{array}
Initial program 76.6%
Simplified76.6%
add-sqr-sqrt68.0%
sqrt-unprod72.2%
pow272.2%
Applied egg-rr72.2%
unpow272.2%
rem-sqrt-square72.2%
associate-+r-72.2%
sub-neg72.2%
+-commutative72.2%
associate-+l+72.2%
+-commutative72.2%
sub-neg72.2%
mul-1-neg72.2%
+-commutative72.2%
distribute-neg-in72.2%
mul-1-neg72.2%
remove-double-neg72.2%
sub-neg72.2%
Simplified72.2%
Taylor expanded in K around 0 91.4%
cos-neg91.4%
fabs-sub91.4%
associate--r+91.4%
unsub-neg91.4%
mul-1-neg91.4%
+-commutative91.4%
fabs-sub91.4%
associate--r+91.4%
fabs-sub91.4%
cancel-sign-sub-inv91.4%
metadata-eval91.4%
*-lft-identity91.4%
Simplified91.4%
Taylor expanded in l around inf 73.6%
Final simplification73.6%
(FPCore (K m n M l)
:precision binary64
(let* ((t_0 (/ (cos (- (* (* n 0.5) K) M)) (exp (* n (* n 0.25))))))
(if (<= n -0.115)
t_0
(if (<= n 3.4e-231)
(* -0.5 (/ (* n (* K (sin (- (* 0.5 (* m K)) M)))) (exp l)))
(if (<= n 0.00068) (/ (cos M) (exp l)) t_0)))))
double code(double K, double m, double n, double M, double l) {
double t_0 = cos((((n * 0.5) * K) - M)) / exp((n * (n * 0.25)));
double tmp;
if (n <= -0.115) {
tmp = t_0;
} else if (n <= 3.4e-231) {
tmp = -0.5 * ((n * (K * sin(((0.5 * (m * K)) - M)))) / exp(l));
} else if (n <= 0.00068) {
tmp = cos(M) / exp(l);
} else {
tmp = t_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((((n * 0.5d0) * k) - m_1)) / exp((n * (n * 0.25d0)))
if (n <= (-0.115d0)) then
tmp = t_0
else if (n <= 3.4d-231) then
tmp = (-0.5d0) * ((n * (k * sin(((0.5d0 * (m * k)) - m_1)))) / exp(l))
else if (n <= 0.00068d0) then
tmp = cos(m_1) / exp(l)
else
tmp = t_0
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((((n * 0.5) * K) - M)) / Math.exp((n * (n * 0.25)));
double tmp;
if (n <= -0.115) {
tmp = t_0;
} else if (n <= 3.4e-231) {
tmp = -0.5 * ((n * (K * Math.sin(((0.5 * (m * K)) - M)))) / Math.exp(l));
} else if (n <= 0.00068) {
tmp = Math.cos(M) / Math.exp(l);
} else {
tmp = t_0;
}
return tmp;
}
def code(K, m, n, M, l): t_0 = math.cos((((n * 0.5) * K) - M)) / math.exp((n * (n * 0.25))) tmp = 0 if n <= -0.115: tmp = t_0 elif n <= 3.4e-231: tmp = -0.5 * ((n * (K * math.sin(((0.5 * (m * K)) - M)))) / math.exp(l)) elif n <= 0.00068: tmp = math.cos(M) / math.exp(l) else: tmp = t_0 return tmp
function code(K, m, n, M, l) t_0 = Float64(cos(Float64(Float64(Float64(n * 0.5) * K) - M)) / exp(Float64(n * Float64(n * 0.25)))) tmp = 0.0 if (n <= -0.115) tmp = t_0; elseif (n <= 3.4e-231) tmp = Float64(-0.5 * Float64(Float64(n * Float64(K * sin(Float64(Float64(0.5 * Float64(m * K)) - M)))) / exp(l))); elseif (n <= 0.00068) tmp = Float64(cos(M) / exp(l)); else tmp = t_0; end return tmp end
function tmp_2 = code(K, m, n, M, l) t_0 = cos((((n * 0.5) * K) - M)) / exp((n * (n * 0.25))); tmp = 0.0; if (n <= -0.115) tmp = t_0; elseif (n <= 3.4e-231) tmp = -0.5 * ((n * (K * sin(((0.5 * (m * K)) - M)))) / exp(l)); elseif (n <= 0.00068) tmp = cos(M) / exp(l); else tmp = t_0; end tmp_2 = tmp; end
code[K_, m_, n_, M_, l_] := Block[{t$95$0 = N[(N[Cos[N[(N[(N[(n * 0.5), $MachinePrecision] * K), $MachinePrecision] - M), $MachinePrecision]], $MachinePrecision] / N[Exp[N[(n * N[(n * 0.25), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[n, -0.115], t$95$0, If[LessEqual[n, 3.4e-231], N[(-0.5 * N[(N[(n * N[(K * N[Sin[N[(N[(0.5 * N[(m * K), $MachinePrecision]), $MachinePrecision] - M), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[Exp[l], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[n, 0.00068], N[(N[Cos[M], $MachinePrecision] / N[Exp[l], $MachinePrecision]), $MachinePrecision], t$95$0]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{\cos \left(\left(n \cdot 0.5\right) \cdot K - M\right)}{e^{n \cdot \left(n \cdot 0.25\right)}}\\
\mathbf{if}\;n \leq -0.115:\\
\;\;\;\;t_0\\
\mathbf{elif}\;n \leq 3.4 \cdot 10^{-231}:\\
\;\;\;\;-0.5 \cdot \frac{n \cdot \left(K \cdot \sin \left(0.5 \cdot \left(m \cdot K\right) - M\right)\right)}{e^{\ell}}\\
\mathbf{elif}\;n \leq 0.00068:\\
\;\;\;\;\frac{\cos M}{e^{\ell}}\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\end{array}
if n < -0.115000000000000005 or 6.8e-4 < n Initial program 71.8%
Simplified71.8%
Taylor expanded in n around inf 64.2%
*-commutative64.2%
unpow264.2%
Simplified64.2%
Taylor expanded in m around 0 66.0%
associate-*r*66.0%
Simplified66.0%
Taylor expanded in n around inf 76.1%
*-commutative76.1%
unpow276.1%
associate-*r*76.1%
Simplified76.1%
if -0.115000000000000005 < n < 3.4e-231Initial program 83.3%
Simplified83.3%
Taylor expanded in l around inf 32.1%
Taylor expanded in n around 0 32.1%
Taylor expanded in n around inf 38.4%
if 3.4e-231 < n < 6.8e-4Initial program 76.9%
Simplified76.9%
Taylor expanded in l around inf 47.3%
Taylor expanded in K around 0 55.4%
cos-neg55.4%
Simplified55.4%
Final simplification59.3%
(FPCore (K m n M l) :precision binary64 (if (or (<= n -53.0) (not (<= n 0.00068))) (/ (cos (- (* (* n 0.5) K) M)) (exp (* n (* n 0.25)))) (/ (cos M) (exp l))))
double code(double K, double m, double n, double M, double l) {
double tmp;
if ((n <= -53.0) || !(n <= 0.00068)) {
tmp = cos((((n * 0.5) * K) - M)) / exp((n * (n * 0.25)));
} 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 ((n <= (-53.0d0)) .or. (.not. (n <= 0.00068d0))) then
tmp = cos((((n * 0.5d0) * k) - m_1)) / exp((n * (n * 0.25d0)))
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 ((n <= -53.0) || !(n <= 0.00068)) {
tmp = Math.cos((((n * 0.5) * K) - M)) / Math.exp((n * (n * 0.25)));
} else {
tmp = Math.cos(M) / Math.exp(l);
}
return tmp;
}
def code(K, m, n, M, l): tmp = 0 if (n <= -53.0) or not (n <= 0.00068): tmp = math.cos((((n * 0.5) * K) - M)) / math.exp((n * (n * 0.25))) else: tmp = math.cos(M) / math.exp(l) return tmp
function code(K, m, n, M, l) tmp = 0.0 if ((n <= -53.0) || !(n <= 0.00068)) tmp = Float64(cos(Float64(Float64(Float64(n * 0.5) * K) - M)) / exp(Float64(n * Float64(n * 0.25)))); else tmp = Float64(cos(M) / exp(l)); end return tmp end
function tmp_2 = code(K, m, n, M, l) tmp = 0.0; if ((n <= -53.0) || ~((n <= 0.00068))) tmp = cos((((n * 0.5) * K) - M)) / exp((n * (n * 0.25))); else tmp = cos(M) / exp(l); end tmp_2 = tmp; end
code[K_, m_, n_, M_, l_] := If[Or[LessEqual[n, -53.0], N[Not[LessEqual[n, 0.00068]], $MachinePrecision]], N[(N[Cos[N[(N[(N[(n * 0.5), $MachinePrecision] * K), $MachinePrecision] - M), $MachinePrecision]], $MachinePrecision] / N[Exp[N[(n * N[(n * 0.25), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(N[Cos[M], $MachinePrecision] / N[Exp[l], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;n \leq -53 \lor \neg \left(n \leq 0.00068\right):\\
\;\;\;\;\frac{\cos \left(\left(n \cdot 0.5\right) \cdot K - M\right)}{e^{n \cdot \left(n \cdot 0.25\right)}}\\
\mathbf{else}:\\
\;\;\;\;\frac{\cos M}{e^{\ell}}\\
\end{array}
\end{array}
if n < -53 or 6.8e-4 < n Initial program 72.4%
Simplified72.4%
Taylor expanded in n around inf 64.8%
*-commutative64.8%
unpow264.8%
Simplified64.8%
Taylor expanded in m around 0 65.7%
associate-*r*65.7%
Simplified65.7%
Taylor expanded in n around inf 76.8%
*-commutative76.8%
unpow276.8%
associate-*r*76.8%
Simplified76.8%
if -53 < n < 6.8e-4Initial program 80.1%
Simplified80.1%
Taylor expanded in l around inf 38.0%
Taylor expanded in K around 0 41.8%
cos-neg41.8%
Simplified41.8%
Final simplification57.7%
(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(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}
\\
\frac{\cos M}{e^{\ell}}
\end{array}
Initial program 76.6%
Simplified76.6%
Taylor expanded in l around inf 29.2%
Taylor expanded in K around 0 33.2%
cos-neg33.2%
Simplified33.2%
Final simplification33.2%
(FPCore (K m n M l) :precision binary64 (/ 1.0 (exp l)))
double code(double K, double m, double n, double M, double l) {
return 1.0 / 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 = 1.0d0 / exp(l)
end function
public static double code(double K, double m, double n, double M, double l) {
return 1.0 / Math.exp(l);
}
def code(K, m, n, M, l): return 1.0 / math.exp(l)
function code(K, m, n, M, l) return Float64(1.0 / exp(l)) end
function tmp = code(K, m, n, M, l) tmp = 1.0 / exp(l); end
code[K_, m_, n_, M_, l_] := N[(1.0 / N[Exp[l], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{1}{e^{\ell}}
\end{array}
Initial program 76.6%
Simplified76.6%
Taylor expanded in l around inf 29.2%
div-inv29.2%
metadata-eval29.2%
flip--19.7%
Applied egg-rr19.7%
Taylor expanded in n around inf 22.0%
unpow222.0%
unpow222.0%
Simplified22.0%
Taylor expanded in n around 0 32.8%
Final simplification32.8%
(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.6%
Simplified76.6%
Taylor expanded in l around inf 29.2%
Taylor expanded in l around 0 7.5%
Taylor expanded in K around 0 8.2%
cos-neg8.2%
Simplified8.2%
Final simplification8.2%
herbie shell --seed 2023189
(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)))))))