
(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 10 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 73.1%
Taylor expanded in K around 0 97.1%
cos-neg97.1%
Simplified97.1%
Final simplification97.1%
(FPCore (K m n M l) :precision binary64 (if (or (<= M -1.15e+76) (not (<= M 5e+58))) (* (cos M) (exp (- (pow M 2.0)))) (* (cos M) (exp (- m (+ n l))))))
double code(double K, double m, double n, double M, double l) {
double tmp;
if ((M <= -1.15e+76) || !(M <= 5e+58)) {
tmp = cos(M) * exp(-pow(M, 2.0));
} else {
tmp = cos(M) * exp((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 <= (-1.15d+76)) .or. (.not. (m_1 <= 5d+58))) then
tmp = cos(m_1) * exp(-(m_1 ** 2.0d0))
else
tmp = cos(m_1) * exp((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 <= -1.15e+76) || !(M <= 5e+58)) {
tmp = Math.cos(M) * Math.exp(-Math.pow(M, 2.0));
} else {
tmp = Math.cos(M) * Math.exp((m - (n + l)));
}
return tmp;
}
def code(K, m, n, M, l): tmp = 0 if (M <= -1.15e+76) or not (M <= 5e+58): tmp = math.cos(M) * math.exp(-math.pow(M, 2.0)) else: tmp = math.cos(M) * math.exp((m - (n + l))) return tmp
function code(K, m, n, M, l) tmp = 0.0 if ((M <= -1.15e+76) || !(M <= 5e+58)) tmp = Float64(cos(M) * exp(Float64(-(M ^ 2.0)))); else tmp = Float64(cos(M) * exp(Float64(m - Float64(n + l)))); end return tmp end
function tmp_2 = code(K, m, n, M, l) tmp = 0.0; if ((M <= -1.15e+76) || ~((M <= 5e+58))) tmp = cos(M) * exp(-(M ^ 2.0)); else tmp = cos(M) * exp((m - (n + l))); end tmp_2 = tmp; end
code[K_, m_, n_, M_, l_] := If[Or[LessEqual[M, -1.15e+76], N[Not[LessEqual[M, 5e+58]], $MachinePrecision]], N[(N[Cos[M], $MachinePrecision] * N[Exp[(-N[Power[M, 2.0], $MachinePrecision])], $MachinePrecision]), $MachinePrecision], N[(N[Cos[M], $MachinePrecision] * N[Exp[N[(m - N[(n + l), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;M \leq -1.15 \cdot 10^{+76} \lor \neg \left(M \leq 5 \cdot 10^{+58}\right):\\
\;\;\;\;\cos M \cdot e^{-{M}^{2}}\\
\mathbf{else}:\\
\;\;\;\;\cos M \cdot e^{m - \left(n + \ell\right)}\\
\end{array}
\end{array}
if M < -1.15000000000000001e76 or 4.99999999999999986e58 < M Initial program 73.1%
Taylor expanded in K around 0 100.0%
cos-neg100.0%
Simplified100.0%
Taylor expanded in M around inf 97.9%
mul-1-neg97.9%
Simplified97.9%
if -1.15000000000000001e76 < M < 4.99999999999999986e58Initial program 73.1%
Taylor expanded in M around inf 37.5%
associate-*r*37.5%
neg-mul-137.5%
unpow237.5%
sqr-neg37.5%
distribute-lft-out37.5%
unsub-neg37.5%
Simplified37.5%
sub-neg37.5%
add-sqr-sqrt17.8%
fabs-sqr17.8%
add-sqr-sqrt53.6%
Applied egg-rr53.6%
sub-neg53.6%
associate--r-53.6%
Simplified53.6%
Taylor expanded in K around 0 68.1%
cos-neg95.5%
Simplified68.1%
Taylor expanded in M around 0 68.1%
Final simplification78.9%
(FPCore (K m n M l) :precision binary64 (if (<= m -2.5e+22) (* (cos M) (exp (* -0.25 (pow m 2.0)))) (* (cos M) (exp (+ (* M (- (+ m n) M)) (- (- m l) n))))))
double code(double K, double m, double n, double M, double l) {
double tmp;
if (m <= -2.5e+22) {
tmp = cos(M) * exp((-0.25 * pow(m, 2.0)));
} else {
tmp = cos(M) * exp(((M * ((m + n) - M)) + ((m - l) - n)));
}
return tmp;
}
real(8) function code(k, m, n, m_1, l)
real(8), intent (in) :: k
real(8), intent (in) :: m
real(8), intent (in) :: n
real(8), intent (in) :: m_1
real(8), intent (in) :: l
real(8) :: tmp
if (m <= (-2.5d+22)) then
tmp = cos(m_1) * exp(((-0.25d0) * (m ** 2.0d0)))
else
tmp = cos(m_1) * exp(((m_1 * ((m + n) - m_1)) + ((m - l) - n)))
end if
code = tmp
end function
public static double code(double K, double m, double n, double M, double l) {
double tmp;
if (m <= -2.5e+22) {
tmp = Math.cos(M) * Math.exp((-0.25 * Math.pow(m, 2.0)));
} else {
tmp = Math.cos(M) * Math.exp(((M * ((m + n) - M)) + ((m - l) - n)));
}
return tmp;
}
def code(K, m, n, M, l): tmp = 0 if m <= -2.5e+22: tmp = math.cos(M) * math.exp((-0.25 * math.pow(m, 2.0))) else: tmp = math.cos(M) * math.exp(((M * ((m + n) - M)) + ((m - l) - n))) return tmp
function code(K, m, n, M, l) tmp = 0.0 if (m <= -2.5e+22) tmp = Float64(cos(M) * exp(Float64(-0.25 * (m ^ 2.0)))); else tmp = Float64(cos(M) * exp(Float64(Float64(M * Float64(Float64(m + n) - M)) + Float64(Float64(m - l) - n)))); end return tmp end
function tmp_2 = code(K, m, n, M, l) tmp = 0.0; if (m <= -2.5e+22) tmp = cos(M) * exp((-0.25 * (m ^ 2.0))); else tmp = cos(M) * exp(((M * ((m + n) - M)) + ((m - l) - n))); end tmp_2 = tmp; end
code[K_, m_, n_, M_, l_] := If[LessEqual[m, -2.5e+22], 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[(N[(M * N[(N[(m + n), $MachinePrecision] - M), $MachinePrecision]), $MachinePrecision] + N[(N[(m - l), $MachinePrecision] - n), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;m \leq -2.5 \cdot 10^{+22}:\\
\;\;\;\;\cos M \cdot e^{-0.25 \cdot {m}^{2}}\\
\mathbf{else}:\\
\;\;\;\;\cos M \cdot e^{M \cdot \left(\left(m + n\right) - M\right) + \left(\left(m - \ell\right) - n\right)}\\
\end{array}
\end{array}
if m < -2.4999999999999998e22Initial program 53.1%
Taylor expanded in K around 0 100.0%
cos-neg100.0%
Simplified100.0%
Taylor expanded in m around inf 98.5%
if -2.4999999999999998e22 < m Initial program 79.8%
Taylor expanded in M around inf 54.1%
associate-*r*54.1%
neg-mul-154.1%
unpow254.1%
sqr-neg54.1%
distribute-lft-out55.7%
unsub-neg55.7%
Simplified55.7%
sub-neg55.7%
add-sqr-sqrt29.7%
fabs-sqr29.7%
add-sqr-sqrt62.2%
Applied egg-rr62.2%
sub-neg62.2%
associate--r-62.2%
Simplified62.2%
Taylor expanded in K around 0 71.4%
cos-neg96.1%
Simplified71.4%
Final simplification78.2%
(FPCore (K m n M l) :precision binary64 (if (<= m -1e+107) (* (cos M) (exp (- m (+ n l)))) (* (cos M) (exp (+ (* M (- (+ m n) M)) (- (- m l) n))))))
double code(double K, double m, double n, double M, double l) {
double tmp;
if (m <= -1e+107) {
tmp = cos(M) * exp((m - (n + l)));
} else {
tmp = cos(M) * exp(((M * ((m + n) - M)) + ((m - l) - n)));
}
return tmp;
}
real(8) function code(k, m, n, m_1, l)
real(8), intent (in) :: k
real(8), intent (in) :: m
real(8), intent (in) :: n
real(8), intent (in) :: m_1
real(8), intent (in) :: l
real(8) :: tmp
if (m <= (-1d+107)) then
tmp = cos(m_1) * exp((m - (n + l)))
else
tmp = cos(m_1) * exp(((m_1 * ((m + n) - m_1)) + ((m - l) - n)))
end if
code = tmp
end function
public static double code(double K, double m, double n, double M, double l) {
double tmp;
if (m <= -1e+107) {
tmp = Math.cos(M) * Math.exp((m - (n + l)));
} else {
tmp = Math.cos(M) * Math.exp(((M * ((m + n) - M)) + ((m - l) - n)));
}
return tmp;
}
def code(K, m, n, M, l): tmp = 0 if m <= -1e+107: tmp = math.cos(M) * math.exp((m - (n + l))) else: tmp = math.cos(M) * math.exp(((M * ((m + n) - M)) + ((m - l) - n))) return tmp
function code(K, m, n, M, l) tmp = 0.0 if (m <= -1e+107) tmp = Float64(cos(M) * exp(Float64(m - Float64(n + l)))); else tmp = Float64(cos(M) * exp(Float64(Float64(M * Float64(Float64(m + n) - M)) + Float64(Float64(m - l) - n)))); end return tmp end
function tmp_2 = code(K, m, n, M, l) tmp = 0.0; if (m <= -1e+107) tmp = cos(M) * exp((m - (n + l))); else tmp = cos(M) * exp(((M * ((m + n) - M)) + ((m - l) - n))); end tmp_2 = tmp; end
code[K_, m_, n_, M_, l_] := If[LessEqual[m, -1e+107], N[(N[Cos[M], $MachinePrecision] * N[Exp[N[(m - N[(n + l), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(N[Cos[M], $MachinePrecision] * N[Exp[N[(N[(M * N[(N[(m + n), $MachinePrecision] - M), $MachinePrecision]), $MachinePrecision] + N[(N[(m - l), $MachinePrecision] - n), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;m \leq -1 \cdot 10^{+107}:\\
\;\;\;\;\cos M \cdot e^{m - \left(n + \ell\right)}\\
\mathbf{else}:\\
\;\;\;\;\cos M \cdot e^{M \cdot \left(\left(m + n\right) - M\right) + \left(\left(m - \ell\right) - n\right)}\\
\end{array}
\end{array}
if m < -9.9999999999999997e106Initial program 47.7%
Taylor expanded in M around inf 18.6%
associate-*r*18.6%
neg-mul-118.6%
unpow218.6%
sqr-neg18.6%
distribute-lft-out20.9%
unsub-neg20.9%
Simplified20.9%
sub-neg20.9%
add-sqr-sqrt2.3%
fabs-sqr2.3%
add-sqr-sqrt43.3%
Applied egg-rr43.3%
sub-neg43.3%
associate--r-43.3%
Simplified43.3%
Taylor expanded in K around 0 86.6%
cos-neg100.0%
Simplified86.6%
Taylor expanded in M around 0 95.5%
if -9.9999999999999997e106 < m Initial program 78.4%
Taylor expanded in M around inf 51.4%
associate-*r*51.4%
neg-mul-151.4%
unpow251.4%
sqr-neg51.4%
distribute-lft-out53.3%
unsub-neg53.3%
Simplified53.3%
sub-neg53.3%
add-sqr-sqrt27.4%
fabs-sqr27.4%
add-sqr-sqrt61.1%
Applied egg-rr61.1%
sub-neg61.1%
associate--r-61.1%
Simplified61.1%
Taylor expanded in K around 0 72.2%
cos-neg96.5%
Simplified72.2%
Final simplification76.2%
(FPCore (K m n M l)
:precision binary64
(let* ((t_0 (- m (+ n l))))
(if (<= m -2e+106)
(* (cos M) (exp t_0))
(exp (+ t_0 (* M (+ m (- n M))))))))
double code(double K, double m, double n, double M, double l) {
double t_0 = m - (n + l);
double tmp;
if (m <= -2e+106) {
tmp = cos(M) * exp(t_0);
} else {
tmp = exp((t_0 + (M * (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) :: t_0
real(8) :: tmp
t_0 = m - (n + l)
if (m <= (-2d+106)) then
tmp = cos(m_1) * exp(t_0)
else
tmp = exp((t_0 + (m_1 * (m + (n - m_1)))))
end if
code = tmp
end function
public static double code(double K, double m, double n, double M, double l) {
double t_0 = m - (n + l);
double tmp;
if (m <= -2e+106) {
tmp = Math.cos(M) * Math.exp(t_0);
} else {
tmp = Math.exp((t_0 + (M * (m + (n - M)))));
}
return tmp;
}
def code(K, m, n, M, l): t_0 = m - (n + l) tmp = 0 if m <= -2e+106: tmp = math.cos(M) * math.exp(t_0) else: tmp = math.exp((t_0 + (M * (m + (n - M))))) return tmp
function code(K, m, n, M, l) t_0 = Float64(m - Float64(n + l)) tmp = 0.0 if (m <= -2e+106) tmp = Float64(cos(M) * exp(t_0)); else tmp = exp(Float64(t_0 + Float64(M * Float64(m + Float64(n - M))))); end return tmp end
function tmp_2 = code(K, m, n, M, l) t_0 = m - (n + l); tmp = 0.0; if (m <= -2e+106) tmp = cos(M) * exp(t_0); else tmp = exp((t_0 + (M * (m + (n - M))))); end tmp_2 = tmp; end
code[K_, m_, n_, M_, l_] := Block[{t$95$0 = N[(m - N[(n + l), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[m, -2e+106], N[(N[Cos[M], $MachinePrecision] * N[Exp[t$95$0], $MachinePrecision]), $MachinePrecision], N[Exp[N[(t$95$0 + N[(M * N[(m + N[(n - M), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := m - \left(n + \ell\right)\\
\mathbf{if}\;m \leq -2 \cdot 10^{+106}:\\
\;\;\;\;\cos M \cdot e^{t\_0}\\
\mathbf{else}:\\
\;\;\;\;e^{t\_0 + M \cdot \left(m + \left(n - M\right)\right)}\\
\end{array}
\end{array}
if m < -2.00000000000000018e106Initial program 46.7%
Taylor expanded in M around inf 18.2%
associate-*r*18.2%
neg-mul-118.2%
unpow218.2%
sqr-neg18.2%
distribute-lft-out20.4%
unsub-neg20.4%
Simplified20.4%
sub-neg20.4%
add-sqr-sqrt2.2%
fabs-sqr2.2%
add-sqr-sqrt42.3%
Applied egg-rr42.3%
sub-neg42.3%
associate--r-42.3%
Simplified42.3%
Taylor expanded in K around 0 86.9%
cos-neg100.0%
Simplified86.9%
Taylor expanded in M around 0 93.4%
if -2.00000000000000018e106 < m Initial program 78.8%
Taylor expanded in M around inf 51.6%
associate-*r*51.6%
neg-mul-151.6%
unpow251.6%
sqr-neg51.6%
distribute-lft-out53.6%
unsub-neg53.6%
Simplified53.6%
Taylor expanded in m around inf 56.3%
*-commutative56.3%
associate-*l*56.3%
Simplified56.3%
Taylor expanded in K around 0 59.6%
mul-1-neg59.6%
associate-+r-59.6%
distribute-lft-neg-in59.6%
associate--r+59.6%
cancel-sign-sub59.6%
Simplified59.6%
sub-neg59.6%
add-sqr-sqrt30.8%
fabs-sqr30.8%
add-sqr-sqrt70.2%
Applied egg-rr70.2%
sub-neg70.2%
associate--l-70.2%
Simplified70.2%
Final simplification74.3%
(FPCore (K m n M l) :precision binary64 (if (<= l 0.000185) (exp (- (* M (+ m (- n M))) l)) (exp (- l))))
double code(double K, double m, double n, double M, double l) {
double tmp;
if (l <= 0.000185) {
tmp = exp(((M * (m + (n - M))) - l));
} 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 <= 0.000185d0) then
tmp = exp(((m_1 * (m + (n - m_1))) - l))
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 <= 0.000185) {
tmp = Math.exp(((M * (m + (n - M))) - l));
} else {
tmp = Math.exp(-l);
}
return tmp;
}
def code(K, m, n, M, l): tmp = 0 if l <= 0.000185: tmp = math.exp(((M * (m + (n - M))) - l)) else: tmp = math.exp(-l) return tmp
function code(K, m, n, M, l) tmp = 0.0 if (l <= 0.000185) tmp = exp(Float64(Float64(M * Float64(m + Float64(n - M))) - l)); else tmp = exp(Float64(-l)); end return tmp end
function tmp_2 = code(K, m, n, M, l) tmp = 0.0; if (l <= 0.000185) tmp = exp(((M * (m + (n - M))) - l)); else tmp = exp(-l); end tmp_2 = tmp; end
code[K_, m_, n_, M_, l_] := If[LessEqual[l, 0.000185], N[Exp[N[(N[(M * N[(m + N[(n - M), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - l), $MachinePrecision]], $MachinePrecision], N[Exp[(-l)], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\ell \leq 0.000185:\\
\;\;\;\;e^{M \cdot \left(m + \left(n - M\right)\right) - \ell}\\
\mathbf{else}:\\
\;\;\;\;e^{-\ell}\\
\end{array}
\end{array}
if l < 1.85e-4Initial program 73.0%
Taylor expanded in M around inf 43.1%
associate-*r*43.1%
neg-mul-143.1%
unpow243.1%
sqr-neg43.1%
distribute-lft-out44.7%
unsub-neg44.7%
Simplified44.7%
Taylor expanded in m around inf 45.6%
*-commutative45.6%
associate-*l*45.6%
Simplified45.6%
Taylor expanded in K around 0 49.4%
mul-1-neg49.4%
associate-+r-49.4%
distribute-lft-neg-in49.4%
associate--r+49.4%
cancel-sign-sub49.4%
Simplified49.4%
Taylor expanded in l around inf 57.8%
neg-mul-157.8%
Simplified57.8%
if 1.85e-4 < l Initial program 73.5%
Taylor expanded in K around 0 100.0%
cos-neg100.0%
Simplified100.0%
Taylor expanded in l around inf 98.6%
mul-1-neg98.6%
Simplified98.6%
Taylor expanded in M around 0 98.6%
Final simplification68.7%
(FPCore (K m n M l) :precision binary64 (exp (+ (- m (+ n l)) (* M (+ m (- n M))))))
double code(double K, double m, double n, double M, double l) {
return exp(((m - (n + l)) + (M * (m + (n - M)))));
}
real(8) function code(k, m, n, m_1, l)
real(8), intent (in) :: k
real(8), intent (in) :: m
real(8), intent (in) :: n
real(8), intent (in) :: m_1
real(8), intent (in) :: l
code = exp(((m - (n + l)) + (m_1 * (m + (n - m_1)))))
end function
public static double code(double K, double m, double n, double M, double l) {
return Math.exp(((m - (n + l)) + (M * (m + (n - M)))));
}
def code(K, m, n, M, l): return math.exp(((m - (n + l)) + (M * (m + (n - M)))))
function code(K, m, n, M, l) return exp(Float64(Float64(m - Float64(n + l)) + Float64(M * Float64(m + Float64(n - M))))) end
function tmp = code(K, m, n, M, l) tmp = exp(((m - (n + l)) + (M * (m + (n - M))))); end
code[K_, m_, n_, M_, l_] := N[Exp[N[(N[(m - N[(n + l), $MachinePrecision]), $MachinePrecision] + N[(M * N[(m + N[(n - M), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
e^{\left(m - \left(n + \ell\right)\right) + M \cdot \left(m + \left(n - M\right)\right)}
\end{array}
Initial program 73.1%
Taylor expanded in M around inf 45.8%
associate-*r*45.8%
neg-mul-145.8%
unpow245.8%
sqr-neg45.8%
distribute-lft-out47.7%
unsub-neg47.7%
Simplified47.7%
Taylor expanded in m around inf 50.4%
*-commutative50.4%
associate-*l*50.4%
Simplified50.4%
Taylor expanded in K around 0 55.9%
mul-1-neg55.9%
associate-+r-55.9%
distribute-lft-neg-in55.9%
associate--r+55.9%
cancel-sign-sub55.9%
Simplified55.9%
sub-neg55.9%
add-sqr-sqrt26.2%
fabs-sqr26.2%
add-sqr-sqrt73.1%
Applied egg-rr73.1%
sub-neg73.1%
associate--l-73.1%
Simplified73.1%
Final simplification73.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 73.1%
Taylor expanded in K around 0 97.1%
cos-neg97.1%
Simplified97.1%
Taylor expanded in l around inf 40.4%
mul-1-neg40.4%
Simplified40.4%
Taylor expanded in M around 0 38.8%
Final simplification38.8%
(FPCore (K m n M l) :precision binary64 (cos M))
double code(double K, double m, double n, double M, double l) {
return cos(M);
}
real(8) function code(k, m, n, m_1, l)
real(8), intent (in) :: k
real(8), intent (in) :: m
real(8), intent (in) :: n
real(8), intent (in) :: m_1
real(8), intent (in) :: l
code = cos(m_1)
end function
public static double code(double K, double m, double n, double M, double l) {
return Math.cos(M);
}
def code(K, m, n, M, l): return math.cos(M)
function code(K, m, n, M, l) return cos(M) end
function tmp = code(K, m, n, M, l) tmp = cos(M); end
code[K_, m_, n_, M_, l_] := N[Cos[M], $MachinePrecision]
\begin{array}{l}
\\
\cos M
\end{array}
Initial program 73.1%
Taylor expanded in K around 0 97.1%
cos-neg97.1%
Simplified97.1%
Taylor expanded in l around inf 40.4%
mul-1-neg40.4%
Simplified40.4%
Taylor expanded in l around 0 8.8%
Final simplification8.8%
(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 73.1%
Taylor expanded in K around 0 97.1%
cos-neg97.1%
Simplified97.1%
Taylor expanded in M around inf 51.1%
mul-1-neg51.1%
Simplified51.1%
Taylor expanded in M around 0 8.7%
Final simplification8.7%
herbie shell --seed 2024062
(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)))))))