
(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 9 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (K m n M l) :precision binary64 (* (cos (- (/ (* K (+ m n)) 2.0) M)) (exp (- (- (pow (- (/ (+ m n) 2.0) M) 2.0)) (- l (fabs (- m n)))))))
double code(double K, double m, double n, double M, double l) {
return cos((((K * (m + n)) / 2.0) - M)) * exp((-pow((((m + n) / 2.0) - M), 2.0) - (l - fabs((m - n)))));
}
real(8) function code(k, m, n, m_1, l)
real(8), intent (in) :: k
real(8), intent (in) :: m
real(8), intent (in) :: n
real(8), intent (in) :: m_1
real(8), intent (in) :: l
code = cos((((k * (m + n)) / 2.0d0) - m_1)) * exp((-((((m + n) / 2.0d0) - m_1) ** 2.0d0) - (l - abs((m - n)))))
end function
public static double code(double K, double m, double n, double M, double l) {
return Math.cos((((K * (m + n)) / 2.0) - M)) * Math.exp((-Math.pow((((m + n) / 2.0) - M), 2.0) - (l - Math.abs((m - n)))));
}
def code(K, m, n, M, l): return math.cos((((K * (m + n)) / 2.0) - M)) * math.exp((-math.pow((((m + n) / 2.0) - M), 2.0) - (l - math.fabs((m - n)))))
function code(K, m, n, M, l) return Float64(cos(Float64(Float64(Float64(K * Float64(m + n)) / 2.0) - M)) * exp(Float64(Float64(-(Float64(Float64(Float64(m + n) / 2.0) - M) ^ 2.0)) - Float64(l - abs(Float64(m - n)))))) end
function tmp = code(K, m, n, M, l) tmp = cos((((K * (m + n)) / 2.0) - M)) * exp((-((((m + n) / 2.0) - M) ^ 2.0) - (l - abs((m - n))))); end
code[K_, m_, n_, M_, l_] := N[(N[Cos[N[(N[(N[(K * N[(m + n), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision] - M), $MachinePrecision]], $MachinePrecision] * N[Exp[N[((-N[Power[N[(N[(N[(m + n), $MachinePrecision] / 2.0), $MachinePrecision] - M), $MachinePrecision], 2.0], $MachinePrecision]) - N[(l - N[Abs[N[(m - n), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\cos \left(\frac{K \cdot \left(m + n\right)}{2} - M\right) \cdot e^{\left(-{\left(\frac{m + n}{2} - M\right)}^{2}\right) - \left(\ell - \left|m - n\right|\right)}
\end{array}
(FPCore (K m n M l) :precision binary64 (* (cos M) (exp (- (- (fabs (- n m)) l) (pow (- (/ (+ m n) 2.0) M) 2.0)))))
double code(double K, double m, double n, double M, double l) {
return cos(M) * exp(((fabs((n - m)) - l) - pow((((m + n) / 2.0) - M), 2.0)));
}
real(8) function code(k, m, n, m_1, l)
real(8), intent (in) :: k
real(8), intent (in) :: m
real(8), intent (in) :: n
real(8), intent (in) :: m_1
real(8), intent (in) :: l
code = cos(m_1) * exp(((abs((n - m)) - l) - ((((m + n) / 2.0d0) - m_1) ** 2.0d0)))
end function
public static double code(double K, double m, double n, double M, double l) {
return Math.cos(M) * Math.exp(((Math.abs((n - m)) - l) - Math.pow((((m + n) / 2.0) - M), 2.0)));
}
def code(K, m, n, M, l): return math.cos(M) * math.exp(((math.fabs((n - m)) - l) - math.pow((((m + n) / 2.0) - M), 2.0)))
function code(K, m, n, M, l) return Float64(cos(M) * exp(Float64(Float64(abs(Float64(n - m)) - l) - (Float64(Float64(Float64(m + n) / 2.0) - M) ^ 2.0)))) end
function tmp = code(K, m, n, M, l) tmp = cos(M) * exp(((abs((n - m)) - l) - ((((m + n) / 2.0) - M) ^ 2.0))); end
code[K_, m_, n_, M_, l_] := N[(N[Cos[M], $MachinePrecision] * N[Exp[N[(N[(N[Abs[N[(n - m), $MachinePrecision]], $MachinePrecision] - l), $MachinePrecision] - N[Power[N[(N[(N[(m + n), $MachinePrecision] / 2.0), $MachinePrecision] - M), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\cos M \cdot e^{\left(\left|n - m\right| - \ell\right) - {\left(\frac{m + n}{2} - M\right)}^{2}}
\end{array}
Initial program 71.3%
Taylor expanded in K around 0 97.2%
cos-neg97.2%
Simplified97.2%
Final simplification97.2%
(FPCore (K m n M l) :precision binary64 (exp (- (fabs (- n m)) (+ l (pow (- (* (+ m n) 0.5) M) 2.0)))))
double code(double K, double m, double n, double M, double l) {
return exp((fabs((n - m)) - (l + pow((((m + n) * 0.5) - M), 2.0))));
}
real(8) function code(k, m, n, m_1, l)
real(8), intent (in) :: k
real(8), intent (in) :: m
real(8), intent (in) :: n
real(8), intent (in) :: m_1
real(8), intent (in) :: l
code = exp((abs((n - m)) - (l + ((((m + n) * 0.5d0) - m_1) ** 2.0d0))))
end function
public static double code(double K, double m, double n, double M, double l) {
return Math.exp((Math.abs((n - m)) - (l + Math.pow((((m + n) * 0.5) - M), 2.0))));
}
def code(K, m, n, M, l): return math.exp((math.fabs((n - m)) - (l + math.pow((((m + n) * 0.5) - M), 2.0))))
function code(K, m, n, M, l) return exp(Float64(abs(Float64(n - m)) - Float64(l + (Float64(Float64(Float64(m + n) * 0.5) - M) ^ 2.0)))) end
function tmp = code(K, m, n, M, l) tmp = exp((abs((n - m)) - (l + ((((m + n) * 0.5) - M) ^ 2.0)))); end
code[K_, m_, n_, M_, l_] := N[Exp[N[(N[Abs[N[(n - m), $MachinePrecision]], $MachinePrecision] - N[(l + N[Power[N[(N[(N[(m + n), $MachinePrecision] * 0.5), $MachinePrecision] - M), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
e^{\left|n - m\right| - \left(\ell + {\left(\left(m + n\right) \cdot 0.5 - M\right)}^{2}\right)}
\end{array}
Initial program 71.3%
Taylor expanded in m around inf 81.4%
*-commutative81.4%
associate-*l*81.4%
Simplified81.4%
Taylor expanded in K around 0 97.0%
Final simplification97.0%
(FPCore (K m n M l)
:precision binary64
(let* ((t_0 (fabs (- n m))))
(if (<= n 2e+20)
(exp (+ t_0 (- (* (- (+ n (* m 0.5)) M) (- M (* m 0.5))) l)))
(exp (+ t_0 (- (* (- (* n 0.5) M) (- M (* n 0.5))) l))))))
double code(double K, double m, double n, double M, double l) {
double t_0 = fabs((n - m));
double tmp;
if (n <= 2e+20) {
tmp = exp((t_0 + ((((n + (m * 0.5)) - M) * (M - (m * 0.5))) - l)));
} else {
tmp = exp((t_0 + ((((n * 0.5) - M) * (M - (n * 0.5))) - l)));
}
return tmp;
}
real(8) function code(k, m, n, m_1, l)
real(8), intent (in) :: k
real(8), intent (in) :: m
real(8), intent (in) :: n
real(8), intent (in) :: m_1
real(8), intent (in) :: l
real(8) :: t_0
real(8) :: tmp
t_0 = abs((n - m))
if (n <= 2d+20) then
tmp = exp((t_0 + ((((n + (m * 0.5d0)) - m_1) * (m_1 - (m * 0.5d0))) - l)))
else
tmp = exp((t_0 + ((((n * 0.5d0) - m_1) * (m_1 - (n * 0.5d0))) - l)))
end if
code = tmp
end function
public static double code(double K, double m, double n, double M, double l) {
double t_0 = Math.abs((n - m));
double tmp;
if (n <= 2e+20) {
tmp = Math.exp((t_0 + ((((n + (m * 0.5)) - M) * (M - (m * 0.5))) - l)));
} else {
tmp = Math.exp((t_0 + ((((n * 0.5) - M) * (M - (n * 0.5))) - l)));
}
return tmp;
}
def code(K, m, n, M, l): t_0 = math.fabs((n - m)) tmp = 0 if n <= 2e+20: tmp = math.exp((t_0 + ((((n + (m * 0.5)) - M) * (M - (m * 0.5))) - l))) else: tmp = math.exp((t_0 + ((((n * 0.5) - M) * (M - (n * 0.5))) - l))) return tmp
function code(K, m, n, M, l) t_0 = abs(Float64(n - m)) tmp = 0.0 if (n <= 2e+20) tmp = exp(Float64(t_0 + Float64(Float64(Float64(Float64(n + Float64(m * 0.5)) - M) * Float64(M - Float64(m * 0.5))) - l))); else tmp = exp(Float64(t_0 + Float64(Float64(Float64(Float64(n * 0.5) - M) * Float64(M - Float64(n * 0.5))) - l))); end return tmp end
function tmp_2 = code(K, m, n, M, l) t_0 = abs((n - m)); tmp = 0.0; if (n <= 2e+20) tmp = exp((t_0 + ((((n + (m * 0.5)) - M) * (M - (m * 0.5))) - l))); else tmp = exp((t_0 + ((((n * 0.5) - M) * (M - (n * 0.5))) - l))); end tmp_2 = tmp; end
code[K_, m_, n_, M_, l_] := Block[{t$95$0 = N[Abs[N[(n - m), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[n, 2e+20], N[Exp[N[(t$95$0 + N[(N[(N[(N[(n + N[(m * 0.5), $MachinePrecision]), $MachinePrecision] - M), $MachinePrecision] * N[(M - N[(m * 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - l), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[Exp[N[(t$95$0 + N[(N[(N[(N[(n * 0.5), $MachinePrecision] - M), $MachinePrecision] * N[(M - N[(n * 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - l), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left|n - m\right|\\
\mathbf{if}\;n \leq 2 \cdot 10^{+20}:\\
\;\;\;\;e^{t\_0 + \left(\left(\left(n + m \cdot 0.5\right) - M\right) \cdot \left(M - m \cdot 0.5\right) - \ell\right)}\\
\mathbf{else}:\\
\;\;\;\;e^{t\_0 + \left(\left(n \cdot 0.5 - M\right) \cdot \left(M - n \cdot 0.5\right) - \ell\right)}\\
\end{array}
\end{array}
if n < 2e20Initial program 71.1%
Taylor expanded in n around 0 63.0%
+-commutative63.0%
unpow263.0%
distribute-rgt-out65.6%
*-commutative65.6%
*-commutative65.6%
Simplified65.6%
Taylor expanded in n around inf 81.5%
*-commutative81.5%
associate-*l*81.5%
Simplified81.5%
Taylor expanded in K around 0 86.5%
if 2e20 < n Initial program 72.1%
Taylor expanded in m around inf 95.1%
*-commutative95.1%
associate-*l*95.1%
Simplified95.1%
Taylor expanded in m around 0 95.2%
unpow295.2%
Applied egg-rr95.2%
Final simplification88.6%
(FPCore (K m n M l)
:precision binary64
(let* ((t_0 (fabs (- n m))))
(if (or (<= M -0.27) (not (<= M 2e+85)))
(exp (+ t_0 (- (* M (- n M)) l)))
(exp (+ t_0 (- (* n (- M (* n 0.25))) l))))))
double code(double K, double m, double n, double M, double l) {
double t_0 = fabs((n - m));
double tmp;
if ((M <= -0.27) || !(M <= 2e+85)) {
tmp = exp((t_0 + ((M * (n - M)) - l)));
} else {
tmp = exp((t_0 + ((n * (M - (n * 0.25))) - l)));
}
return tmp;
}
real(8) function code(k, m, n, m_1, l)
real(8), intent (in) :: k
real(8), intent (in) :: m
real(8), intent (in) :: n
real(8), intent (in) :: m_1
real(8), intent (in) :: l
real(8) :: t_0
real(8) :: tmp
t_0 = abs((n - m))
if ((m_1 <= (-0.27d0)) .or. (.not. (m_1 <= 2d+85))) then
tmp = exp((t_0 + ((m_1 * (n - m_1)) - l)))
else
tmp = exp((t_0 + ((n * (m_1 - (n * 0.25d0))) - l)))
end if
code = tmp
end function
public static double code(double K, double m, double n, double M, double l) {
double t_0 = Math.abs((n - m));
double tmp;
if ((M <= -0.27) || !(M <= 2e+85)) {
tmp = Math.exp((t_0 + ((M * (n - M)) - l)));
} else {
tmp = Math.exp((t_0 + ((n * (M - (n * 0.25))) - l)));
}
return tmp;
}
def code(K, m, n, M, l): t_0 = math.fabs((n - m)) tmp = 0 if (M <= -0.27) or not (M <= 2e+85): tmp = math.exp((t_0 + ((M * (n - M)) - l))) else: tmp = math.exp((t_0 + ((n * (M - (n * 0.25))) - l))) return tmp
function code(K, m, n, M, l) t_0 = abs(Float64(n - m)) tmp = 0.0 if ((M <= -0.27) || !(M <= 2e+85)) tmp = exp(Float64(t_0 + Float64(Float64(M * Float64(n - M)) - l))); else tmp = exp(Float64(t_0 + Float64(Float64(n * Float64(M - Float64(n * 0.25))) - l))); end return tmp end
function tmp_2 = code(K, m, n, M, l) t_0 = abs((n - m)); tmp = 0.0; if ((M <= -0.27) || ~((M <= 2e+85))) tmp = exp((t_0 + ((M * (n - M)) - l))); else tmp = exp((t_0 + ((n * (M - (n * 0.25))) - l))); end tmp_2 = tmp; end
code[K_, m_, n_, M_, l_] := Block[{t$95$0 = N[Abs[N[(n - m), $MachinePrecision]], $MachinePrecision]}, If[Or[LessEqual[M, -0.27], N[Not[LessEqual[M, 2e+85]], $MachinePrecision]], N[Exp[N[(t$95$0 + N[(N[(M * N[(n - M), $MachinePrecision]), $MachinePrecision] - l), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[Exp[N[(t$95$0 + N[(N[(n * N[(M - N[(n * 0.25), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - l), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left|n - m\right|\\
\mathbf{if}\;M \leq -0.27 \lor \neg \left(M \leq 2 \cdot 10^{+85}\right):\\
\;\;\;\;e^{t\_0 + \left(M \cdot \left(n - M\right) - \ell\right)}\\
\mathbf{else}:\\
\;\;\;\;e^{t\_0 + \left(n \cdot \left(M - n \cdot 0.25\right) - \ell\right)}\\
\end{array}
\end{array}
if M < -0.27000000000000002 or 2e85 < M Initial program 74.3%
Taylor expanded in m around inf 84.1%
*-commutative84.1%
associate-*l*84.1%
Simplified84.1%
Taylor expanded in m around 0 95.6%
Taylor expanded in n around 0 82.5%
mul-1-neg82.5%
distribute-rgt-neg-in82.5%
mul-1-neg82.5%
unpow282.5%
distribute-lft-in86.9%
+-commutative86.9%
mul-1-neg86.9%
unsub-neg86.9%
Simplified86.9%
if -0.27000000000000002 < M < 2e85Initial program 69.0%
Taylor expanded in m around inf 79.3%
*-commutative79.3%
associate-*l*79.3%
Simplified79.3%
Taylor expanded in m around 0 69.9%
unpow269.9%
Applied egg-rr69.9%
Taylor expanded in M around 0 69.9%
associate-+r+69.9%
unpow269.9%
associate-*r*69.9%
*-commutative69.9%
associate-+r+69.9%
mul-1-neg69.9%
*-commutative69.9%
distribute-rgt-neg-in69.9%
distribute-lft-in69.9%
+-commutative69.9%
unsub-neg69.9%
*-commutative69.9%
Simplified69.9%
Final simplification77.4%
(FPCore (K m n M l)
:precision binary64
(let* ((t_0 (fabs (- n m))))
(if (<= n -8e-95)
(* (cos (* (* n 0.5) K)) (exp (* n (- M (* m 0.5)))))
(if (<= n 4.8e+47)
(exp (+ t_0 (- (* M (- n M)) l)))
(exp (+ t_0 (- (* n (- M (* n 0.25))) l)))))))
double code(double K, double m, double n, double M, double l) {
double t_0 = fabs((n - m));
double tmp;
if (n <= -8e-95) {
tmp = cos(((n * 0.5) * K)) * exp((n * (M - (m * 0.5))));
} else if (n <= 4.8e+47) {
tmp = exp((t_0 + ((M * (n - M)) - l)));
} else {
tmp = exp((t_0 + ((n * (M - (n * 0.25))) - l)));
}
return tmp;
}
real(8) function code(k, m, n, m_1, l)
real(8), intent (in) :: k
real(8), intent (in) :: m
real(8), intent (in) :: n
real(8), intent (in) :: m_1
real(8), intent (in) :: l
real(8) :: t_0
real(8) :: tmp
t_0 = abs((n - m))
if (n <= (-8d-95)) then
tmp = cos(((n * 0.5d0) * k)) * exp((n * (m_1 - (m * 0.5d0))))
else if (n <= 4.8d+47) then
tmp = exp((t_0 + ((m_1 * (n - m_1)) - l)))
else
tmp = exp((t_0 + ((n * (m_1 - (n * 0.25d0))) - l)))
end if
code = tmp
end function
public static double code(double K, double m, double n, double M, double l) {
double t_0 = Math.abs((n - m));
double tmp;
if (n <= -8e-95) {
tmp = Math.cos(((n * 0.5) * K)) * Math.exp((n * (M - (m * 0.5))));
} else if (n <= 4.8e+47) {
tmp = Math.exp((t_0 + ((M * (n - M)) - l)));
} else {
tmp = Math.exp((t_0 + ((n * (M - (n * 0.25))) - l)));
}
return tmp;
}
def code(K, m, n, M, l): t_0 = math.fabs((n - m)) tmp = 0 if n <= -8e-95: tmp = math.cos(((n * 0.5) * K)) * math.exp((n * (M - (m * 0.5)))) elif n <= 4.8e+47: tmp = math.exp((t_0 + ((M * (n - M)) - l))) else: tmp = math.exp((t_0 + ((n * (M - (n * 0.25))) - l))) return tmp
function code(K, m, n, M, l) t_0 = abs(Float64(n - m)) tmp = 0.0 if (n <= -8e-95) tmp = Float64(cos(Float64(Float64(n * 0.5) * K)) * exp(Float64(n * Float64(M - Float64(m * 0.5))))); elseif (n <= 4.8e+47) tmp = exp(Float64(t_0 + Float64(Float64(M * Float64(n - M)) - l))); else tmp = exp(Float64(t_0 + Float64(Float64(n * Float64(M - Float64(n * 0.25))) - l))); end return tmp end
function tmp_2 = code(K, m, n, M, l) t_0 = abs((n - m)); tmp = 0.0; if (n <= -8e-95) tmp = cos(((n * 0.5) * K)) * exp((n * (M - (m * 0.5)))); elseif (n <= 4.8e+47) tmp = exp((t_0 + ((M * (n - M)) - l))); else tmp = exp((t_0 + ((n * (M - (n * 0.25))) - l))); end tmp_2 = tmp; end
code[K_, m_, n_, M_, l_] := Block[{t$95$0 = N[Abs[N[(n - m), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[n, -8e-95], N[(N[Cos[N[(N[(n * 0.5), $MachinePrecision] * K), $MachinePrecision]], $MachinePrecision] * N[Exp[N[(n * N[(M - N[(m * 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[n, 4.8e+47], N[Exp[N[(t$95$0 + N[(N[(M * N[(n - M), $MachinePrecision]), $MachinePrecision] - l), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[Exp[N[(t$95$0 + N[(N[(n * N[(M - N[(n * 0.25), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - l), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left|n - m\right|\\
\mathbf{if}\;n \leq -8 \cdot 10^{-95}:\\
\;\;\;\;\cos \left(\left(n \cdot 0.5\right) \cdot K\right) \cdot e^{n \cdot \left(M - m \cdot 0.5\right)}\\
\mathbf{elif}\;n \leq 4.8 \cdot 10^{+47}:\\
\;\;\;\;e^{t\_0 + \left(M \cdot \left(n - M\right) - \ell\right)}\\
\mathbf{else}:\\
\;\;\;\;e^{t\_0 + \left(n \cdot \left(M - n \cdot 0.25\right) - \ell\right)}\\
\end{array}
\end{array}
if n < -7.99999999999999992e-95Initial program 67.4%
Taylor expanded in n around 0 49.0%
+-commutative49.0%
unpow249.0%
distribute-rgt-out54.9%
*-commutative54.9%
*-commutative54.9%
Simplified54.9%
Taylor expanded in n around inf 67.6%
*-commutative67.6%
associate-*l*67.6%
Simplified67.6%
Taylor expanded in n around inf 36.9%
if -7.99999999999999992e-95 < n < 4.80000000000000037e47Initial program 75.1%
Taylor expanded in m around inf 75.8%
*-commutative75.8%
associate-*l*75.8%
Simplified75.8%
Taylor expanded in m around 0 71.8%
Taylor expanded in n around 0 70.9%
mul-1-neg70.9%
distribute-rgt-neg-in70.9%
mul-1-neg70.9%
unpow270.9%
distribute-lft-in70.9%
+-commutative70.9%
mul-1-neg70.9%
unsub-neg70.9%
Simplified70.9%
if 4.80000000000000037e47 < n Initial program 69.6%
Taylor expanded in m around inf 94.6%
*-commutative94.6%
associate-*l*94.6%
Simplified94.6%
Taylor expanded in m around 0 94.7%
unpow294.7%
Applied egg-rr94.7%
Taylor expanded in M around 0 78.8%
associate-+r+78.8%
unpow278.8%
associate-*r*78.8%
*-commutative78.8%
associate-+r+78.8%
mul-1-neg78.8%
*-commutative78.8%
distribute-rgt-neg-in78.8%
distribute-lft-in82.4%
+-commutative82.4%
unsub-neg82.4%
*-commutative82.4%
Simplified82.4%
Final simplification62.0%
(FPCore (K m n M l) :precision binary64 (if (or (<= l 1300000000.0) (not (<= l 7e+180))) (exp (+ (fabs (- n m)) (- (* M (- n M)) l))) (* (cos (* (* n 0.5) K)) (exp (- l)))))
double code(double K, double m, double n, double M, double l) {
double tmp;
if ((l <= 1300000000.0) || !(l <= 7e+180)) {
tmp = exp((fabs((n - m)) + ((M * (n - M)) - l)));
} else {
tmp = cos(((n * 0.5) * K)) * exp(-l);
}
return tmp;
}
real(8) function code(k, m, n, m_1, l)
real(8), intent (in) :: k
real(8), intent (in) :: m
real(8), intent (in) :: n
real(8), intent (in) :: m_1
real(8), intent (in) :: l
real(8) :: tmp
if ((l <= 1300000000.0d0) .or. (.not. (l <= 7d+180))) then
tmp = exp((abs((n - m)) + ((m_1 * (n - m_1)) - l)))
else
tmp = cos(((n * 0.5d0) * k)) * exp(-l)
end if
code = tmp
end function
public static double code(double K, double m, double n, double M, double l) {
double tmp;
if ((l <= 1300000000.0) || !(l <= 7e+180)) {
tmp = Math.exp((Math.abs((n - m)) + ((M * (n - M)) - l)));
} else {
tmp = Math.cos(((n * 0.5) * K)) * Math.exp(-l);
}
return tmp;
}
def code(K, m, n, M, l): tmp = 0 if (l <= 1300000000.0) or not (l <= 7e+180): tmp = math.exp((math.fabs((n - m)) + ((M * (n - M)) - l))) else: tmp = math.cos(((n * 0.5) * K)) * math.exp(-l) return tmp
function code(K, m, n, M, l) tmp = 0.0 if ((l <= 1300000000.0) || !(l <= 7e+180)) tmp = exp(Float64(abs(Float64(n - m)) + Float64(Float64(M * Float64(n - M)) - l))); else tmp = Float64(cos(Float64(Float64(n * 0.5) * K)) * exp(Float64(-l))); end return tmp end
function tmp_2 = code(K, m, n, M, l) tmp = 0.0; if ((l <= 1300000000.0) || ~((l <= 7e+180))) tmp = exp((abs((n - m)) + ((M * (n - M)) - l))); else tmp = cos(((n * 0.5) * K)) * exp(-l); end tmp_2 = tmp; end
code[K_, m_, n_, M_, l_] := If[Or[LessEqual[l, 1300000000.0], N[Not[LessEqual[l, 7e+180]], $MachinePrecision]], N[Exp[N[(N[Abs[N[(n - m), $MachinePrecision]], $MachinePrecision] + N[(N[(M * N[(n - M), $MachinePrecision]), $MachinePrecision] - l), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[(N[Cos[N[(N[(n * 0.5), $MachinePrecision] * K), $MachinePrecision]], $MachinePrecision] * N[Exp[(-l)], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\ell \leq 1300000000 \lor \neg \left(\ell \leq 7 \cdot 10^{+180}\right):\\
\;\;\;\;e^{\left|n - m\right| + \left(M \cdot \left(n - M\right) - \ell\right)}\\
\mathbf{else}:\\
\;\;\;\;\cos \left(\left(n \cdot 0.5\right) \cdot K\right) \cdot e^{-\ell}\\
\end{array}
\end{array}
if l < 1.3e9 or 6.9999999999999996e180 < l Initial program 70.2%
Taylor expanded in m around inf 80.4%
*-commutative80.4%
associate-*l*80.4%
Simplified80.4%
Taylor expanded in m around 0 79.4%
Taylor expanded in n around 0 52.9%
mul-1-neg52.9%
distribute-rgt-neg-in52.9%
mul-1-neg52.9%
unpow252.9%
distribute-lft-in54.7%
+-commutative54.7%
mul-1-neg54.7%
unsub-neg54.7%
Simplified54.7%
if 1.3e9 < l < 6.9999999999999996e180Initial program 78.8%
Taylor expanded in n around 0 72.8%
+-commutative72.8%
unpow272.8%
distribute-rgt-out75.8%
*-commutative75.8%
*-commutative75.8%
Simplified75.8%
Taylor expanded in n around inf 84.9%
*-commutative84.9%
associate-*l*84.9%
Simplified84.9%
Taylor expanded in l around inf 87.9%
neg-mul-187.9%
Simplified87.9%
Final simplification59.0%
(FPCore (K m n M l) :precision binary64 (exp (+ (fabs (- n m)) (- (* (- (* n 0.5) M) (- M (* n 0.5))) l))))
double code(double K, double m, double n, double M, double l) {
return exp((fabs((n - m)) + ((((n * 0.5) - M) * (M - (n * 0.5))) - l)));
}
real(8) function code(k, m, n, m_1, l)
real(8), intent (in) :: k
real(8), intent (in) :: m
real(8), intent (in) :: n
real(8), intent (in) :: m_1
real(8), intent (in) :: l
code = exp((abs((n - m)) + ((((n * 0.5d0) - m_1) * (m_1 - (n * 0.5d0))) - l)))
end function
public static double code(double K, double m, double n, double M, double l) {
return Math.exp((Math.abs((n - m)) + ((((n * 0.5) - M) * (M - (n * 0.5))) - l)));
}
def code(K, m, n, M, l): return math.exp((math.fabs((n - m)) + ((((n * 0.5) - M) * (M - (n * 0.5))) - l)))
function code(K, m, n, M, l) return exp(Float64(abs(Float64(n - m)) + Float64(Float64(Float64(Float64(n * 0.5) - M) * Float64(M - Float64(n * 0.5))) - l))) end
function tmp = code(K, m, n, M, l) tmp = exp((abs((n - m)) + ((((n * 0.5) - M) * (M - (n * 0.5))) - l))); end
code[K_, m_, n_, M_, l_] := N[Exp[N[(N[Abs[N[(n - m), $MachinePrecision]], $MachinePrecision] + N[(N[(N[(N[(n * 0.5), $MachinePrecision] - M), $MachinePrecision] * N[(M - N[(n * 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - l), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
e^{\left|n - m\right| + \left(\left(n \cdot 0.5 - M\right) \cdot \left(M - n \cdot 0.5\right) - \ell\right)}
\end{array}
Initial program 71.3%
Taylor expanded in m around inf 81.4%
*-commutative81.4%
associate-*l*81.4%
Simplified81.4%
Taylor expanded in m around 0 81.3%
unpow281.3%
Applied egg-rr81.3%
Final simplification81.3%
(FPCore (K m n M l) :precision binary64 (* (cos (* (* n 0.5) K)) (exp (- l))))
double code(double K, double m, double n, double M, double l) {
return cos(((n * 0.5) * K)) * exp(-l);
}
real(8) function code(k, m, n, m_1, l)
real(8), intent (in) :: k
real(8), intent (in) :: m
real(8), intent (in) :: n
real(8), intent (in) :: m_1
real(8), intent (in) :: l
code = cos(((n * 0.5d0) * k)) * exp(-l)
end function
public static double code(double K, double m, double n, double M, double l) {
return Math.cos(((n * 0.5) * K)) * Math.exp(-l);
}
def code(K, m, n, M, l): return math.cos(((n * 0.5) * K)) * math.exp(-l)
function code(K, m, n, M, l) return Float64(cos(Float64(Float64(n * 0.5) * K)) * exp(Float64(-l))) end
function tmp = code(K, m, n, M, l) tmp = cos(((n * 0.5) * K)) * exp(-l); end
code[K_, m_, n_, M_, l_] := N[(N[Cos[N[(N[(n * 0.5), $MachinePrecision] * K), $MachinePrecision]], $MachinePrecision] * N[Exp[(-l)], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\cos \left(\left(n \cdot 0.5\right) \cdot K\right) \cdot e^{-\ell}
\end{array}
Initial program 71.3%
Taylor expanded in n around 0 58.2%
+-commutative58.2%
unpow258.2%
distribute-rgt-out61.4%
*-commutative61.4%
*-commutative61.4%
Simplified61.4%
Taylor expanded in n around inf 73.5%
*-commutative73.5%
associate-*l*73.5%
Simplified73.5%
Taylor expanded in l around inf 31.3%
neg-mul-131.3%
Simplified31.3%
Final simplification31.3%
(FPCore (K m n M l) :precision binary64 (exp (- (fabs (- n m)) l)))
double code(double K, double m, double n, double M, double l) {
return exp((fabs((n - m)) - l));
}
real(8) function code(k, m, n, m_1, l)
real(8), intent (in) :: k
real(8), intent (in) :: m
real(8), intent (in) :: n
real(8), intent (in) :: m_1
real(8), intent (in) :: l
code = exp((abs((n - m)) - l))
end function
public static double code(double K, double m, double n, double M, double l) {
return Math.exp((Math.abs((n - m)) - l));
}
def code(K, m, n, M, l): return math.exp((math.fabs((n - m)) - l))
function code(K, m, n, M, l) return exp(Float64(abs(Float64(n - m)) - l)) end
function tmp = code(K, m, n, M, l) tmp = exp((abs((n - m)) - l)); end
code[K_, m_, n_, M_, l_] := N[Exp[N[(N[Abs[N[(n - m), $MachinePrecision]], $MachinePrecision] - l), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
e^{\left|n - m\right| - \ell}
\end{array}
Initial program 71.3%
Taylor expanded in m around inf 81.4%
*-commutative81.4%
associate-*l*81.4%
Simplified81.4%
Taylor expanded in K around 0 97.0%
Taylor expanded in l around inf 27.1%
Final simplification27.1%
herbie shell --seed 2024094
(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)))))))