
(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 8 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (K m n M l) :precision binary64 (* (cos (- (/ (* K (+ m n)) 2.0) M)) (exp (- (- (pow (- (/ (+ m n) 2.0) M) 2.0)) (- l (fabs (- m n)))))))
double code(double K, double m, double n, double M, double l) {
return cos((((K * (m + n)) / 2.0) - M)) * exp((-pow((((m + n) / 2.0) - M), 2.0) - (l - fabs((m - n)))));
}
real(8) function code(k, m, n, m_1, l)
real(8), intent (in) :: k
real(8), intent (in) :: m
real(8), intent (in) :: n
real(8), intent (in) :: m_1
real(8), intent (in) :: l
code = cos((((k * (m + n)) / 2.0d0) - m_1)) * exp((-((((m + n) / 2.0d0) - m_1) ** 2.0d0) - (l - abs((m - n)))))
end function
public static double code(double K, double m, double n, double M, double l) {
return Math.cos((((K * (m + n)) / 2.0) - M)) * Math.exp((-Math.pow((((m + n) / 2.0) - M), 2.0) - (l - Math.abs((m - n)))));
}
def code(K, m, n, M, l): return math.cos((((K * (m + n)) / 2.0) - M)) * math.exp((-math.pow((((m + n) / 2.0) - M), 2.0) - (l - math.fabs((m - n)))))
function code(K, m, n, M, l) return Float64(cos(Float64(Float64(Float64(K * Float64(m + n)) / 2.0) - M)) * exp(Float64(Float64(-(Float64(Float64(Float64(m + n) / 2.0) - M) ^ 2.0)) - Float64(l - abs(Float64(m - n)))))) end
function tmp = code(K, m, n, M, l) tmp = cos((((K * (m + n)) / 2.0) - M)) * exp((-((((m + n) / 2.0) - M) ^ 2.0) - (l - abs((m - n))))); end
code[K_, m_, n_, M_, l_] := N[(N[Cos[N[(N[(N[(K * N[(m + n), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision] - M), $MachinePrecision]], $MachinePrecision] * N[Exp[N[((-N[Power[N[(N[(N[(m + n), $MachinePrecision] / 2.0), $MachinePrecision] - M), $MachinePrecision], 2.0], $MachinePrecision]) - N[(l - N[Abs[N[(m - n), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\cos \left(\frac{K \cdot \left(m + n\right)}{2} - M\right) \cdot e^{\left(-{\left(\frac{m + n}{2} - M\right)}^{2}\right) - \left(\ell - \left|m - n\right|\right)}
\end{array}
(FPCore (K m n M l) :precision binary64 (* (cos M) (exp (- (- (fabs (- m n)) l) (pow (- (/ (+ m n) 2.0) M) 2.0)))))
double code(double K, double m, double n, double M, double l) {
return cos(M) * exp(((fabs((m - n)) - l) - pow((((m + n) / 2.0) - M), 2.0)));
}
real(8) function code(k, m, n, m_1, l)
real(8), intent (in) :: k
real(8), intent (in) :: m
real(8), intent (in) :: n
real(8), intent (in) :: m_1
real(8), intent (in) :: l
code = cos(m_1) * exp(((abs((m - n)) - l) - ((((m + n) / 2.0d0) - m_1) ** 2.0d0)))
end function
public static double code(double K, double m, double n, double M, double l) {
return Math.cos(M) * Math.exp(((Math.abs((m - n)) - l) - Math.pow((((m + n) / 2.0) - M), 2.0)));
}
def code(K, m, n, M, l): return math.cos(M) * math.exp(((math.fabs((m - n)) - l) - math.pow((((m + n) / 2.0) - M), 2.0)))
function code(K, m, n, M, l) return Float64(cos(M) * exp(Float64(Float64(abs(Float64(m - n)) - l) - (Float64(Float64(Float64(m + n) / 2.0) - M) ^ 2.0)))) end
function tmp = code(K, m, n, M, l) tmp = cos(M) * exp(((abs((m - n)) - l) - ((((m + n) / 2.0) - M) ^ 2.0))); end
code[K_, m_, n_, M_, l_] := N[(N[Cos[M], $MachinePrecision] * N[Exp[N[(N[(N[Abs[N[(m - n), $MachinePrecision]], $MachinePrecision] - l), $MachinePrecision] - N[Power[N[(N[(N[(m + n), $MachinePrecision] / 2.0), $MachinePrecision] - M), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\cos M \cdot e^{\left(\left|m - n\right| - \ell\right) - {\left(\frac{m + n}{2} - M\right)}^{2}}
\end{array}
Initial program 78.1%
Taylor expanded in K around 0 95.6%
cos-neg95.6%
Simplified95.6%
Final simplification95.6%
(FPCore (K m n M l)
:precision binary64
(if (<= m -55.0)
(* (cos M) (exp (* -0.25 (pow m 2.0))))
(if (<= m 4.4e-277)
(*
(cos (- (/ (* (+ m n) K) 2.0) M))
(exp (+ (* M (- n M)) (- (fabs (- 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 (m <= -55.0) {
tmp = cos(M) * exp((-0.25 * pow(m, 2.0)));
} else if (m <= 4.4e-277) {
tmp = cos(((((m + n) * K) / 2.0) - M)) * exp(((M * (n - M)) + (fabs((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 (m <= (-55.0d0)) then
tmp = cos(m_1) * exp(((-0.25d0) * (m ** 2.0d0)))
else if (m <= 4.4d-277) then
tmp = cos(((((m + n) * k) / 2.0d0) - m_1)) * exp(((m_1 * (n - m_1)) + (abs((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 (m <= -55.0) {
tmp = Math.cos(M) * Math.exp((-0.25 * Math.pow(m, 2.0)));
} else if (m <= 4.4e-277) {
tmp = Math.cos(((((m + n) * K) / 2.0) - M)) * Math.exp(((M * (n - M)) + (Math.abs((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 m <= -55.0: tmp = math.cos(M) * math.exp((-0.25 * math.pow(m, 2.0))) elif m <= 4.4e-277: tmp = math.cos(((((m + n) * K) / 2.0) - M)) * math.exp(((M * (n - M)) + (math.fabs((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 (m <= -55.0) tmp = Float64(cos(M) * exp(Float64(-0.25 * (m ^ 2.0)))); elseif (m <= 4.4e-277) tmp = Float64(cos(Float64(Float64(Float64(Float64(m + n) * K) / 2.0) - M)) * exp(Float64(Float64(M * Float64(n - M)) + Float64(abs(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 (m <= -55.0) tmp = cos(M) * exp((-0.25 * (m ^ 2.0))); elseif (m <= 4.4e-277) tmp = cos(((((m + n) * K) / 2.0) - M)) * exp(((M * (n - M)) + (abs((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[m, -55.0], N[(N[Cos[M], $MachinePrecision] * N[Exp[N[(-0.25 * N[Power[m, 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[m, 4.4e-277], N[(N[Cos[N[(N[(N[(N[(m + n), $MachinePrecision] * K), $MachinePrecision] / 2.0), $MachinePrecision] - M), $MachinePrecision]], $MachinePrecision] * N[Exp[N[(N[(M * N[(n - M), $MachinePrecision]), $MachinePrecision] + N[(N[Abs[N[(m - n), $MachinePrecision]], $MachinePrecision] - l), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(N[Cos[M], $MachinePrecision] * N[Exp[N[(-0.25 * N[Power[n, 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;m \leq -55:\\
\;\;\;\;\cos M \cdot e^{-0.25 \cdot {m}^{2}}\\
\mathbf{elif}\;m \leq 4.4 \cdot 10^{-277}:\\
\;\;\;\;\cos \left(\frac{\left(m + n\right) \cdot K}{2} - M\right) \cdot e^{M \cdot \left(n - 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 m < -55Initial program 69.6%
Taylor expanded in K around 0 98.6%
cos-neg98.6%
Simplified98.6%
Taylor expanded in m around inf 95.7%
if -55 < m < 4.39999999999999991e-277Initial program 84.7%
Taylor expanded in n around 0 54.7%
+-commutative54.7%
unpow254.7%
distribute-rgt-out59.0%
*-commutative59.0%
*-commutative59.0%
Simplified59.0%
Taylor expanded in m around 0 59.0%
associate--r+59.0%
associate-*r*59.0%
neg-mul-159.0%
cancel-sign-sub59.0%
Simplified59.0%
if 4.39999999999999991e-277 < m Initial program 79.3%
Taylor expanded in K around 0 97.5%
cos-neg97.5%
Simplified97.5%
Taylor expanded in n around inf 54.9%
Final simplification67.0%
(FPCore (K m n M l)
:precision binary64
(let* ((t_0 (- M (* m 0.5))))
(if (<= n 155.0)
(* (cos M) (exp (+ (* (- n t_0) t_0) (- (fabs (- 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 t_0 = M - (m * 0.5);
double tmp;
if (n <= 155.0) {
tmp = cos(M) * exp((((n - t_0) * t_0) + (fabs((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) :: t_0
real(8) :: tmp
t_0 = m_1 - (m * 0.5d0)
if (n <= 155.0d0) then
tmp = cos(m_1) * exp((((n - t_0) * t_0) + (abs((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 t_0 = M - (m * 0.5);
double tmp;
if (n <= 155.0) {
tmp = Math.cos(M) * Math.exp((((n - t_0) * t_0) + (Math.abs((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): t_0 = M - (m * 0.5) tmp = 0 if n <= 155.0: tmp = math.cos(M) * math.exp((((n - t_0) * t_0) + (math.fabs((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) t_0 = Float64(M - Float64(m * 0.5)) tmp = 0.0 if (n <= 155.0) tmp = Float64(cos(M) * exp(Float64(Float64(Float64(n - t_0) * t_0) + Float64(abs(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) t_0 = M - (m * 0.5); tmp = 0.0; if (n <= 155.0) tmp = cos(M) * exp((((n - t_0) * t_0) + (abs((m - n)) - l))); else tmp = cos(M) * exp((-0.25 * (n ^ 2.0))); end tmp_2 = tmp; end
code[K_, m_, n_, M_, l_] := Block[{t$95$0 = N[(M - N[(m * 0.5), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[n, 155.0], N[(N[Cos[M], $MachinePrecision] * N[Exp[N[(N[(N[(n - t$95$0), $MachinePrecision] * t$95$0), $MachinePrecision] + N[(N[Abs[N[(m - n), $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}
t_0 := M - m \cdot 0.5\\
\mathbf{if}\;n \leq 155:\\
\;\;\;\;\cos M \cdot e^{\left(n - t\_0\right) \cdot t\_0 + \left(\left|m - n\right| - \ell\right)}\\
\mathbf{else}:\\
\;\;\;\;\cos M \cdot e^{-0.25 \cdot {n}^{2}}\\
\end{array}
\end{array}
if n < 155Initial program 81.0%
Taylor expanded in K around 0 94.6%
cos-neg94.6%
Simplified94.6%
Taylor expanded in n around 0 78.7%
+-commutative67.7%
unpow267.7%
distribute-rgt-out70.9%
*-commutative70.9%
*-commutative70.9%
Simplified81.9%
if 155 < n Initial program 70.1%
Taylor expanded in K around 0 98.5%
cos-neg98.5%
Simplified98.5%
Taylor expanded in n around inf 97.1%
Final simplification85.9%
(FPCore (K m n M l) :precision binary64 (if (or (<= m -55.0) (not (<= m 3.35))) (* (cos M) (exp (* -0.25 (pow m 2.0)))) (* (cos M) (exp (* M (- M))))))
double code(double K, double m, double n, double M, double l) {
double tmp;
if ((m <= -55.0) || !(m <= 3.35)) {
tmp = cos(M) * exp((-0.25 * pow(m, 2.0)));
} else {
tmp = cos(M) * exp((M * -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 <= (-55.0d0)) .or. (.not. (m <= 3.35d0))) then
tmp = cos(m_1) * exp(((-0.25d0) * (m ** 2.0d0)))
else
tmp = cos(m_1) * exp((m_1 * -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 <= -55.0) || !(m <= 3.35)) {
tmp = Math.cos(M) * Math.exp((-0.25 * Math.pow(m, 2.0)));
} else {
tmp = Math.cos(M) * Math.exp((M * -M));
}
return tmp;
}
def code(K, m, n, M, l): tmp = 0 if (m <= -55.0) or not (m <= 3.35): tmp = math.cos(M) * math.exp((-0.25 * math.pow(m, 2.0))) else: tmp = math.cos(M) * math.exp((M * -M)) return tmp
function code(K, m, n, M, l) tmp = 0.0 if ((m <= -55.0) || !(m <= 3.35)) tmp = Float64(cos(M) * exp(Float64(-0.25 * (m ^ 2.0)))); else tmp = Float64(cos(M) * exp(Float64(M * Float64(-M)))); end return tmp end
function tmp_2 = code(K, m, n, M, l) tmp = 0.0; if ((m <= -55.0) || ~((m <= 3.35))) tmp = cos(M) * exp((-0.25 * (m ^ 2.0))); else tmp = cos(M) * exp((M * -M)); end tmp_2 = tmp; end
code[K_, m_, n_, M_, l_] := If[Or[LessEqual[m, -55.0], N[Not[LessEqual[m, 3.35]], $MachinePrecision]], N[(N[Cos[M], $MachinePrecision] * N[Exp[N[(-0.25 * N[Power[m, 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(N[Cos[M], $MachinePrecision] * N[Exp[N[(M * (-M)), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;m \leq -55 \lor \neg \left(m \leq 3.35\right):\\
\;\;\;\;\cos M \cdot e^{-0.25 \cdot {m}^{2}}\\
\mathbf{else}:\\
\;\;\;\;\cos M \cdot e^{M \cdot \left(-M\right)}\\
\end{array}
\end{array}
if m < -55 or 3.35000000000000009 < m Initial program 71.2%
Taylor expanded in K around 0 99.2%
cos-neg99.2%
Simplified99.2%
Taylor expanded in m around inf 96.3%
if -55 < m < 3.35000000000000009Initial program 85.5%
Taylor expanded in K around 0 91.8%
cos-neg91.8%
Simplified91.8%
Taylor expanded in M around inf 55.7%
mul-1-neg55.7%
Simplified55.7%
unpow255.7%
Applied egg-rr55.7%
Final simplification76.6%
(FPCore (K m n M l)
:precision binary64
(if (<= m -55.0)
(* (cos M) (exp (* -0.25 (pow m 2.0))))
(if (<= m -2.6e-219)
(* (cos M) (exp (* M (- 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 (m <= -55.0) {
tmp = cos(M) * exp((-0.25 * pow(m, 2.0)));
} else if (m <= -2.6e-219) {
tmp = cos(M) * exp((M * -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 (m <= (-55.0d0)) then
tmp = cos(m_1) * exp(((-0.25d0) * (m ** 2.0d0)))
else if (m <= (-2.6d-219)) then
tmp = cos(m_1) * exp((m_1 * -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 (m <= -55.0) {
tmp = Math.cos(M) * Math.exp((-0.25 * Math.pow(m, 2.0)));
} else if (m <= -2.6e-219) {
tmp = Math.cos(M) * Math.exp((M * -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 m <= -55.0: tmp = math.cos(M) * math.exp((-0.25 * math.pow(m, 2.0))) elif m <= -2.6e-219: tmp = math.cos(M) * math.exp((M * -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 (m <= -55.0) tmp = Float64(cos(M) * exp(Float64(-0.25 * (m ^ 2.0)))); elseif (m <= -2.6e-219) tmp = Float64(cos(M) * exp(Float64(M * Float64(-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 (m <= -55.0) tmp = cos(M) * exp((-0.25 * (m ^ 2.0))); elseif (m <= -2.6e-219) tmp = cos(M) * exp((M * -M)); else tmp = cos(M) * exp((-0.25 * (n ^ 2.0))); end tmp_2 = tmp; end
code[K_, m_, n_, M_, l_] := If[LessEqual[m, -55.0], N[(N[Cos[M], $MachinePrecision] * N[Exp[N[(-0.25 * N[Power[m, 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[m, -2.6e-219], N[(N[Cos[M], $MachinePrecision] * N[Exp[N[(M * (-M)), $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}\;m \leq -55:\\
\;\;\;\;\cos M \cdot e^{-0.25 \cdot {m}^{2}}\\
\mathbf{elif}\;m \leq -2.6 \cdot 10^{-219}:\\
\;\;\;\;\cos M \cdot e^{M \cdot \left(-M\right)}\\
\mathbf{else}:\\
\;\;\;\;\cos M \cdot e^{-0.25 \cdot {n}^{2}}\\
\end{array}
\end{array}
if m < -55Initial program 69.6%
Taylor expanded in K around 0 98.6%
cos-neg98.6%
Simplified98.6%
Taylor expanded in m around inf 95.7%
if -55 < m < -2.60000000000000002e-219Initial program 85.5%
Taylor expanded in K around 0 93.0%
cos-neg93.0%
Simplified93.0%
Taylor expanded in M around inf 65.5%
mul-1-neg65.5%
Simplified65.5%
unpow265.5%
Applied egg-rr65.5%
if -2.60000000000000002e-219 < m Initial program 80.2%
Taylor expanded in K around 0 94.9%
cos-neg94.9%
Simplified94.9%
Taylor expanded in n around inf 52.9%
Final simplification66.4%
(FPCore (K m n M l) :precision binary64 (if (or (<= M -7.5e-16) (not (<= M 0.025))) (* (cos M) (exp (* M (- M)))) (* (cos M) (exp (- l)))))
double code(double K, double m, double n, double M, double l) {
double tmp;
if ((M <= -7.5e-16) || !(M <= 0.025)) {
tmp = cos(M) * exp((M * -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 ((m_1 <= (-7.5d-16)) .or. (.not. (m_1 <= 0.025d0))) then
tmp = cos(m_1) * exp((m_1 * -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 ((M <= -7.5e-16) || !(M <= 0.025)) {
tmp = Math.cos(M) * Math.exp((M * -M));
} else {
tmp = Math.cos(M) * Math.exp(-l);
}
return tmp;
}
def code(K, m, n, M, l): tmp = 0 if (M <= -7.5e-16) or not (M <= 0.025): tmp = math.cos(M) * math.exp((M * -M)) else: tmp = math.cos(M) * math.exp(-l) return tmp
function code(K, m, n, M, l) tmp = 0.0 if ((M <= -7.5e-16) || !(M <= 0.025)) tmp = Float64(cos(M) * exp(Float64(M * Float64(-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 ((M <= -7.5e-16) || ~((M <= 0.025))) tmp = cos(M) * exp((M * -M)); else tmp = cos(M) * exp(-l); end tmp_2 = tmp; end
code[K_, m_, n_, M_, l_] := If[Or[LessEqual[M, -7.5e-16], N[Not[LessEqual[M, 0.025]], $MachinePrecision]], N[(N[Cos[M], $MachinePrecision] * N[Exp[N[(M * (-M)), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(N[Cos[M], $MachinePrecision] * N[Exp[(-l)], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;M \leq -7.5 \cdot 10^{-16} \lor \neg \left(M \leq 0.025\right):\\
\;\;\;\;\cos M \cdot e^{M \cdot \left(-M\right)}\\
\mathbf{else}:\\
\;\;\;\;\cos M \cdot e^{-\ell}\\
\end{array}
\end{array}
if M < -7.5e-16 or 0.025000000000000001 < M Initial program 82.2%
Taylor expanded in K around 0 98.4%
cos-neg98.4%
Simplified98.4%
Taylor expanded in M around inf 93.9%
mul-1-neg93.9%
Simplified93.9%
unpow293.9%
Applied egg-rr93.9%
if -7.5e-16 < M < 0.025000000000000001Initial program 74.0%
Taylor expanded in l around inf 35.1%
mul-1-neg35.1%
Simplified35.1%
Taylor expanded in K around 0 38.5%
cos-neg38.5%
Simplified38.5%
Final simplification66.4%
(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 78.1%
Taylor expanded in l around inf 27.6%
mul-1-neg27.6%
Simplified27.6%
Taylor expanded in K around 0 30.7%
cos-neg30.7%
Simplified30.7%
Final simplification30.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(Float64(-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 \left(-M\right)
\end{array}
Initial program 78.1%
Taylor expanded in l around inf 27.6%
mul-1-neg27.6%
Simplified27.6%
Taylor expanded in l around 0 7.3%
associate-*r*7.3%
fmm-def7.3%
remove-double-neg7.3%
mul-1-neg7.3%
sub-neg7.3%
fmm-def7.3%
associate-*r*7.3%
associate-*r*7.3%
sub-neg7.3%
mul-1-neg7.3%
remove-double-neg7.3%
associate-*r*7.3%
+-commutative7.3%
Simplified7.3%
Taylor expanded in K around 0 7.8%
neg-mul-17.8%
Simplified7.8%
Final simplification7.8%
herbie shell --seed 2024112
(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)))))))