
(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 6 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 (- m n)) 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((m - n)) - 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((m - n)) - 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((m - n)) - 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((m - n)) - 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(m - n)) - 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((m - n)) - 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[(m - n), $MachinePrecision]], $MachinePrecision] - l), $MachinePrecision] - N[Power[N[(N[(N[(m + n), $MachinePrecision] / 2.0), $MachinePrecision] - M), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\cos M \cdot e^{\left(\left|m - n\right| - \ell\right) - {\left(\frac{m + n}{2} - M\right)}^{2}}
\end{array}
Initial program 77.8%
Taylor expanded in K around 0 95.6%
cos-neg95.6%
Simplified95.6%
Final simplification95.6%
(FPCore (K m n M l)
:precision binary64
(let* ((t_0 (fabs (- m n))))
(if (or (<= M -6e-41) (not (<= M 1.9e+63)))
(* (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 <= -6e-41) || !(M <= 1.9e+63)) {
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 <= (-6d-41)) .or. (.not. (m_1 <= 1.9d+63))) 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 <= -6e-41) || !(M <= 1.9e+63)) {
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 <= -6e-41) or not (M <= 1.9e+63): 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 <= -6e-41) || !(M <= 1.9e+63)) tmp = Float64(cos(M) * exp(Float64(t_0 - (Float64(Float64(Float64(m + n) * 0.5) - M) ^ 2.0)))); else tmp = exp(Float64(t_0 - Float64(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 <= -6e-41) || ~((M <= 1.9e+63))) 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, -6e-41], N[Not[LessEqual[M, 1.9e+63]], $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[(t$95$0 - N[(l + N[(0.25 * N[(N[(m + n), $MachinePrecision] * N[(m + n), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left|m - n\right|\\
\mathbf{if}\;M \leq -6 \cdot 10^{-41} \lor \neg \left(M \leq 1.9 \cdot 10^{+63}\right):\\
\;\;\;\;\cos M \cdot e^{t_0 - {\left(\left(m + n\right) \cdot 0.5 - M\right)}^{2}}\\
\mathbf{else}:\\
\;\;\;\;e^{t_0 - \left(\ell + 0.25 \cdot \left(\left(m + n\right) \cdot \left(m + n\right)\right)\right)}\\
\end{array}
\end{array}
if M < -5.99999999999999978e-41 or 1.9000000000000001e63 < M Initial program 79.7%
Taylor expanded in K around 0 97.7%
cos-neg97.7%
Simplified97.7%
Taylor expanded in l around 0 96.9%
*-commutative96.9%
unpow296.9%
unpow296.9%
Simplified96.9%
if -5.99999999999999978e-41 < M < 1.9000000000000001e63Initial program 75.9%
Taylor expanded in K around 0 93.5%
cos-neg93.5%
Simplified93.5%
Taylor expanded in M around 0 93.1%
unpow293.1%
Applied egg-rr93.1%
Final simplification95.0%
(FPCore (K m n M l)
:precision binary64
(let* ((t_0 (fabs (- m n))))
(if (or (<= n 2.9e-251) (not (<= n 900.0)))
(exp (- t_0 (+ l (* 0.25 (* (+ m n) (+ m n))))))
(*
(cos (- (/ (* (+ m n) K) 2.0) M))
(exp (+ (* (- (* m 0.5) M) (- (- M (* m 0.5)) n)) (- t_0 l)))))))
double code(double K, double m, double n, double M, double l) {
double t_0 = fabs((m - n));
double tmp;
if ((n <= 2.9e-251) || !(n <= 900.0)) {
tmp = exp((t_0 - (l + (0.25 * ((m + n) * (m + n))))));
} else {
tmp = cos(((((m + n) * K) / 2.0) - M)) * exp(((((m * 0.5) - M) * ((M - (m * 0.5)) - n)) + (t_0 - 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((m - n))
if ((n <= 2.9d-251) .or. (.not. (n <= 900.0d0))) then
tmp = exp((t_0 - (l + (0.25d0 * ((m + n) * (m + n))))))
else
tmp = cos(((((m + n) * k) / 2.0d0) - m_1)) * exp(((((m * 0.5d0) - m_1) * ((m_1 - (m * 0.5d0)) - n)) + (t_0 - 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((m - n));
double tmp;
if ((n <= 2.9e-251) || !(n <= 900.0)) {
tmp = Math.exp((t_0 - (l + (0.25 * ((m + n) * (m + n))))));
} else {
tmp = Math.cos(((((m + n) * K) / 2.0) - M)) * Math.exp(((((m * 0.5) - M) * ((M - (m * 0.5)) - n)) + (t_0 - l)));
}
return tmp;
}
def code(K, m, n, M, l): t_0 = math.fabs((m - n)) tmp = 0 if (n <= 2.9e-251) or not (n <= 900.0): tmp = math.exp((t_0 - (l + (0.25 * ((m + n) * (m + n)))))) else: tmp = math.cos(((((m + n) * K) / 2.0) - M)) * math.exp(((((m * 0.5) - M) * ((M - (m * 0.5)) - n)) + (t_0 - l))) return tmp
function code(K, m, n, M, l) t_0 = abs(Float64(m - n)) tmp = 0.0 if ((n <= 2.9e-251) || !(n <= 900.0)) tmp = exp(Float64(t_0 - Float64(l + Float64(0.25 * Float64(Float64(m + n) * Float64(m + n)))))); else tmp = Float64(cos(Float64(Float64(Float64(Float64(m + n) * K) / 2.0) - M)) * exp(Float64(Float64(Float64(Float64(m * 0.5) - M) * Float64(Float64(M - Float64(m * 0.5)) - n)) + Float64(t_0 - l)))); end return tmp end
function tmp_2 = code(K, m, n, M, l) t_0 = abs((m - n)); tmp = 0.0; if ((n <= 2.9e-251) || ~((n <= 900.0))) tmp = exp((t_0 - (l + (0.25 * ((m + n) * (m + n)))))); else tmp = cos(((((m + n) * K) / 2.0) - M)) * exp(((((m * 0.5) - M) * ((M - (m * 0.5)) - n)) + (t_0 - l))); 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, 2.9e-251], N[Not[LessEqual[n, 900.0]], $MachinePrecision]], N[Exp[N[(t$95$0 - N[(l + N[(0.25 * N[(N[(m + n), $MachinePrecision] * N[(m + n), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[(N[Cos[N[(N[(N[(N[(m + n), $MachinePrecision] * K), $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] + N[(t$95$0 - l), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left|m - n\right|\\
\mathbf{if}\;n \leq 2.9 \cdot 10^{-251} \lor \neg \left(n \leq 900\right):\\
\;\;\;\;e^{t_0 - \left(\ell + 0.25 \cdot \left(\left(m + n\right) \cdot \left(m + n\right)\right)\right)}\\
\mathbf{else}:\\
\;\;\;\;\cos \left(\frac{\left(m + n\right) \cdot K}{2} - M\right) \cdot e^{\left(m \cdot 0.5 - M\right) \cdot \left(\left(M - m \cdot 0.5\right) - n\right) + \left(t_0 - \ell\right)}\\
\end{array}
\end{array}
if n < 2.9000000000000001e-251 or 900 < n Initial program 74.6%
Taylor expanded in K around 0 95.1%
cos-neg95.1%
Simplified95.1%
Taylor expanded in M around 0 89.6%
unpow289.6%
Applied egg-rr89.6%
if 2.9000000000000001e-251 < n < 900Initial program 91.7%
Taylor expanded in n around 0 91.7%
+-commutative91.7%
unpow291.7%
distribute-rgt-out91.7%
*-commutative91.7%
*-commutative91.7%
Simplified91.7%
Final simplification90.0%
(FPCore (K m n M l)
:precision binary64
(let* ((t_0 (fabs (- m n))))
(if (<= M 6e+126)
(exp (- t_0 (+ l (* 0.25 (* (+ m n) (+ m n))))))
(* (cos M) (exp (+ t_0 (- (* M (- m M)) l)))))))
double code(double K, double m, double n, double M, double l) {
double t_0 = fabs((m - n));
double tmp;
if (M <= 6e+126) {
tmp = exp((t_0 - (l + (0.25 * ((m + n) * (m + n))))));
} else {
tmp = cos(M) * exp((t_0 + ((M * (m - M)) - 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((m - n))
if (m_1 <= 6d+126) then
tmp = exp((t_0 - (l + (0.25d0 * ((m + n) * (m + n))))))
else
tmp = cos(m_1) * exp((t_0 + ((m_1 * (m - m_1)) - 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((m - n));
double tmp;
if (M <= 6e+126) {
tmp = Math.exp((t_0 - (l + (0.25 * ((m + n) * (m + n))))));
} else {
tmp = Math.cos(M) * Math.exp((t_0 + ((M * (m - M)) - l)));
}
return tmp;
}
def code(K, m, n, M, l): t_0 = math.fabs((m - n)) tmp = 0 if M <= 6e+126: tmp = math.exp((t_0 - (l + (0.25 * ((m + n) * (m + n)))))) else: tmp = math.cos(M) * math.exp((t_0 + ((M * (m - M)) - l))) return tmp
function code(K, m, n, M, l) t_0 = abs(Float64(m - n)) tmp = 0.0 if (M <= 6e+126) tmp = exp(Float64(t_0 - Float64(l + Float64(0.25 * Float64(Float64(m + n) * Float64(m + n)))))); else tmp = Float64(cos(M) * exp(Float64(t_0 + Float64(Float64(M * Float64(m - M)) - l)))); end return tmp end
function tmp_2 = code(K, m, n, M, l) t_0 = abs((m - n)); tmp = 0.0; if (M <= 6e+126) tmp = exp((t_0 - (l + (0.25 * ((m + n) * (m + n)))))); else tmp = cos(M) * exp((t_0 + ((M * (m - M)) - l))); end tmp_2 = tmp; end
code[K_, m_, n_, M_, l_] := Block[{t$95$0 = N[Abs[N[(m - n), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[M, 6e+126], N[Exp[N[(t$95$0 - N[(l + N[(0.25 * N[(N[(m + n), $MachinePrecision] * N[(m + n), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[(N[Cos[M], $MachinePrecision] * N[Exp[N[(t$95$0 + N[(N[(M * N[(m - M), $MachinePrecision]), $MachinePrecision] - l), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left|m - n\right|\\
\mathbf{if}\;M \leq 6 \cdot 10^{+126}:\\
\;\;\;\;e^{t_0 - \left(\ell + 0.25 \cdot \left(\left(m + n\right) \cdot \left(m + n\right)\right)\right)}\\
\mathbf{else}:\\
\;\;\;\;\cos M \cdot e^{t_0 + \left(M \cdot \left(m - M\right) - \ell\right)}\\
\end{array}
\end{array}
if M < 6.0000000000000005e126Initial program 78.1%
Taylor expanded in K around 0 94.7%
cos-neg94.7%
Simplified94.7%
Taylor expanded in M around 0 89.0%
unpow289.0%
Applied egg-rr89.0%
if 6.0000000000000005e126 < M Initial program 76.2%
Taylor expanded in K around 0 100.0%
cos-neg100.0%
Simplified100.0%
Taylor expanded in M around inf 54.8%
associate-*r*54.8%
neg-mul-154.8%
unpow254.8%
sqr-neg54.8%
distribute-lft-out93.0%
unsub-neg93.0%
Simplified93.0%
Taylor expanded in n around 0 90.6%
fabs-sub90.6%
mul-1-neg90.6%
unsub-neg90.6%
Simplified90.6%
Final simplification89.3%
(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(abs(Float64(m - n)) - Float64(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[Abs[N[(m - n), $MachinePrecision]], $MachinePrecision] - N[(l + N[(0.25 * N[(N[(m + n), $MachinePrecision] * N[(m + n), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
e^{\left|m - n\right| - \left(\ell + 0.25 \cdot \left(\left(m + n\right) \cdot \left(m + n\right)\right)\right)}
\end{array}
Initial program 77.8%
Taylor expanded in K around 0 95.6%
cos-neg95.6%
Simplified95.6%
Taylor expanded in M around 0 88.9%
unpow288.9%
Applied egg-rr88.9%
Final simplification88.9%
(FPCore (K m n M l) :precision binary64 (exp (- (fabs (- m n)) l)))
double code(double K, double m, double n, double M, double l) {
return exp((fabs((m - 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((abs((m - n)) - l))
end function
public static double code(double K, double m, double n, double M, double l) {
return Math.exp((Math.abs((m - n)) - l));
}
def code(K, m, n, M, l): return math.exp((math.fabs((m - n)) - l))
function code(K, m, n, M, l) return exp(Float64(abs(Float64(m - n)) - l)) end
function tmp = code(K, m, n, M, l) tmp = exp((abs((m - n)) - l)); end
code[K_, m_, n_, M_, l_] := N[Exp[N[(N[Abs[N[(m - n), $MachinePrecision]], $MachinePrecision] - l), $MachinePrecision]], $MachinePrecision]
\begin{array}{l}
\\
e^{\left|m - n\right| - \ell}
\end{array}
Initial program 77.8%
Taylor expanded in K around 0 95.6%
cos-neg95.6%
Simplified95.6%
Taylor expanded in M around inf 46.6%
associate-*r*46.6%
neg-mul-146.6%
unpow246.6%
sqr-neg46.6%
distribute-lft-out53.7%
unsub-neg53.7%
Simplified53.7%
Taylor expanded in M around 0 27.0%
fabs-sub27.0%
sub-neg27.0%
mul-1-neg27.0%
fabs-neg27.0%
fabs-neg27.0%
mul-1-neg27.0%
sub-neg27.0%
Simplified27.0%
Final simplification27.0%
herbie shell --seed 2023314
(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)))))))