
(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}
NOTE: K, m, n, M, and l should be sorted in increasing order before calling this function. (FPCore (K m n M l) :precision binary64 (* (exp (- (- (- n m) l) (pow (- (* 0.5 (+ n m)) M) 2.0))) (cos M)))
assert(K < m && m < n && n < M && M < l);
double code(double K, double m, double n, double M, double l) {
return exp((((n - m) - l) - pow(((0.5 * (n + m)) - M), 2.0))) * cos(M);
}
NOTE: K, m, n, M, and l should be sorted in increasing order before calling this function.
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((((n - m) - l) - (((0.5d0 * (n + m)) - m_1) ** 2.0d0))) * cos(m_1)
end function
assert K < m && m < n && n < M && M < l;
public static double code(double K, double m, double n, double M, double l) {
return Math.exp((((n - m) - l) - Math.pow(((0.5 * (n + m)) - M), 2.0))) * Math.cos(M);
}
[K, m, n, M, l] = sort([K, m, n, M, l]) def code(K, m, n, M, l): return math.exp((((n - m) - l) - math.pow(((0.5 * (n + m)) - M), 2.0))) * math.cos(M)
K, m, n, M, l = sort([K, m, n, M, l]) function code(K, m, n, M, l) return Float64(exp(Float64(Float64(Float64(n - m) - l) - (Float64(Float64(0.5 * Float64(n + m)) - M) ^ 2.0))) * cos(M)) end
K, m, n, M, l = num2cell(sort([K, m, n, M, l])){:}
function tmp = code(K, m, n, M, l)
tmp = exp((((n - m) - l) - (((0.5 * (n + m)) - M) ^ 2.0))) * cos(M);
end
NOTE: K, m, n, M, and l should be sorted in increasing order before calling this function. code[K_, m_, n_, M_, l_] := N[(N[Exp[N[(N[(N[(n - m), $MachinePrecision] - l), $MachinePrecision] - N[Power[N[(N[(0.5 * N[(n + m), $MachinePrecision]), $MachinePrecision] - M), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * N[Cos[M], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
[K, m, n, M, l] = \mathsf{sort}([K, m, n, M, l])\\
\\
e^{\left(\left(n - m\right) - \ell\right) - {\left(0.5 \cdot \left(n + m\right) - M\right)}^{2}} \cdot \cos M
\end{array}
Initial program 77.4%
Taylor expanded in K around 0 96.7%
Simplified96.7%
unpow296.7%
+-commutative96.7%
+-commutative96.7%
Applied egg-rr96.7%
Taylor expanded in n around -inf 96.7%
fabs-neg96.7%
neg-mul-196.7%
sub-neg96.7%
rem-square-sqrt51.3%
fabs-sqr51.3%
rem-square-sqrt96.6%
Simplified96.6%
sub-neg96.6%
add-sqr-sqrt51.3%
fabs-sqr51.3%
add-sqr-sqrt96.7%
fabs-sub96.7%
add-sqr-sqrt45.4%
fabs-sqr45.4%
add-sqr-sqrt96.3%
pow296.3%
*-commutative96.3%
Applied egg-rr96.3%
sub-neg96.3%
associate--r+96.3%
*-commutative96.3%
+-commutative96.3%
Simplified96.3%
Final simplification96.3%
NOTE: K, m, n, M, and l should be sorted in increasing order before calling this function. (FPCore (K m n M l) :precision binary64 (let* ((t_0 (* 0.5 (+ n m)))) (* (cos M) (exp (+ (- m n) (- (* (- t_0 M) (- M t_0)) l))))))
assert(K < m && m < n && n < M && M < l);
double code(double K, double m, double n, double M, double l) {
double t_0 = 0.5 * (n + m);
return cos(M) * exp(((m - n) + (((t_0 - M) * (M - t_0)) - l)));
}
NOTE: K, m, n, M, and l should be sorted in increasing order before calling this function.
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
t_0 = 0.5d0 * (n + m)
code = cos(m_1) * exp(((m - n) + (((t_0 - m_1) * (m_1 - t_0)) - l)))
end function
assert K < m && m < n && n < M && M < l;
public static double code(double K, double m, double n, double M, double l) {
double t_0 = 0.5 * (n + m);
return Math.cos(M) * Math.exp(((m - n) + (((t_0 - M) * (M - t_0)) - l)));
}
[K, m, n, M, l] = sort([K, m, n, M, l]) def code(K, m, n, M, l): t_0 = 0.5 * (n + m) return math.cos(M) * math.exp(((m - n) + (((t_0 - M) * (M - t_0)) - l)))
K, m, n, M, l = sort([K, m, n, M, l]) function code(K, m, n, M, l) t_0 = Float64(0.5 * Float64(n + m)) return Float64(cos(M) * exp(Float64(Float64(m - n) + Float64(Float64(Float64(t_0 - M) * Float64(M - t_0)) - l)))) end
K, m, n, M, l = num2cell(sort([K, m, n, M, l])){:}
function tmp = code(K, m, n, M, l)
t_0 = 0.5 * (n + m);
tmp = cos(M) * exp(((m - n) + (((t_0 - M) * (M - t_0)) - l)));
end
NOTE: K, m, n, M, and l should be sorted in increasing order before calling this function.
code[K_, m_, n_, M_, l_] := Block[{t$95$0 = N[(0.5 * N[(n + m), $MachinePrecision]), $MachinePrecision]}, N[(N[Cos[M], $MachinePrecision] * N[Exp[N[(N[(m - n), $MachinePrecision] + N[(N[(N[(t$95$0 - M), $MachinePrecision] * N[(M - t$95$0), $MachinePrecision]), $MachinePrecision] - l), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[K, m, n, M, l] = \mathsf{sort}([K, m, n, M, l])\\
\\
\begin{array}{l}
t_0 := 0.5 \cdot \left(n + m\right)\\
\cos M \cdot e^{\left(m - n\right) + \left(\left(t\_0 - M\right) \cdot \left(M - t\_0\right) - \ell\right)}
\end{array}
\end{array}
Initial program 77.4%
Taylor expanded in K around 0 96.7%
Simplified96.7%
unpow296.7%
+-commutative96.7%
+-commutative96.7%
Applied egg-rr96.7%
Taylor expanded in n around -inf 96.7%
fabs-neg96.7%
neg-mul-196.7%
sub-neg96.7%
rem-square-sqrt51.3%
fabs-sqr51.3%
rem-square-sqrt96.6%
Simplified96.6%
Final simplification96.6%
NOTE: K, m, n, M, and l should be sorted in increasing order before calling this function. (FPCore (K m n M l) :precision binary64 (if (<= n 2e+138) (* (cos M) (exp (+ (- m n) (- (* M (- (* 0.5 (+ n m)) M)) l)))) (* (cos M) (exp (- (- m n) l)))))
assert(K < m && m < n && n < M && M < l);
double code(double K, double m, double n, double M, double l) {
double tmp;
if (n <= 2e+138) {
tmp = cos(M) * exp(((m - n) + ((M * ((0.5 * (n + m)) - M)) - l)));
} else {
tmp = cos(M) * exp(((m - n) - l));
}
return tmp;
}
NOTE: K, m, n, M, and l should be sorted in increasing order before calling this function.
real(8) function code(k, m, n, m_1, l)
real(8), intent (in) :: k
real(8), intent (in) :: m
real(8), intent (in) :: n
real(8), intent (in) :: m_1
real(8), intent (in) :: l
real(8) :: tmp
if (n <= 2d+138) then
tmp = cos(m_1) * exp(((m - n) + ((m_1 * ((0.5d0 * (n + m)) - m_1)) - l)))
else
tmp = cos(m_1) * exp(((m - n) - l))
end if
code = tmp
end function
assert K < m && m < n && n < M && M < l;
public static double code(double K, double m, double n, double M, double l) {
double tmp;
if (n <= 2e+138) {
tmp = Math.cos(M) * Math.exp(((m - n) + ((M * ((0.5 * (n + m)) - M)) - l)));
} else {
tmp = Math.cos(M) * Math.exp(((m - n) - l));
}
return tmp;
}
[K, m, n, M, l] = sort([K, m, n, M, l]) def code(K, m, n, M, l): tmp = 0 if n <= 2e+138: tmp = math.cos(M) * math.exp(((m - n) + ((M * ((0.5 * (n + m)) - M)) - l))) else: tmp = math.cos(M) * math.exp(((m - n) - l)) return tmp
K, m, n, M, l = sort([K, m, n, M, l]) function code(K, m, n, M, l) tmp = 0.0 if (n <= 2e+138) tmp = Float64(cos(M) * exp(Float64(Float64(m - n) + Float64(Float64(M * Float64(Float64(0.5 * Float64(n + m)) - M)) - l)))); else tmp = Float64(cos(M) * exp(Float64(Float64(m - n) - l))); end return tmp end
K, m, n, M, l = num2cell(sort([K, m, n, M, l])){:}
function tmp_2 = code(K, m, n, M, l)
tmp = 0.0;
if (n <= 2e+138)
tmp = cos(M) * exp(((m - n) + ((M * ((0.5 * (n + m)) - M)) - l)));
else
tmp = cos(M) * exp(((m - n) - l));
end
tmp_2 = tmp;
end
NOTE: K, m, n, M, and l should be sorted in increasing order before calling this function. code[K_, m_, n_, M_, l_] := If[LessEqual[n, 2e+138], N[(N[Cos[M], $MachinePrecision] * N[Exp[N[(N[(m - n), $MachinePrecision] + N[(N[(M * N[(N[(0.5 * N[(n + m), $MachinePrecision]), $MachinePrecision] - M), $MachinePrecision]), $MachinePrecision] - l), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(N[Cos[M], $MachinePrecision] * N[Exp[N[(N[(m - n), $MachinePrecision] - l), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[K, m, n, M, l] = \mathsf{sort}([K, m, n, M, l])\\
\\
\begin{array}{l}
\mathbf{if}\;n \leq 2 \cdot 10^{+138}:\\
\;\;\;\;\cos M \cdot e^{\left(m - n\right) + \left(M \cdot \left(0.5 \cdot \left(n + m\right) - M\right) - \ell\right)}\\
\mathbf{else}:\\
\;\;\;\;\cos M \cdot e^{\left(m - n\right) - \ell}\\
\end{array}
\end{array}
if n < 2.0000000000000001e138Initial program 80.9%
Taylor expanded in K around 0 96.2%
Simplified96.2%
unpow296.2%
+-commutative96.2%
+-commutative96.2%
Applied egg-rr96.2%
Taylor expanded in n around -inf 96.2%
fabs-neg96.2%
neg-mul-196.2%
sub-neg96.2%
rem-square-sqrt59.1%
fabs-sqr59.1%
rem-square-sqrt96.0%
Simplified96.0%
Taylor expanded in M around inf 67.7%
neg-mul-167.7%
Simplified67.7%
if 2.0000000000000001e138 < n Initial program 56.8%
Taylor expanded in K around 0 100.0%
Simplified100.0%
Taylor expanded in l around inf 6.9%
Taylor expanded in n around -inf 6.9%
fabs-neg100.0%
neg-mul-1100.0%
sub-neg100.0%
rem-square-sqrt5.4%
fabs-sqr5.4%
rem-square-sqrt100.0%
Simplified89.4%
Final simplification70.8%
NOTE: K, m, n, M, and l should be sorted in increasing order before calling this function. (FPCore (K m n M l) :precision binary64 (if (<= l -5e+59) (* (cos M) (exp l)) (* (cos M) (exp (- (- m n) l)))))
assert(K < m && m < n && n < M && M < l);
double code(double K, double m, double n, double M, double l) {
double tmp;
if (l <= -5e+59) {
tmp = cos(M) * exp(l);
} else {
tmp = cos(M) * exp(((m - n) - l));
}
return tmp;
}
NOTE: K, m, n, M, and l should be sorted in increasing order before calling this function.
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 <= (-5d+59)) then
tmp = cos(m_1) * exp(l)
else
tmp = cos(m_1) * exp(((m - n) - l))
end if
code = tmp
end function
assert K < m && m < n && n < M && M < l;
public static double code(double K, double m, double n, double M, double l) {
double tmp;
if (l <= -5e+59) {
tmp = Math.cos(M) * Math.exp(l);
} else {
tmp = Math.cos(M) * Math.exp(((m - n) - l));
}
return tmp;
}
[K, m, n, M, l] = sort([K, m, n, M, l]) def code(K, m, n, M, l): tmp = 0 if l <= -5e+59: tmp = math.cos(M) * math.exp(l) else: tmp = math.cos(M) * math.exp(((m - n) - l)) return tmp
K, m, n, M, l = sort([K, m, n, M, l]) function code(K, m, n, M, l) tmp = 0.0 if (l <= -5e+59) tmp = Float64(cos(M) * exp(l)); else tmp = Float64(cos(M) * exp(Float64(Float64(m - n) - l))); end return tmp end
K, m, n, M, l = num2cell(sort([K, m, n, M, l])){:}
function tmp_2 = code(K, m, n, M, l)
tmp = 0.0;
if (l <= -5e+59)
tmp = cos(M) * exp(l);
else
tmp = cos(M) * exp(((m - n) - l));
end
tmp_2 = tmp;
end
NOTE: K, m, n, M, and l should be sorted in increasing order before calling this function. code[K_, m_, n_, M_, l_] := If[LessEqual[l, -5e+59], N[(N[Cos[M], $MachinePrecision] * N[Exp[l], $MachinePrecision]), $MachinePrecision], N[(N[Cos[M], $MachinePrecision] * N[Exp[N[(N[(m - n), $MachinePrecision] - l), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[K, m, n, M, l] = \mathsf{sort}([K, m, n, M, l])\\
\\
\begin{array}{l}
\mathbf{if}\;\ell \leq -5 \cdot 10^{+59}:\\
\;\;\;\;\cos M \cdot e^{\ell}\\
\mathbf{else}:\\
\;\;\;\;\cos M \cdot e^{\left(m - n\right) - \ell}\\
\end{array}
\end{array}
if l < -4.9999999999999997e59Initial program 75.0%
Taylor expanded in l around inf 17.0%
mul-1-neg17.0%
Simplified17.0%
Taylor expanded in K around 0 12.0%
cos-neg12.0%
Simplified12.0%
pow112.0%
add-sqr-sqrt12.0%
sqrt-unprod12.0%
sqr-neg12.0%
sqrt-unprod0.0%
add-sqr-sqrt82.4%
Applied egg-rr82.4%
unpow182.4%
Simplified82.4%
if -4.9999999999999997e59 < l Initial program 78.1%
Taylor expanded in K around 0 97.8%
Simplified97.8%
Taylor expanded in l around inf 29.5%
Taylor expanded in n around -inf 29.5%
fabs-neg97.8%
neg-mul-197.8%
sub-neg97.8%
rem-square-sqrt51.2%
fabs-sqr51.2%
rem-square-sqrt97.6%
Simplified58.8%
Final simplification64.0%
NOTE: K, m, n, M, and l should be sorted in increasing order before calling this function. (FPCore (K m n M l) :precision binary64 (if (<= l -1e-34) (* (cos M) (exp l)) (* (cos M) (exp (- l)))))
assert(K < m && m < n && n < M && M < l);
double code(double K, double m, double n, double M, double l) {
double tmp;
if (l <= -1e-34) {
tmp = cos(M) * exp(l);
} else {
tmp = cos(M) * exp(-l);
}
return tmp;
}
NOTE: K, m, n, M, and l should be sorted in increasing order before calling this function.
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 <= (-1d-34)) then
tmp = cos(m_1) * exp(l)
else
tmp = cos(m_1) * exp(-l)
end if
code = tmp
end function
assert K < m && m < n && n < M && M < l;
public static double code(double K, double m, double n, double M, double l) {
double tmp;
if (l <= -1e-34) {
tmp = Math.cos(M) * Math.exp(l);
} else {
tmp = Math.cos(M) * Math.exp(-l);
}
return tmp;
}
[K, m, n, M, l] = sort([K, m, n, M, l]) def code(K, m, n, M, l): tmp = 0 if l <= -1e-34: tmp = math.cos(M) * math.exp(l) else: tmp = math.cos(M) * math.exp(-l) return tmp
K, m, n, M, l = sort([K, m, n, M, l]) function code(K, m, n, M, l) tmp = 0.0 if (l <= -1e-34) tmp = Float64(cos(M) * exp(l)); else tmp = Float64(cos(M) * exp(Float64(-l))); end return tmp end
K, m, n, M, l = num2cell(sort([K, m, n, M, l])){:}
function tmp_2 = code(K, m, n, M, l)
tmp = 0.0;
if (l <= -1e-34)
tmp = cos(M) * exp(l);
else
tmp = cos(M) * exp(-l);
end
tmp_2 = tmp;
end
NOTE: K, m, n, M, and l should be sorted in increasing order before calling this function. code[K_, m_, n_, M_, l_] := If[LessEqual[l, -1e-34], N[(N[Cos[M], $MachinePrecision] * N[Exp[l], $MachinePrecision]), $MachinePrecision], N[(N[Cos[M], $MachinePrecision] * N[Exp[(-l)], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[K, m, n, M, l] = \mathsf{sort}([K, m, n, M, l])\\
\\
\begin{array}{l}
\mathbf{if}\;\ell \leq -1 \cdot 10^{-34}:\\
\;\;\;\;\cos M \cdot e^{\ell}\\
\mathbf{else}:\\
\;\;\;\;\cos M \cdot e^{-\ell}\\
\end{array}
\end{array}
if l < -9.99999999999999928e-35Initial program 78.3%
Taylor expanded in l around inf 18.4%
mul-1-neg18.4%
Simplified18.4%
Taylor expanded in K around 0 14.4%
cos-neg14.4%
Simplified14.4%
pow114.4%
add-sqr-sqrt14.4%
sqrt-unprod14.4%
sqr-neg14.4%
sqrt-unprod0.0%
add-sqr-sqrt74.4%
Applied egg-rr74.4%
unpow174.4%
Simplified74.4%
if -9.99999999999999928e-35 < l Initial program 77.1%
Taylor expanded in l around inf 39.1%
mul-1-neg39.1%
Simplified39.1%
Taylor expanded in K around 0 44.6%
cos-neg44.6%
Simplified44.6%
NOTE: K, m, n, M, and l should be sorted in increasing order before calling this function. (FPCore (K m n M l) :precision binary64 (if (<= l 0.12) (* (cos M) (exp l)) (exp (- l))))
assert(K < m && m < n && n < M && M < l);
double code(double K, double m, double n, double M, double l) {
double tmp;
if (l <= 0.12) {
tmp = cos(M) * exp(l);
} else {
tmp = exp(-l);
}
return tmp;
}
NOTE: K, m, n, M, and l should be sorted in increasing order before calling this function.
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.12d0) then
tmp = cos(m_1) * exp(l)
else
tmp = exp(-l)
end if
code = tmp
end function
assert K < m && m < n && n < M && M < l;
public static double code(double K, double m, double n, double M, double l) {
double tmp;
if (l <= 0.12) {
tmp = Math.cos(M) * Math.exp(l);
} else {
tmp = Math.exp(-l);
}
return tmp;
}
[K, m, n, M, l] = sort([K, m, n, M, l]) def code(K, m, n, M, l): tmp = 0 if l <= 0.12: tmp = math.cos(M) * math.exp(l) else: tmp = math.exp(-l) return tmp
K, m, n, M, l = sort([K, m, n, M, l]) function code(K, m, n, M, l) tmp = 0.0 if (l <= 0.12) tmp = Float64(cos(M) * exp(l)); else tmp = exp(Float64(-l)); end return tmp end
K, m, n, M, l = num2cell(sort([K, m, n, M, l])){:}
function tmp_2 = code(K, m, n, M, l)
tmp = 0.0;
if (l <= 0.12)
tmp = cos(M) * exp(l);
else
tmp = exp(-l);
end
tmp_2 = tmp;
end
NOTE: K, m, n, M, and l should be sorted in increasing order before calling this function. code[K_, m_, n_, M_, l_] := If[LessEqual[l, 0.12], N[(N[Cos[M], $MachinePrecision] * N[Exp[l], $MachinePrecision]), $MachinePrecision], N[Exp[(-l)], $MachinePrecision]]
\begin{array}{l}
[K, m, n, M, l] = \mathsf{sort}([K, m, n, M, l])\\
\\
\begin{array}{l}
\mathbf{if}\;\ell \leq 0.12:\\
\;\;\;\;\cos M \cdot e^{\ell}\\
\mathbf{else}:\\
\;\;\;\;e^{-\ell}\\
\end{array}
\end{array}
if l < 0.12Initial program 74.9%
Taylor expanded in l around inf 15.7%
mul-1-neg15.7%
Simplified15.7%
Taylor expanded in K around 0 14.4%
cos-neg14.4%
Simplified14.4%
pow114.4%
add-sqr-sqrt8.9%
sqrt-unprod14.4%
sqr-neg14.4%
sqrt-unprod5.6%
add-sqr-sqrt36.2%
Applied egg-rr36.2%
unpow136.2%
Simplified36.2%
if 0.12 < l Initial program 84.8%
Taylor expanded in l around inf 84.8%
mul-1-neg84.8%
Simplified84.8%
Taylor expanded in K around 0 100.0%
cos-neg100.0%
Simplified100.0%
Taylor expanded in M around 0 100.0%
NOTE: K, m, n, M, and l should be sorted in increasing order before calling this function. (FPCore (K m n M l) :precision binary64 (exp (- l)))
assert(K < m && m < n && n < M && M < l);
double code(double K, double m, double n, double M, double l) {
return exp(-l);
}
NOTE: K, m, n, M, and l should be sorted in increasing order before calling this function.
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
assert K < m && m < n && n < M && M < l;
public static double code(double K, double m, double n, double M, double l) {
return Math.exp(-l);
}
[K, m, n, M, l] = sort([K, m, n, M, l]) def code(K, m, n, M, l): return math.exp(-l)
K, m, n, M, l = sort([K, m, n, M, l]) function code(K, m, n, M, l) return exp(Float64(-l)) end
K, m, n, M, l = num2cell(sort([K, m, n, M, l])){:}
function tmp = code(K, m, n, M, l)
tmp = exp(-l);
end
NOTE: K, m, n, M, and l should be sorted in increasing order before calling this function. code[K_, m_, n_, M_, l_] := N[Exp[(-l)], $MachinePrecision]
\begin{array}{l}
[K, m, n, M, l] = \mathsf{sort}([K, m, n, M, l])\\
\\
e^{-\ell}
\end{array}
Initial program 77.4%
Taylor expanded in l around inf 33.5%
mul-1-neg33.5%
Simplified33.5%
Taylor expanded in K around 0 36.5%
cos-neg36.5%
Simplified36.5%
Taylor expanded in M around 0 36.5%
NOTE: K, m, n, M, and l should be sorted in increasing order before calling this function. (FPCore (K m n M l) :precision binary64 (cos M))
assert(K < m && m < n && n < M && M < l);
double code(double K, double m, double n, double M, double l) {
return cos(M);
}
NOTE: K, m, n, M, and l should be sorted in increasing order before calling this function.
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
assert K < m && m < n && n < M && M < l;
public static double code(double K, double m, double n, double M, double l) {
return Math.cos(M);
}
[K, m, n, M, l] = sort([K, m, n, M, l]) def code(K, m, n, M, l): return math.cos(M)
K, m, n, M, l = sort([K, m, n, M, l]) function code(K, m, n, M, l) return cos(M) end
K, m, n, M, l = num2cell(sort([K, m, n, M, l])){:}
function tmp = code(K, m, n, M, l)
tmp = cos(M);
end
NOTE: K, m, n, M, and l should be sorted in increasing order before calling this function. code[K_, m_, n_, M_, l_] := N[Cos[M], $MachinePrecision]
\begin{array}{l}
[K, m, n, M, l] = \mathsf{sort}([K, m, n, M, l])\\
\\
\cos M
\end{array}
Initial program 77.4%
Taylor expanded in l around inf 33.5%
mul-1-neg33.5%
Simplified33.5%
Taylor expanded in l around 0 8.0%
Taylor expanded in K around 0 8.4%
cos-neg8.4%
Simplified8.4%
herbie shell --seed 2024144
(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)))))))