
(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}
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 (exp (- (- (fabs (- m n)) l) (pow (- (/ (+ m n) 2.0) M) 2.0)))))
(if (<= (* (cos (- (/ (* K (+ m n)) 2.0) M)) t_0) INFINITY)
(* t_0 (cos (- (pow (cbrt (* (+ m n) (* K 0.5))) 3.0) M)))
(exp (- m n)))))assert(K < m && m < n && n < M && M < l);
double code(double K, double m, double n, double M, double l) {
double t_0 = exp(((fabs((m - n)) - l) - pow((((m + n) / 2.0) - M), 2.0)));
double tmp;
if ((cos((((K * (m + n)) / 2.0) - M)) * t_0) <= ((double) INFINITY)) {
tmp = t_0 * cos((pow(cbrt(((m + n) * (K * 0.5))), 3.0) - M));
} else {
tmp = exp((m - n));
}
return tmp;
}
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 = Math.exp(((Math.abs((m - n)) - l) - Math.pow((((m + n) / 2.0) - M), 2.0)));
double tmp;
if ((Math.cos((((K * (m + n)) / 2.0) - M)) * t_0) <= Double.POSITIVE_INFINITY) {
tmp = t_0 * Math.cos((Math.pow(Math.cbrt(((m + n) * (K * 0.5))), 3.0) - M));
} else {
tmp = Math.exp((m - n));
}
return tmp;
}
K, m, n, M, l = sort([K, m, n, M, l]) function code(K, m, n, M, l) t_0 = exp(Float64(Float64(abs(Float64(m - n)) - l) - (Float64(Float64(Float64(m + n) / 2.0) - M) ^ 2.0))) tmp = 0.0 if (Float64(cos(Float64(Float64(Float64(K * Float64(m + n)) / 2.0) - M)) * t_0) <= Inf) tmp = Float64(t_0 * cos(Float64((cbrt(Float64(Float64(m + n) * Float64(K * 0.5))) ^ 3.0) - M))); else tmp = exp(Float64(m - n)); end return 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_] := Block[{t$95$0 = 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]}, If[LessEqual[N[(N[Cos[N[(N[(N[(K * N[(m + n), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision] - M), $MachinePrecision]], $MachinePrecision] * t$95$0), $MachinePrecision], Infinity], N[(t$95$0 * N[Cos[N[(N[Power[N[Power[N[(N[(m + n), $MachinePrecision] * N[(K * 0.5), $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision], 3.0], $MachinePrecision] - M), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[Exp[N[(m - n), $MachinePrecision]], $MachinePrecision]]]
\begin{array}{l}
[K, m, n, M, l] = \mathsf{sort}([K, m, n, M, l])\\
\\
\begin{array}{l}
t_0 := e^{\left(\left|m - n\right| - \ell\right) - {\left(\frac{m + n}{2} - M\right)}^{2}}\\
\mathbf{if}\;\cos \left(\frac{K \cdot \left(m + n\right)}{2} - M\right) \cdot t\_0 \leq \infty:\\
\;\;\;\;t\_0 \cdot \cos \left({\left(\sqrt[3]{\left(m + n\right) \cdot \left(K \cdot 0.5\right)}\right)}^{3} - M\right)\\
\mathbf{else}:\\
\;\;\;\;e^{m - n}\\
\end{array}
\end{array}
if (*.f64 (cos.f64 (-.f64 (/.f64 (*.f64 K (+.f64 m n)) #s(literal 2 binary64)) M)) (exp.f64 (-.f64 (neg.f64 (pow.f64 (-.f64 (/.f64 (+.f64 m n) #s(literal 2 binary64)) M) #s(literal 2 binary64))) (-.f64 l (fabs.f64 (-.f64 m n)))))) < +inf.0Initial program 95.9%
add-cube-cbrt96.8%
pow396.9%
div-inv96.9%
*-commutative96.9%
associate-*l*96.9%
metadata-eval96.9%
Applied egg-rr96.9%
if +inf.0 < (*.f64 (cos.f64 (-.f64 (/.f64 (*.f64 K (+.f64 m n)) #s(literal 2 binary64)) M)) (exp.f64 (-.f64 (neg.f64 (pow.f64 (-.f64 (/.f64 (+.f64 m n) #s(literal 2 binary64)) M) #s(literal 2 binary64))) (-.f64 l (fabs.f64 (-.f64 m n)))))) Initial program 0.0%
Taylor expanded in K around 0 98.0%
Simplified98.0%
Taylor expanded in l around 0 98.0%
fabs-sub98.0%
rem-square-sqrt50.0%
fabs-sqr50.0%
rem-square-sqrt98.0%
Simplified98.0%
Taylor expanded in M around inf 58.7%
Taylor expanded in M around 0 48.8%
Final simplification87.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
(let* ((t_0
(*
(cos (- (/ (* K (+ m n)) 2.0) M))
(exp (- (- (fabs (- m n)) l) (pow (- (/ (+ m n) 2.0) M) 2.0))))))
(if (<= t_0 INFINITY) t_0 (exp (- m n)))))assert(K < m && m < n && n < M && M < l);
double code(double K, double m, double n, double M, double l) {
double t_0 = cos((((K * (m + n)) / 2.0) - M)) * exp(((fabs((m - n)) - l) - pow((((m + n) / 2.0) - M), 2.0)));
double tmp;
if (t_0 <= ((double) INFINITY)) {
tmp = t_0;
} else {
tmp = exp((m - n));
}
return tmp;
}
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 = Math.cos((((K * (m + n)) / 2.0) - M)) * Math.exp(((Math.abs((m - n)) - l) - Math.pow((((m + n) / 2.0) - M), 2.0)));
double tmp;
if (t_0 <= Double.POSITIVE_INFINITY) {
tmp = t_0;
} else {
tmp = Math.exp((m - n));
}
return tmp;
}
[K, m, n, M, l] = sort([K, m, n, M, l]) def code(K, m, n, M, l): t_0 = math.cos((((K * (m + n)) / 2.0) - M)) * math.exp(((math.fabs((m - n)) - l) - math.pow((((m + n) / 2.0) - M), 2.0))) tmp = 0 if t_0 <= math.inf: tmp = t_0 else: tmp = math.exp((m - n)) return tmp
K, m, n, M, l = sort([K, m, n, M, l]) function code(K, m, n, M, l) t_0 = Float64(cos(Float64(Float64(Float64(K * Float64(m + n)) / 2.0) - M)) * exp(Float64(Float64(abs(Float64(m - n)) - l) - (Float64(Float64(Float64(m + n) / 2.0) - M) ^ 2.0)))) tmp = 0.0 if (t_0 <= Inf) tmp = t_0; else tmp = exp(Float64(m - n)); 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)
t_0 = cos((((K * (m + n)) / 2.0) - M)) * exp(((abs((m - n)) - l) - ((((m + n) / 2.0) - M) ^ 2.0)));
tmp = 0.0;
if (t_0 <= Inf)
tmp = t_0;
else
tmp = exp((m - n));
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_] := Block[{t$95$0 = N[(N[Cos[N[(N[(N[(K * N[(m + n), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision] - M), $MachinePrecision]], $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]}, If[LessEqual[t$95$0, Infinity], t$95$0, N[Exp[N[(m - n), $MachinePrecision]], $MachinePrecision]]]
\begin{array}{l}
[K, m, n, M, l] = \mathsf{sort}([K, m, n, M, l])\\
\\
\begin{array}{l}
t_0 := \cos \left(\frac{K \cdot \left(m + n\right)}{2} - M\right) \cdot e^{\left(\left|m - n\right| - \ell\right) - {\left(\frac{m + n}{2} - M\right)}^{2}}\\
\mathbf{if}\;t\_0 \leq \infty:\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;e^{m - n}\\
\end{array}
\end{array}
if (*.f64 (cos.f64 (-.f64 (/.f64 (*.f64 K (+.f64 m n)) #s(literal 2 binary64)) M)) (exp.f64 (-.f64 (neg.f64 (pow.f64 (-.f64 (/.f64 (+.f64 m n) #s(literal 2 binary64)) M) #s(literal 2 binary64))) (-.f64 l (fabs.f64 (-.f64 m n)))))) < +inf.0Initial program 95.9%
if +inf.0 < (*.f64 (cos.f64 (-.f64 (/.f64 (*.f64 K (+.f64 m n)) #s(literal 2 binary64)) M)) (exp.f64 (-.f64 (neg.f64 (pow.f64 (-.f64 (/.f64 (+.f64 m n) #s(literal 2 binary64)) M) #s(literal 2 binary64))) (-.f64 l (fabs.f64 (-.f64 m n)))))) Initial program 0.0%
Taylor expanded in K around 0 98.0%
Simplified98.0%
Taylor expanded in l around 0 98.0%
fabs-sub98.0%
rem-square-sqrt50.0%
fabs-sqr50.0%
rem-square-sqrt98.0%
Simplified98.0%
Taylor expanded in M around inf 58.7%
Taylor expanded in M around 0 48.8%
Final simplification86.7%
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 (- (fabs (- m n)) (+ l (pow (- (* (+ m n) 0.5) 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((fabs((m - n)) - (l + pow((((m + n) * 0.5) - 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((abs((m - n)) - (l + ((((m + n) * 0.5d0) - 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((Math.abs((m - n)) - (l + Math.pow((((m + n) * 0.5) - 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((math.fabs((m - n)) - (l + math.pow((((m + n) * 0.5) - 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(abs(Float64(m - n)) - Float64(l + (Float64(Float64(Float64(m + n) * 0.5) - 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((abs((m - n)) - (l + ((((m + n) * 0.5) - 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[Abs[N[(m - n), $MachinePrecision]], $MachinePrecision] - N[(l + N[Power[N[(N[(N[(m + n), $MachinePrecision] * 0.5), $MachinePrecision] - M), $MachinePrecision], 2.0], $MachinePrecision]), $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|m - n\right| - \left(\ell + {\left(\left(m + n\right) \cdot 0.5 - M\right)}^{2}\right)} \cdot \cos M
\end{array}
Initial program 77.2%
Taylor expanded in K around 0 94.5%
Simplified94.5%
Final simplification94.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
(if (<= n 1.02e-7)
(*
(cos M)
(exp (+ (- (fabs (- m n)) l) (* (+ (* m 0.5) (- n M)) (- M (* m 0.5))))))
(* (cos M) (exp (- (- m n) (pow M 2.0))))))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 <= 1.02e-7) {
tmp = cos(M) * exp(((fabs((m - n)) - l) + (((m * 0.5) + (n - M)) * (M - (m * 0.5)))));
} else {
tmp = cos(M) * exp(((m - n) - pow(M, 2.0)));
}
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 <= 1.02d-7) then
tmp = cos(m_1) * exp(((abs((m - n)) - l) + (((m * 0.5d0) + (n - m_1)) * (m_1 - (m * 0.5d0)))))
else
tmp = cos(m_1) * exp(((m - n) - (m_1 ** 2.0d0)))
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 <= 1.02e-7) {
tmp = Math.cos(M) * Math.exp(((Math.abs((m - n)) - l) + (((m * 0.5) + (n - M)) * (M - (m * 0.5)))));
} else {
tmp = Math.cos(M) * Math.exp(((m - n) - Math.pow(M, 2.0)));
}
return tmp;
}
[K, m, n, M, l] = sort([K, m, n, M, l]) def code(K, m, n, M, l): tmp = 0 if n <= 1.02e-7: tmp = math.cos(M) * math.exp(((math.fabs((m - n)) - l) + (((m * 0.5) + (n - M)) * (M - (m * 0.5))))) else: tmp = math.cos(M) * math.exp(((m - n) - math.pow(M, 2.0))) 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 <= 1.02e-7) tmp = Float64(cos(M) * exp(Float64(Float64(abs(Float64(m - n)) - l) + Float64(Float64(Float64(m * 0.5) + Float64(n - M)) * Float64(M - Float64(m * 0.5)))))); else tmp = Float64(cos(M) * exp(Float64(Float64(m - n) - (M ^ 2.0)))); 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 <= 1.02e-7)
tmp = cos(M) * exp(((abs((m - n)) - l) + (((m * 0.5) + (n - M)) * (M - (m * 0.5)))));
else
tmp = cos(M) * exp(((m - n) - (M ^ 2.0)));
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, 1.02e-7], N[(N[Cos[M], $MachinePrecision] * N[Exp[N[(N[(N[Abs[N[(m - n), $MachinePrecision]], $MachinePrecision] - l), $MachinePrecision] + N[(N[(N[(m * 0.5), $MachinePrecision] + N[(n - M), $MachinePrecision]), $MachinePrecision] * N[(M - N[(m * 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(N[Cos[M], $MachinePrecision] * N[Exp[N[(N[(m - n), $MachinePrecision] - N[Power[M, 2.0], $MachinePrecision]), $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 1.02 \cdot 10^{-7}:\\
\;\;\;\;\cos M \cdot e^{\left(\left|m - n\right| - \ell\right) + \left(m \cdot 0.5 + \left(n - M\right)\right) \cdot \left(M - m \cdot 0.5\right)}\\
\mathbf{else}:\\
\;\;\;\;\cos M \cdot e^{\left(m - n\right) - {M}^{2}}\\
\end{array}
\end{array}
if n < 1.02e-7Initial program 77.2%
Taylor expanded in n around 0 66.0%
+-commutative66.0%
unpow266.0%
distribute-rgt-out66.5%
*-commutative66.5%
*-commutative66.5%
Simplified66.5%
Taylor expanded in K around 0 77.9%
Simplified77.9%
if 1.02e-7 < n Initial program 77.0%
Taylor expanded in K around 0 100.0%
Simplified100.0%
Taylor expanded in l around 0 96.8%
fabs-sub96.8%
rem-square-sqrt13.1%
fabs-sqr13.1%
rem-square-sqrt96.8%
Simplified96.8%
Taylor expanded in M around inf 85.5%
Final simplification79.7%
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 (or (<= M -1.3e+48) (not (<= M 27.0))) (* (cos M) (exp (- (pow M 2.0)))) (exp (- m n))))
assert(K < m && m < n && n < M && M < l);
double code(double K, double m, double n, double M, double l) {
double tmp;
if ((M <= -1.3e+48) || !(M <= 27.0)) {
tmp = cos(M) * exp(-pow(M, 2.0));
} else {
tmp = exp((m - n));
}
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 ((m_1 <= (-1.3d+48)) .or. (.not. (m_1 <= 27.0d0))) then
tmp = cos(m_1) * exp(-(m_1 ** 2.0d0))
else
tmp = exp((m - n))
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 ((M <= -1.3e+48) || !(M <= 27.0)) {
tmp = Math.cos(M) * Math.exp(-Math.pow(M, 2.0));
} else {
tmp = Math.exp((m - n));
}
return tmp;
}
[K, m, n, M, l] = sort([K, m, n, M, l]) def code(K, m, n, M, l): tmp = 0 if (M <= -1.3e+48) or not (M <= 27.0): tmp = math.cos(M) * math.exp(-math.pow(M, 2.0)) else: tmp = math.exp((m - n)) return tmp
K, m, n, M, l = sort([K, m, n, M, l]) function code(K, m, n, M, l) tmp = 0.0 if ((M <= -1.3e+48) || !(M <= 27.0)) tmp = Float64(cos(M) * exp(Float64(-(M ^ 2.0)))); else tmp = exp(Float64(m - n)); 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 ((M <= -1.3e+48) || ~((M <= 27.0)))
tmp = cos(M) * exp(-(M ^ 2.0));
else
tmp = exp((m - n));
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[Or[LessEqual[M, -1.3e+48], N[Not[LessEqual[M, 27.0]], $MachinePrecision]], N[(N[Cos[M], $MachinePrecision] * N[Exp[(-N[Power[M, 2.0], $MachinePrecision])], $MachinePrecision]), $MachinePrecision], N[Exp[N[(m - n), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
[K, m, n, M, l] = \mathsf{sort}([K, m, n, M, l])\\
\\
\begin{array}{l}
\mathbf{if}\;M \leq -1.3 \cdot 10^{+48} \lor \neg \left(M \leq 27\right):\\
\;\;\;\;\cos M \cdot e^{-{M}^{2}}\\
\mathbf{else}:\\
\;\;\;\;e^{m - n}\\
\end{array}
\end{array}
if M < -1.29999999999999998e48 or 27 < M Initial program 78.8%
Taylor expanded in K around 0 99.1%
Simplified99.1%
Taylor expanded in l around 0 99.1%
fabs-sub99.1%
rem-square-sqrt47.8%
fabs-sqr47.8%
rem-square-sqrt99.1%
Simplified99.1%
Taylor expanded in M around inf 88.7%
Taylor expanded in M around inf 99.1%
neg-mul-199.1%
Simplified99.1%
if -1.29999999999999998e48 < M < 27Initial program 75.9%
Taylor expanded in K around 0 90.9%
Simplified90.9%
Taylor expanded in l around 0 78.7%
fabs-sub78.7%
rem-square-sqrt42.6%
fabs-sqr42.6%
rem-square-sqrt78.4%
Simplified78.4%
Taylor expanded in M around inf 41.5%
Taylor expanded in M around 0 41.5%
Final simplification67.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 720.0) (* (cos M) (exp (- (- m n) (pow M 2.0)))) (* (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 <= 720.0) {
tmp = cos(M) * exp(((m - n) - pow(M, 2.0)));
} 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 <= 720.0d0) then
tmp = cos(m_1) * exp(((m - n) - (m_1 ** 2.0d0)))
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 <= 720.0) {
tmp = Math.cos(M) * Math.exp(((m - n) - Math.pow(M, 2.0)));
} 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 <= 720.0: tmp = math.cos(M) * math.exp(((m - n) - math.pow(M, 2.0))) 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 <= 720.0) tmp = Float64(cos(M) * exp(Float64(Float64(m - n) - (M ^ 2.0)))); 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 <= 720.0)
tmp = cos(M) * exp(((m - n) - (M ^ 2.0)));
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, 720.0], N[(N[Cos[M], $MachinePrecision] * N[Exp[N[(N[(m - n), $MachinePrecision] - N[Power[M, 2.0], $MachinePrecision]), $MachinePrecision]], $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 720:\\
\;\;\;\;\cos M \cdot e^{\left(m - n\right) - {M}^{2}}\\
\mathbf{else}:\\
\;\;\;\;\cos M \cdot e^{-\ell}\\
\end{array}
\end{array}
if l < 720Initial program 75.3%
Taylor expanded in K around 0 93.1%
Simplified93.1%
Taylor expanded in l around 0 88.8%
fabs-sub88.8%
rem-square-sqrt46.5%
fabs-sqr46.5%
rem-square-sqrt88.6%
Simplified88.6%
Taylor expanded in M around inf 63.8%
if 720 < l Initial program 84.6%
Taylor expanded in l around inf 84.6%
mul-1-neg84.6%
Simplified84.6%
Taylor expanded in K around 0 100.0%
cos-neg100.0%
Simplified100.0%
Final simplification71.1%
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 750.0) (exp (- m n)) (* (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 <= 750.0) {
tmp = exp((m - n));
} 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 <= 750.0d0) then
tmp = exp((m - n))
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 <= 750.0) {
tmp = Math.exp((m - n));
} 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 <= 750.0: tmp = math.exp((m - n)) 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 <= 750.0) tmp = exp(Float64(m - n)); 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 <= 750.0)
tmp = exp((m - n));
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, 750.0], N[Exp[N[(m - n), $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 750:\\
\;\;\;\;e^{m - n}\\
\mathbf{else}:\\
\;\;\;\;\cos M \cdot e^{-\ell}\\
\end{array}
\end{array}
if l < 750Initial program 75.3%
Taylor expanded in K around 0 93.1%
Simplified93.1%
Taylor expanded in l around 0 88.8%
fabs-sub88.8%
rem-square-sqrt46.5%
fabs-sqr46.5%
rem-square-sqrt88.6%
Simplified88.6%
Taylor expanded in M around inf 63.8%
Taylor expanded in M around 0 44.1%
if 750 < l Initial program 84.6%
Taylor expanded in l around inf 84.6%
mul-1-neg84.6%
Simplified84.6%
Taylor expanded in K around 0 100.0%
cos-neg100.0%
Simplified100.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 (- m n)))
assert(K < m && m < n && n < M && M < l);
double code(double K, double m, double n, double M, double l) {
return exp((m - n));
}
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((m - n))
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((m - n));
}
[K, m, n, M, l] = sort([K, m, n, M, l]) def code(K, m, n, M, l): return math.exp((m - n))
K, m, n, M, l = sort([K, m, n, M, l]) function code(K, m, n, M, l) return exp(Float64(m - n)) end
K, m, n, M, l = num2cell(sort([K, m, n, M, l])){:}
function tmp = code(K, m, n, M, l)
tmp = exp((m - n));
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[N[(m - n), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
[K, m, n, M, l] = \mathsf{sort}([K, m, n, M, l])\\
\\
e^{m - n}
\end{array}
Initial program 77.2%
Taylor expanded in K around 0 94.5%
Simplified94.5%
Taylor expanded in l around 0 87.7%
fabs-sub87.7%
rem-square-sqrt44.9%
fabs-sqr44.9%
rem-square-sqrt87.5%
Simplified87.5%
Taylor expanded in M around inf 62.3%
Taylor expanded in M around 0 43.2%
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.2%
Taylor expanded in l around inf 28.5%
mul-1-neg28.5%
Simplified28.5%
Taylor expanded in l around 0 7.5%
Taylor expanded in K around 0 7.4%
cos-neg7.4%
Simplified7.4%
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 1.0)
assert(K < m && m < n && n < M && M < l);
double code(double K, double m, double n, double M, double l) {
return 1.0;
}
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 = 1.0d0
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 1.0;
}
[K, m, n, M, l] = sort([K, m, n, M, l]) def code(K, m, n, M, l): return 1.0
K, m, n, M, l = sort([K, m, n, M, l]) function code(K, m, n, M, l) return 1.0 end
K, m, n, M, l = num2cell(sort([K, m, n, M, l])){:}
function tmp = code(K, m, n, M, l)
tmp = 1.0;
end
NOTE: K, m, n, M, and l should be sorted in increasing order before calling this function. code[K_, m_, n_, M_, l_] := 1.0
\begin{array}{l}
[K, m, n, M, l] = \mathsf{sort}([K, m, n, M, l])\\
\\
1
\end{array}
Initial program 77.2%
Taylor expanded in l around inf 28.5%
mul-1-neg28.5%
Simplified28.5%
Taylor expanded in l around 0 7.5%
Taylor expanded in K around 0 7.1%
cos-neg7.1%
associate-*r*7.1%
sin-neg7.1%
Simplified7.1%
Taylor expanded in M around 0 7.4%
herbie shell --seed 2024137
(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)))))))