
(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 (- (/ (+ m n) 2.0) M) 2.0)))))
double code(double K, double m, double n, double M, double l) {
return cos(M) * exp(((fabs((n - m)) - l) - pow((((m + n) / 2.0) - M), 2.0)));
}
real(8) function code(k, m, n, m_1, l)
real(8), intent (in) :: k
real(8), intent (in) :: m
real(8), intent (in) :: n
real(8), intent (in) :: m_1
real(8), intent (in) :: l
code = cos(m_1) * exp(((abs((n - m)) - l) - ((((m + n) / 2.0d0) - m_1) ** 2.0d0)))
end function
public static double code(double K, double m, double n, double M, double l) {
return Math.cos(M) * Math.exp(((Math.abs((n - m)) - l) - Math.pow((((m + n) / 2.0) - M), 2.0)));
}
def code(K, m, n, M, l): return math.cos(M) * math.exp(((math.fabs((n - m)) - l) - math.pow((((m + n) / 2.0) - M), 2.0)))
function code(K, m, n, M, l) return Float64(cos(M) * exp(Float64(Float64(abs(Float64(n - m)) - l) - (Float64(Float64(Float64(m + n) / 2.0) - M) ^ 2.0)))) end
function tmp = code(K, m, n, M, l) tmp = cos(M) * exp(((abs((n - m)) - 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[(n - m), $MachinePrecision]], $MachinePrecision] - l), $MachinePrecision] - N[Power[N[(N[(N[(m + n), $MachinePrecision] / 2.0), $MachinePrecision] - M), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\cos M \cdot e^{\left(\left|n - m\right| - \ell\right) - {\left(\frac{m + n}{2} - M\right)}^{2}}
\end{array}
Initial program 75.5%
associate-/l*75.6%
+-commutative75.6%
fabs-sub75.6%
+-commutative75.6%
Simplified75.6%
Taylor expanded in K around 0 97.5%
cos-neg97.5%
Simplified97.5%
Final simplification97.5%
(FPCore (K m n M l)
:precision binary64
(if (<= n -4.8e-102)
(* (cos M) (exp (* -0.25 (pow m 2.0))))
(if (<= n 56.0)
(*
(cos (- (/ K (/ 2.0 n)) M))
(exp (+ (* (+ n (- (* m 0.5) M)) (- M (* m 0.5))) (- (fabs (- n m)) 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 <= -4.8e-102) {
tmp = cos(M) * exp((-0.25 * pow(m, 2.0)));
} else if (n <= 56.0) {
tmp = cos(((K / (2.0 / n)) - M)) * exp((((n + ((m * 0.5) - M)) * (M - (m * 0.5))) + (fabs((n - m)) - 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 <= (-4.8d-102)) then
tmp = cos(m_1) * exp(((-0.25d0) * (m ** 2.0d0)))
else if (n <= 56.0d0) then
tmp = cos(((k / (2.0d0 / n)) - m_1)) * exp((((n + ((m * 0.5d0) - m_1)) * (m_1 - (m * 0.5d0))) + (abs((n - m)) - 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 <= -4.8e-102) {
tmp = Math.cos(M) * Math.exp((-0.25 * Math.pow(m, 2.0)));
} else if (n <= 56.0) {
tmp = Math.cos(((K / (2.0 / n)) - M)) * Math.exp((((n + ((m * 0.5) - M)) * (M - (m * 0.5))) + (Math.abs((n - m)) - 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 <= -4.8e-102: tmp = math.cos(M) * math.exp((-0.25 * math.pow(m, 2.0))) elif n <= 56.0: tmp = math.cos(((K / (2.0 / n)) - M)) * math.exp((((n + ((m * 0.5) - M)) * (M - (m * 0.5))) + (math.fabs((n - m)) - 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 <= -4.8e-102) tmp = Float64(cos(M) * exp(Float64(-0.25 * (m ^ 2.0)))); elseif (n <= 56.0) tmp = Float64(cos(Float64(Float64(K / Float64(2.0 / n)) - M)) * exp(Float64(Float64(Float64(n + Float64(Float64(m * 0.5) - M)) * Float64(M - Float64(m * 0.5))) + Float64(abs(Float64(n - m)) - 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 <= -4.8e-102) tmp = cos(M) * exp((-0.25 * (m ^ 2.0))); elseif (n <= 56.0) tmp = cos(((K / (2.0 / n)) - M)) * exp((((n + ((m * 0.5) - M)) * (M - (m * 0.5))) + (abs((n - m)) - 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, -4.8e-102], N[(N[Cos[M], $MachinePrecision] * N[Exp[N[(-0.25 * N[Power[m, 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[n, 56.0], N[(N[Cos[N[(N[(K / N[(2.0 / n), $MachinePrecision]), $MachinePrecision] - M), $MachinePrecision]], $MachinePrecision] * N[Exp[N[(N[(N[(n + N[(N[(m * 0.5), $MachinePrecision] - M), $MachinePrecision]), $MachinePrecision] * N[(M - N[(m * 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(N[Abs[N[(n - m), $MachinePrecision]], $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 -4.8 \cdot 10^{-102}:\\
\;\;\;\;\cos M \cdot e^{-0.25 \cdot {m}^{2}}\\
\mathbf{elif}\;n \leq 56:\\
\;\;\;\;\cos \left(\frac{K}{\frac{2}{n}} - M\right) \cdot e^{\left(n + \left(m \cdot 0.5 - M\right)\right) \cdot \left(M - m \cdot 0.5\right) + \left(\left|n - m\right| - \ell\right)}\\
\mathbf{else}:\\
\;\;\;\;\cos M \cdot e^{-0.25 \cdot {n}^{2}}\\
\end{array}
\end{array}
if n < -4.8e-102Initial program 71.3%
associate-/l*71.6%
+-commutative71.6%
fabs-sub71.6%
+-commutative71.6%
Simplified71.6%
Taylor expanded in K around 0 97.7%
cos-neg97.7%
Simplified97.7%
Taylor expanded in m around inf 44.2%
if -4.8e-102 < n < 56Initial program 83.1%
associate-/l*83.1%
+-commutative83.1%
fabs-sub83.1%
+-commutative83.1%
Simplified83.1%
Taylor expanded in n around 0 83.1%
+-commutative83.1%
unpow283.1%
distribute-rgt-out83.1%
*-commutative83.1%
*-commutative83.1%
Simplified83.1%
Taylor expanded in m around 0 98.3%
if 56 < n Initial program 66.1%
associate-/l*66.1%
+-commutative66.1%
fabs-sub66.1%
+-commutative66.1%
Simplified66.1%
Taylor expanded in K around 0 98.4%
cos-neg98.4%
Simplified98.4%
Taylor expanded in n around inf 96.8%
Final simplification81.9%
(FPCore (K m n M l) :precision binary64 (if (or (<= m -5.2e-12) (not (<= m 54.0))) (* (cos M) (exp (* -0.25 (pow m 2.0)))) (* (cos (- (/ K (/ 2.0 n)) M)) (exp (+ (+ l (- m n)) (* M (- n M)))))))
double code(double K, double m, double n, double M, double l) {
double tmp;
if ((m <= -5.2e-12) || !(m <= 54.0)) {
tmp = cos(M) * exp((-0.25 * pow(m, 2.0)));
} else {
tmp = cos(((K / (2.0 / n)) - M)) * exp(((l + (m - n)) + (M * (n - 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 ((m <= (-5.2d-12)) .or. (.not. (m <= 54.0d0))) then
tmp = cos(m_1) * exp(((-0.25d0) * (m ** 2.0d0)))
else
tmp = cos(((k / (2.0d0 / n)) - m_1)) * exp(((l + (m - n)) + (m_1 * (n - 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 ((m <= -5.2e-12) || !(m <= 54.0)) {
tmp = Math.cos(M) * Math.exp((-0.25 * Math.pow(m, 2.0)));
} else {
tmp = Math.cos(((K / (2.0 / n)) - M)) * Math.exp(((l + (m - n)) + (M * (n - M))));
}
return tmp;
}
def code(K, m, n, M, l): tmp = 0 if (m <= -5.2e-12) or not (m <= 54.0): tmp = math.cos(M) * math.exp((-0.25 * math.pow(m, 2.0))) else: tmp = math.cos(((K / (2.0 / n)) - M)) * math.exp(((l + (m - n)) + (M * (n - M)))) return tmp
function code(K, m, n, M, l) tmp = 0.0 if ((m <= -5.2e-12) || !(m <= 54.0)) tmp = Float64(cos(M) * exp(Float64(-0.25 * (m ^ 2.0)))); else tmp = Float64(cos(Float64(Float64(K / Float64(2.0 / n)) - M)) * exp(Float64(Float64(l + Float64(m - n)) + Float64(M * Float64(n - M))))); end return tmp end
function tmp_2 = code(K, m, n, M, l) tmp = 0.0; if ((m <= -5.2e-12) || ~((m <= 54.0))) tmp = cos(M) * exp((-0.25 * (m ^ 2.0))); else tmp = cos(((K / (2.0 / n)) - M)) * exp(((l + (m - n)) + (M * (n - M)))); end tmp_2 = tmp; end
code[K_, m_, n_, M_, l_] := If[Or[LessEqual[m, -5.2e-12], N[Not[LessEqual[m, 54.0]], $MachinePrecision]], N[(N[Cos[M], $MachinePrecision] * N[Exp[N[(-0.25 * N[Power[m, 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(N[Cos[N[(N[(K / N[(2.0 / n), $MachinePrecision]), $MachinePrecision] - M), $MachinePrecision]], $MachinePrecision] * N[Exp[N[(N[(l + N[(m - n), $MachinePrecision]), $MachinePrecision] + N[(M * N[(n - M), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;m \leq -5.2 \cdot 10^{-12} \lor \neg \left(m \leq 54\right):\\
\;\;\;\;\cos M \cdot e^{-0.25 \cdot {m}^{2}}\\
\mathbf{else}:\\
\;\;\;\;\cos \left(\frac{K}{\frac{2}{n}} - M\right) \cdot e^{\left(\ell + \left(m - n\right)\right) + M \cdot \left(n - M\right)}\\
\end{array}
\end{array}
if m < -5.19999999999999965e-12 or 54 < m Initial program 64.6%
associate-/l*64.6%
+-commutative64.6%
fabs-sub64.6%
+-commutative64.6%
Simplified64.6%
Taylor expanded in K around 0 99.2%
cos-neg99.2%
Simplified99.2%
Taylor expanded in m around inf 97.7%
if -5.19999999999999965e-12 < m < 54Initial program 86.2%
associate-/l*86.4%
+-commutative86.4%
fabs-sub86.4%
+-commutative86.4%
Simplified86.4%
Taylor expanded in n around 0 65.8%
+-commutative65.8%
unpow265.8%
distribute-rgt-out66.6%
*-commutative66.6%
*-commutative66.6%
Simplified66.6%
Taylor expanded in m around 0 67.3%
Taylor expanded in m around 0 67.3%
associate--r+67.3%
sub-neg67.3%
mul-1-neg67.3%
associate-*r*67.3%
neg-mul-167.3%
cancel-sign-sub67.3%
mul-1-neg67.3%
sub-neg67.3%
fabs-sub67.3%
Simplified67.3%
sub-neg67.3%
add-sqr-sqrt38.5%
sqrt-unprod52.1%
sqr-neg52.1%
sqrt-unprod21.3%
add-sqr-sqrt52.2%
add-sqr-sqrt27.8%
fabs-sqr27.8%
add-sqr-sqrt59.8%
Applied egg-rr59.8%
Final simplification78.6%
(FPCore (K m n M l)
:precision binary64
(if (<= n -1.02e+124)
(* (cos M) (exp (* n (- M (* m 0.5)))))
(if (<= n 55.0)
(* (cos (- (/ K (/ 2.0 n)) M)) (exp (+ (+ l (- m n)) (* M (- n M)))))
(* (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 <= -1.02e+124) {
tmp = cos(M) * exp((n * (M - (m * 0.5))));
} else if (n <= 55.0) {
tmp = cos(((K / (2.0 / n)) - M)) * exp(((l + (m - n)) + (M * (n - M))));
} 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 <= (-1.02d+124)) then
tmp = cos(m_1) * exp((n * (m_1 - (m * 0.5d0))))
else if (n <= 55.0d0) then
tmp = cos(((k / (2.0d0 / n)) - m_1)) * exp(((l + (m - n)) + (m_1 * (n - m_1))))
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 <= -1.02e+124) {
tmp = Math.cos(M) * Math.exp((n * (M - (m * 0.5))));
} else if (n <= 55.0) {
tmp = Math.cos(((K / (2.0 / n)) - M)) * Math.exp(((l + (m - n)) + (M * (n - M))));
} 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 <= -1.02e+124: tmp = math.cos(M) * math.exp((n * (M - (m * 0.5)))) elif n <= 55.0: tmp = math.cos(((K / (2.0 / n)) - M)) * math.exp(((l + (m - n)) + (M * (n - M)))) 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 <= -1.02e+124) tmp = Float64(cos(M) * exp(Float64(n * Float64(M - Float64(m * 0.5))))); elseif (n <= 55.0) tmp = Float64(cos(Float64(Float64(K / Float64(2.0 / n)) - M)) * exp(Float64(Float64(l + Float64(m - n)) + Float64(M * Float64(n - M))))); 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 <= -1.02e+124) tmp = cos(M) * exp((n * (M - (m * 0.5)))); elseif (n <= 55.0) tmp = cos(((K / (2.0 / n)) - M)) * exp(((l + (m - n)) + (M * (n - M)))); else tmp = cos(M) * exp((-0.25 * (n ^ 2.0))); end tmp_2 = tmp; end
code[K_, m_, n_, M_, l_] := If[LessEqual[n, -1.02e+124], N[(N[Cos[M], $MachinePrecision] * N[Exp[N[(n * N[(M - N[(m * 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[n, 55.0], N[(N[Cos[N[(N[(K / N[(2.0 / n), $MachinePrecision]), $MachinePrecision] - M), $MachinePrecision]], $MachinePrecision] * N[Exp[N[(N[(l + N[(m - n), $MachinePrecision]), $MachinePrecision] + N[(M * N[(n - M), $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.02 \cdot 10^{+124}:\\
\;\;\;\;\cos M \cdot e^{n \cdot \left(M - m \cdot 0.5\right)}\\
\mathbf{elif}\;n \leq 55:\\
\;\;\;\;\cos \left(\frac{K}{\frac{2}{n}} - M\right) \cdot e^{\left(\ell + \left(m - n\right)\right) + M \cdot \left(n - M\right)}\\
\mathbf{else}:\\
\;\;\;\;\cos M \cdot e^{-0.25 \cdot {n}^{2}}\\
\end{array}
\end{array}
if n < -1.01999999999999994e124Initial program 54.5%
associate-/l*54.5%
+-commutative54.5%
fabs-sub54.5%
+-commutative54.5%
Simplified54.5%
Taylor expanded in n around 0 18.6%
+-commutative18.6%
unpow218.6%
distribute-rgt-out24.7%
*-commutative24.7%
*-commutative24.7%
Simplified24.7%
Taylor expanded in n around inf 24.8%
Taylor expanded in K around 0 61.4%
cos-neg100.0%
Simplified61.4%
if -1.01999999999999994e124 < n < 55Initial program 83.4%
associate-/l*83.5%
+-commutative83.5%
fabs-sub83.5%
+-commutative83.5%
Simplified83.5%
Taylor expanded in n around 0 79.8%
+-commutative79.8%
unpow279.8%
distribute-rgt-out80.5%
*-commutative80.5%
*-commutative80.5%
Simplified80.5%
Taylor expanded in m around 0 92.3%
Taylor expanded in m around 0 68.4%
associate--r+68.4%
sub-neg68.4%
mul-1-neg68.4%
associate-*r*68.4%
neg-mul-168.4%
cancel-sign-sub68.4%
mul-1-neg68.4%
sub-neg68.4%
fabs-sub68.4%
Simplified68.4%
sub-neg68.4%
add-sqr-sqrt34.7%
sqrt-unprod51.3%
sqr-neg51.3%
sqrt-unprod24.0%
add-sqr-sqrt53.2%
add-sqr-sqrt30.5%
fabs-sqr30.5%
add-sqr-sqrt61.8%
Applied egg-rr61.8%
if 55 < n Initial program 66.1%
associate-/l*66.1%
+-commutative66.1%
fabs-sub66.1%
+-commutative66.1%
Simplified66.1%
Taylor expanded in K around 0 98.4%
cos-neg98.4%
Simplified98.4%
Taylor expanded in n around inf 96.8%
Final simplification70.2%
(FPCore (K m n M l) :precision binary64 (if (<= l 740.0) (* (cos (- (/ K (/ 2.0 n)) M)) (exp (+ (+ l (- m n)) (* M (- n M))))) (exp (- l))))
double code(double K, double m, double n, double M, double l) {
double tmp;
if (l <= 740.0) {
tmp = cos(((K / (2.0 / n)) - M)) * exp(((l + (m - n)) + (M * (n - M))));
} else {
tmp = 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 <= 740.0d0) then
tmp = cos(((k / (2.0d0 / n)) - m_1)) * exp(((l + (m - n)) + (m_1 * (n - m_1))))
else
tmp = 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 <= 740.0) {
tmp = Math.cos(((K / (2.0 / n)) - M)) * Math.exp(((l + (m - n)) + (M * (n - M))));
} else {
tmp = Math.exp(-l);
}
return tmp;
}
def code(K, m, n, M, l): tmp = 0 if l <= 740.0: tmp = math.cos(((K / (2.0 / n)) - M)) * math.exp(((l + (m - n)) + (M * (n - M)))) else: tmp = math.exp(-l) return tmp
function code(K, m, n, M, l) tmp = 0.0 if (l <= 740.0) tmp = Float64(cos(Float64(Float64(K / Float64(2.0 / n)) - M)) * exp(Float64(Float64(l + Float64(m - n)) + Float64(M * Float64(n - M))))); else tmp = exp(Float64(-l)); end return tmp end
function tmp_2 = code(K, m, n, M, l) tmp = 0.0; if (l <= 740.0) tmp = cos(((K / (2.0 / n)) - M)) * exp(((l + (m - n)) + (M * (n - M)))); else tmp = exp(-l); end tmp_2 = tmp; end
code[K_, m_, n_, M_, l_] := If[LessEqual[l, 740.0], N[(N[Cos[N[(N[(K / N[(2.0 / n), $MachinePrecision]), $MachinePrecision] - M), $MachinePrecision]], $MachinePrecision] * N[Exp[N[(N[(l + N[(m - n), $MachinePrecision]), $MachinePrecision] + N[(M * N[(n - M), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[Exp[(-l)], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\ell \leq 740:\\
\;\;\;\;\cos \left(\frac{K}{\frac{2}{n}} - M\right) \cdot e^{\left(\ell + \left(m - n\right)\right) + M \cdot \left(n - M\right)}\\
\mathbf{else}:\\
\;\;\;\;e^{-\ell}\\
\end{array}
\end{array}
if l < 740Initial program 73.5%
associate-/l*73.6%
+-commutative73.6%
fabs-sub73.6%
+-commutative73.6%
Simplified73.6%
Taylor expanded in n around 0 57.6%
+-commutative57.6%
unpow257.6%
distribute-rgt-out60.5%
*-commutative60.5%
*-commutative60.5%
Simplified60.5%
Taylor expanded in m around 0 70.9%
Taylor expanded in m around 0 48.1%
associate--r+48.1%
sub-neg48.1%
mul-1-neg48.1%
associate-*r*48.1%
neg-mul-148.1%
cancel-sign-sub48.1%
mul-1-neg48.1%
sub-neg48.1%
fabs-sub48.1%
Simplified48.1%
sub-neg48.1%
add-sqr-sqrt33.1%
sqrt-unprod43.7%
sqr-neg43.7%
sqrt-unprod14.6%
add-sqr-sqrt43.8%
add-sqr-sqrt23.2%
fabs-sqr23.2%
add-sqr-sqrt57.4%
Applied egg-rr57.4%
if 740 < l Initial program 83.0%
associate-/l*83.0%
+-commutative83.0%
fabs-sub83.0%
+-commutative83.0%
Simplified83.0%
Taylor expanded in K around 0 100.0%
cos-neg100.0%
Simplified100.0%
Taylor expanded in l around inf 100.0%
mul-1-neg100.0%
Simplified100.0%
Taylor expanded in M around 0 100.0%
Final simplification66.2%
(FPCore (K m n M l) :precision binary64 (if (<= l 700.0) (* (cos M) (exp (* n (- M (* m 0.5))))) (exp (- l))))
double code(double K, double m, double n, double M, double l) {
double tmp;
if (l <= 700.0) {
tmp = cos(M) * exp((n * (M - (m * 0.5))));
} else {
tmp = 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 <= 700.0d0) then
tmp = cos(m_1) * exp((n * (m_1 - (m * 0.5d0))))
else
tmp = 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 <= 700.0) {
tmp = Math.cos(M) * Math.exp((n * (M - (m * 0.5))));
} else {
tmp = Math.exp(-l);
}
return tmp;
}
def code(K, m, n, M, l): tmp = 0 if l <= 700.0: tmp = math.cos(M) * math.exp((n * (M - (m * 0.5)))) else: tmp = math.exp(-l) return tmp
function code(K, m, n, M, l) tmp = 0.0 if (l <= 700.0) tmp = Float64(cos(M) * exp(Float64(n * Float64(M - Float64(m * 0.5))))); else tmp = exp(Float64(-l)); end return tmp end
function tmp_2 = code(K, m, n, M, l) tmp = 0.0; if (l <= 700.0) tmp = cos(M) * exp((n * (M - (m * 0.5)))); else tmp = exp(-l); end tmp_2 = tmp; end
code[K_, m_, n_, M_, l_] := If[LessEqual[l, 700.0], N[(N[Cos[M], $MachinePrecision] * N[Exp[N[(n * N[(M - N[(m * 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[Exp[(-l)], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\ell \leq 700:\\
\;\;\;\;\cos M \cdot e^{n \cdot \left(M - m \cdot 0.5\right)}\\
\mathbf{else}:\\
\;\;\;\;e^{-\ell}\\
\end{array}
\end{array}
if l < 700Initial program 73.5%
associate-/l*73.6%
+-commutative73.6%
fabs-sub73.6%
+-commutative73.6%
Simplified73.6%
Taylor expanded in n around 0 57.6%
+-commutative57.6%
unpow257.6%
distribute-rgt-out60.5%
*-commutative60.5%
*-commutative60.5%
Simplified60.5%
Taylor expanded in n around inf 30.9%
Taylor expanded in K around 0 41.5%
cos-neg96.8%
Simplified41.5%
if 700 < l Initial program 83.0%
associate-/l*83.0%
+-commutative83.0%
fabs-sub83.0%
+-commutative83.0%
Simplified83.0%
Taylor expanded in K around 0 100.0%
cos-neg100.0%
Simplified100.0%
Taylor expanded in l around inf 100.0%
mul-1-neg100.0%
Simplified100.0%
Taylor expanded in M around 0 100.0%
Final simplification53.6%
(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 75.5%
associate-/l*75.6%
+-commutative75.6%
fabs-sub75.6%
+-commutative75.6%
Simplified75.6%
Taylor expanded in K around 0 97.5%
cos-neg97.5%
Simplified97.5%
Taylor expanded in l around inf 32.1%
mul-1-neg32.1%
Simplified32.1%
Final simplification32.1%
(FPCore (K m n M l) :precision binary64 (exp (- l)))
double code(double K, double m, double n, double M, double l) {
return 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 = exp(-l)
end function
public static double code(double K, double m, double n, double M, double l) {
return Math.exp(-l);
}
def code(K, m, n, M, l): return math.exp(-l)
function code(K, m, n, M, l) return exp(Float64(-l)) end
function tmp = code(K, m, n, M, l) tmp = exp(-l); end
code[K_, m_, n_, M_, l_] := N[Exp[(-l)], $MachinePrecision]
\begin{array}{l}
\\
e^{-\ell}
\end{array}
Initial program 75.5%
associate-/l*75.6%
+-commutative75.6%
fabs-sub75.6%
+-commutative75.6%
Simplified75.6%
Taylor expanded in K around 0 97.5%
cos-neg97.5%
Simplified97.5%
Taylor expanded in l around inf 32.1%
mul-1-neg32.1%
Simplified32.1%
Taylor expanded in M around 0 32.1%
Final simplification32.1%
(FPCore (K m n M l) :precision binary64 1.0)
double code(double K, double m, double n, double M, double l) {
return 1.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 = 1.0d0
end function
public static double code(double K, double m, double n, double M, double l) {
return 1.0;
}
def code(K, m, n, M, l): return 1.0
function code(K, m, n, M, l) return 1.0 end
function tmp = code(K, m, n, M, l) tmp = 1.0; end
code[K_, m_, n_, M_, l_] := 1.0
\begin{array}{l}
\\
1
\end{array}
Initial program 75.5%
associate-/l*75.6%
+-commutative75.6%
fabs-sub75.6%
+-commutative75.6%
Simplified75.6%
Taylor expanded in K around 0 97.5%
cos-neg97.5%
Simplified97.5%
Taylor expanded in M around inf 54.0%
mul-1-neg54.0%
Simplified54.0%
Taylor expanded in M around 0 7.4%
Final simplification7.4%
herbie shell --seed 2024021
(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)))))))