
(FPCore (K m n M l) :precision binary64 (* (cos (- (/ (* K (+ m n)) 2.0) M)) (exp (- (- (pow (- (/ (+ m n) 2.0) M) 2.0)) (- l (fabs (- m n)))))))
double code(double K, double m, double n, double M, double l) {
return cos((((K * (m + n)) / 2.0) - M)) * exp((-pow((((m + n) / 2.0) - M), 2.0) - (l - fabs((m - n)))));
}
real(8) function code(k, m, n, m_1, l)
real(8), intent (in) :: k
real(8), intent (in) :: m
real(8), intent (in) :: n
real(8), intent (in) :: m_1
real(8), intent (in) :: l
code = cos((((k * (m + n)) / 2.0d0) - m_1)) * exp((-((((m + n) / 2.0d0) - m_1) ** 2.0d0) - (l - abs((m - n)))))
end function
public static double code(double K, double m, double n, double M, double l) {
return Math.cos((((K * (m + n)) / 2.0) - M)) * Math.exp((-Math.pow((((m + n) / 2.0) - M), 2.0) - (l - Math.abs((m - n)))));
}
def code(K, m, n, M, l): return math.cos((((K * (m + n)) / 2.0) - M)) * math.exp((-math.pow((((m + n) / 2.0) - M), 2.0) - (l - math.fabs((m - n)))))
function code(K, m, n, M, l) return Float64(cos(Float64(Float64(Float64(K * Float64(m + n)) / 2.0) - M)) * exp(Float64(Float64(-(Float64(Float64(Float64(m + n) / 2.0) - M) ^ 2.0)) - Float64(l - abs(Float64(m - n)))))) end
function tmp = code(K, m, n, M, l) tmp = cos((((K * (m + n)) / 2.0) - M)) * exp((-((((m + n) / 2.0) - M) ^ 2.0) - (l - abs((m - n))))); end
code[K_, m_, n_, M_, l_] := N[(N[Cos[N[(N[(N[(K * N[(m + n), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision] - M), $MachinePrecision]], $MachinePrecision] * N[Exp[N[((-N[Power[N[(N[(N[(m + n), $MachinePrecision] / 2.0), $MachinePrecision] - M), $MachinePrecision], 2.0], $MachinePrecision]) - N[(l - N[Abs[N[(m - n), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\cos \left(\frac{K \cdot \left(m + n\right)}{2} - M\right) \cdot e^{\left(-{\left(\frac{m + n}{2} - M\right)}^{2}\right) - \left(\ell - \left|m - n\right|\right)}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 10 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (K m n M l) :precision binary64 (* (cos (- (/ (* K (+ m n)) 2.0) M)) (exp (- (- (pow (- (/ (+ m n) 2.0) M) 2.0)) (- l (fabs (- m n)))))))
double code(double K, double m, double n, double M, double l) {
return cos((((K * (m + n)) / 2.0) - M)) * exp((-pow((((m + n) / 2.0) - M), 2.0) - (l - fabs((m - n)))));
}
real(8) function code(k, m, n, m_1, l)
real(8), intent (in) :: k
real(8), intent (in) :: m
real(8), intent (in) :: n
real(8), intent (in) :: m_1
real(8), intent (in) :: l
code = cos((((k * (m + n)) / 2.0d0) - m_1)) * exp((-((((m + n) / 2.0d0) - m_1) ** 2.0d0) - (l - abs((m - n)))))
end function
public static double code(double K, double m, double n, double M, double l) {
return Math.cos((((K * (m + n)) / 2.0) - M)) * Math.exp((-Math.pow((((m + n) / 2.0) - M), 2.0) - (l - Math.abs((m - n)))));
}
def code(K, m, n, M, l): return math.cos((((K * (m + n)) / 2.0) - M)) * math.exp((-math.pow((((m + n) / 2.0) - M), 2.0) - (l - math.fabs((m - n)))))
function code(K, m, n, M, l) return Float64(cos(Float64(Float64(Float64(K * Float64(m + n)) / 2.0) - M)) * exp(Float64(Float64(-(Float64(Float64(Float64(m + n) / 2.0) - M) ^ 2.0)) - Float64(l - abs(Float64(m - n)))))) end
function tmp = code(K, m, n, M, l) tmp = cos((((K * (m + n)) / 2.0) - M)) * exp((-((((m + n) / 2.0) - M) ^ 2.0) - (l - abs((m - n))))); end
code[K_, m_, n_, M_, l_] := N[(N[Cos[N[(N[(N[(K * N[(m + n), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision] - M), $MachinePrecision]], $MachinePrecision] * N[Exp[N[((-N[Power[N[(N[(N[(m + n), $MachinePrecision] / 2.0), $MachinePrecision] - M), $MachinePrecision], 2.0], $MachinePrecision]) - N[(l - N[Abs[N[(m - n), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\cos \left(\frac{K \cdot \left(m + n\right)}{2} - M\right) \cdot e^{\left(-{\left(\frac{m + n}{2} - M\right)}^{2}\right) - \left(\ell - \left|m - n\right|\right)}
\end{array}
(FPCore (K m n M l)
:precision binary64
(let* ((t_0 (- (fabs (- m n)) l))
(t_1 (exp (- t_0 (pow (- (/ (+ m n) 2.0) M) 2.0))))
(t_2 (* K (+ m n))))
(if (<= (* (cos (- (/ t_2 2.0) M)) t_1) 1.0)
(* t_1 (cos (- (/ (pow (cbrt t_2) 3.0) 2.0) M)))
(exp (- t_0 (* 0.25 (* (+ m n) (+ m n))))))))
double code(double K, double m, double n, double M, double l) {
double t_0 = fabs((m - n)) - l;
double t_1 = exp((t_0 - pow((((m + n) / 2.0) - M), 2.0)));
double t_2 = K * (m + n);
double tmp;
if ((cos(((t_2 / 2.0) - M)) * t_1) <= 1.0) {
tmp = t_1 * cos(((pow(cbrt(t_2), 3.0) / 2.0) - M));
} else {
tmp = exp((t_0 - (0.25 * ((m + n) * (m + n)))));
}
return tmp;
}
public static double code(double K, double m, double n, double M, double l) {
double t_0 = Math.abs((m - n)) - l;
double t_1 = Math.exp((t_0 - Math.pow((((m + n) / 2.0) - M), 2.0)));
double t_2 = K * (m + n);
double tmp;
if ((Math.cos(((t_2 / 2.0) - M)) * t_1) <= 1.0) {
tmp = t_1 * Math.cos(((Math.pow(Math.cbrt(t_2), 3.0) / 2.0) - M));
} else {
tmp = Math.exp((t_0 - (0.25 * ((m + n) * (m + n)))));
}
return tmp;
}
function code(K, m, n, M, l) t_0 = Float64(abs(Float64(m - n)) - l) t_1 = exp(Float64(t_0 - (Float64(Float64(Float64(m + n) / 2.0) - M) ^ 2.0))) t_2 = Float64(K * Float64(m + n)) tmp = 0.0 if (Float64(cos(Float64(Float64(t_2 / 2.0) - M)) * t_1) <= 1.0) tmp = Float64(t_1 * cos(Float64(Float64((cbrt(t_2) ^ 3.0) / 2.0) - M))); else tmp = exp(Float64(t_0 - Float64(0.25 * Float64(Float64(m + n) * Float64(m + n))))); end return tmp end
code[K_, m_, n_, M_, l_] := Block[{t$95$0 = N[(N[Abs[N[(m - n), $MachinePrecision]], $MachinePrecision] - l), $MachinePrecision]}, Block[{t$95$1 = N[Exp[N[(t$95$0 - N[Power[N[(N[(N[(m + n), $MachinePrecision] / 2.0), $MachinePrecision] - M), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = N[(K * N[(m + n), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(N[Cos[N[(N[(t$95$2 / 2.0), $MachinePrecision] - M), $MachinePrecision]], $MachinePrecision] * t$95$1), $MachinePrecision], 1.0], N[(t$95$1 * N[Cos[N[(N[(N[Power[N[Power[t$95$2, 1/3], $MachinePrecision], 3.0], $MachinePrecision] / 2.0), $MachinePrecision] - M), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[Exp[N[(t$95$0 - N[(0.25 * N[(N[(m + n), $MachinePrecision] * N[(m + n), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left|m - n\right| - \ell\\
t_1 := e^{t\_0 - {\left(\frac{m + n}{2} - M\right)}^{2}}\\
t_2 := K \cdot \left(m + n\right)\\
\mathbf{if}\;\cos \left(\frac{t\_2}{2} - M\right) \cdot t\_1 \leq 1:\\
\;\;\;\;t\_1 \cdot \cos \left(\frac{{\left(\sqrt[3]{t\_2}\right)}^{3}}{2} - M\right)\\
\mathbf{else}:\\
\;\;\;\;e^{t\_0 - 0.25 \cdot \left(\left(m + n\right) \cdot \left(m + n\right)\right)}\\
\end{array}
\end{array}
if (*.f64 (cos.f64 (-.f64 (/.f64 (*.f64 K (+.f64 m n)) #s(literal 2 binary64)) M)) (exp.f64 (-.f64 (neg.f64 (pow.f64 (-.f64 (/.f64 (+.f64 m n) #s(literal 2 binary64)) M) #s(literal 2 binary64))) (-.f64 l (fabs.f64 (-.f64 m n)))))) < 1Initial program 96.5%
add-cube-cbrt96.6%
pow397.1%
Applied egg-rr97.1%
if 1 < (*.f64 (cos.f64 (-.f64 (/.f64 (*.f64 K (+.f64 m n)) #s(literal 2 binary64)) M)) (exp.f64 (-.f64 (neg.f64 (pow.f64 (-.f64 (/.f64 (+.f64 m n) #s(literal 2 binary64)) M) #s(literal 2 binary64))) (-.f64 l (fabs.f64 (-.f64 m n)))))) Initial program 18.0%
Taylor expanded in K around 0 96.7%
Taylor expanded in M around 0 98.4%
associate--r+98.4%
Simplified98.4%
unpow298.4%
Applied egg-rr98.4%
Final simplification97.4%
(FPCore (K m n M l)
:precision binary64
(let* ((t_0 (fabs (- m n))))
(if (or (<= M -4.8e-57) (not (<= M 1.35)))
(* (cos (- M)) (exp (- t_0 (pow (- (* (+ m n) 0.5) M) 2.0))))
(exp (- (- t_0 l) (* 0.25 (* (+ m n) (+ m n))))))))
double code(double K, double m, double n, double M, double l) {
double t_0 = fabs((m - n));
double tmp;
if ((M <= -4.8e-57) || !(M <= 1.35)) {
tmp = cos(-M) * exp((t_0 - pow((((m + n) * 0.5) - M), 2.0)));
} else {
tmp = exp(((t_0 - l) - (0.25 * ((m + n) * (m + 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) :: tmp
t_0 = abs((m - n))
if ((m_1 <= (-4.8d-57)) .or. (.not. (m_1 <= 1.35d0))) then
tmp = cos(-m_1) * exp((t_0 - ((((m + n) * 0.5d0) - m_1) ** 2.0d0)))
else
tmp = exp(((t_0 - l) - (0.25d0 * ((m + n) * (m + 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.abs((m - n));
double tmp;
if ((M <= -4.8e-57) || !(M <= 1.35)) {
tmp = Math.cos(-M) * Math.exp((t_0 - Math.pow((((m + n) * 0.5) - M), 2.0)));
} else {
tmp = Math.exp(((t_0 - l) - (0.25 * ((m + n) * (m + n)))));
}
return tmp;
}
def code(K, m, n, M, l): t_0 = math.fabs((m - n)) tmp = 0 if (M <= -4.8e-57) or not (M <= 1.35): tmp = math.cos(-M) * math.exp((t_0 - math.pow((((m + n) * 0.5) - M), 2.0))) else: tmp = math.exp(((t_0 - l) - (0.25 * ((m + n) * (m + n))))) return tmp
function code(K, m, n, M, l) t_0 = abs(Float64(m - n)) tmp = 0.0 if ((M <= -4.8e-57) || !(M <= 1.35)) tmp = Float64(cos(Float64(-M)) * exp(Float64(t_0 - (Float64(Float64(Float64(m + n) * 0.5) - M) ^ 2.0)))); else tmp = exp(Float64(Float64(t_0 - l) - Float64(0.25 * Float64(Float64(m + n) * Float64(m + n))))); end return tmp end
function tmp_2 = code(K, m, n, M, l) t_0 = abs((m - n)); tmp = 0.0; if ((M <= -4.8e-57) || ~((M <= 1.35))) tmp = cos(-M) * exp((t_0 - ((((m + n) * 0.5) - M) ^ 2.0))); else tmp = exp(((t_0 - l) - (0.25 * ((m + n) * (m + n))))); end tmp_2 = tmp; end
code[K_, m_, n_, M_, l_] := Block[{t$95$0 = N[Abs[N[(m - n), $MachinePrecision]], $MachinePrecision]}, If[Or[LessEqual[M, -4.8e-57], N[Not[LessEqual[M, 1.35]], $MachinePrecision]], N[(N[Cos[(-M)], $MachinePrecision] * N[Exp[N[(t$95$0 - N[Power[N[(N[(N[(m + n), $MachinePrecision] * 0.5), $MachinePrecision] - M), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[Exp[N[(N[(t$95$0 - l), $MachinePrecision] - N[(0.25 * N[(N[(m + n), $MachinePrecision] * N[(m + n), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left|m - n\right|\\
\mathbf{if}\;M \leq -4.8 \cdot 10^{-57} \lor \neg \left(M \leq 1.35\right):\\
\;\;\;\;\cos \left(-M\right) \cdot e^{t\_0 - {\left(\left(m + n\right) \cdot 0.5 - M\right)}^{2}}\\
\mathbf{else}:\\
\;\;\;\;e^{\left(t\_0 - \ell\right) - 0.25 \cdot \left(\left(m + n\right) \cdot \left(m + n\right)\right)}\\
\end{array}
\end{array}
if M < -4.80000000000000012e-57 or 1.3500000000000001 < M Initial program 78.9%
Taylor expanded in K around 0 97.2%
Taylor expanded in l around 0 94.3%
if -4.80000000000000012e-57 < M < 1.3500000000000001Initial program 76.6%
Taylor expanded in K around 0 94.4%
Taylor expanded in M around 0 94.4%
associate--r+94.4%
Simplified94.4%
unpow294.4%
Applied egg-rr94.4%
Final simplification94.3%
(FPCore (K m n M l) :precision binary64 (* (cos (- M)) (exp (- (fabs (- m n)) (+ l (pow (- (* (+ m n) 0.5) M) 2.0))))))
double code(double K, double m, double n, double M, double l) {
return cos(-M) * exp((fabs((m - n)) - (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 = cos(-m_1) * exp((abs((m - n)) - (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.cos(-M) * Math.exp((Math.abs((m - n)) - (l + Math.pow((((m + n) * 0.5) - M), 2.0))));
}
def code(K, m, n, M, l): return math.cos(-M) * math.exp((math.fabs((m - n)) - (l + math.pow((((m + n) * 0.5) - M), 2.0))))
function code(K, m, n, M, l) return Float64(cos(Float64(-M)) * exp(Float64(abs(Float64(m - n)) - Float64(l + (Float64(Float64(Float64(m + n) * 0.5) - M) ^ 2.0))))) end
function tmp = code(K, m, n, M, l) tmp = cos(-M) * exp((abs((m - n)) - (l + ((((m + n) * 0.5) - M) ^ 2.0)))); end
code[K_, m_, n_, M_, l_] := N[(N[Cos[(-M)], $MachinePrecision] * N[Exp[N[(N[Abs[N[(m - n), $MachinePrecision]], $MachinePrecision] - N[(l + N[Power[N[(N[(N[(m + n), $MachinePrecision] * 0.5), $MachinePrecision] - M), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\cos \left(-M\right) \cdot e^{\left|m - n\right| - \left(\ell + {\left(\left(m + n\right) \cdot 0.5 - M\right)}^{2}\right)}
\end{array}
Initial program 77.8%
Taylor expanded in K around 0 95.8%
Final simplification95.8%
(FPCore (K m n M l)
:precision binary64
(let* ((t_0 (- (fabs (- m n)) l)))
(if (or (<= n -1.8e-167) (not (<= n 2.4e-25)))
(exp (- t_0 (* 0.25 (* (+ m n) (+ m n)))))
(*
(cos (- (/ (* K (+ m n)) 2.0) M))
(exp (+ (* (- (* m 0.5) M) (- (- M (* m 0.5)) n)) t_0))))))
double code(double K, double m, double n, double M, double l) {
double t_0 = fabs((m - n)) - l;
double tmp;
if ((n <= -1.8e-167) || !(n <= 2.4e-25)) {
tmp = exp((t_0 - (0.25 * ((m + n) * (m + n)))));
} else {
tmp = cos((((K * (m + n)) / 2.0) - M)) * exp(((((m * 0.5) - M) * ((M - (m * 0.5)) - n)) + t_0));
}
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((m - n)) - l
if ((n <= (-1.8d-167)) .or. (.not. (n <= 2.4d-25))) then
tmp = exp((t_0 - (0.25d0 * ((m + n) * (m + n)))))
else
tmp = cos((((k * (m + n)) / 2.0d0) - m_1)) * exp(((((m * 0.5d0) - m_1) * ((m_1 - (m * 0.5d0)) - n)) + t_0))
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((m - n)) - l;
double tmp;
if ((n <= -1.8e-167) || !(n <= 2.4e-25)) {
tmp = Math.exp((t_0 - (0.25 * ((m + n) * (m + n)))));
} else {
tmp = Math.cos((((K * (m + n)) / 2.0) - M)) * Math.exp(((((m * 0.5) - M) * ((M - (m * 0.5)) - n)) + t_0));
}
return tmp;
}
def code(K, m, n, M, l): t_0 = math.fabs((m - n)) - l tmp = 0 if (n <= -1.8e-167) or not (n <= 2.4e-25): tmp = math.exp((t_0 - (0.25 * ((m + n) * (m + n))))) else: tmp = math.cos((((K * (m + n)) / 2.0) - M)) * math.exp(((((m * 0.5) - M) * ((M - (m * 0.5)) - n)) + t_0)) return tmp
function code(K, m, n, M, l) t_0 = Float64(abs(Float64(m - n)) - l) tmp = 0.0 if ((n <= -1.8e-167) || !(n <= 2.4e-25)) tmp = exp(Float64(t_0 - Float64(0.25 * Float64(Float64(m + n) * Float64(m + n))))); else tmp = Float64(cos(Float64(Float64(Float64(K * Float64(m + n)) / 2.0) - M)) * exp(Float64(Float64(Float64(Float64(m * 0.5) - M) * Float64(Float64(M - Float64(m * 0.5)) - n)) + t_0))); end return tmp end
function tmp_2 = code(K, m, n, M, l) t_0 = abs((m - n)) - l; tmp = 0.0; if ((n <= -1.8e-167) || ~((n <= 2.4e-25))) tmp = exp((t_0 - (0.25 * ((m + n) * (m + n))))); else tmp = cos((((K * (m + n)) / 2.0) - M)) * exp(((((m * 0.5) - M) * ((M - (m * 0.5)) - n)) + t_0)); end tmp_2 = tmp; end
code[K_, m_, n_, M_, l_] := Block[{t$95$0 = N[(N[Abs[N[(m - n), $MachinePrecision]], $MachinePrecision] - l), $MachinePrecision]}, If[Or[LessEqual[n, -1.8e-167], N[Not[LessEqual[n, 2.4e-25]], $MachinePrecision]], N[Exp[N[(t$95$0 - N[(0.25 * N[(N[(m + n), $MachinePrecision] * N[(m + n), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[(N[Cos[N[(N[(N[(K * N[(m + n), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision] - M), $MachinePrecision]], $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] + t$95$0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left|m - n\right| - \ell\\
\mathbf{if}\;n \leq -1.8 \cdot 10^{-167} \lor \neg \left(n \leq 2.4 \cdot 10^{-25}\right):\\
\;\;\;\;e^{t\_0 - 0.25 \cdot \left(\left(m + n\right) \cdot \left(m + n\right)\right)}\\
\mathbf{else}:\\
\;\;\;\;\cos \left(\frac{K \cdot \left(m + n\right)}{2} - M\right) \cdot e^{\left(m \cdot 0.5 - M\right) \cdot \left(\left(M - m \cdot 0.5\right) - n\right) + t\_0}\\
\end{array}
\end{array}
if n < -1.8e-167 or 2.40000000000000009e-25 < n Initial program 74.1%
Taylor expanded in K around 0 98.1%
Taylor expanded in M around 0 92.9%
associate--r+92.9%
Simplified92.9%
unpow292.9%
Applied egg-rr92.9%
if -1.8e-167 < n < 2.40000000000000009e-25Initial program 85.2%
Taylor expanded in n around 0 85.2%
+-commutative85.2%
unpow285.2%
distribute-rgt-out85.2%
*-commutative85.2%
*-commutative85.2%
Simplified85.2%
Final simplification90.3%
(FPCore (K m n M l)
:precision binary64
(let* ((t_0 (- (fabs (- m n)) l)))
(if (or (<= m -4.4e-24) (not (<= m 8.6e-176)))
(exp (- t_0 (* 0.25 (* (+ m n) (+ m n)))))
(*
(cos (- (/ (* K (+ m n)) 2.0) M))
(exp (+ (* (- (* n 0.5) M) (- (- M (* n 0.5)) m)) t_0))))))
double code(double K, double m, double n, double M, double l) {
double t_0 = fabs((m - n)) - l;
double tmp;
if ((m <= -4.4e-24) || !(m <= 8.6e-176)) {
tmp = exp((t_0 - (0.25 * ((m + n) * (m + n)))));
} else {
tmp = cos((((K * (m + n)) / 2.0) - M)) * exp(((((n * 0.5) - M) * ((M - (n * 0.5)) - m)) + t_0));
}
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((m - n)) - l
if ((m <= (-4.4d-24)) .or. (.not. (m <= 8.6d-176))) then
tmp = exp((t_0 - (0.25d0 * ((m + n) * (m + n)))))
else
tmp = cos((((k * (m + n)) / 2.0d0) - m_1)) * exp(((((n * 0.5d0) - m_1) * ((m_1 - (n * 0.5d0)) - m)) + t_0))
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((m - n)) - l;
double tmp;
if ((m <= -4.4e-24) || !(m <= 8.6e-176)) {
tmp = Math.exp((t_0 - (0.25 * ((m + n) * (m + n)))));
} else {
tmp = Math.cos((((K * (m + n)) / 2.0) - M)) * Math.exp(((((n * 0.5) - M) * ((M - (n * 0.5)) - m)) + t_0));
}
return tmp;
}
def code(K, m, n, M, l): t_0 = math.fabs((m - n)) - l tmp = 0 if (m <= -4.4e-24) or not (m <= 8.6e-176): tmp = math.exp((t_0 - (0.25 * ((m + n) * (m + n))))) else: tmp = math.cos((((K * (m + n)) / 2.0) - M)) * math.exp(((((n * 0.5) - M) * ((M - (n * 0.5)) - m)) + t_0)) return tmp
function code(K, m, n, M, l) t_0 = Float64(abs(Float64(m - n)) - l) tmp = 0.0 if ((m <= -4.4e-24) || !(m <= 8.6e-176)) tmp = exp(Float64(t_0 - Float64(0.25 * Float64(Float64(m + n) * Float64(m + n))))); else tmp = Float64(cos(Float64(Float64(Float64(K * Float64(m + n)) / 2.0) - M)) * exp(Float64(Float64(Float64(Float64(n * 0.5) - M) * Float64(Float64(M - Float64(n * 0.5)) - m)) + t_0))); end return tmp end
function tmp_2 = code(K, m, n, M, l) t_0 = abs((m - n)) - l; tmp = 0.0; if ((m <= -4.4e-24) || ~((m <= 8.6e-176))) tmp = exp((t_0 - (0.25 * ((m + n) * (m + n))))); else tmp = cos((((K * (m + n)) / 2.0) - M)) * exp(((((n * 0.5) - M) * ((M - (n * 0.5)) - m)) + t_0)); end tmp_2 = tmp; end
code[K_, m_, n_, M_, l_] := Block[{t$95$0 = N[(N[Abs[N[(m - n), $MachinePrecision]], $MachinePrecision] - l), $MachinePrecision]}, If[Or[LessEqual[m, -4.4e-24], N[Not[LessEqual[m, 8.6e-176]], $MachinePrecision]], N[Exp[N[(t$95$0 - N[(0.25 * N[(N[(m + n), $MachinePrecision] * N[(m + n), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[(N[Cos[N[(N[(N[(K * N[(m + n), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision] - M), $MachinePrecision]], $MachinePrecision] * N[Exp[N[(N[(N[(N[(n * 0.5), $MachinePrecision] - M), $MachinePrecision] * N[(N[(M - N[(n * 0.5), $MachinePrecision]), $MachinePrecision] - m), $MachinePrecision]), $MachinePrecision] + t$95$0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left|m - n\right| - \ell\\
\mathbf{if}\;m \leq -4.4 \cdot 10^{-24} \lor \neg \left(m \leq 8.6 \cdot 10^{-176}\right):\\
\;\;\;\;e^{t\_0 - 0.25 \cdot \left(\left(m + n\right) \cdot \left(m + n\right)\right)}\\
\mathbf{else}:\\
\;\;\;\;\cos \left(\frac{K \cdot \left(m + n\right)}{2} - M\right) \cdot e^{\left(n \cdot 0.5 - M\right) \cdot \left(\left(M - n \cdot 0.5\right) - m\right) + t\_0}\\
\end{array}
\end{array}
if m < -4.40000000000000003e-24 or 8.60000000000000025e-176 < m Initial program 73.3%
Taylor expanded in K around 0 95.8%
Taylor expanded in M around 0 94.3%
associate--r+94.3%
Simplified94.3%
unpow294.3%
Applied egg-rr94.3%
if -4.40000000000000003e-24 < m < 8.60000000000000025e-176Initial program 85.5%
Taylor expanded in m around 0 85.5%
+-commutative85.5%
unpow285.5%
distribute-rgt-out85.5%
*-commutative85.5%
*-commutative85.5%
Simplified85.5%
Final simplification91.1%
(FPCore (K m n M l)
:precision binary64
(let* ((t_0 (fabs (- m n))))
(if (or (<= n 2e-209) (not (<= n 8.4e-26)))
(exp (- (- t_0 l) (* 0.25 (* (+ m n) (+ m n)))))
(* (cos (- (* 0.5 (* K n)) M)) (exp (- (* M (- n M)) (- l t_0)))))))
double code(double K, double m, double n, double M, double l) {
double t_0 = fabs((m - n));
double tmp;
if ((n <= 2e-209) || !(n <= 8.4e-26)) {
tmp = exp(((t_0 - l) - (0.25 * ((m + n) * (m + n)))));
} else {
tmp = cos(((0.5 * (K * n)) - M)) * exp(((M * (n - M)) - (l - t_0)));
}
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((m - n))
if ((n <= 2d-209) .or. (.not. (n <= 8.4d-26))) then
tmp = exp(((t_0 - l) - (0.25d0 * ((m + n) * (m + n)))))
else
tmp = cos(((0.5d0 * (k * n)) - m_1)) * exp(((m_1 * (n - m_1)) - (l - t_0)))
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((m - n));
double tmp;
if ((n <= 2e-209) || !(n <= 8.4e-26)) {
tmp = Math.exp(((t_0 - l) - (0.25 * ((m + n) * (m + n)))));
} else {
tmp = Math.cos(((0.5 * (K * n)) - M)) * Math.exp(((M * (n - M)) - (l - t_0)));
}
return tmp;
}
def code(K, m, n, M, l): t_0 = math.fabs((m - n)) tmp = 0 if (n <= 2e-209) or not (n <= 8.4e-26): tmp = math.exp(((t_0 - l) - (0.25 * ((m + n) * (m + n))))) else: tmp = math.cos(((0.5 * (K * n)) - M)) * math.exp(((M * (n - M)) - (l - t_0))) return tmp
function code(K, m, n, M, l) t_0 = abs(Float64(m - n)) tmp = 0.0 if ((n <= 2e-209) || !(n <= 8.4e-26)) tmp = exp(Float64(Float64(t_0 - l) - Float64(0.25 * Float64(Float64(m + n) * Float64(m + n))))); else tmp = Float64(cos(Float64(Float64(0.5 * Float64(K * n)) - M)) * exp(Float64(Float64(M * Float64(n - M)) - Float64(l - t_0)))); end return tmp end
function tmp_2 = code(K, m, n, M, l) t_0 = abs((m - n)); tmp = 0.0; if ((n <= 2e-209) || ~((n <= 8.4e-26))) tmp = exp(((t_0 - l) - (0.25 * ((m + n) * (m + n))))); else tmp = cos(((0.5 * (K * n)) - M)) * exp(((M * (n - M)) - (l - t_0))); end tmp_2 = tmp; end
code[K_, m_, n_, M_, l_] := Block[{t$95$0 = N[Abs[N[(m - n), $MachinePrecision]], $MachinePrecision]}, If[Or[LessEqual[n, 2e-209], N[Not[LessEqual[n, 8.4e-26]], $MachinePrecision]], N[Exp[N[(N[(t$95$0 - l), $MachinePrecision] - N[(0.25 * N[(N[(m + n), $MachinePrecision] * N[(m + n), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[(N[Cos[N[(N[(0.5 * N[(K * n), $MachinePrecision]), $MachinePrecision] - M), $MachinePrecision]], $MachinePrecision] * N[Exp[N[(N[(M * N[(n - M), $MachinePrecision]), $MachinePrecision] - N[(l - t$95$0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left|m - n\right|\\
\mathbf{if}\;n \leq 2 \cdot 10^{-209} \lor \neg \left(n \leq 8.4 \cdot 10^{-26}\right):\\
\;\;\;\;e^{\left(t\_0 - \ell\right) - 0.25 \cdot \left(\left(m + n\right) \cdot \left(m + n\right)\right)}\\
\mathbf{else}:\\
\;\;\;\;\cos \left(0.5 \cdot \left(K \cdot n\right) - M\right) \cdot e^{M \cdot \left(n - M\right) - \left(\ell - t\_0\right)}\\
\end{array}
\end{array}
if n < 2.0000000000000001e-209 or 8.40000000000000032e-26 < n Initial program 76.2%
Taylor expanded in K around 0 96.9%
Taylor expanded in M around 0 88.5%
associate--r+88.5%
Simplified88.5%
unpow288.5%
Applied egg-rr88.5%
if 2.0000000000000001e-209 < n < 8.40000000000000032e-26Initial program 86.1%
Taylor expanded in n around 0 86.1%
+-commutative86.1%
unpow286.1%
distribute-rgt-out86.1%
*-commutative86.1%
*-commutative86.1%
Simplified86.1%
Taylor expanded in m around 0 72.2%
*-commutative72.2%
associate--r+72.2%
associate-*r*72.2%
neg-mul-172.2%
cancel-sign-sub72.2%
Simplified72.2%
Final simplification85.8%
(FPCore (K m n M l) :precision binary64 (if (<= m -5.5e+66) (exp (- (+ m (* 0.25 (* n (+ n (* m 2.0))))) (+ n l))) (exp (- (+ m (* 0.25 (pow m 2.0))) (+ n l)))))
double code(double K, double m, double n, double M, double l) {
double tmp;
if (m <= -5.5e+66) {
tmp = exp(((m + (0.25 * (n * (n + (m * 2.0))))) - (n + l)));
} else {
tmp = exp(((m + (0.25 * pow(m, 2.0))) - (n + 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 <= (-5.5d+66)) then
tmp = exp(((m + (0.25d0 * (n * (n + (m * 2.0d0))))) - (n + l)))
else
tmp = exp(((m + (0.25d0 * (m ** 2.0d0))) - (n + 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 <= -5.5e+66) {
tmp = Math.exp(((m + (0.25 * (n * (n + (m * 2.0))))) - (n + l)));
} else {
tmp = Math.exp(((m + (0.25 * Math.pow(m, 2.0))) - (n + l)));
}
return tmp;
}
def code(K, m, n, M, l): tmp = 0 if m <= -5.5e+66: tmp = math.exp(((m + (0.25 * (n * (n + (m * 2.0))))) - (n + l))) else: tmp = math.exp(((m + (0.25 * math.pow(m, 2.0))) - (n + l))) return tmp
function code(K, m, n, M, l) tmp = 0.0 if (m <= -5.5e+66) tmp = exp(Float64(Float64(m + Float64(0.25 * Float64(n * Float64(n + Float64(m * 2.0))))) - Float64(n + l))); else tmp = exp(Float64(Float64(m + Float64(0.25 * (m ^ 2.0))) - Float64(n + l))); end return tmp end
function tmp_2 = code(K, m, n, M, l) tmp = 0.0; if (m <= -5.5e+66) tmp = exp(((m + (0.25 * (n * (n + (m * 2.0))))) - (n + l))); else tmp = exp(((m + (0.25 * (m ^ 2.0))) - (n + l))); end tmp_2 = tmp; end
code[K_, m_, n_, M_, l_] := If[LessEqual[m, -5.5e+66], N[Exp[N[(N[(m + N[(0.25 * N[(n * N[(n + N[(m * 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(n + l), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[Exp[N[(N[(m + N[(0.25 * N[Power[m, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(n + l), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;m \leq -5.5 \cdot 10^{+66}:\\
\;\;\;\;e^{\left(m + 0.25 \cdot \left(n \cdot \left(n + m \cdot 2\right)\right)\right) - \left(n + \ell\right)}\\
\mathbf{else}:\\
\;\;\;\;e^{\left(m + 0.25 \cdot {m}^{2}\right) - \left(n + \ell\right)}\\
\end{array}
\end{array}
if m < -5.5e66Initial program 68.4%
log1p-expm1-u68.4%
associate-/l*68.4%
fmm-def68.4%
div-inv68.4%
metadata-eval68.4%
associate--r-68.4%
+-commutative68.4%
Applied egg-rr1.1%
Taylor expanded in K around 0 1.6%
Taylor expanded in M around 0 1.6%
Taylor expanded in m around 0 63.5%
+-commutative63.5%
unpow263.5%
associate-*r*63.5%
distribute-rgt-in71.5%
*-commutative71.5%
Simplified71.5%
if -5.5e66 < m Initial program 79.4%
log1p-expm1-u79.4%
associate-/l*79.4%
fmm-def79.4%
div-inv79.4%
metadata-eval79.4%
associate--r-79.4%
+-commutative79.4%
Applied egg-rr21.3%
Taylor expanded in K around 0 20.3%
Taylor expanded in M around 0 21.7%
Taylor expanded in m around inf 42.9%
Final simplification47.2%
(FPCore (K m n M l) :precision binary64 (if (<= n 50000000000.0) (exp (- (+ m (* 0.25 (pow n 2.0))) (+ n l))) (exp (- (+ m (* 0.25 (pow m 2.0))) (+ n l)))))
double code(double K, double m, double n, double M, double l) {
double tmp;
if (n <= 50000000000.0) {
tmp = exp(((m + (0.25 * pow(n, 2.0))) - (n + l)));
} else {
tmp = exp(((m + (0.25 * pow(m, 2.0))) - (n + 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 (n <= 50000000000.0d0) then
tmp = exp(((m + (0.25d0 * (n ** 2.0d0))) - (n + l)))
else
tmp = exp(((m + (0.25d0 * (m ** 2.0d0))) - (n + l)))
end if
code = tmp
end function
public static double code(double K, double m, double n, double M, double l) {
double tmp;
if (n <= 50000000000.0) {
tmp = Math.exp(((m + (0.25 * Math.pow(n, 2.0))) - (n + l)));
} else {
tmp = Math.exp(((m + (0.25 * Math.pow(m, 2.0))) - (n + l)));
}
return tmp;
}
def code(K, m, n, M, l): tmp = 0 if n <= 50000000000.0: tmp = math.exp(((m + (0.25 * math.pow(n, 2.0))) - (n + l))) else: tmp = math.exp(((m + (0.25 * math.pow(m, 2.0))) - (n + l))) return tmp
function code(K, m, n, M, l) tmp = 0.0 if (n <= 50000000000.0) tmp = exp(Float64(Float64(m + Float64(0.25 * (n ^ 2.0))) - Float64(n + l))); else tmp = exp(Float64(Float64(m + Float64(0.25 * (m ^ 2.0))) - Float64(n + l))); end return tmp end
function tmp_2 = code(K, m, n, M, l) tmp = 0.0; if (n <= 50000000000.0) tmp = exp(((m + (0.25 * (n ^ 2.0))) - (n + l))); else tmp = exp(((m + (0.25 * (m ^ 2.0))) - (n + l))); end tmp_2 = tmp; end
code[K_, m_, n_, M_, l_] := If[LessEqual[n, 50000000000.0], N[Exp[N[(N[(m + N[(0.25 * N[Power[n, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(n + l), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[Exp[N[(N[(m + N[(0.25 * N[Power[m, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(n + l), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;n \leq 50000000000:\\
\;\;\;\;e^{\left(m + 0.25 \cdot {n}^{2}\right) - \left(n + \ell\right)}\\
\mathbf{else}:\\
\;\;\;\;e^{\left(m + 0.25 \cdot {m}^{2}\right) - \left(n + \ell\right)}\\
\end{array}
\end{array}
if n < 5e10Initial program 80.0%
log1p-expm1-u80.0%
associate-/l*80.0%
fmm-def80.0%
div-inv80.0%
metadata-eval80.0%
associate--r-80.0%
+-commutative80.0%
Applied egg-rr21.8%
Taylor expanded in K around 0 21.0%
Taylor expanded in M around 0 23.3%
Taylor expanded in m around 0 37.1%
if 5e10 < n Initial program 72.7%
log1p-expm1-u72.7%
associate-/l*72.7%
fmm-def72.7%
div-inv72.7%
metadata-eval72.7%
associate--r-72.7%
+-commutative72.7%
Applied egg-rr10.1%
Taylor expanded in K around 0 9.2%
Taylor expanded in M around 0 7.9%
Taylor expanded in m around inf 62.9%
Final simplification44.9%
(FPCore (K m n M l) :precision binary64 (exp (- (- (fabs (- m n)) l) (* 0.25 (* (+ m n) (+ m n))))))
double code(double K, double m, double n, double M, double l) {
return exp(((fabs((m - n)) - l) - (0.25 * ((m + n) * (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 = exp(((abs((m - n)) - l) - (0.25d0 * ((m + n) * (m + n)))))
end function
public static double code(double K, double m, double n, double M, double l) {
return Math.exp(((Math.abs((m - n)) - l) - (0.25 * ((m + n) * (m + n)))));
}
def code(K, m, n, M, l): return math.exp(((math.fabs((m - n)) - l) - (0.25 * ((m + n) * (m + n)))))
function code(K, m, n, M, l) return exp(Float64(Float64(abs(Float64(m - n)) - l) - Float64(0.25 * Float64(Float64(m + n) * Float64(m + n))))) end
function tmp = code(K, m, n, M, l) tmp = exp(((abs((m - n)) - l) - (0.25 * ((m + n) * (m + n))))); end
code[K_, m_, n_, M_, l_] := N[Exp[N[(N[(N[Abs[N[(m - n), $MachinePrecision]], $MachinePrecision] - l), $MachinePrecision] - N[(0.25 * N[(N[(m + n), $MachinePrecision] * N[(m + n), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
e^{\left(\left|m - n\right| - \ell\right) - 0.25 \cdot \left(\left(m + n\right) \cdot \left(m + n\right)\right)}
\end{array}
Initial program 77.8%
Taylor expanded in K around 0 95.8%
Taylor expanded in M around 0 84.6%
associate--r+84.6%
Simplified84.6%
unpow284.6%
Applied egg-rr84.6%
Final simplification84.6%
(FPCore (K m n M l) :precision binary64 (exp (- (+ m (* 0.25 (* n (+ n (* m 2.0))))) (+ n l))))
double code(double K, double m, double n, double M, double l) {
return exp(((m + (0.25 * (n * (n + (m * 2.0))))) - (n + 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(((m + (0.25d0 * (n * (n + (m * 2.0d0))))) - (n + l)))
end function
public static double code(double K, double m, double n, double M, double l) {
return Math.exp(((m + (0.25 * (n * (n + (m * 2.0))))) - (n + l)));
}
def code(K, m, n, M, l): return math.exp(((m + (0.25 * (n * (n + (m * 2.0))))) - (n + l)))
function code(K, m, n, M, l) return exp(Float64(Float64(m + Float64(0.25 * Float64(n * Float64(n + Float64(m * 2.0))))) - Float64(n + l))) end
function tmp = code(K, m, n, M, l) tmp = exp(((m + (0.25 * (n * (n + (m * 2.0))))) - (n + l))); end
code[K_, m_, n_, M_, l_] := N[Exp[N[(N[(m + N[(0.25 * N[(n * N[(n + N[(m * 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(n + l), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
e^{\left(m + 0.25 \cdot \left(n \cdot \left(n + m \cdot 2\right)\right)\right) - \left(n + \ell\right)}
\end{array}
Initial program 77.8%
log1p-expm1-u77.8%
associate-/l*77.8%
fmm-def77.8%
div-inv77.8%
metadata-eval77.8%
associate--r-77.8%
+-commutative77.8%
Applied egg-rr18.3%
Taylor expanded in K around 0 17.5%
Taylor expanded in M around 0 18.7%
Taylor expanded in m around 0 30.9%
+-commutative30.9%
unpow230.9%
associate-*r*30.9%
distribute-rgt-in33.3%
*-commutative33.3%
Simplified33.3%
Final simplification33.3%
herbie shell --seed 2024131
(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)))))))