
(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)) (+ (pow (- (/ (+ m n) 2.0) M) 2.0) l)))))
double code(double K, double m, double n, double M, double l) {
return cos(M) * exp((fabs((n - m)) - (pow((((m + n) / 2.0) - M), 2.0) + 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(m_1) * exp((abs((n - m)) - (((((m + n) / 2.0d0) - m_1) ** 2.0d0) + l)))
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)) - (Math.pow((((m + n) / 2.0) - M), 2.0) + l)));
}
def code(K, m, n, M, l): return math.cos(M) * math.exp((math.fabs((n - m)) - (math.pow((((m + n) / 2.0) - M), 2.0) + l)))
function code(K, m, n, M, l) return Float64(cos(M) * exp(Float64(abs(Float64(n - m)) - Float64((Float64(Float64(Float64(m + n) / 2.0) - M) ^ 2.0) + l)))) end
function tmp = code(K, m, n, M, l) tmp = cos(M) * exp((abs((n - m)) - (((((m + n) / 2.0) - M) ^ 2.0) + l))); end
code[K_, m_, n_, M_, l_] := N[(N[Cos[M], $MachinePrecision] * N[Exp[N[(N[Abs[N[(n - m), $MachinePrecision]], $MachinePrecision] - N[(N[Power[N[(N[(N[(m + n), $MachinePrecision] / 2.0), $MachinePrecision] - M), $MachinePrecision], 2.0], $MachinePrecision] + l), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\cos M \cdot e^{\left|n - m\right| - \left({\left(\frac{m + n}{2} - M\right)}^{2} + \ell\right)}
\end{array}
Initial program 75.3%
+-commutative75.3%
+-commutative75.3%
fabs-sub75.3%
associate-/l*75.4%
+-commutative75.4%
Simplified75.4%
Taylor expanded in K around 0 95.5%
cos-neg95.5%
Simplified95.5%
Final simplification95.5%
(FPCore (K m n M l)
:precision binary64
(let* ((t_0 (fabs (- n m))))
(if (or (<= M -4e+126) (not (<= M 1.55e+77)))
(* (cos M) (exp (- t_0 (* M M))))
(exp (- t_0 (+ l (* (pow (+ m n) 2.0) 0.25)))))))
double code(double K, double m, double n, double M, double l) {
double t_0 = fabs((n - m));
double tmp;
if ((M <= -4e+126) || !(M <= 1.55e+77)) {
tmp = cos(M) * exp((t_0 - (M * M)));
} else {
tmp = exp((t_0 - (l + (pow((m + n), 2.0) * 0.25))));
}
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 <= (-4d+126)) .or. (.not. (m_1 <= 1.55d+77))) then
tmp = cos(m_1) * exp((t_0 - (m_1 * m_1)))
else
tmp = exp((t_0 - (l + (((m + n) ** 2.0d0) * 0.25d0))))
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 <= -4e+126) || !(M <= 1.55e+77)) {
tmp = Math.cos(M) * Math.exp((t_0 - (M * M)));
} else {
tmp = Math.exp((t_0 - (l + (Math.pow((m + n), 2.0) * 0.25))));
}
return tmp;
}
def code(K, m, n, M, l): t_0 = math.fabs((n - m)) tmp = 0 if (M <= -4e+126) or not (M <= 1.55e+77): tmp = math.cos(M) * math.exp((t_0 - (M * M))) else: tmp = math.exp((t_0 - (l + (math.pow((m + n), 2.0) * 0.25)))) return tmp
function code(K, m, n, M, l) t_0 = abs(Float64(n - m)) tmp = 0.0 if ((M <= -4e+126) || !(M <= 1.55e+77)) tmp = Float64(cos(M) * exp(Float64(t_0 - Float64(M * M)))); else tmp = exp(Float64(t_0 - Float64(l + Float64((Float64(m + n) ^ 2.0) * 0.25)))); end return tmp end
function tmp_2 = code(K, m, n, M, l) t_0 = abs((n - m)); tmp = 0.0; if ((M <= -4e+126) || ~((M <= 1.55e+77))) tmp = cos(M) * exp((t_0 - (M * M))); else tmp = exp((t_0 - (l + (((m + n) ^ 2.0) * 0.25)))); 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, -4e+126], N[Not[LessEqual[M, 1.55e+77]], $MachinePrecision]], N[(N[Cos[M], $MachinePrecision] * N[Exp[N[(t$95$0 - N[(M * M), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[Exp[N[(t$95$0 - N[(l + N[(N[Power[N[(m + n), $MachinePrecision], 2.0], $MachinePrecision] * 0.25), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left|n - m\right|\\
\mathbf{if}\;M \leq -4 \cdot 10^{+126} \lor \neg \left(M \leq 1.55 \cdot 10^{+77}\right):\\
\;\;\;\;\cos M \cdot e^{t_0 - M \cdot M}\\
\mathbf{else}:\\
\;\;\;\;e^{t_0 - \left(\ell + {\left(m + n\right)}^{2} \cdot 0.25\right)}\\
\end{array}
\end{array}
if M < -3.9999999999999997e126 or 1.54999999999999999e77 < M Initial program 78.8%
+-commutative78.8%
+-commutative78.8%
fabs-sub78.8%
associate-/l*80.0%
+-commutative80.0%
Simplified80.0%
Taylor expanded in K around 0 100.0%
cos-neg100.0%
Simplified100.0%
Taylor expanded in M around inf 97.7%
mul-1-neg97.7%
unpow297.7%
distribute-rgt-neg-in97.7%
Simplified97.7%
if -3.9999999999999997e126 < M < 1.54999999999999999e77Initial program 73.5%
+-commutative73.5%
+-commutative73.5%
fabs-sub73.5%
associate-/l*73.1%
+-commutative73.1%
Simplified73.1%
Taylor expanded in K around 0 84.8%
cos-neg84.8%
associate-*r*84.8%
Simplified84.8%
Taylor expanded in M around 0 92.1%
*-commutative92.1%
+-commutative92.1%
Simplified92.1%
Final simplification94.0%
(FPCore (K m n M l)
:precision binary64
(let* ((t_0 (* (cos (- (/ (* (+ m n) K) 2.0) M)) (exp (- (- l) (* M M)))))
(t_1 (fabs (- n m))))
(if (<= n -1.75e-299)
(* (cos M) (exp (+ t_1 (* (* m m) -0.25))))
(if (<= n 8.5e-192)
t_0
(if (<= n 6.2e-120)
(exp (- t_1 (* 0.25 (* m m))))
(if (<= n 1.32e-101)
(/ (cos M) (exp l))
(if (<= n 2.9e+35) t_0 (exp (- t_1 (* 0.25 (* n n)))))))))))
double code(double K, double m, double n, double M, double l) {
double t_0 = cos(((((m + n) * K) / 2.0) - M)) * exp((-l - (M * M)));
double t_1 = fabs((n - m));
double tmp;
if (n <= -1.75e-299) {
tmp = cos(M) * exp((t_1 + ((m * m) * -0.25)));
} else if (n <= 8.5e-192) {
tmp = t_0;
} else if (n <= 6.2e-120) {
tmp = exp((t_1 - (0.25 * (m * m))));
} else if (n <= 1.32e-101) {
tmp = cos(M) / exp(l);
} else if (n <= 2.9e+35) {
tmp = t_0;
} else {
tmp = exp((t_1 - (0.25 * (n * n))));
}
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) :: t_1
real(8) :: tmp
t_0 = cos(((((m + n) * k) / 2.0d0) - m_1)) * exp((-l - (m_1 * m_1)))
t_1 = abs((n - m))
if (n <= (-1.75d-299)) then
tmp = cos(m_1) * exp((t_1 + ((m * m) * (-0.25d0))))
else if (n <= 8.5d-192) then
tmp = t_0
else if (n <= 6.2d-120) then
tmp = exp((t_1 - (0.25d0 * (m * m))))
else if (n <= 1.32d-101) then
tmp = cos(m_1) / exp(l)
else if (n <= 2.9d+35) then
tmp = t_0
else
tmp = exp((t_1 - (0.25d0 * (n * n))))
end if
code = tmp
end function
public static double code(double K, double m, double n, double M, double l) {
double t_0 = Math.cos(((((m + n) * K) / 2.0) - M)) * Math.exp((-l - (M * M)));
double t_1 = Math.abs((n - m));
double tmp;
if (n <= -1.75e-299) {
tmp = Math.cos(M) * Math.exp((t_1 + ((m * m) * -0.25)));
} else if (n <= 8.5e-192) {
tmp = t_0;
} else if (n <= 6.2e-120) {
tmp = Math.exp((t_1 - (0.25 * (m * m))));
} else if (n <= 1.32e-101) {
tmp = Math.cos(M) / Math.exp(l);
} else if (n <= 2.9e+35) {
tmp = t_0;
} else {
tmp = Math.exp((t_1 - (0.25 * (n * n))));
}
return tmp;
}
def code(K, m, n, M, l): t_0 = math.cos(((((m + n) * K) / 2.0) - M)) * math.exp((-l - (M * M))) t_1 = math.fabs((n - m)) tmp = 0 if n <= -1.75e-299: tmp = math.cos(M) * math.exp((t_1 + ((m * m) * -0.25))) elif n <= 8.5e-192: tmp = t_0 elif n <= 6.2e-120: tmp = math.exp((t_1 - (0.25 * (m * m)))) elif n <= 1.32e-101: tmp = math.cos(M) / math.exp(l) elif n <= 2.9e+35: tmp = t_0 else: tmp = math.exp((t_1 - (0.25 * (n * n)))) return tmp
function code(K, m, n, M, l) t_0 = Float64(cos(Float64(Float64(Float64(Float64(m + n) * K) / 2.0) - M)) * exp(Float64(Float64(-l) - Float64(M * M)))) t_1 = abs(Float64(n - m)) tmp = 0.0 if (n <= -1.75e-299) tmp = Float64(cos(M) * exp(Float64(t_1 + Float64(Float64(m * m) * -0.25)))); elseif (n <= 8.5e-192) tmp = t_0; elseif (n <= 6.2e-120) tmp = exp(Float64(t_1 - Float64(0.25 * Float64(m * m)))); elseif (n <= 1.32e-101) tmp = Float64(cos(M) / exp(l)); elseif (n <= 2.9e+35) tmp = t_0; else tmp = exp(Float64(t_1 - Float64(0.25 * Float64(n * n)))); end return tmp end
function tmp_2 = code(K, m, n, M, l) t_0 = cos(((((m + n) * K) / 2.0) - M)) * exp((-l - (M * M))); t_1 = abs((n - m)); tmp = 0.0; if (n <= -1.75e-299) tmp = cos(M) * exp((t_1 + ((m * m) * -0.25))); elseif (n <= 8.5e-192) tmp = t_0; elseif (n <= 6.2e-120) tmp = exp((t_1 - (0.25 * (m * m)))); elseif (n <= 1.32e-101) tmp = cos(M) / exp(l); elseif (n <= 2.9e+35) tmp = t_0; else tmp = exp((t_1 - (0.25 * (n * n)))); end tmp_2 = tmp; end
code[K_, m_, n_, M_, l_] := Block[{t$95$0 = N[(N[Cos[N[(N[(N[(N[(m + n), $MachinePrecision] * K), $MachinePrecision] / 2.0), $MachinePrecision] - M), $MachinePrecision]], $MachinePrecision] * N[Exp[N[((-l) - N[(M * M), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[Abs[N[(n - m), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[n, -1.75e-299], N[(N[Cos[M], $MachinePrecision] * N[Exp[N[(t$95$1 + N[(N[(m * m), $MachinePrecision] * -0.25), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[n, 8.5e-192], t$95$0, If[LessEqual[n, 6.2e-120], N[Exp[N[(t$95$1 - N[(0.25 * N[(m * m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], If[LessEqual[n, 1.32e-101], N[(N[Cos[M], $MachinePrecision] / N[Exp[l], $MachinePrecision]), $MachinePrecision], If[LessEqual[n, 2.9e+35], t$95$0, N[Exp[N[(t$95$1 - N[(0.25 * N[(n * n), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \left(\frac{\left(m + n\right) \cdot K}{2} - M\right) \cdot e^{\left(-\ell\right) - M \cdot M}\\
t_1 := \left|n - m\right|\\
\mathbf{if}\;n \leq -1.75 \cdot 10^{-299}:\\
\;\;\;\;\cos M \cdot e^{t_1 + \left(m \cdot m\right) \cdot -0.25}\\
\mathbf{elif}\;n \leq 8.5 \cdot 10^{-192}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;n \leq 6.2 \cdot 10^{-120}:\\
\;\;\;\;e^{t_1 - 0.25 \cdot \left(m \cdot m\right)}\\
\mathbf{elif}\;n \leq 1.32 \cdot 10^{-101}:\\
\;\;\;\;\frac{\cos M}{e^{\ell}}\\
\mathbf{elif}\;n \leq 2.9 \cdot 10^{+35}:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;e^{t_1 - 0.25 \cdot \left(n \cdot n\right)}\\
\end{array}
\end{array}
if n < -1.74999999999999995e-299Initial program 77.6%
+-commutative77.6%
+-commutative77.6%
fabs-sub77.6%
associate-/l*78.6%
+-commutative78.6%
Simplified78.6%
Taylor expanded in K around 0 95.8%
cos-neg95.8%
Simplified95.8%
Taylor expanded in m around inf 49.6%
*-commutative49.6%
unpow249.6%
Simplified49.6%
if -1.74999999999999995e-299 < n < 8.49999999999999985e-192 or 1.32e-101 < n < 2.89999999999999995e35Initial program 79.3%
Taylor expanded in M around inf 58.3%
unpow258.3%
Simplified58.3%
Taylor expanded in l around inf 72.4%
if 8.49999999999999985e-192 < n < 6.20000000000000038e-120Initial program 66.7%
+-commutative66.7%
+-commutative66.7%
fabs-sub66.7%
associate-/l*66.7%
+-commutative66.7%
Simplified66.7%
Taylor expanded in K around 0 66.7%
cos-neg66.7%
associate-*r*66.7%
Simplified66.7%
Taylor expanded in M around 0 100.0%
*-commutative100.0%
+-commutative100.0%
Simplified100.0%
Taylor expanded in m around inf 83.9%
*-commutative83.9%
unpow283.9%
Simplified83.9%
if 6.20000000000000038e-120 < n < 1.32e-101Initial program 75.4%
+-commutative75.4%
+-commutative75.4%
fabs-sub75.4%
associate-/l*50.4%
+-commutative50.4%
Simplified50.4%
Taylor expanded in l around inf 1.2%
neg-mul-11.2%
Simplified1.2%
Taylor expanded in l around inf 1.6%
neg-mul-11.6%
Simplified1.6%
Taylor expanded in m around 0 1.3%
Taylor expanded in K around 0 31.6%
exp-neg31.6%
associate-*r/31.6%
*-rgt-identity31.6%
cos-neg31.6%
Simplified31.6%
if 2.89999999999999995e35 < n Initial program 68.2%
+-commutative68.2%
+-commutative68.2%
fabs-sub68.2%
associate-/l*68.2%
+-commutative68.2%
Simplified68.2%
Taylor expanded in K around 0 81.8%
cos-neg81.8%
associate-*r*81.8%
Simplified81.8%
Taylor expanded in M around 0 100.0%
*-commutative100.0%
+-commutative100.0%
Simplified100.0%
Taylor expanded in n around inf 94.0%
*-commutative94.0%
unpow294.0%
Simplified94.0%
Final simplification66.6%
(FPCore (K m n M l)
:precision binary64
(let* ((t_0 (* (cos (- (/ (* (+ m n) K) 2.0) M)) (exp (- (- l) (* M M)))))
(t_1 (fabs (- n m)))
(t_2 (exp (- t_1 (* 0.25 (* m m))))))
(if (<= n -1.46e-297)
t_2
(if (<= n 8e-192)
t_0
(if (<= n 7.1e-122)
t_2
(if (<= n 1.66e-102)
(/ (cos M) (exp l))
(if (<= n 5.5e+33) t_0 (exp (- t_1 (* 0.25 (* n n)))))))))))
double code(double K, double m, double n, double M, double l) {
double t_0 = cos(((((m + n) * K) / 2.0) - M)) * exp((-l - (M * M)));
double t_1 = fabs((n - m));
double t_2 = exp((t_1 - (0.25 * (m * m))));
double tmp;
if (n <= -1.46e-297) {
tmp = t_2;
} else if (n <= 8e-192) {
tmp = t_0;
} else if (n <= 7.1e-122) {
tmp = t_2;
} else if (n <= 1.66e-102) {
tmp = cos(M) / exp(l);
} else if (n <= 5.5e+33) {
tmp = t_0;
} else {
tmp = exp((t_1 - (0.25 * (n * n))));
}
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) :: t_1
real(8) :: t_2
real(8) :: tmp
t_0 = cos(((((m + n) * k) / 2.0d0) - m_1)) * exp((-l - (m_1 * m_1)))
t_1 = abs((n - m))
t_2 = exp((t_1 - (0.25d0 * (m * m))))
if (n <= (-1.46d-297)) then
tmp = t_2
else if (n <= 8d-192) then
tmp = t_0
else if (n <= 7.1d-122) then
tmp = t_2
else if (n <= 1.66d-102) then
tmp = cos(m_1) / exp(l)
else if (n <= 5.5d+33) then
tmp = t_0
else
tmp = exp((t_1 - (0.25d0 * (n * n))))
end if
code = tmp
end function
public static double code(double K, double m, double n, double M, double l) {
double t_0 = Math.cos(((((m + n) * K) / 2.0) - M)) * Math.exp((-l - (M * M)));
double t_1 = Math.abs((n - m));
double t_2 = Math.exp((t_1 - (0.25 * (m * m))));
double tmp;
if (n <= -1.46e-297) {
tmp = t_2;
} else if (n <= 8e-192) {
tmp = t_0;
} else if (n <= 7.1e-122) {
tmp = t_2;
} else if (n <= 1.66e-102) {
tmp = Math.cos(M) / Math.exp(l);
} else if (n <= 5.5e+33) {
tmp = t_0;
} else {
tmp = Math.exp((t_1 - (0.25 * (n * n))));
}
return tmp;
}
def code(K, m, n, M, l): t_0 = math.cos(((((m + n) * K) / 2.0) - M)) * math.exp((-l - (M * M))) t_1 = math.fabs((n - m)) t_2 = math.exp((t_1 - (0.25 * (m * m)))) tmp = 0 if n <= -1.46e-297: tmp = t_2 elif n <= 8e-192: tmp = t_0 elif n <= 7.1e-122: tmp = t_2 elif n <= 1.66e-102: tmp = math.cos(M) / math.exp(l) elif n <= 5.5e+33: tmp = t_0 else: tmp = math.exp((t_1 - (0.25 * (n * n)))) return tmp
function code(K, m, n, M, l) t_0 = Float64(cos(Float64(Float64(Float64(Float64(m + n) * K) / 2.0) - M)) * exp(Float64(Float64(-l) - Float64(M * M)))) t_1 = abs(Float64(n - m)) t_2 = exp(Float64(t_1 - Float64(0.25 * Float64(m * m)))) tmp = 0.0 if (n <= -1.46e-297) tmp = t_2; elseif (n <= 8e-192) tmp = t_0; elseif (n <= 7.1e-122) tmp = t_2; elseif (n <= 1.66e-102) tmp = Float64(cos(M) / exp(l)); elseif (n <= 5.5e+33) tmp = t_0; else tmp = exp(Float64(t_1 - Float64(0.25 * Float64(n * n)))); end return tmp end
function tmp_2 = code(K, m, n, M, l) t_0 = cos(((((m + n) * K) / 2.0) - M)) * exp((-l - (M * M))); t_1 = abs((n - m)); t_2 = exp((t_1 - (0.25 * (m * m)))); tmp = 0.0; if (n <= -1.46e-297) tmp = t_2; elseif (n <= 8e-192) tmp = t_0; elseif (n <= 7.1e-122) tmp = t_2; elseif (n <= 1.66e-102) tmp = cos(M) / exp(l); elseif (n <= 5.5e+33) tmp = t_0; else tmp = exp((t_1 - (0.25 * (n * n)))); end tmp_2 = tmp; end
code[K_, m_, n_, M_, l_] := Block[{t$95$0 = N[(N[Cos[N[(N[(N[(N[(m + n), $MachinePrecision] * K), $MachinePrecision] / 2.0), $MachinePrecision] - M), $MachinePrecision]], $MachinePrecision] * N[Exp[N[((-l) - N[(M * M), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[Abs[N[(n - m), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = N[Exp[N[(t$95$1 - N[(0.25 * N[(m * m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[n, -1.46e-297], t$95$2, If[LessEqual[n, 8e-192], t$95$0, If[LessEqual[n, 7.1e-122], t$95$2, If[LessEqual[n, 1.66e-102], N[(N[Cos[M], $MachinePrecision] / N[Exp[l], $MachinePrecision]), $MachinePrecision], If[LessEqual[n, 5.5e+33], t$95$0, N[Exp[N[(t$95$1 - N[(0.25 * N[(n * n), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \left(\frac{\left(m + n\right) \cdot K}{2} - M\right) \cdot e^{\left(-\ell\right) - M \cdot M}\\
t_1 := \left|n - m\right|\\
t_2 := e^{t_1 - 0.25 \cdot \left(m \cdot m\right)}\\
\mathbf{if}\;n \leq -1.46 \cdot 10^{-297}:\\
\;\;\;\;t_2\\
\mathbf{elif}\;n \leq 8 \cdot 10^{-192}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;n \leq 7.1 \cdot 10^{-122}:\\
\;\;\;\;t_2\\
\mathbf{elif}\;n \leq 1.66 \cdot 10^{-102}:\\
\;\;\;\;\frac{\cos M}{e^{\ell}}\\
\mathbf{elif}\;n \leq 5.5 \cdot 10^{+33}:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;e^{t_1 - 0.25 \cdot \left(n \cdot n\right)}\\
\end{array}
\end{array}
if n < -1.4600000000000001e-297 or 8.0000000000000008e-192 < n < 7.09999999999999955e-122Initial program 77.1%
+-commutative77.1%
+-commutative77.1%
fabs-sub77.1%
associate-/l*78.1%
+-commutative78.1%
Simplified78.1%
Taylor expanded in K around 0 84.3%
cos-neg84.3%
associate-*r*85.0%
Simplified85.0%
Taylor expanded in M around 0 87.7%
*-commutative87.7%
+-commutative87.7%
Simplified87.7%
Taylor expanded in m around inf 51.2%
*-commutative51.2%
unpow251.2%
Simplified51.2%
if -1.4600000000000001e-297 < n < 8.0000000000000008e-192 or 1.66000000000000001e-102 < n < 5.5000000000000006e33Initial program 79.3%
Taylor expanded in M around inf 58.3%
unpow258.3%
Simplified58.3%
Taylor expanded in l around inf 72.4%
if 7.09999999999999955e-122 < n < 1.66000000000000001e-102Initial program 75.4%
+-commutative75.4%
+-commutative75.4%
fabs-sub75.4%
associate-/l*50.4%
+-commutative50.4%
Simplified50.4%
Taylor expanded in l around inf 1.2%
neg-mul-11.2%
Simplified1.2%
Taylor expanded in l around inf 1.6%
neg-mul-11.6%
Simplified1.6%
Taylor expanded in m around 0 1.3%
Taylor expanded in K around 0 31.6%
exp-neg31.6%
associate-*r/31.6%
*-rgt-identity31.6%
cos-neg31.6%
Simplified31.6%
if 5.5000000000000006e33 < n Initial program 68.2%
+-commutative68.2%
+-commutative68.2%
fabs-sub68.2%
associate-/l*68.2%
+-commutative68.2%
Simplified68.2%
Taylor expanded in K around 0 81.8%
cos-neg81.8%
associate-*r*81.8%
Simplified81.8%
Taylor expanded in M around 0 100.0%
*-commutative100.0%
+-commutative100.0%
Simplified100.0%
Taylor expanded in n around inf 94.0%
*-commutative94.0%
unpow294.0%
Simplified94.0%
Final simplification66.6%
(FPCore (K m n M l)
:precision binary64
(let* ((t_0 (fabs (- n m))))
(if (<= m -8.5e+38)
(exp (- t_0 (* 0.25 (* m m))))
(if (or (<= m -6.6e-149) (not (<= m -9.5e-194)))
(exp (- t_0 (* 0.25 (* n n))))
(* (cos (* m (* K 0.5))) (exp (- l)))))))
double code(double K, double m, double n, double M, double l) {
double t_0 = fabs((n - m));
double tmp;
if (m <= -8.5e+38) {
tmp = exp((t_0 - (0.25 * (m * m))));
} else if ((m <= -6.6e-149) || !(m <= -9.5e-194)) {
tmp = exp((t_0 - (0.25 * (n * n))));
} else {
tmp = cos((m * (K * 0.5))) * 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) :: t_0
real(8) :: tmp
t_0 = abs((n - m))
if (m <= (-8.5d+38)) then
tmp = exp((t_0 - (0.25d0 * (m * m))))
else if ((m <= (-6.6d-149)) .or. (.not. (m <= (-9.5d-194)))) then
tmp = exp((t_0 - (0.25d0 * (n * n))))
else
tmp = cos((m * (k * 0.5d0))) * exp(-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 <= -8.5e+38) {
tmp = Math.exp((t_0 - (0.25 * (m * m))));
} else if ((m <= -6.6e-149) || !(m <= -9.5e-194)) {
tmp = Math.exp((t_0 - (0.25 * (n * n))));
} else {
tmp = Math.cos((m * (K * 0.5))) * Math.exp(-l);
}
return tmp;
}
def code(K, m, n, M, l): t_0 = math.fabs((n - m)) tmp = 0 if m <= -8.5e+38: tmp = math.exp((t_0 - (0.25 * (m * m)))) elif (m <= -6.6e-149) or not (m <= -9.5e-194): tmp = math.exp((t_0 - (0.25 * (n * n)))) else: tmp = math.cos((m * (K * 0.5))) * math.exp(-l) return tmp
function code(K, m, n, M, l) t_0 = abs(Float64(n - m)) tmp = 0.0 if (m <= -8.5e+38) tmp = exp(Float64(t_0 - Float64(0.25 * Float64(m * m)))); elseif ((m <= -6.6e-149) || !(m <= -9.5e-194)) tmp = exp(Float64(t_0 - Float64(0.25 * Float64(n * n)))); else tmp = Float64(cos(Float64(m * Float64(K * 0.5))) * exp(Float64(-l))); end return tmp end
function tmp_2 = code(K, m, n, M, l) t_0 = abs((n - m)); tmp = 0.0; if (m <= -8.5e+38) tmp = exp((t_0 - (0.25 * (m * m)))); elseif ((m <= -6.6e-149) || ~((m <= -9.5e-194))) tmp = exp((t_0 - (0.25 * (n * n)))); else tmp = cos((m * (K * 0.5))) * exp(-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[m, -8.5e+38], N[Exp[N[(t$95$0 - N[(0.25 * N[(m * m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], If[Or[LessEqual[m, -6.6e-149], N[Not[LessEqual[m, -9.5e-194]], $MachinePrecision]], N[Exp[N[(t$95$0 - N[(0.25 * N[(n * n), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[(N[Cos[N[(m * N[(K * 0.5), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * N[Exp[(-l)], $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left|n - m\right|\\
\mathbf{if}\;m \leq -8.5 \cdot 10^{+38}:\\
\;\;\;\;e^{t_0 - 0.25 \cdot \left(m \cdot m\right)}\\
\mathbf{elif}\;m \leq -6.6 \cdot 10^{-149} \lor \neg \left(m \leq -9.5 \cdot 10^{-194}\right):\\
\;\;\;\;e^{t_0 - 0.25 \cdot \left(n \cdot n\right)}\\
\mathbf{else}:\\
\;\;\;\;\cos \left(m \cdot \left(K \cdot 0.5\right)\right) \cdot e^{-\ell}\\
\end{array}
\end{array}
if m < -8.4999999999999997e38Initial program 69.8%
+-commutative69.8%
+-commutative69.8%
fabs-sub69.8%
associate-/l*69.8%
+-commutative69.8%
Simplified69.8%
Taylor expanded in K around 0 81.1%
cos-neg81.1%
associate-*r*81.1%
Simplified81.1%
Taylor expanded in M around 0 100.0%
*-commutative100.0%
+-commutative100.0%
Simplified100.0%
Taylor expanded in m around inf 98.1%
*-commutative98.1%
unpow298.1%
Simplified98.1%
if -8.4999999999999997e38 < m < -6.60000000000000034e-149 or -9.50000000000000009e-194 < m Initial program 76.2%
+-commutative76.2%
+-commutative76.2%
fabs-sub76.2%
associate-/l*76.3%
+-commutative76.3%
Simplified76.3%
Taylor expanded in K around 0 83.2%
cos-neg83.2%
associate-*r*83.7%
Simplified83.7%
Taylor expanded in M around 0 83.2%
*-commutative83.2%
+-commutative83.2%
Simplified83.2%
Taylor expanded in n around inf 55.6%
*-commutative55.6%
unpow255.6%
Simplified55.6%
if -6.60000000000000034e-149 < m < -9.50000000000000009e-194Initial program 85.0%
+-commutative85.0%
+-commutative85.0%
fabs-sub85.0%
associate-/l*85.0%
+-commutative85.0%
Simplified85.0%
Taylor expanded in l around inf 44.1%
neg-mul-144.1%
Simplified44.1%
Taylor expanded in l around inf 44.3%
neg-mul-144.3%
Simplified44.3%
Taylor expanded in m around inf 52.7%
associate-*r*52.7%
Simplified52.7%
Final simplification64.3%
(FPCore (K m n M l) :precision binary64 (if (or (<= m -1.8e+39) (not (<= m 7.8e+88))) (exp (- (fabs (- n m)) (* 0.25 (* m m)))) (/ (cos M) (exp l))))
double code(double K, double m, double n, double M, double l) {
double tmp;
if ((m <= -1.8e+39) || !(m <= 7.8e+88)) {
tmp = exp((fabs((n - m)) - (0.25 * (m * m))));
} else {
tmp = cos(M) / 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 ((m <= (-1.8d+39)) .or. (.not. (m <= 7.8d+88))) then
tmp = exp((abs((n - m)) - (0.25d0 * (m * m))))
else
tmp = cos(m_1) / 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 ((m <= -1.8e+39) || !(m <= 7.8e+88)) {
tmp = Math.exp((Math.abs((n - m)) - (0.25 * (m * m))));
} else {
tmp = Math.cos(M) / Math.exp(l);
}
return tmp;
}
def code(K, m, n, M, l): tmp = 0 if (m <= -1.8e+39) or not (m <= 7.8e+88): tmp = math.exp((math.fabs((n - m)) - (0.25 * (m * m)))) else: tmp = math.cos(M) / math.exp(l) return tmp
function code(K, m, n, M, l) tmp = 0.0 if ((m <= -1.8e+39) || !(m <= 7.8e+88)) tmp = exp(Float64(abs(Float64(n - m)) - Float64(0.25 * Float64(m * m)))); else tmp = Float64(cos(M) / exp(l)); end return tmp end
function tmp_2 = code(K, m, n, M, l) tmp = 0.0; if ((m <= -1.8e+39) || ~((m <= 7.8e+88))) tmp = exp((abs((n - m)) - (0.25 * (m * m)))); else tmp = cos(M) / exp(l); end tmp_2 = tmp; end
code[K_, m_, n_, M_, l_] := If[Or[LessEqual[m, -1.8e+39], N[Not[LessEqual[m, 7.8e+88]], $MachinePrecision]], N[Exp[N[(N[Abs[N[(n - m), $MachinePrecision]], $MachinePrecision] - N[(0.25 * N[(m * m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[(N[Cos[M], $MachinePrecision] / N[Exp[l], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;m \leq -1.8 \cdot 10^{+39} \lor \neg \left(m \leq 7.8 \cdot 10^{+88}\right):\\
\;\;\;\;e^{\left|n - m\right| - 0.25 \cdot \left(m \cdot m\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{\cos M}{e^{\ell}}\\
\end{array}
\end{array}
if m < -1.79999999999999992e39 or 7.8000000000000002e88 < m Initial program 68.1%
+-commutative68.1%
+-commutative68.1%
fabs-sub68.1%
associate-/l*68.1%
+-commutative68.1%
Simplified68.1%
Taylor expanded in K around 0 80.9%
cos-neg80.9%
associate-*r*80.9%
Simplified80.9%
Taylor expanded in M around 0 100.0%
*-commutative100.0%
+-commutative100.0%
Simplified100.0%
Taylor expanded in m around inf 99.0%
*-commutative99.0%
unpow299.0%
Simplified99.0%
if -1.79999999999999992e39 < m < 7.8000000000000002e88Initial program 79.4%
+-commutative79.4%
+-commutative79.4%
fabs-sub79.4%
associate-/l*79.6%
+-commutative79.6%
Simplified79.6%
Taylor expanded in l around inf 30.1%
neg-mul-130.1%
Simplified30.1%
Taylor expanded in l around inf 35.2%
neg-mul-135.2%
Simplified35.2%
Taylor expanded in m around 0 35.7%
Taylor expanded in K around 0 41.3%
exp-neg41.3%
associate-*r/41.3%
*-rgt-identity41.3%
cos-neg41.3%
Simplified41.3%
Final simplification62.4%
(FPCore (K m n M l) :precision binary64 (exp (fabs (- n m))))
double code(double K, double m, double n, double M, double l) {
return exp(fabs((n - m)));
}
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)))
end function
public static double code(double K, double m, double n, double M, double l) {
return Math.exp(Math.abs((n - m)));
}
def code(K, m, n, M, l): return math.exp(math.fabs((n - m)))
function code(K, m, n, M, l) return exp(abs(Float64(n - m))) end
function tmp = code(K, m, n, M, l) tmp = exp(abs((n - m))); end
code[K_, m_, n_, M_, l_] := N[Exp[N[Abs[N[(n - m), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
e^{\left|n - m\right|}
\end{array}
Initial program 75.3%
+-commutative75.3%
+-commutative75.3%
fabs-sub75.3%
associate-/l*75.4%
+-commutative75.4%
Simplified75.4%
Taylor expanded in K around 0 95.5%
cos-neg95.5%
Simplified95.5%
Taylor expanded in n around inf 51.5%
*-commutative51.5%
unpow251.5%
Simplified51.5%
Taylor expanded in n around 0 8.2%
Taylor expanded in M around 0 8.6%
Final simplification8.6%
(FPCore (K m n M l) :precision binary64 (/ (cos M) (exp l)))
double code(double K, double m, double n, double M, double l) {
return cos(M) / 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(m_1) / exp(l)
end function
public static double code(double K, double m, double n, double M, double l) {
return Math.cos(M) / Math.exp(l);
}
def code(K, m, n, M, l): return math.cos(M) / math.exp(l)
function code(K, m, n, M, l) return Float64(cos(M) / exp(l)) end
function tmp = code(K, m, n, M, l) tmp = cos(M) / exp(l); end
code[K_, m_, n_, M_, l_] := N[(N[Cos[M], $MachinePrecision] / N[Exp[l], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\cos M}{e^{\ell}}
\end{array}
Initial program 75.3%
+-commutative75.3%
+-commutative75.3%
fabs-sub75.3%
associate-/l*75.4%
+-commutative75.4%
Simplified75.4%
Taylor expanded in l around inf 21.4%
neg-mul-121.4%
Simplified21.4%
Taylor expanded in l around inf 27.5%
neg-mul-127.5%
Simplified27.5%
Taylor expanded in m around 0 28.6%
Taylor expanded in K around 0 34.7%
exp-neg34.7%
associate-*r/34.7%
*-rgt-identity34.7%
cos-neg34.7%
Simplified34.7%
Final simplification34.7%
(FPCore (K m n M l) :precision binary64 (cos M))
double code(double K, double m, double n, double M, double l) {
return cos(M);
}
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
public static double code(double K, double m, double n, double M, double l) {
return Math.cos(M);
}
def code(K, m, n, M, l): return math.cos(M)
function code(K, m, n, M, l) return cos(M) end
function tmp = code(K, m, n, M, l) tmp = cos(M); end
code[K_, m_, n_, M_, l_] := N[Cos[M], $MachinePrecision]
\begin{array}{l}
\\
\cos M
\end{array}
Initial program 75.3%
+-commutative75.3%
+-commutative75.3%
fabs-sub75.3%
associate-/l*75.4%
+-commutative75.4%
Simplified75.4%
Taylor expanded in l around inf 21.4%
neg-mul-121.4%
Simplified21.4%
Taylor expanded in l around inf 27.5%
neg-mul-127.5%
Simplified27.5%
Taylor expanded in l around 0 5.8%
Taylor expanded in K around 0 6.7%
cos-neg6.7%
Simplified6.7%
Final simplification6.7%
herbie shell --seed 2023279
(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)))))))