
(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 7 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 (pow (- (cbrt M)) 3.0)) (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(pow(-cbrt(M), 3.0)) * exp(((fabs((n - m)) - l) - pow((((m + n) / 2.0) - M), 2.0)));
}
public static double code(double K, double m, double n, double M, double l) {
return Math.cos(Math.pow(-Math.cbrt(M), 3.0)) * Math.exp(((Math.abs((n - m)) - l) - Math.pow((((m + n) / 2.0) - M), 2.0)));
}
function code(K, m, n, M, l) return Float64(cos((Float64(-cbrt(M)) ^ 3.0)) * exp(Float64(Float64(abs(Float64(n - m)) - l) - (Float64(Float64(Float64(m + n) / 2.0) - M) ^ 2.0)))) end
code[K_, m_, n_, M_, l_] := N[(N[Cos[N[Power[(-N[Power[M, 1/3], $MachinePrecision]), 3.0], $MachinePrecision]], $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 \left({\left(-\sqrt[3]{M}\right)}^{3}\right) \cdot e^{\left(\left|n - m\right| - \ell\right) - {\left(\frac{m + n}{2} - M\right)}^{2}}
\end{array}
Initial program 76.7%
add-cube-cbrt76.3%
pow376.7%
associate-/l*76.7%
fma-neg76.7%
div-inv76.7%
metadata-eval76.7%
Applied egg-rr76.7%
Taylor expanded in M around -inf 97.0%
neg-mul-197.0%
Simplified97.0%
Final simplification97.0%
(FPCore (K m n M l) :precision binary64 (* (exp (- (- (fabs (- n m)) l) (pow (- (/ (+ m n) 2.0) M) 2.0))) (cos M)))
double code(double K, double m, double n, double M, double l) {
return exp(((fabs((n - m)) - l) - pow((((m + n) / 2.0) - M), 2.0))) * 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 = exp(((abs((n - m)) - l) - ((((m + n) / 2.0d0) - m_1) ** 2.0d0))) * cos(m_1)
end function
public static double code(double K, double m, double n, double M, double l) {
return Math.exp(((Math.abs((n - m)) - l) - Math.pow((((m + n) / 2.0) - M), 2.0))) * Math.cos(M);
}
def code(K, m, n, M, l): return math.exp(((math.fabs((n - m)) - l) - math.pow((((m + n) / 2.0) - M), 2.0))) * math.cos(M)
function code(K, m, n, M, l) return Float64(exp(Float64(Float64(abs(Float64(n - m)) - l) - (Float64(Float64(Float64(m + n) / 2.0) - M) ^ 2.0))) * cos(M)) end
function tmp = code(K, m, n, M, l) tmp = exp(((abs((n - m)) - l) - ((((m + n) / 2.0) - M) ^ 2.0))) * cos(M); end
code[K_, m_, n_, M_, l_] := N[(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] * N[Cos[M], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
e^{\left(\left|n - m\right| - \ell\right) - {\left(\frac{m + n}{2} - M\right)}^{2}} \cdot \cos M
\end{array}
Initial program 76.7%
Taylor expanded in K around 0 96.6%
cos-neg96.6%
Simplified96.6%
Final simplification96.6%
(FPCore (K m n M l)
:precision binary64
(let* ((t_0 (- (fabs (- n m)) l)))
(if (<= m -2.2e+56)
(* (cos M) (exp (+ (* (- (* m 0.5) M) (- M (* m 0.5))) t_0)))
(* (cos M) (exp (+ (* (- (* n 0.5) M) (- (- M (* n 0.5)) m)) t_0))))))
double code(double K, double m, double n, double M, double l) {
double t_0 = fabs((n - m)) - l;
double tmp;
if (m <= -2.2e+56) {
tmp = cos(M) * exp(((((m * 0.5) - M) * (M - (m * 0.5))) + t_0));
} else {
tmp = cos(M) * exp(((((n * 0.5) - M) * ((M - (n * 0.5)) - m)) + 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 = abs((n - m)) - l
if (m <= (-2.2d+56)) then
tmp = cos(m_1) * exp(((((m * 0.5d0) - m_1) * (m_1 - (m * 0.5d0))) + t_0))
else
tmp = cos(m_1) * exp(((((n * 0.5d0) - m_1) * ((m_1 - (n * 0.5d0)) - m)) + 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.abs((n - m)) - l;
double tmp;
if (m <= -2.2e+56) {
tmp = Math.cos(M) * Math.exp(((((m * 0.5) - M) * (M - (m * 0.5))) + t_0));
} else {
tmp = Math.cos(M) * Math.exp(((((n * 0.5) - M) * ((M - (n * 0.5)) - m)) + t_0));
}
return tmp;
}
def code(K, m, n, M, l): t_0 = math.fabs((n - m)) - l tmp = 0 if m <= -2.2e+56: tmp = math.cos(M) * math.exp(((((m * 0.5) - M) * (M - (m * 0.5))) + t_0)) else: tmp = math.cos(M) * math.exp(((((n * 0.5) - M) * ((M - (n * 0.5)) - m)) + t_0)) return tmp
function code(K, m, n, M, l) t_0 = Float64(abs(Float64(n - m)) - l) tmp = 0.0 if (m <= -2.2e+56) tmp = Float64(cos(M) * exp(Float64(Float64(Float64(Float64(m * 0.5) - M) * Float64(M - Float64(m * 0.5))) + t_0))); else tmp = Float64(cos(M) * exp(Float64(Float64(Float64(Float64(n * 0.5) - M) * Float64(Float64(M - Float64(n * 0.5)) - m)) + t_0))); end return tmp end
function tmp_2 = code(K, m, n, M, l) t_0 = abs((n - m)) - l; tmp = 0.0; if (m <= -2.2e+56) tmp = cos(M) * exp(((((m * 0.5) - M) * (M - (m * 0.5))) + t_0)); else tmp = cos(M) * exp(((((n * 0.5) - M) * ((M - (n * 0.5)) - m)) + t_0)); end tmp_2 = tmp; end
code[K_, m_, n_, M_, l_] := Block[{t$95$0 = N[(N[Abs[N[(n - m), $MachinePrecision]], $MachinePrecision] - l), $MachinePrecision]}, If[LessEqual[m, -2.2e+56], N[(N[Cos[M], $MachinePrecision] * N[Exp[N[(N[(N[(N[(m * 0.5), $MachinePrecision] - M), $MachinePrecision] * N[(M - N[(m * 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + t$95$0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(N[Cos[M], $MachinePrecision] * N[Exp[N[(N[(N[(N[(n * 0.5), $MachinePrecision] - M), $MachinePrecision] * N[(N[(M - N[(n * 0.5), $MachinePrecision]), $MachinePrecision] - m), $MachinePrecision]), $MachinePrecision] + t$95$0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left|n - m\right| - \ell\\
\mathbf{if}\;m \leq -2.2 \cdot 10^{+56}:\\
\;\;\;\;\cos M \cdot e^{\left(m \cdot 0.5 - M\right) \cdot \left(M - m \cdot 0.5\right) + t\_0}\\
\mathbf{else}:\\
\;\;\;\;\cos M \cdot e^{\left(n \cdot 0.5 - M\right) \cdot \left(\left(M - n \cdot 0.5\right) - m\right) + t\_0}\\
\end{array}
\end{array}
if m < -2.20000000000000016e56Initial program 64.7%
Taylor expanded in K around 0 100.0%
cos-neg100.0%
Simplified100.0%
Taylor expanded in n around 0 86.3%
+-commutative86.3%
unpow286.3%
distribute-rgt-out96.1%
*-commutative96.1%
*-commutative96.1%
Simplified96.1%
Taylor expanded in n around 0 100.0%
if -2.20000000000000016e56 < m Initial program 79.6%
Taylor expanded in K around 0 95.8%
cos-neg95.8%
Simplified95.8%
Taylor expanded in m around 0 80.1%
+-commutative80.1%
unpow280.1%
distribute-rgt-out83.1%
*-commutative83.1%
*-commutative83.1%
Simplified83.1%
Final simplification86.4%
(FPCore (K m n M l) :precision binary64 (if (or (<= M -4.9e-5) (not (<= M 30.5))) (* (cos M) (exp (- (pow M 2.0)))) (* (cos M) (exp (+ (* M (- M n)) (- (- m n) l))))))
double code(double K, double m, double n, double M, double l) {
double tmp;
if ((M <= -4.9e-5) || !(M <= 30.5)) {
tmp = cos(M) * exp(-pow(M, 2.0));
} else {
tmp = cos(M) * exp(((M * (M - n)) + ((m - n) - l)));
}
return tmp;
}
real(8) function code(k, m, n, m_1, l)
real(8), intent (in) :: k
real(8), intent (in) :: m
real(8), intent (in) :: n
real(8), intent (in) :: m_1
real(8), intent (in) :: l
real(8) :: tmp
if ((m_1 <= (-4.9d-5)) .or. (.not. (m_1 <= 30.5d0))) then
tmp = cos(m_1) * exp(-(m_1 ** 2.0d0))
else
tmp = cos(m_1) * exp(((m_1 * (m_1 - n)) + ((m - n) - l)))
end if
code = tmp
end function
public static double code(double K, double m, double n, double M, double l) {
double tmp;
if ((M <= -4.9e-5) || !(M <= 30.5)) {
tmp = Math.cos(M) * Math.exp(-Math.pow(M, 2.0));
} else {
tmp = Math.cos(M) * Math.exp(((M * (M - n)) + ((m - n) - l)));
}
return tmp;
}
def code(K, m, n, M, l): tmp = 0 if (M <= -4.9e-5) or not (M <= 30.5): tmp = math.cos(M) * math.exp(-math.pow(M, 2.0)) else: tmp = math.cos(M) * math.exp(((M * (M - n)) + ((m - n) - l))) return tmp
function code(K, m, n, M, l) tmp = 0.0 if ((M <= -4.9e-5) || !(M <= 30.5)) tmp = Float64(cos(M) * exp(Float64(-(M ^ 2.0)))); else tmp = Float64(cos(M) * exp(Float64(Float64(M * Float64(M - n)) + Float64(Float64(m - n) - l)))); end return tmp end
function tmp_2 = code(K, m, n, M, l) tmp = 0.0; if ((M <= -4.9e-5) || ~((M <= 30.5))) tmp = cos(M) * exp(-(M ^ 2.0)); else tmp = cos(M) * exp(((M * (M - n)) + ((m - n) - l))); end tmp_2 = tmp; end
code[K_, m_, n_, M_, l_] := If[Or[LessEqual[M, -4.9e-5], N[Not[LessEqual[M, 30.5]], $MachinePrecision]], N[(N[Cos[M], $MachinePrecision] * N[Exp[(-N[Power[M, 2.0], $MachinePrecision])], $MachinePrecision]), $MachinePrecision], N[(N[Cos[M], $MachinePrecision] * N[Exp[N[(N[(M * N[(M - n), $MachinePrecision]), $MachinePrecision] + N[(N[(m - n), $MachinePrecision] - l), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;M \leq -4.9 \cdot 10^{-5} \lor \neg \left(M \leq 30.5\right):\\
\;\;\;\;\cos M \cdot e^{-{M}^{2}}\\
\mathbf{else}:\\
\;\;\;\;\cos M \cdot e^{M \cdot \left(M - n\right) + \left(\left(m - n\right) - \ell\right)}\\
\end{array}
\end{array}
if M < -4.9e-5 or 30.5 < M Initial program 78.7%
Taylor expanded in K around 0 98.4%
cos-neg98.4%
Simplified98.4%
Taylor expanded in n around 0 84.4%
+-commutative84.4%
unpow284.4%
distribute-rgt-out88.6%
*-commutative88.6%
*-commutative88.6%
Simplified88.6%
Taylor expanded in m around 0 88.6%
associate-*r*88.6%
neg-mul-188.6%
Simplified88.6%
Taylor expanded in M around inf 96.7%
mul-1-neg96.7%
Simplified96.7%
if -4.9e-5 < M < 30.5Initial program 74.8%
Taylor expanded in K around 0 95.1%
cos-neg95.1%
Simplified95.1%
Taylor expanded in n around 0 71.7%
+-commutative71.7%
unpow271.7%
distribute-rgt-out76.9%
*-commutative76.9%
*-commutative76.9%
Simplified76.9%
Taylor expanded in m around 0 36.4%
associate-*r*36.4%
neg-mul-136.4%
Simplified36.4%
distribute-rgt-neg-in36.4%
fma-neg36.4%
add-sqr-sqrt16.5%
sqrt-unprod36.4%
sqr-neg36.4%
sqrt-unprod19.9%
add-sqr-sqrt36.4%
sub-neg36.4%
distribute-neg-in36.4%
remove-double-neg36.4%
add-sqr-sqrt21.6%
fabs-sqr21.6%
add-sqr-sqrt58.8%
Applied egg-rr58.8%
fma-undefine58.8%
unsub-neg58.8%
neg-mul-158.8%
+-commutative58.8%
neg-mul-158.8%
sub-neg58.8%
sub-neg58.8%
sub-neg58.8%
neg-mul-158.8%
+-commutative58.8%
distribute-neg-in58.8%
neg-mul-158.8%
remove-double-neg58.8%
sub-neg58.8%
Simplified58.8%
Final simplification76.8%
(FPCore (K m n M l)
:precision binary64
(if (<= M -9.2e+23)
(* (cos M) (exp (* M n)))
(if (<= M 3.9e+117)
(* (cos M) (exp (+ (* M (- M n)) (- (- m n) l))))
(* (cos M) (exp (- l))))))
double code(double K, double m, double n, double M, double l) {
double tmp;
if (M <= -9.2e+23) {
tmp = cos(M) * exp((M * n));
} else if (M <= 3.9e+117) {
tmp = cos(M) * exp(((M * (M - n)) + ((m - n) - l)));
} else {
tmp = cos(M) * exp(-l);
}
return tmp;
}
real(8) function code(k, m, n, m_1, l)
real(8), intent (in) :: k
real(8), intent (in) :: m
real(8), intent (in) :: n
real(8), intent (in) :: m_1
real(8), intent (in) :: l
real(8) :: tmp
if (m_1 <= (-9.2d+23)) then
tmp = cos(m_1) * exp((m_1 * n))
else if (m_1 <= 3.9d+117) then
tmp = cos(m_1) * exp(((m_1 * (m_1 - n)) + ((m - n) - l)))
else
tmp = cos(m_1) * exp(-l)
end if
code = tmp
end function
public static double code(double K, double m, double n, double M, double l) {
double tmp;
if (M <= -9.2e+23) {
tmp = Math.cos(M) * Math.exp((M * n));
} else if (M <= 3.9e+117) {
tmp = Math.cos(M) * Math.exp(((M * (M - n)) + ((m - n) - l)));
} else {
tmp = Math.cos(M) * Math.exp(-l);
}
return tmp;
}
def code(K, m, n, M, l): tmp = 0 if M <= -9.2e+23: tmp = math.cos(M) * math.exp((M * n)) elif M <= 3.9e+117: tmp = math.cos(M) * math.exp(((M * (M - n)) + ((m - n) - l))) else: tmp = math.cos(M) * math.exp(-l) return tmp
function code(K, m, n, M, l) tmp = 0.0 if (M <= -9.2e+23) tmp = Float64(cos(M) * exp(Float64(M * n))); elseif (M <= 3.9e+117) tmp = Float64(cos(M) * exp(Float64(Float64(M * Float64(M - n)) + Float64(Float64(m - n) - l)))); else tmp = Float64(cos(M) * exp(Float64(-l))); end return tmp end
function tmp_2 = code(K, m, n, M, l) tmp = 0.0; if (M <= -9.2e+23) tmp = cos(M) * exp((M * n)); elseif (M <= 3.9e+117) tmp = cos(M) * exp(((M * (M - n)) + ((m - n) - l))); else tmp = cos(M) * exp(-l); end tmp_2 = tmp; end
code[K_, m_, n_, M_, l_] := If[LessEqual[M, -9.2e+23], N[(N[Cos[M], $MachinePrecision] * N[Exp[N[(M * n), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[M, 3.9e+117], N[(N[Cos[M], $MachinePrecision] * N[Exp[N[(N[(M * N[(M - n), $MachinePrecision]), $MachinePrecision] + N[(N[(m - n), $MachinePrecision] - l), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(N[Cos[M], $MachinePrecision] * N[Exp[(-l)], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;M \leq -9.2 \cdot 10^{+23}:\\
\;\;\;\;\cos M \cdot e^{M \cdot n}\\
\mathbf{elif}\;M \leq 3.9 \cdot 10^{+117}:\\
\;\;\;\;\cos M \cdot e^{M \cdot \left(M - n\right) + \left(\left(m - n\right) - \ell\right)}\\
\mathbf{else}:\\
\;\;\;\;\cos M \cdot e^{-\ell}\\
\end{array}
\end{array}
if M < -9.2000000000000002e23Initial program 76.3%
Taylor expanded in K around 0 98.3%
cos-neg98.3%
Simplified98.3%
Taylor expanded in n around 0 81.5%
+-commutative81.5%
unpow281.5%
distribute-rgt-out88.3%
*-commutative88.3%
*-commutative88.3%
Simplified88.3%
Taylor expanded in m around 0 86.6%
associate-*r*86.6%
neg-mul-186.6%
Simplified86.6%
Taylor expanded in n around inf 40.3%
if -9.2000000000000002e23 < M < 3.8999999999999999e117Initial program 77.7%
Taylor expanded in K around 0 95.3%
cos-neg95.3%
Simplified95.3%
Taylor expanded in n around 0 73.0%
+-commutative73.0%
unpow273.0%
distribute-rgt-out77.4%
*-commutative77.4%
*-commutative77.4%
Simplified77.4%
Taylor expanded in m around 0 43.8%
associate-*r*43.8%
neg-mul-143.8%
Simplified43.8%
distribute-rgt-neg-in43.8%
fma-neg43.8%
add-sqr-sqrt15.8%
sqrt-unprod35.8%
sqr-neg35.8%
sqrt-unprod20.1%
add-sqr-sqrt35.2%
sub-neg35.2%
distribute-neg-in35.2%
remove-double-neg35.2%
add-sqr-sqrt20.8%
fabs-sqr20.8%
add-sqr-sqrt54.8%
Applied egg-rr54.8%
fma-undefine54.8%
unsub-neg54.8%
neg-mul-154.8%
+-commutative54.8%
neg-mul-154.8%
sub-neg54.8%
sub-neg54.8%
sub-neg54.8%
neg-mul-154.8%
+-commutative54.8%
distribute-neg-in54.8%
neg-mul-154.8%
remove-double-neg54.8%
sub-neg54.8%
Simplified54.8%
if 3.8999999999999999e117 < M Initial program 73.0%
Taylor expanded in K around 0 100.0%
cos-neg100.0%
Simplified100.0%
Taylor expanded in n around 0 91.9%
+-commutative91.9%
unpow291.9%
distribute-rgt-out94.7%
*-commutative94.7%
*-commutative94.7%
Simplified94.7%
Taylor expanded in m around 0 94.7%
associate-*r*94.7%
neg-mul-194.7%
Simplified94.7%
Taylor expanded in l around inf 23.8%
neg-mul-123.8%
Simplified23.8%
Final simplification47.0%
(FPCore (K m n M l) :precision binary64 (if (or (<= l -1.65e+125) (not (<= l 9.2e-39))) (* (cos M) (exp (- l))) (* (cos M) (exp (* M n)))))
double code(double K, double m, double n, double M, double l) {
double tmp;
if ((l <= -1.65e+125) || !(l <= 9.2e-39)) {
tmp = cos(M) * exp(-l);
} else {
tmp = cos(M) * exp((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 ((l <= (-1.65d+125)) .or. (.not. (l <= 9.2d-39))) then
tmp = cos(m_1) * exp(-l)
else
tmp = cos(m_1) * exp((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 ((l <= -1.65e+125) || !(l <= 9.2e-39)) {
tmp = Math.cos(M) * Math.exp(-l);
} else {
tmp = Math.cos(M) * Math.exp((M * n));
}
return tmp;
}
def code(K, m, n, M, l): tmp = 0 if (l <= -1.65e+125) or not (l <= 9.2e-39): tmp = math.cos(M) * math.exp(-l) else: tmp = math.cos(M) * math.exp((M * n)) return tmp
function code(K, m, n, M, l) tmp = 0.0 if ((l <= -1.65e+125) || !(l <= 9.2e-39)) tmp = Float64(cos(M) * exp(Float64(-l))); else tmp = Float64(cos(M) * exp(Float64(M * n))); end return tmp end
function tmp_2 = code(K, m, n, M, l) tmp = 0.0; if ((l <= -1.65e+125) || ~((l <= 9.2e-39))) tmp = cos(M) * exp(-l); else tmp = cos(M) * exp((M * n)); end tmp_2 = tmp; end
code[K_, m_, n_, M_, l_] := If[Or[LessEqual[l, -1.65e+125], N[Not[LessEqual[l, 9.2e-39]], $MachinePrecision]], N[(N[Cos[M], $MachinePrecision] * N[Exp[(-l)], $MachinePrecision]), $MachinePrecision], N[(N[Cos[M], $MachinePrecision] * N[Exp[N[(M * n), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\ell \leq -1.65 \cdot 10^{+125} \lor \neg \left(\ell \leq 9.2 \cdot 10^{-39}\right):\\
\;\;\;\;\cos M \cdot e^{-\ell}\\
\mathbf{else}:\\
\;\;\;\;\cos M \cdot e^{M \cdot n}\\
\end{array}
\end{array}
if l < -1.65000000000000003e125 or 9.20000000000000033e-39 < l Initial program 74.0%
Taylor expanded in K around 0 96.7%
cos-neg96.7%
Simplified96.7%
Taylor expanded in n around 0 79.8%
+-commutative79.8%
unpow279.8%
distribute-rgt-out82.3%
*-commutative82.3%
*-commutative82.3%
Simplified82.3%
Taylor expanded in m around 0 63.5%
associate-*r*63.5%
neg-mul-163.5%
Simplified63.5%
Taylor expanded in l around inf 67.4%
neg-mul-167.4%
Simplified67.4%
if -1.65000000000000003e125 < l < 9.20000000000000033e-39Initial program 79.1%
Taylor expanded in K around 0 96.5%
cos-neg96.5%
Simplified96.5%
Taylor expanded in n around 0 75.7%
+-commutative75.7%
unpow275.7%
distribute-rgt-out82.5%
*-commutative82.5%
*-commutative82.5%
Simplified82.5%
Taylor expanded in m around 0 58.8%
associate-*r*58.8%
neg-mul-158.8%
Simplified58.8%
Taylor expanded in n around inf 32.6%
Final simplification49.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 76.7%
Taylor expanded in K around 0 96.6%
cos-neg96.6%
Simplified96.6%
Taylor expanded in n around 0 77.7%
+-commutative77.7%
unpow277.7%
distribute-rgt-out82.4%
*-commutative82.4%
*-commutative82.4%
Simplified82.4%
Taylor expanded in m around 0 61.1%
associate-*r*61.1%
neg-mul-161.1%
Simplified61.1%
Taylor expanded in l around inf 38.4%
neg-mul-138.4%
Simplified38.4%
herbie shell --seed 2024090
(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)))))))