
(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 (- 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 72.5%
*-commutative72.5%
associate-*r/72.5%
associate--r-72.5%
+-commutative72.5%
associate-+r-72.5%
unsub-neg72.5%
associate--r+72.5%
+-commutative72.5%
associate--r+72.5%
Simplified72.5%
Taylor expanded in K around 0 96.8%
cos-neg96.8%
Simplified96.8%
Final simplification96.8%
(FPCore (K m n M l)
:precision binary64
(let* ((t_0 (* (cos M) (exp (- (- (fabs (- m n)) l) (* M M))))))
(if (<= l -3.8e+159)
t_0
(if (<= l -1.5e-29)
(* (cos (- (* (* K 0.5) (+ m n)) M)) (exp l))
(if (<= l 5.3e-17) t_0 (exp (- l)))))))
double code(double K, double m, double n, double M, double l) {
double t_0 = cos(M) * exp(((fabs((m - n)) - l) - (M * M)));
double tmp;
if (l <= -3.8e+159) {
tmp = t_0;
} else if (l <= -1.5e-29) {
tmp = cos((((K * 0.5) * (m + n)) - M)) * exp(l);
} else if (l <= 5.3e-17) {
tmp = t_0;
} 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) :: t_0
real(8) :: tmp
t_0 = cos(m_1) * exp(((abs((m - n)) - l) - (m_1 * m_1)))
if (l <= (-3.8d+159)) then
tmp = t_0
else if (l <= (-1.5d-29)) then
tmp = cos((((k * 0.5d0) * (m + n)) - m_1)) * exp(l)
else if (l <= 5.3d-17) then
tmp = t_0
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 t_0 = Math.cos(M) * Math.exp(((Math.abs((m - n)) - l) - (M * M)));
double tmp;
if (l <= -3.8e+159) {
tmp = t_0;
} else if (l <= -1.5e-29) {
tmp = Math.cos((((K * 0.5) * (m + n)) - M)) * Math.exp(l);
} else if (l <= 5.3e-17) {
tmp = t_0;
} else {
tmp = Math.exp(-l);
}
return tmp;
}
def code(K, m, n, M, l): t_0 = math.cos(M) * math.exp(((math.fabs((m - n)) - l) - (M * M))) tmp = 0 if l <= -3.8e+159: tmp = t_0 elif l <= -1.5e-29: tmp = math.cos((((K * 0.5) * (m + n)) - M)) * math.exp(l) elif l <= 5.3e-17: tmp = t_0 else: tmp = math.exp(-l) return tmp
function code(K, m, n, M, l) t_0 = Float64(cos(M) * exp(Float64(Float64(abs(Float64(m - n)) - l) - Float64(M * M)))) tmp = 0.0 if (l <= -3.8e+159) tmp = t_0; elseif (l <= -1.5e-29) tmp = Float64(cos(Float64(Float64(Float64(K * 0.5) * Float64(m + n)) - M)) * exp(l)); elseif (l <= 5.3e-17) tmp = t_0; else tmp = exp(Float64(-l)); end return tmp end
function tmp_2 = code(K, m, n, M, l) t_0 = cos(M) * exp(((abs((m - n)) - l) - (M * M))); tmp = 0.0; if (l <= -3.8e+159) tmp = t_0; elseif (l <= -1.5e-29) tmp = cos((((K * 0.5) * (m + n)) - M)) * exp(l); elseif (l <= 5.3e-17) tmp = t_0; else tmp = exp(-l); end tmp_2 = tmp; end
code[K_, m_, n_, M_, l_] := Block[{t$95$0 = N[(N[Cos[M], $MachinePrecision] * N[Exp[N[(N[(N[Abs[N[(m - n), $MachinePrecision]], $MachinePrecision] - l), $MachinePrecision] - N[(M * M), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[l, -3.8e+159], t$95$0, If[LessEqual[l, -1.5e-29], N[(N[Cos[N[(N[(N[(K * 0.5), $MachinePrecision] * N[(m + n), $MachinePrecision]), $MachinePrecision] - M), $MachinePrecision]], $MachinePrecision] * N[Exp[l], $MachinePrecision]), $MachinePrecision], If[LessEqual[l, 5.3e-17], t$95$0, N[Exp[(-l)], $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos M \cdot e^{\left(\left|m - n\right| - \ell\right) - M \cdot M}\\
\mathbf{if}\;\ell \leq -3.8 \cdot 10^{+159}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;\ell \leq -1.5 \cdot 10^{-29}:\\
\;\;\;\;\cos \left(\left(K \cdot 0.5\right) \cdot \left(m + n\right) - M\right) \cdot e^{\ell}\\
\mathbf{elif}\;\ell \leq 5.3 \cdot 10^{-17}:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;e^{-\ell}\\
\end{array}
\end{array}
if l < -3.79999999999999965e159 or -1.5000000000000001e-29 < l < 5.2999999999999998e-17Initial program 66.2%
*-commutative66.2%
associate-*r/66.2%
associate--r-66.2%
+-commutative66.2%
associate-+r-66.2%
unsub-neg66.2%
associate--r+66.2%
+-commutative66.2%
associate--r+66.2%
Simplified66.2%
Taylor expanded in K around 0 94.5%
cos-neg94.5%
Simplified94.5%
Taylor expanded in M around inf 52.9%
unpow252.9%
Simplified52.9%
if -3.79999999999999965e159 < l < -1.5000000000000001e-29Initial program 81.6%
sub-neg81.6%
associate--r+81.6%
exp-diff13.2%
associate-*r/13.2%
associate-/l*13.2%
associate-*r/13.2%
exp-diff5.3%
Simplified81.6%
Taylor expanded in l around inf 9.2%
div-inv9.2%
div-inv9.2%
metadata-eval9.2%
*-commutative9.2%
+-commutative9.2%
associate-*r*9.2%
+-commutative9.2%
rec-exp9.2%
Applied egg-rr9.2%
expm1-log1p-u6.1%
expm1-udef6.1%
associate-*l*6.1%
+-commutative6.1%
*-commutative6.1%
add-sqr-sqrt6.1%
sqrt-unprod6.1%
sqr-neg6.1%
sqrt-unprod0.0%
add-sqr-sqrt63.7%
Applied egg-rr63.7%
expm1-def63.7%
expm1-log1p63.7%
associate-*r*63.7%
*-commutative63.7%
associate-*r*63.7%
*-commutative63.7%
Simplified63.7%
if 5.2999999999999998e-17 < l Initial program 81.2%
sub-neg81.2%
associate--r+81.2%
exp-diff27.5%
associate-*r/27.5%
associate-/l*27.5%
associate-*r/27.5%
exp-diff27.5%
Simplified81.2%
Taylor expanded in l around inf 79.7%
Taylor expanded in n around inf 87.0%
*-commutative87.0%
associate-*r*87.0%
*-commutative87.0%
associate-*l*87.0%
Simplified87.0%
Taylor expanded in K around 0 97.2%
rec-exp97.2%
Simplified97.2%
Final simplification66.4%
(FPCore (K m n M l)
:precision binary64
(let* ((t_0 (- (fabs (- m n)) l)))
(if (or (<= M -2.1e+125) (not (<= M 3.1e+61)))
(* (cos M) (exp (- t_0 (* M M))))
(* (cos M) (exp (- t_0 (* 0.25 (* n n))))))))
double code(double K, double m, double n, double M, double l) {
double t_0 = fabs((m - n)) - l;
double tmp;
if ((M <= -2.1e+125) || !(M <= 3.1e+61)) {
tmp = cos(M) * exp((t_0 - (M * M)));
} else {
tmp = cos(M) * exp((t_0 - (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) :: t_0
real(8) :: tmp
t_0 = abs((m - n)) - l
if ((m_1 <= (-2.1d+125)) .or. (.not. (m_1 <= 3.1d+61))) then
tmp = cos(m_1) * exp((t_0 - (m_1 * m_1)))
else
tmp = cos(m_1) * exp((t_0 - (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 t_0 = Math.abs((m - n)) - l;
double tmp;
if ((M <= -2.1e+125) || !(M <= 3.1e+61)) {
tmp = Math.cos(M) * Math.exp((t_0 - (M * M)));
} else {
tmp = Math.cos(M) * Math.exp((t_0 - (0.25 * (n * n))));
}
return tmp;
}
def code(K, m, n, M, l): t_0 = math.fabs((m - n)) - l tmp = 0 if (M <= -2.1e+125) or not (M <= 3.1e+61): tmp = math.cos(M) * math.exp((t_0 - (M * M))) else: tmp = math.cos(M) * math.exp((t_0 - (0.25 * (n * n)))) return tmp
function code(K, m, n, M, l) t_0 = Float64(abs(Float64(m - n)) - l) tmp = 0.0 if ((M <= -2.1e+125) || !(M <= 3.1e+61)) tmp = Float64(cos(M) * exp(Float64(t_0 - Float64(M * M)))); else tmp = Float64(cos(M) * exp(Float64(t_0 - Float64(0.25 * Float64(n * n))))); end return tmp end
function tmp_2 = code(K, m, n, M, l) t_0 = abs((m - n)) - l; tmp = 0.0; if ((M <= -2.1e+125) || ~((M <= 3.1e+61))) tmp = cos(M) * exp((t_0 - (M * M))); else tmp = cos(M) * exp((t_0 - (0.25 * (n * n)))); end tmp_2 = tmp; end
code[K_, m_, n_, M_, l_] := Block[{t$95$0 = N[(N[Abs[N[(m - n), $MachinePrecision]], $MachinePrecision] - l), $MachinePrecision]}, If[Or[LessEqual[M, -2.1e+125], N[Not[LessEqual[M, 3.1e+61]], $MachinePrecision]], N[(N[Cos[M], $MachinePrecision] * N[Exp[N[(t$95$0 - N[(M * M), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(N[Cos[M], $MachinePrecision] * N[Exp[N[(t$95$0 - N[(0.25 * N[(n * n), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left|m - n\right| - \ell\\
\mathbf{if}\;M \leq -2.1 \cdot 10^{+125} \lor \neg \left(M \leq 3.1 \cdot 10^{+61}\right):\\
\;\;\;\;\cos M \cdot e^{t_0 - M \cdot M}\\
\mathbf{else}:\\
\;\;\;\;\cos M \cdot e^{t_0 - 0.25 \cdot \left(n \cdot n\right)}\\
\end{array}
\end{array}
if M < -2.1000000000000001e125 or 3.0999999999999999e61 < M Initial program 73.9%
*-commutative73.9%
associate-*r/73.9%
associate--r-73.9%
+-commutative73.9%
associate-+r-73.9%
unsub-neg73.9%
associate--r+73.9%
+-commutative73.9%
associate--r+73.9%
Simplified73.9%
Taylor expanded in K around 0 100.0%
cos-neg100.0%
Simplified100.0%
Taylor expanded in M around inf 95.7%
unpow295.7%
Simplified95.7%
if -2.1000000000000001e125 < M < 3.0999999999999999e61Initial program 71.7%
*-commutative71.7%
associate-*r/71.7%
associate--r-71.7%
+-commutative71.7%
associate-+r-71.7%
unsub-neg71.7%
associate--r+71.7%
+-commutative71.7%
associate--r+71.7%
Simplified71.7%
Taylor expanded in K around 0 95.0%
cos-neg95.0%
Simplified95.0%
Taylor expanded in n around inf 72.2%
*-commutative72.2%
unpow272.2%
Simplified72.2%
Final simplification80.7%
(FPCore (K m n M l)
:precision binary64
(let* ((t_0 (fabs (- m n))))
(if (<= n 8e+60)
(/ (cos M) (exp (+ l (- (* (* m m) 0.25) t_0))))
(* (cos M) (exp (- (- t_0 l) (* 0.25 (* n n))))))))
double code(double K, double m, double n, double M, double l) {
double t_0 = fabs((m - n));
double tmp;
if (n <= 8e+60) {
tmp = cos(M) / exp((l + (((m * m) * 0.25) - t_0)));
} else {
tmp = cos(M) * exp(((t_0 - l) - (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) :: t_0
real(8) :: tmp
t_0 = abs((m - n))
if (n <= 8d+60) then
tmp = cos(m_1) / exp((l + (((m * m) * 0.25d0) - t_0)))
else
tmp = cos(m_1) * exp(((t_0 - l) - (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 t_0 = Math.abs((m - n));
double tmp;
if (n <= 8e+60) {
tmp = Math.cos(M) / Math.exp((l + (((m * m) * 0.25) - t_0)));
} else {
tmp = Math.cos(M) * Math.exp(((t_0 - l) - (0.25 * (n * n))));
}
return tmp;
}
def code(K, m, n, M, l): t_0 = math.fabs((m - n)) tmp = 0 if n <= 8e+60: tmp = math.cos(M) / math.exp((l + (((m * m) * 0.25) - t_0))) else: tmp = math.cos(M) * math.exp(((t_0 - l) - (0.25 * (n * n)))) return tmp
function code(K, m, n, M, l) t_0 = abs(Float64(m - n)) tmp = 0.0 if (n <= 8e+60) tmp = Float64(cos(M) / exp(Float64(l + Float64(Float64(Float64(m * m) * 0.25) - t_0)))); else tmp = Float64(cos(M) * exp(Float64(Float64(t_0 - l) - Float64(0.25 * Float64(n * n))))); end return tmp end
function tmp_2 = code(K, m, n, M, l) t_0 = abs((m - n)); tmp = 0.0; if (n <= 8e+60) tmp = cos(M) / exp((l + (((m * m) * 0.25) - t_0))); else tmp = cos(M) * exp(((t_0 - l) - (0.25 * (n * n)))); end tmp_2 = tmp; end
code[K_, m_, n_, M_, l_] := Block[{t$95$0 = N[Abs[N[(m - n), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[n, 8e+60], N[(N[Cos[M], $MachinePrecision] / N[Exp[N[(l + N[(N[(N[(m * m), $MachinePrecision] * 0.25), $MachinePrecision] - t$95$0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(N[Cos[M], $MachinePrecision] * N[Exp[N[(N[(t$95$0 - l), $MachinePrecision] - N[(0.25 * N[(n * n), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left|m - n\right|\\
\mathbf{if}\;n \leq 8 \cdot 10^{+60}:\\
\;\;\;\;\frac{\cos M}{e^{\ell + \left(\left(m \cdot m\right) \cdot 0.25 - t_0\right)}}\\
\mathbf{else}:\\
\;\;\;\;\cos M \cdot e^{\left(t_0 - \ell\right) - 0.25 \cdot \left(n \cdot n\right)}\\
\end{array}
\end{array}
if n < 7.9999999999999996e60Initial program 77.3%
sub-neg77.3%
associate--r+77.3%
exp-diff27.8%
associate-*r/27.8%
associate-/l*27.8%
associate-*r/27.8%
exp-diff21.7%
Simplified77.3%
Taylor expanded in m around inf 57.3%
*-commutative57.3%
unpow257.3%
Simplified57.3%
Taylor expanded in K around 0 72.3%
cos-neg72.3%
exp-diff21.2%
fabs-sub21.2%
sub-neg21.2%
mul-1-neg21.2%
+-commutative21.2%
fabs-neg21.2%
exp-diff72.3%
associate--l+72.3%
*-commutative72.3%
unpow272.3%
fabs-neg72.3%
+-commutative72.3%
mul-1-neg72.3%
sub-neg72.3%
fabs-sub72.3%
Simplified72.3%
if 7.9999999999999996e60 < n Initial program 56.7%
*-commutative56.7%
associate-*r/56.7%
associate--r-56.7%
+-commutative56.7%
associate-+r-56.7%
unsub-neg56.7%
associate--r+56.7%
+-commutative56.7%
associate--r+56.7%
Simplified56.7%
Taylor expanded in K around 0 98.3%
cos-neg98.3%
Simplified98.3%
Taylor expanded in n around inf 95.1%
*-commutative95.1%
unpow295.1%
Simplified95.1%
Final simplification77.7%
(FPCore (K m n M l) :precision binary64 (if (<= l -13.0) (* (cos (- (* (* K 0.5) (+ m n)) M)) (exp l)) (* (cos M) (exp (- l)))))
double code(double K, double m, double n, double M, double l) {
double tmp;
if (l <= -13.0) {
tmp = cos((((K * 0.5) * (m + n)) - M)) * exp(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 (l <= (-13.0d0)) then
tmp = cos((((k * 0.5d0) * (m + n)) - m_1)) * exp(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 (l <= -13.0) {
tmp = Math.cos((((K * 0.5) * (m + n)) - M)) * Math.exp(l);
} else {
tmp = Math.cos(M) * Math.exp(-l);
}
return tmp;
}
def code(K, m, n, M, l): tmp = 0 if l <= -13.0: tmp = math.cos((((K * 0.5) * (m + n)) - M)) * math.exp(l) else: tmp = math.cos(M) * math.exp(-l) return tmp
function code(K, m, n, M, l) tmp = 0.0 if (l <= -13.0) tmp = Float64(cos(Float64(Float64(Float64(K * 0.5) * Float64(m + n)) - M)) * exp(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 (l <= -13.0) tmp = cos((((K * 0.5) * (m + n)) - M)) * exp(l); else tmp = cos(M) * exp(-l); end tmp_2 = tmp; end
code[K_, m_, n_, M_, l_] := If[LessEqual[l, -13.0], N[(N[Cos[N[(N[(N[(K * 0.5), $MachinePrecision] * N[(m + n), $MachinePrecision]), $MachinePrecision] - M), $MachinePrecision]], $MachinePrecision] * N[Exp[l], $MachinePrecision]), $MachinePrecision], N[(N[Cos[M], $MachinePrecision] * N[Exp[(-l)], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\ell \leq -13:\\
\;\;\;\;\cos \left(\left(K \cdot 0.5\right) \cdot \left(m + n\right) - M\right) \cdot e^{\ell}\\
\mathbf{else}:\\
\;\;\;\;\cos M \cdot e^{-\ell}\\
\end{array}
\end{array}
if l < -13Initial program 73.3%
sub-neg73.3%
associate--r+73.3%
exp-diff24.0%
associate-*r/24.0%
associate-/l*24.0%
associate-*r/24.0%
exp-diff6.7%
Simplified73.3%
Taylor expanded in l around inf 19.5%
div-inv19.5%
div-inv19.5%
metadata-eval19.5%
*-commutative19.5%
+-commutative19.5%
associate-*r*19.5%
+-commutative19.5%
rec-exp19.5%
Applied egg-rr19.5%
expm1-log1p-u13.7%
expm1-udef13.7%
associate-*l*13.7%
+-commutative13.7%
*-commutative13.7%
add-sqr-sqrt13.7%
sqrt-unprod13.7%
sqr-neg13.7%
sqrt-unprod0.0%
add-sqr-sqrt53.7%
Applied egg-rr53.7%
expm1-def53.7%
expm1-log1p53.7%
associate-*r*53.7%
*-commutative53.7%
associate-*r*53.7%
*-commutative53.7%
Simplified53.7%
if -13 < l Initial program 72.2%
sub-neg72.2%
associate--r+72.2%
exp-diff20.8%
associate-*r/20.8%
associate-/l*20.8%
associate-*r/20.8%
exp-diff20.7%
Simplified72.1%
Taylor expanded in l around inf 35.6%
div-inv35.6%
div-inv35.6%
metadata-eval35.6%
*-commutative35.6%
+-commutative35.6%
associate-*r*35.6%
+-commutative35.6%
rec-exp35.6%
Applied egg-rr35.6%
Taylor expanded in K around 0 43.0%
*-commutative43.0%
cos-neg43.0%
Simplified43.0%
Final simplification46.1%
(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 72.5%
sub-neg72.5%
associate--r+72.5%
exp-diff21.7%
associate-*r/21.7%
associate-/l*21.7%
associate-*r/21.7%
exp-diff16.6%
Simplified72.5%
Taylor expanded in l around inf 30.9%
div-inv30.9%
div-inv30.9%
metadata-eval30.9%
*-commutative30.9%
+-commutative30.9%
associate-*r*30.9%
+-commutative30.9%
rec-exp30.9%
Applied egg-rr30.9%
Taylor expanded in K around 0 36.2%
*-commutative36.2%
cos-neg36.2%
Simplified36.2%
Final simplification36.2%
(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 72.5%
sub-neg72.5%
associate--r+72.5%
exp-diff21.7%
associate-*r/21.7%
associate-/l*21.7%
associate-*r/21.7%
exp-diff16.6%
Simplified72.5%
Taylor expanded in l around inf 30.9%
Taylor expanded in K around 0 36.2%
cos-neg36.2%
Simplified36.2%
Final simplification36.2%
(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 72.5%
sub-neg72.5%
associate--r+72.5%
exp-diff21.7%
associate-*r/21.7%
associate-/l*21.7%
associate-*r/21.7%
exp-diff16.6%
Simplified72.5%
Taylor expanded in l around inf 30.9%
Taylor expanded in n around inf 33.6%
*-commutative33.6%
associate-*r*33.6%
*-commutative33.6%
associate-*l*33.6%
Simplified33.6%
Taylor expanded in K around 0 35.4%
rec-exp35.4%
Simplified35.4%
Final simplification35.4%
(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 72.5%
sub-neg72.5%
associate--r+72.5%
exp-diff21.7%
associate-*r/21.7%
associate-/l*21.7%
associate-*r/21.7%
exp-diff16.6%
Simplified72.5%
Taylor expanded in l around inf 30.9%
Taylor expanded in l around 0 5.4%
associate-*r*5.4%
*-commutative5.4%
+-commutative5.4%
fma-neg5.4%
+-commutative5.4%
*-lft-identity5.4%
metadata-eval5.4%
cancel-sign-sub-inv5.4%
fma-neg5.4%
sub-neg5.4%
mul-1-neg5.4%
remove-double-neg5.4%
+-commutative5.4%
associate-*l*5.4%
+-commutative5.4%
Simplified5.4%
Taylor expanded in K around 0 6.2%
cos-neg6.2%
Simplified6.2%
Final simplification6.2%
herbie shell --seed 2023187
(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)))))))