
(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 (- M (* n 0.5))) (t_1 (fabs (- m n))))
(if (<= m -6.2)
(exp (- t_1 (* 0.25 (pow (+ m n) 2.0))))
(* (cos M) (exp (+ (* (- m t_0) t_0) (- t_1 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 = M - (n * 0.5);
double t_1 = fabs((m - n));
double tmp;
if (m <= -6.2) {
tmp = exp((t_1 - (0.25 * pow((m + n), 2.0))));
} else {
tmp = cos(M) * exp((((m - t_0) * t_0) + (t_1 - 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) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = m_1 - (n * 0.5d0)
t_1 = abs((m - n))
if (m <= (-6.2d0)) then
tmp = exp((t_1 - (0.25d0 * ((m + n) ** 2.0d0))))
else
tmp = cos(m_1) * exp((((m - t_0) * t_0) + (t_1 - 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 t_0 = M - (n * 0.5);
double t_1 = Math.abs((m - n));
double tmp;
if (m <= -6.2) {
tmp = Math.exp((t_1 - (0.25 * Math.pow((m + n), 2.0))));
} else {
tmp = Math.cos(M) * Math.exp((((m - t_0) * t_0) + (t_1 - l)));
}
return tmp;
}
[K, m, n, M, l] = sort([K, m, n, M, l]) def code(K, m, n, M, l): t_0 = M - (n * 0.5) t_1 = math.fabs((m - n)) tmp = 0 if m <= -6.2: tmp = math.exp((t_1 - (0.25 * math.pow((m + n), 2.0)))) else: tmp = math.cos(M) * math.exp((((m - t_0) * t_0) + (t_1 - l))) return tmp
K, m, n, M, l = sort([K, m, n, M, l]) function code(K, m, n, M, l) t_0 = Float64(M - Float64(n * 0.5)) t_1 = abs(Float64(m - n)) tmp = 0.0 if (m <= -6.2) tmp = exp(Float64(t_1 - Float64(0.25 * (Float64(m + n) ^ 2.0)))); else tmp = Float64(cos(M) * exp(Float64(Float64(Float64(m - t_0) * t_0) + Float64(t_1 - 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)
t_0 = M - (n * 0.5);
t_1 = abs((m - n));
tmp = 0.0;
if (m <= -6.2)
tmp = exp((t_1 - (0.25 * ((m + n) ^ 2.0))));
else
tmp = cos(M) * exp((((m - t_0) * t_0) + (t_1 - 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_] := Block[{t$95$0 = N[(M - N[(n * 0.5), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[Abs[N[(m - n), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[m, -6.2], N[Exp[N[(t$95$1 - N[(0.25 * N[Power[N[(m + n), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[(N[Cos[M], $MachinePrecision] * N[Exp[N[(N[(N[(m - t$95$0), $MachinePrecision] * t$95$0), $MachinePrecision] + N[(t$95$1 - 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 := M - n \cdot 0.5\\
t_1 := \left|m - n\right|\\
\mathbf{if}\;m \leq -6.2:\\
\;\;\;\;e^{t_1 - 0.25 \cdot {\left(m + n\right)}^{2}}\\
\mathbf{else}:\\
\;\;\;\;\cos M \cdot e^{\left(m - t_0\right) \cdot t_0 + \left(t_1 - \ell\right)}\\
\end{array}
\end{array}
if m < -6.20000000000000018Initial program 72.6%
Taylor expanded in l around 0 72.6%
fabs-sub72.6%
*-commutative72.6%
Simplified72.6%
Taylor expanded in K around 0 96.8%
cos-neg96.8%
Simplified96.8%
Taylor expanded in M around 0 96.8%
if -6.20000000000000018 < m Initial program 82.2%
Taylor expanded in K around 0 97.1%
cos-neg89.3%
Simplified97.1%
Taylor expanded in m around 0 80.8%
+-commutative80.8%
unpow280.8%
distribute-rgt-out84.9%
*-commutative84.9%
*-commutative84.9%
Simplified84.9%
Final simplification87.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 (* (cos M) (exp (- (- (fabs (- m n)) l) (pow (- (/ (+ m n) 2.0) 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((m - n)) - l) - pow((((m + n) / 2.0) - 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((m - n)) - l) - ((((m + n) / 2.0d0) - 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((m - n)) - l) - Math.pow((((m + n) / 2.0) - 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((m - n)) - l) - math.pow((((m + n) / 2.0) - M), 2.0)))
K, m, n, M, l = sort([K, m, n, M, l]) 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
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((m - n)) - l) - ((((m + n) / 2.0) - 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[(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}
[K, m, n, M, l] = \mathsf{sort}([K, m, n, M, l])\\
\\
\cos M \cdot e^{\left(\left|m - n\right| - \ell\right) - {\left(\frac{m + n}{2} - M\right)}^{2}}
\end{array}
Initial program 79.9%
Taylor expanded in K around 0 97.0%
cos-neg91.1%
Simplified97.0%
Final simplification97.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
(let* ((t_0 (fabs (- m n))))
(if (<= n 290.0)
(* (cos M) (exp (+ (* (- (* m 0.5) M) (- (- M (* m 0.5)) n)) (- t_0 l))))
(exp (- t_0 (* 0.25 (pow (+ m n) 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 = fabs((m - n));
double tmp;
if (n <= 290.0) {
tmp = cos(M) * exp(((((m * 0.5) - M) * ((M - (m * 0.5)) - n)) + (t_0 - l)));
} else {
tmp = exp((t_0 - (0.25 * pow((m + n), 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 = abs((m - n))
if (n <= 290.0d0) then
tmp = cos(m_1) * exp(((((m * 0.5d0) - m_1) * ((m_1 - (m * 0.5d0)) - n)) + (t_0 - l)))
else
tmp = exp((t_0 - (0.25d0 * ((m + n) ** 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.abs((m - n));
double tmp;
if (n <= 290.0) {
tmp = Math.cos(M) * Math.exp(((((m * 0.5) - M) * ((M - (m * 0.5)) - n)) + (t_0 - l)));
} else {
tmp = Math.exp((t_0 - (0.25 * Math.pow((m + n), 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.fabs((m - n)) tmp = 0 if n <= 290.0: tmp = math.cos(M) * math.exp(((((m * 0.5) - M) * ((M - (m * 0.5)) - n)) + (t_0 - l))) else: tmp = math.exp((t_0 - (0.25 * math.pow((m + n), 2.0)))) return tmp
K, m, n, M, l = sort([K, m, n, M, l]) function code(K, m, n, M, l) t_0 = abs(Float64(m - n)) tmp = 0.0 if (n <= 290.0) tmp = Float64(cos(M) * exp(Float64(Float64(Float64(Float64(m * 0.5) - M) * Float64(Float64(M - Float64(m * 0.5)) - n)) + Float64(t_0 - l)))); else tmp = exp(Float64(t_0 - Float64(0.25 * (Float64(m + n) ^ 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 = abs((m - n));
tmp = 0.0;
if (n <= 290.0)
tmp = cos(M) * exp(((((m * 0.5) - M) * ((M - (m * 0.5)) - n)) + (t_0 - l)));
else
tmp = exp((t_0 - (0.25 * ((m + n) ^ 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[Abs[N[(m - n), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[n, 290.0], N[(N[Cos[M], $MachinePrecision] * N[Exp[N[(N[(N[(N[(m * 0.5), $MachinePrecision] - M), $MachinePrecision] * N[(N[(M - N[(m * 0.5), $MachinePrecision]), $MachinePrecision] - n), $MachinePrecision]), $MachinePrecision] + N[(t$95$0 - l), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[Exp[N[(t$95$0 - N[(0.25 * N[Power[N[(m + n), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]
\begin{array}{l}
[K, m, n, M, l] = \mathsf{sort}([K, m, n, M, l])\\
\\
\begin{array}{l}
t_0 := \left|m - n\right|\\
\mathbf{if}\;n \leq 290:\\
\;\;\;\;\cos M \cdot e^{\left(m \cdot 0.5 - M\right) \cdot \left(\left(M - m \cdot 0.5\right) - n\right) + \left(t_0 - \ell\right)}\\
\mathbf{else}:\\
\;\;\;\;e^{t_0 - 0.25 \cdot {\left(m + n\right)}^{2}}\\
\end{array}
\end{array}
if n < 290Initial program 82.2%
Taylor expanded in K around 0 96.2%
cos-neg88.3%
Simplified96.2%
Taylor expanded in n around 0 76.8%
+-commutative76.8%
unpow276.8%
distribute-rgt-out80.2%
*-commutative80.2%
*-commutative80.2%
Simplified80.2%
if 290 < n Initial program 74.7%
Taylor expanded in l around 0 73.4%
fabs-sub73.4%
*-commutative73.4%
Simplified73.4%
Taylor expanded in K around 0 97.5%
cos-neg97.5%
Simplified97.5%
Taylor expanded in M around 0 97.5%
Final simplification85.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 (fabs (- m n))) (t_1 (exp (- t_0 (* 0.25 (pow (+ m n) 2.0))))))
(if (<= n -5e-19)
t_1
(if (<= n 9.8e-169)
(exp (+ m (- (pow (* n 0.5) 2.0) (+ n l))))
(if (<= n 0.012) (* (cos M) (exp (+ (* M (- m M)) (- t_0 l)))) t_1)))))assert(K < m && m < n && n < M && M < l);
double code(double K, double m, double n, double M, double l) {
double t_0 = fabs((m - n));
double t_1 = exp((t_0 - (0.25 * pow((m + n), 2.0))));
double tmp;
if (n <= -5e-19) {
tmp = t_1;
} else if (n <= 9.8e-169) {
tmp = exp((m + (pow((n * 0.5), 2.0) - (n + l))));
} else if (n <= 0.012) {
tmp = cos(M) * exp(((M * (m - M)) + (t_0 - l)));
} else {
tmp = t_1;
}
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) :: t_1
real(8) :: tmp
t_0 = abs((m - n))
t_1 = exp((t_0 - (0.25d0 * ((m + n) ** 2.0d0))))
if (n <= (-5d-19)) then
tmp = t_1
else if (n <= 9.8d-169) then
tmp = exp((m + (((n * 0.5d0) ** 2.0d0) - (n + l))))
else if (n <= 0.012d0) then
tmp = cos(m_1) * exp(((m_1 * (m - m_1)) + (t_0 - l)))
else
tmp = t_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 = Math.abs((m - n));
double t_1 = Math.exp((t_0 - (0.25 * Math.pow((m + n), 2.0))));
double tmp;
if (n <= -5e-19) {
tmp = t_1;
} else if (n <= 9.8e-169) {
tmp = Math.exp((m + (Math.pow((n * 0.5), 2.0) - (n + l))));
} else if (n <= 0.012) {
tmp = Math.cos(M) * Math.exp(((M * (m - M)) + (t_0 - l)));
} else {
tmp = t_1;
}
return tmp;
}
[K, m, n, M, l] = sort([K, m, n, M, l]) def code(K, m, n, M, l): t_0 = math.fabs((m - n)) t_1 = math.exp((t_0 - (0.25 * math.pow((m + n), 2.0)))) tmp = 0 if n <= -5e-19: tmp = t_1 elif n <= 9.8e-169: tmp = math.exp((m + (math.pow((n * 0.5), 2.0) - (n + l)))) elif n <= 0.012: tmp = math.cos(M) * math.exp(((M * (m - M)) + (t_0 - l))) else: tmp = t_1 return tmp
K, m, n, M, l = sort([K, m, n, M, l]) function code(K, m, n, M, l) t_0 = abs(Float64(m - n)) t_1 = exp(Float64(t_0 - Float64(0.25 * (Float64(m + n) ^ 2.0)))) tmp = 0.0 if (n <= -5e-19) tmp = t_1; elseif (n <= 9.8e-169) tmp = exp(Float64(m + Float64((Float64(n * 0.5) ^ 2.0) - Float64(n + l)))); elseif (n <= 0.012) tmp = Float64(cos(M) * exp(Float64(Float64(M * Float64(m - M)) + Float64(t_0 - l)))); else tmp = t_1; 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 = abs((m - n));
t_1 = exp((t_0 - (0.25 * ((m + n) ^ 2.0))));
tmp = 0.0;
if (n <= -5e-19)
tmp = t_1;
elseif (n <= 9.8e-169)
tmp = exp((m + (((n * 0.5) ^ 2.0) - (n + l))));
elseif (n <= 0.012)
tmp = cos(M) * exp(((M * (m - M)) + (t_0 - l)));
else
tmp = t_1;
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[Abs[N[(m - n), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[Exp[N[(t$95$0 - N[(0.25 * N[Power[N[(m + n), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[n, -5e-19], t$95$1, If[LessEqual[n, 9.8e-169], N[Exp[N[(m + N[(N[Power[N[(n * 0.5), $MachinePrecision], 2.0], $MachinePrecision] - N[(n + l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], If[LessEqual[n, 0.012], N[(N[Cos[M], $MachinePrecision] * N[Exp[N[(N[(M * N[(m - M), $MachinePrecision]), $MachinePrecision] + N[(t$95$0 - l), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], t$95$1]]]]]
\begin{array}{l}
[K, m, n, M, l] = \mathsf{sort}([K, m, n, M, l])\\
\\
\begin{array}{l}
t_0 := \left|m - n\right|\\
t_1 := e^{t_0 - 0.25 \cdot {\left(m + n\right)}^{2}}\\
\mathbf{if}\;n \leq -5 \cdot 10^{-19}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;n \leq 9.8 \cdot 10^{-169}:\\
\;\;\;\;e^{m + \left({\left(n \cdot 0.5\right)}^{2} - \left(n + \ell\right)\right)}\\
\mathbf{elif}\;n \leq 0.012:\\
\;\;\;\;\cos M \cdot e^{M \cdot \left(m - M\right) + \left(t_0 - \ell\right)}\\
\mathbf{else}:\\
\;\;\;\;t_1\\
\end{array}
\end{array}
if n < -5.0000000000000004e-19 or 0.012 < n Initial program 76.8%
Taylor expanded in l around 0 75.5%
fabs-sub75.5%
*-commutative75.5%
Simplified75.5%
Taylor expanded in K around 0 97.9%
cos-neg97.9%
Simplified97.9%
Taylor expanded in M around 0 97.9%
if -5.0000000000000004e-19 < n < 9.7999999999999999e-169Initial program 79.8%
expm1-log1p-u79.8%
expm1-udef79.7%
Applied egg-rr27.8%
expm1-def27.8%
expm1-log1p27.8%
+-commutative27.8%
associate-+l-27.8%
associate--r-27.8%
+-commutative27.8%
Simplified27.8%
Taylor expanded in M around 0 30.8%
*-commutative30.8%
*-commutative30.8%
associate-*l*30.8%
+-commutative30.8%
associate--l+30.8%
+-commutative30.8%
+-commutative30.8%
Simplified30.8%
Taylor expanded in K around 0 30.7%
Taylor expanded in n around inf 53.9%
metadata-eval53.9%
unpow253.9%
swap-sqr53.9%
unpow253.9%
*-commutative53.9%
Simplified53.9%
if 9.7999999999999999e-169 < n < 0.012Initial program 92.4%
Taylor expanded in K around 0 97.8%
cos-neg87.3%
Simplified97.8%
Taylor expanded in m around 0 68.5%
+-commutative68.5%
unpow268.5%
distribute-rgt-out68.5%
*-commutative68.5%
*-commutative68.5%
Simplified68.5%
Taylor expanded in n around 0 68.5%
fabs-sub68.5%
associate--r+68.5%
associate-*r*68.5%
neg-mul-168.5%
cancel-sign-sub68.5%
fabs-sub68.5%
Simplified68.5%
Final simplification81.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 (if (or (<= n -2.2e-19) (not (<= n 3e-8))) (exp (- (fabs (- m n)) (* 0.25 (pow (+ m n) 2.0)))) (exp (+ m (- (pow (* n 0.5) 2.0) (+ 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 <= -2.2e-19) || !(n <= 3e-8)) {
tmp = exp((fabs((m - n)) - (0.25 * pow((m + n), 2.0))));
} else {
tmp = exp((m + (pow((n * 0.5), 2.0) - (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 <= (-2.2d-19)) .or. (.not. (n <= 3d-8))) then
tmp = exp((abs((m - n)) - (0.25d0 * ((m + n) ** 2.0d0))))
else
tmp = exp((m + (((n * 0.5d0) ** 2.0d0) - (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 <= -2.2e-19) || !(n <= 3e-8)) {
tmp = Math.exp((Math.abs((m - n)) - (0.25 * Math.pow((m + n), 2.0))));
} else {
tmp = Math.exp((m + (Math.pow((n * 0.5), 2.0) - (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 <= -2.2e-19) or not (n <= 3e-8): tmp = math.exp((math.fabs((m - n)) - (0.25 * math.pow((m + n), 2.0)))) else: tmp = math.exp((m + (math.pow((n * 0.5), 2.0) - (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 <= -2.2e-19) || !(n <= 3e-8)) tmp = exp(Float64(abs(Float64(m - n)) - Float64(0.25 * (Float64(m + n) ^ 2.0)))); else tmp = exp(Float64(m + Float64((Float64(n * 0.5) ^ 2.0) - Float64(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 <= -2.2e-19) || ~((n <= 3e-8)))
tmp = exp((abs((m - n)) - (0.25 * ((m + n) ^ 2.0))));
else
tmp = exp((m + (((n * 0.5) ^ 2.0) - (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[Or[LessEqual[n, -2.2e-19], N[Not[LessEqual[n, 3e-8]], $MachinePrecision]], N[Exp[N[(N[Abs[N[(m - n), $MachinePrecision]], $MachinePrecision] - N[(0.25 * N[Power[N[(m + n), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[Exp[N[(m + N[(N[Power[N[(n * 0.5), $MachinePrecision], 2.0], $MachinePrecision] - N[(n + l), $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 -2.2 \cdot 10^{-19} \lor \neg \left(n \leq 3 \cdot 10^{-8}\right):\\
\;\;\;\;e^{\left|m - n\right| - 0.25 \cdot {\left(m + n\right)}^{2}}\\
\mathbf{else}:\\
\;\;\;\;e^{m + \left({\left(n \cdot 0.5\right)}^{2} - \left(n + \ell\right)\right)}\\
\end{array}
\end{array}
if n < -2.1999999999999998e-19 or 2.99999999999999973e-8 < n Initial program 77.0%
Taylor expanded in l around 0 75.6%
fabs-sub75.6%
*-commutative75.6%
Simplified75.6%
Taylor expanded in K around 0 98.0%
cos-neg98.0%
Simplified98.0%
Taylor expanded in M around 0 98.0%
if -2.1999999999999998e-19 < n < 2.99999999999999973e-8Initial program 83.9%
expm1-log1p-u83.9%
expm1-udef83.9%
Applied egg-rr27.4%
expm1-def27.4%
expm1-log1p27.4%
+-commutative27.4%
associate-+l-27.4%
associate--r-27.4%
+-commutative27.4%
Simplified27.4%
Taylor expanded in M around 0 32.2%
*-commutative32.2%
*-commutative32.2%
associate-*l*32.2%
+-commutative32.2%
associate--l+32.2%
+-commutative32.2%
+-commutative32.2%
Simplified32.2%
Taylor expanded in K around 0 32.2%
Taylor expanded in n around inf 50.4%
metadata-eval50.4%
unpow250.4%
swap-sqr50.4%
unpow250.4%
*-commutative50.4%
Simplified50.4%
Final simplification77.9%
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 (<= m -1.36e+82) (exp (- l)) (exp (+ m (- (* 0.25 (pow m 2.0)) (+ 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 (m <= -1.36e+82) {
tmp = exp(-l);
} else {
tmp = exp((m + ((0.25 * pow(m, 2.0)) - (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 (m <= (-1.36d+82)) then
tmp = exp(-l)
else
tmp = exp((m + ((0.25d0 * (m ** 2.0d0)) - (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 (m <= -1.36e+82) {
tmp = Math.exp(-l);
} else {
tmp = Math.exp((m + ((0.25 * Math.pow(m, 2.0)) - (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 m <= -1.36e+82: tmp = math.exp(-l) else: tmp = math.exp((m + ((0.25 * math.pow(m, 2.0)) - (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 (m <= -1.36e+82) tmp = exp(Float64(-l)); else tmp = exp(Float64(m + Float64(Float64(0.25 * (m ^ 2.0)) - Float64(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 (m <= -1.36e+82)
tmp = exp(-l);
else
tmp = exp((m + ((0.25 * (m ^ 2.0)) - (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[m, -1.36e+82], N[Exp[(-l)], $MachinePrecision], N[Exp[N[(m + N[(N[(0.25 * N[Power[m, 2.0], $MachinePrecision]), $MachinePrecision] - N[(n + l), $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 -1.36 \cdot 10^{+82}:\\
\;\;\;\;e^{-\ell}\\
\mathbf{else}:\\
\;\;\;\;e^{m + \left(0.25 \cdot {m}^{2} - \left(n + \ell\right)\right)}\\
\end{array}
\end{array}
if m < -1.36000000000000001e82Initial program 70.8%
expm1-log1p-u70.8%
expm1-udef70.8%
Applied egg-rr3.2%
expm1-def3.2%
expm1-log1p3.2%
+-commutative3.2%
associate-+l-3.2%
associate--r-3.2%
+-commutative3.2%
Simplified3.2%
Taylor expanded in M around 0 5.2%
*-commutative5.2%
*-commutative5.2%
associate-*l*5.2%
+-commutative5.2%
associate--l+5.2%
+-commutative5.2%
+-commutative5.2%
Simplified5.2%
Taylor expanded in m around 0 16.0%
Taylor expanded in n around 0 31.1%
if -1.36000000000000001e82 < m Initial program 82.0%
expm1-log1p-u82.0%
expm1-udef81.7%
Applied egg-rr15.6%
expm1-def15.6%
expm1-log1p15.6%
+-commutative15.6%
associate-+l-15.6%
associate--r-15.6%
+-commutative15.6%
Simplified15.6%
Taylor expanded in M around 0 19.0%
*-commutative19.0%
*-commutative19.0%
associate-*l*19.0%
+-commutative19.0%
associate--l+19.0%
+-commutative19.0%
+-commutative19.0%
Simplified19.0%
Taylor expanded in K around 0 18.7%
Taylor expanded in n around 0 38.1%
Final simplification36.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 (<= n 0.00065) (exp (+ m (- (pow (* n 0.5) 2.0) (+ n l)))) (exp (+ m (- (* 0.25 (pow m 2.0)) (+ 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 <= 0.00065) {
tmp = exp((m + (pow((n * 0.5), 2.0) - (n + l))));
} else {
tmp = exp((m + ((0.25 * pow(m, 2.0)) - (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 <= 0.00065d0) then
tmp = exp((m + (((n * 0.5d0) ** 2.0d0) - (n + l))))
else
tmp = exp((m + ((0.25d0 * (m ** 2.0d0)) - (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 <= 0.00065) {
tmp = Math.exp((m + (Math.pow((n * 0.5), 2.0) - (n + l))));
} else {
tmp = Math.exp((m + ((0.25 * Math.pow(m, 2.0)) - (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 <= 0.00065: tmp = math.exp((m + (math.pow((n * 0.5), 2.0) - (n + l)))) else: tmp = math.exp((m + ((0.25 * math.pow(m, 2.0)) - (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 <= 0.00065) tmp = exp(Float64(m + Float64((Float64(n * 0.5) ^ 2.0) - Float64(n + l)))); else tmp = exp(Float64(m + Float64(Float64(0.25 * (m ^ 2.0)) - Float64(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 <= 0.00065)
tmp = exp((m + (((n * 0.5) ^ 2.0) - (n + l))));
else
tmp = exp((m + ((0.25 * (m ^ 2.0)) - (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, 0.00065], N[Exp[N[(m + N[(N[Power[N[(n * 0.5), $MachinePrecision], 2.0], $MachinePrecision] - N[(n + l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[Exp[N[(m + N[(N[(0.25 * N[Power[m, 2.0], $MachinePrecision]), $MachinePrecision] - N[(n + l), $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 0.00065:\\
\;\;\;\;e^{m + \left({\left(n \cdot 0.5\right)}^{2} - \left(n + \ell\right)\right)}\\
\mathbf{else}:\\
\;\;\;\;e^{m + \left(0.25 \cdot {m}^{2} - \left(n + \ell\right)\right)}\\
\end{array}
\end{array}
if n < 6.4999999999999997e-4Initial program 82.2%
expm1-log1p-u82.2%
expm1-udef81.9%
Applied egg-rr18.1%
expm1-def18.1%
expm1-log1p18.1%
+-commutative18.1%
associate-+l-18.1%
associate--r-18.1%
+-commutative18.1%
Simplified18.1%
Taylor expanded in M around 0 21.6%
*-commutative21.6%
*-commutative21.6%
associate-*l*21.6%
+-commutative21.6%
associate--l+21.6%
+-commutative21.6%
+-commutative21.6%
Simplified21.6%
Taylor expanded in K around 0 21.1%
Taylor expanded in n around inf 35.0%
metadata-eval35.0%
unpow235.0%
swap-sqr35.0%
unpow235.0%
*-commutative35.0%
Simplified35.0%
if 6.4999999999999997e-4 < n Initial program 74.7%
expm1-log1p-u74.7%
expm1-udef74.7%
Applied egg-rr2.4%
expm1-def2.4%
expm1-log1p2.4%
+-commutative2.4%
associate-+l-2.4%
associate--r-2.4%
+-commutative2.4%
Simplified2.4%
Taylor expanded in M around 0 4.9%
*-commutative4.9%
*-commutative4.9%
associate-*l*4.9%
+-commutative4.9%
associate--l+4.9%
+-commutative4.9%
+-commutative4.9%
Simplified4.9%
Taylor expanded in K around 0 5.3%
Taylor expanded in n around 0 52.6%
Final simplification40.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 (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 79.9%
expm1-log1p-u79.9%
expm1-udef79.7%
Applied egg-rr13.3%
expm1-def13.3%
expm1-log1p13.3%
+-commutative13.3%
associate-+l-13.3%
associate--r-13.3%
+-commutative13.3%
Simplified13.3%
Taylor expanded in M around 0 16.4%
*-commutative16.4%
*-commutative16.4%
associate-*l*16.4%
+-commutative16.4%
associate--l+16.4%
+-commutative16.4%
+-commutative16.4%
Simplified16.4%
Taylor expanded in m around 0 21.4%
Taylor expanded in n around 0 32.7%
Final simplification32.7%
herbie shell --seed 2023333
(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)))))))