
(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
(let* ((t_0 (cos (- M))))
(if (or (<= M -65000.0) (not (<= M 22000000.0)))
(* t_0 (exp (- (pow M 2.0))))
(* t_0 (exp (+ (- n (+ m l)) (* -0.25 (pow (+ n 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 t_0 = cos(-M);
double tmp;
if ((M <= -65000.0) || !(M <= 22000000.0)) {
tmp = t_0 * exp(-pow(M, 2.0));
} else {
tmp = t_0 * exp(((n - (m + l)) + (-0.25 * pow((n + 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) :: t_0
real(8) :: tmp
t_0 = cos(-m_1)
if ((m_1 <= (-65000.0d0)) .or. (.not. (m_1 <= 22000000.0d0))) then
tmp = t_0 * exp(-(m_1 ** 2.0d0))
else
tmp = t_0 * exp(((n - (m + l)) + ((-0.25d0) * ((n + m) ** 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 t_0 = Math.cos(-M);
double tmp;
if ((M <= -65000.0) || !(M <= 22000000.0)) {
tmp = t_0 * Math.exp(-Math.pow(M, 2.0));
} else {
tmp = t_0 * Math.exp(((n - (m + l)) + (-0.25 * Math.pow((n + m), 2.0))));
}
return tmp;
}
[K, m, n, M, l] = sort([K, m, n, M, l]) def code(K, m, n, M, l): t_0 = math.cos(-M) tmp = 0 if (M <= -65000.0) or not (M <= 22000000.0): tmp = t_0 * math.exp(-math.pow(M, 2.0)) else: tmp = t_0 * math.exp(((n - (m + l)) + (-0.25 * math.pow((n + m), 2.0)))) return tmp
K, m, n, M, l = sort([K, m, n, M, l]) function code(K, m, n, M, l) t_0 = cos(Float64(-M)) tmp = 0.0 if ((M <= -65000.0) || !(M <= 22000000.0)) tmp = Float64(t_0 * exp(Float64(-(M ^ 2.0)))); else tmp = Float64(t_0 * exp(Float64(Float64(n - Float64(m + l)) + Float64(-0.25 * (Float64(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)
t_0 = cos(-M);
tmp = 0.0;
if ((M <= -65000.0) || ~((M <= 22000000.0)))
tmp = t_0 * exp(-(M ^ 2.0));
else
tmp = t_0 * exp(((n - (m + l)) + (-0.25 * ((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_] := Block[{t$95$0 = N[Cos[(-M)], $MachinePrecision]}, If[Or[LessEqual[M, -65000.0], N[Not[LessEqual[M, 22000000.0]], $MachinePrecision]], N[(t$95$0 * N[Exp[(-N[Power[M, 2.0], $MachinePrecision])], $MachinePrecision]), $MachinePrecision], N[(t$95$0 * N[Exp[N[(N[(n - N[(m + l), $MachinePrecision]), $MachinePrecision] + N[(-0.25 * N[Power[N[(n + m), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
[K, m, n, M, l] = \mathsf{sort}([K, m, n, M, l])\\
\\
\begin{array}{l}
t_0 := \cos \left(-M\right)\\
\mathbf{if}\;M \leq -65000 \lor \neg \left(M \leq 22000000\right):\\
\;\;\;\;t\_0 \cdot e^{-{M}^{2}}\\
\mathbf{else}:\\
\;\;\;\;t\_0 \cdot e^{\left(n - \left(m + \ell\right)\right) + -0.25 \cdot {\left(n + m\right)}^{2}}\\
\end{array}
\end{array}
if M < -65000 or 2.2e7 < M Initial program 83.6%
Simplified83.6%
Taylor expanded in K around 0 99.3%
Taylor expanded in M around inf 99.3%
mul-1-neg99.3%
Simplified99.3%
if -65000 < M < 2.2e7Initial program 72.8%
Simplified73.7%
Taylor expanded in K around 0 93.5%
Taylor expanded in M around 0 93.5%
fabs-sub93.5%
associate--r+93.5%
cancel-sign-sub-inv93.5%
fabs-sub93.5%
sub-neg93.5%
neg-mul-193.5%
neg-mul-193.5%
sub-neg93.5%
rem-square-sqrt47.6%
fabs-sqr47.6%
rem-square-sqrt93.0%
associate--r+93.0%
metadata-eval93.0%
+-commutative93.0%
Simplified93.0%
Final simplification96.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 (* (cos (- M)) (exp (- (fabs (- n m)) (+ l (pow (- (* 0.5 (+ n m)) M) 2.0))))))
assert(K < m && m < n && n < M && M < l);
double code(double K, double m, double n, double M, double l) {
return cos(-M) * exp((fabs((n - m)) - (l + pow(((0.5 * (n + m)) - M), 2.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 = cos(-m_1) * exp((abs((n - m)) - (l + (((0.5d0 * (n + m)) - m_1) ** 2.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 Math.cos(-M) * Math.exp((Math.abs((n - m)) - (l + Math.pow(((0.5 * (n + m)) - M), 2.0))));
}
[K, m, n, M, l] = sort([K, m, n, M, l]) def code(K, m, n, M, l): return math.cos(-M) * math.exp((math.fabs((n - m)) - (l + math.pow(((0.5 * (n + m)) - M), 2.0))))
K, m, n, M, l = sort([K, m, n, M, l]) function code(K, m, n, M, l) return Float64(cos(Float64(-M)) * exp(Float64(abs(Float64(n - m)) - Float64(l + (Float64(Float64(0.5 * Float64(n + m)) - M) ^ 2.0))))) end
K, m, n, M, l = num2cell(sort([K, m, n, M, l])){:}
function tmp = code(K, m, n, M, l)
tmp = cos(-M) * exp((abs((n - m)) - (l + (((0.5 * (n + m)) - M) ^ 2.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_] := N[(N[Cos[(-M)], $MachinePrecision] * N[Exp[N[(N[Abs[N[(n - m), $MachinePrecision]], $MachinePrecision] - N[(l + N[Power[N[(N[(0.5 * N[(n + m), $MachinePrecision]), $MachinePrecision] - M), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
[K, m, n, M, l] = \mathsf{sort}([K, m, n, M, l])\\
\\
\cos \left(-M\right) \cdot e^{\left|n - m\right| - \left(\ell + {\left(0.5 \cdot \left(n + m\right) - M\right)}^{2}\right)}
\end{array}
Initial program 78.7%
Simplified79.1%
Taylor expanded in K around 0 96.7%
Final simplification96.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 -2050.0) (not (<= M 38.0))) (* (cos (- M)) (exp (- (pow M 2.0)))) (exp (+ (- n (+ m l)) (* -0.25 (* (+ n m) (+ n m)))))))
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 <= -2050.0) || !(M <= 38.0)) {
tmp = cos(-M) * exp(-pow(M, 2.0));
} else {
tmp = exp(((n - (m + l)) + (-0.25 * ((n + m) * (n + m)))));
}
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 <= (-2050.0d0)) .or. (.not. (m_1 <= 38.0d0))) then
tmp = cos(-m_1) * exp(-(m_1 ** 2.0d0))
else
tmp = exp(((n - (m + l)) + ((-0.25d0) * ((n + m) * (n + m)))))
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 <= -2050.0) || !(M <= 38.0)) {
tmp = Math.cos(-M) * Math.exp(-Math.pow(M, 2.0));
} else {
tmp = Math.exp(((n - (m + l)) + (-0.25 * ((n + m) * (n + m)))));
}
return tmp;
}
[K, m, n, M, l] = sort([K, m, n, M, l]) def code(K, m, n, M, l): tmp = 0 if (M <= -2050.0) or not (M <= 38.0): tmp = math.cos(-M) * math.exp(-math.pow(M, 2.0)) else: tmp = math.exp(((n - (m + l)) + (-0.25 * ((n + m) * (n + m))))) 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 <= -2050.0) || !(M <= 38.0)) tmp = Float64(cos(Float64(-M)) * exp(Float64(-(M ^ 2.0)))); else tmp = exp(Float64(Float64(n - Float64(m + l)) + Float64(-0.25 * Float64(Float64(n + m) * Float64(n + m))))); 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 <= -2050.0) || ~((M <= 38.0)))
tmp = cos(-M) * exp(-(M ^ 2.0));
else
tmp = exp(((n - (m + l)) + (-0.25 * ((n + m) * (n + m)))));
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, -2050.0], N[Not[LessEqual[M, 38.0]], $MachinePrecision]], N[(N[Cos[(-M)], $MachinePrecision] * N[Exp[(-N[Power[M, 2.0], $MachinePrecision])], $MachinePrecision]), $MachinePrecision], N[Exp[N[(N[(n - N[(m + l), $MachinePrecision]), $MachinePrecision] + N[(-0.25 * N[(N[(n + m), $MachinePrecision] * N[(n + m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
[K, m, n, M, l] = \mathsf{sort}([K, m, n, M, l])\\
\\
\begin{array}{l}
\mathbf{if}\;M \leq -2050 \lor \neg \left(M \leq 38\right):\\
\;\;\;\;\cos \left(-M\right) \cdot e^{-{M}^{2}}\\
\mathbf{else}:\\
\;\;\;\;e^{\left(n - \left(m + \ell\right)\right) + -0.25 \cdot \left(\left(n + m\right) \cdot \left(n + m\right)\right)}\\
\end{array}
\end{array}
if M < -2050 or 38 < M Initial program 83.6%
Simplified83.6%
Taylor expanded in K around 0 99.3%
Taylor expanded in M around inf 99.3%
mul-1-neg99.3%
Simplified99.3%
if -2050 < M < 38Initial program 72.8%
Simplified73.7%
Taylor expanded in K around 0 93.5%
Taylor expanded in M around 0 93.5%
fabs-sub93.5%
associate--r+93.5%
cancel-sign-sub-inv93.5%
fabs-sub93.5%
sub-neg93.5%
neg-mul-193.5%
neg-mul-193.5%
sub-neg93.5%
rem-square-sqrt47.6%
fabs-sqr47.6%
rem-square-sqrt93.0%
associate--r+93.0%
metadata-eval93.0%
+-commutative93.0%
Simplified93.0%
Taylor expanded in M around 0 93.0%
unpow293.0%
Applied egg-rr93.0%
Final simplification96.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
(let* ((t_0 (- n (+ m l))))
(if (or (<= n 7.2e-209) (not (<= n 1.2e-80)))
(exp (+ t_0 (* -0.25 (* (+ n m) (+ n m)))))
(* (cos (- (* K (/ (+ n m) 2.0)) M)) (exp (+ t_0 (* M (- m M))))))))assert(K < m && m < n && n < M && M < l);
double code(double K, double m, double n, double M, double l) {
double t_0 = n - (m + l);
double tmp;
if ((n <= 7.2e-209) || !(n <= 1.2e-80)) {
tmp = exp((t_0 + (-0.25 * ((n + m) * (n + m)))));
} else {
tmp = cos(((K * ((n + m) / 2.0)) - M)) * exp((t_0 + (M * (m - M))));
}
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) :: t_0
real(8) :: tmp
t_0 = n - (m + l)
if ((n <= 7.2d-209) .or. (.not. (n <= 1.2d-80))) then
tmp = exp((t_0 + ((-0.25d0) * ((n + m) * (n + m)))))
else
tmp = cos(((k * ((n + m) / 2.0d0)) - m_1)) * exp((t_0 + (m_1 * (m - m_1))))
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 t_0 = n - (m + l);
double tmp;
if ((n <= 7.2e-209) || !(n <= 1.2e-80)) {
tmp = Math.exp((t_0 + (-0.25 * ((n + m) * (n + m)))));
} else {
tmp = Math.cos(((K * ((n + m) / 2.0)) - M)) * Math.exp((t_0 + (M * (m - M))));
}
return tmp;
}
[K, m, n, M, l] = sort([K, m, n, M, l]) def code(K, m, n, M, l): t_0 = n - (m + l) tmp = 0 if (n <= 7.2e-209) or not (n <= 1.2e-80): tmp = math.exp((t_0 + (-0.25 * ((n + m) * (n + m))))) else: tmp = math.cos(((K * ((n + m) / 2.0)) - M)) * math.exp((t_0 + (M * (m - M)))) return tmp
K, m, n, M, l = sort([K, m, n, M, l]) function code(K, m, n, M, l) t_0 = Float64(n - Float64(m + l)) tmp = 0.0 if ((n <= 7.2e-209) || !(n <= 1.2e-80)) tmp = exp(Float64(t_0 + Float64(-0.25 * Float64(Float64(n + m) * Float64(n + m))))); else tmp = Float64(cos(Float64(Float64(K * Float64(Float64(n + m) / 2.0)) - M)) * exp(Float64(t_0 + Float64(M * Float64(m - M))))); 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 = n - (m + l);
tmp = 0.0;
if ((n <= 7.2e-209) || ~((n <= 1.2e-80)))
tmp = exp((t_0 + (-0.25 * ((n + m) * (n + m)))));
else
tmp = cos(((K * ((n + m) / 2.0)) - M)) * exp((t_0 + (M * (m - M))));
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 - N[(m + l), $MachinePrecision]), $MachinePrecision]}, If[Or[LessEqual[n, 7.2e-209], N[Not[LessEqual[n, 1.2e-80]], $MachinePrecision]], N[Exp[N[(t$95$0 + N[(-0.25 * N[(N[(n + m), $MachinePrecision] * N[(n + m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[(N[Cos[N[(N[(K * N[(N[(n + m), $MachinePrecision] / 2.0), $MachinePrecision]), $MachinePrecision] - M), $MachinePrecision]], $MachinePrecision] * N[Exp[N[(t$95$0 + N[(M * N[(m - M), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
[K, m, n, M, l] = \mathsf{sort}([K, m, n, M, l])\\
\\
\begin{array}{l}
t_0 := n - \left(m + \ell\right)\\
\mathbf{if}\;n \leq 7.2 \cdot 10^{-209} \lor \neg \left(n \leq 1.2 \cdot 10^{-80}\right):\\
\;\;\;\;e^{t\_0 + -0.25 \cdot \left(\left(n + m\right) \cdot \left(n + m\right)\right)}\\
\mathbf{else}:\\
\;\;\;\;\cos \left(K \cdot \frac{n + m}{2} - M\right) \cdot e^{t\_0 + M \cdot \left(m - M\right)}\\
\end{array}
\end{array}
if n < 7.20000000000000032e-209 or 1.2e-80 < n Initial program 76.9%
Simplified77.4%
Taylor expanded in K around 0 96.3%
Taylor expanded in M around 0 85.8%
fabs-sub85.8%
associate--r+85.8%
cancel-sign-sub-inv85.8%
fabs-sub85.8%
sub-neg85.8%
neg-mul-185.8%
neg-mul-185.8%
sub-neg85.8%
rem-square-sqrt44.2%
fabs-sqr44.2%
rem-square-sqrt85.6%
associate--r+85.6%
metadata-eval85.6%
+-commutative85.6%
Simplified85.6%
Taylor expanded in M around 0 85.6%
unpow285.6%
Applied egg-rr85.6%
if 7.20000000000000032e-209 < n < 1.2e-80Initial program 95.8%
associate-/l*95.8%
+-commutative95.8%
associate-/l*95.8%
associate-/l*95.8%
+-commutative95.8%
exp-diff62.5%
sub-neg62.5%
exp-sum50.0%
associate-/r*50.0%
exp-diff54.2%
Simplified95.8%
Taylor expanded in m around 0 71.1%
+-commutative71.1%
unpow271.1%
distribute-rgt-out75.3%
*-commutative75.3%
*-commutative75.3%
Simplified75.3%
Taylor expanded in n around 0 75.3%
fabs-sub75.3%
associate--r+75.3%
associate-*r*75.3%
neg-mul-175.3%
cancel-sign-sub75.3%
fabs-sub75.3%
sub-neg75.3%
neg-mul-175.3%
neg-mul-175.3%
sub-neg75.3%
rem-square-sqrt54.2%
fabs-sqr54.2%
rem-square-sqrt79.4%
associate--r+79.4%
Simplified79.4%
Final simplification85.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 (+ (- n (+ m l)) (* -0.25 (* (+ n m) (+ n 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)) + (-0.25 * ((n + m) * (n + 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.25d0) * ((n + m) * (n + m)))))
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)) + (-0.25 * ((n + m) * (n + 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)) + (-0.25 * ((n + m) * (n + m)))))
K, m, n, M, l = sort([K, m, n, M, l]) function code(K, m, n, M, l) return exp(Float64(Float64(n - Float64(m + l)) + Float64(-0.25 * Float64(Float64(n + m) * Float64(n + 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.25 * ((n + m) * (n + 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[Exp[N[(N[(n - N[(m + l), $MachinePrecision]), $MachinePrecision] + N[(-0.25 * N[(N[(n + m), $MachinePrecision] * N[(n + m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
[K, m, n, M, l] = \mathsf{sort}([K, m, n, M, l])\\
\\
e^{\left(n - \left(m + \ell\right)\right) + -0.25 \cdot \left(\left(n + m\right) \cdot \left(n + m\right)\right)}
\end{array}
Initial program 78.7%
Simplified79.1%
Taylor expanded in K around 0 96.7%
Taylor expanded in M around 0 84.5%
fabs-sub84.5%
associate--r+84.5%
cancel-sign-sub-inv84.5%
fabs-sub84.5%
sub-neg84.5%
neg-mul-184.5%
neg-mul-184.5%
sub-neg84.5%
rem-square-sqrt43.6%
fabs-sqr43.6%
rem-square-sqrt84.3%
associate--r+84.3%
metadata-eval84.3%
+-commutative84.3%
Simplified84.3%
Taylor expanded in M around 0 84.3%
unpow284.3%
Applied egg-rr84.3%
Final simplification84.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 (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 78.7%
Simplified79.1%
Taylor expanded in K around 0 96.7%
Taylor expanded in M around 0 84.5%
fabs-sub84.5%
associate--r+84.5%
cancel-sign-sub-inv84.5%
fabs-sub84.5%
sub-neg84.5%
neg-mul-184.5%
neg-mul-184.5%
sub-neg84.5%
rem-square-sqrt43.6%
fabs-sqr43.6%
rem-square-sqrt84.3%
associate--r+84.3%
metadata-eval84.3%
+-commutative84.3%
Simplified84.3%
Taylor expanded in M around 0 84.3%
Taylor expanded in l around inf 35.2%
neg-mul-135.2%
Simplified35.2%
Final simplification35.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 78.7%
associate-/l*79.1%
+-commutative79.1%
associate-/l*78.7%
associate-/l*79.1%
+-commutative79.1%
exp-diff29.5%
sub-neg29.5%
exp-sum21.7%
associate-/r*21.7%
exp-diff24.8%
Simplified79.1%
Taylor expanded in l around inf 29.4%
mul-1-neg29.4%
Simplified29.4%
Taylor expanded in l around 0 5.9%
neg-mul-15.9%
unsub-neg5.9%
Simplified5.9%
Taylor expanded in K around 0 6.1%
cos-neg6.1%
Simplified6.1%
Taylor expanded in l around 0 6.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 l))
assert(K < m && m < n && n < M && M < l);
double code(double K, double m, double n, double M, double l) {
return 1.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
code = 1.0d0 - 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 1.0 - l;
}
[K, m, n, M, l] = sort([K, m, n, M, l]) def code(K, m, n, M, l): return 1.0 - l
K, m, n, M, l = sort([K, m, n, M, l]) function code(K, m, n, M, l) return Float64(1.0 - l) end
K, m, n, M, l = num2cell(sort([K, m, n, M, l])){:}
function tmp = code(K, m, n, M, l)
tmp = 1.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_] := N[(1.0 - l), $MachinePrecision]
\begin{array}{l}
[K, m, n, M, l] = \mathsf{sort}([K, m, n, M, l])\\
\\
1 - \ell
\end{array}
Initial program 78.7%
associate-/l*79.1%
+-commutative79.1%
associate-/l*78.7%
associate-/l*79.1%
+-commutative79.1%
exp-diff29.5%
sub-neg29.5%
exp-sum21.7%
associate-/r*21.7%
exp-diff24.8%
Simplified79.1%
Taylor expanded in l around inf 29.4%
mul-1-neg29.4%
Simplified29.4%
Taylor expanded in l around 0 5.9%
neg-mul-15.9%
unsub-neg5.9%
Simplified5.9%
Taylor expanded in K around 0 6.1%
cos-neg6.1%
Simplified6.1%
Taylor expanded in M around 0 6.1%
herbie shell --seed 2024123
(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)))))))