
(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 7 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) 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(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 M \cdot e^{\left|m - n\right| - \left(\ell + {\left(\left(m + n\right) \cdot 0.5 - M\right)}^{2}\right)}
\end{array}
Initial program 74.4%
Taylor expanded in K around 0 96.8%
cos-neg96.8%
sub-neg96.8%
sub-neg96.8%
associate--r+96.8%
*-commutative96.8%
associate--r+96.8%
Simplified96.8%
(FPCore (K m n M l) :precision binary64 (if (or (<= M -9500000000.0) (not (<= M 27.0))) (* (cos M) (exp (- (pow M 2.0)))) (* (cos M) (exp (+ (- m n) (- (* M (+ M m)) l))))))
double code(double K, double m, double n, double M, double l) {
double tmp;
if ((M <= -9500000000.0) || !(M <= 27.0)) {
tmp = cos(M) * exp(-pow(M, 2.0));
} else {
tmp = cos(M) * exp(((m - n) + ((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) :: tmp
if ((m_1 <= (-9500000000.0d0)) .or. (.not. (m_1 <= 27.0d0))) then
tmp = cos(m_1) * exp(-(m_1 ** 2.0d0))
else
tmp = cos(m_1) * exp(((m - n) + ((m_1 * (m_1 + m)) - 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 <= -9500000000.0) || !(M <= 27.0)) {
tmp = Math.cos(M) * Math.exp(-Math.pow(M, 2.0));
} else {
tmp = Math.cos(M) * Math.exp(((m - n) + ((M * (M + m)) - l)));
}
return tmp;
}
def code(K, m, n, M, l): tmp = 0 if (M <= -9500000000.0) or not (M <= 27.0): tmp = math.cos(M) * math.exp(-math.pow(M, 2.0)) else: tmp = math.cos(M) * math.exp(((m - n) + ((M * (M + m)) - l))) return tmp
function code(K, m, n, M, l) tmp = 0.0 if ((M <= -9500000000.0) || !(M <= 27.0)) tmp = Float64(cos(M) * exp(Float64(-(M ^ 2.0)))); else tmp = Float64(cos(M) * exp(Float64(Float64(m - n) + Float64(Float64(M * Float64(M + m)) - l)))); end return tmp end
function tmp_2 = code(K, m, n, M, l) tmp = 0.0; if ((M <= -9500000000.0) || ~((M <= 27.0))) tmp = cos(M) * exp(-(M ^ 2.0)); else tmp = cos(M) * exp(((m - n) + ((M * (M + m)) - l))); end tmp_2 = tmp; end
code[K_, m_, n_, M_, l_] := If[Or[LessEqual[M, -9500000000.0], N[Not[LessEqual[M, 27.0]], $MachinePrecision]], N[(N[Cos[M], $MachinePrecision] * N[Exp[(-N[Power[M, 2.0], $MachinePrecision])], $MachinePrecision]), $MachinePrecision], N[(N[Cos[M], $MachinePrecision] * N[Exp[N[(N[(m - n), $MachinePrecision] + N[(N[(M * N[(M + m), $MachinePrecision]), $MachinePrecision] - l), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;M \leq -9500000000 \lor \neg \left(M \leq 27\right):\\
\;\;\;\;\cos M \cdot e^{-{M}^{2}}\\
\mathbf{else}:\\
\;\;\;\;\cos M \cdot e^{\left(m - n\right) + \left(M \cdot \left(M + m\right) - \ell\right)}\\
\end{array}
\end{array}
if M < -9.5e9 or 27 < M Initial program 78.4%
Taylor expanded in K around 0 99.1%
cos-neg99.1%
sub-neg99.1%
sub-neg99.1%
associate--r+99.1%
*-commutative99.1%
associate--r+99.1%
Simplified99.1%
Taylor expanded in M around inf 97.5%
mul-1-neg97.5%
Simplified97.5%
if -9.5e9 < M < 27Initial program 71.0%
Taylor expanded in m around 0 50.6%
+-commutative50.6%
unpow250.6%
distribute-rgt-out50.7%
*-commutative50.7%
*-commutative50.7%
Simplified50.7%
Taylor expanded in n around 0 28.9%
associate--r+28.9%
associate-*r*28.9%
neg-mul-128.9%
cancel-sign-sub28.9%
Simplified28.9%
associate-+l-28.9%
add-sqr-sqrt16.2%
fabs-sqr16.2%
add-sqr-sqrt50.0%
sub-neg50.0%
add-sqr-sqrt24.8%
sqrt-unprod50.0%
sqr-neg50.0%
sqrt-unprod25.1%
add-sqr-sqrt50.0%
Applied egg-rr50.0%
Taylor expanded in K around 0 63.1%
cos-neg63.1%
Simplified63.1%
Final simplification78.7%
(FPCore (K m n M l)
:precision binary64
(let* ((t_0 (* (+ m n) K)))
(if (<= M -41000000000.0)
(* (cos (* 0.5 t_0)) (exp (- m (+ n l))))
(if (<= M 1.08e+96)
(* (cos M) (exp (+ (- m n) (- (* M (+ M m)) l))))
(* (cos (- (/ t_0 2.0) M)) (exp (* m (- M (* n 0.5)))))))))
double code(double K, double m, double n, double M, double l) {
double t_0 = (m + n) * K;
double tmp;
if (M <= -41000000000.0) {
tmp = cos((0.5 * t_0)) * exp((m - (n + l)));
} else if (M <= 1.08e+96) {
tmp = cos(M) * exp(((m - n) + ((M * (M + m)) - l)));
} else {
tmp = cos(((t_0 / 2.0) - M)) * exp((m * (M - (n * 0.5))));
}
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 = (m + n) * k
if (m_1 <= (-41000000000.0d0)) then
tmp = cos((0.5d0 * t_0)) * exp((m - (n + l)))
else if (m_1 <= 1.08d+96) then
tmp = cos(m_1) * exp(((m - n) + ((m_1 * (m_1 + m)) - l)))
else
tmp = cos(((t_0 / 2.0d0) - m_1)) * exp((m * (m_1 - (n * 0.5d0))))
end if
code = tmp
end function
public static double code(double K, double m, double n, double M, double l) {
double t_0 = (m + n) * K;
double tmp;
if (M <= -41000000000.0) {
tmp = Math.cos((0.5 * t_0)) * Math.exp((m - (n + l)));
} else if (M <= 1.08e+96) {
tmp = Math.cos(M) * Math.exp(((m - n) + ((M * (M + m)) - l)));
} else {
tmp = Math.cos(((t_0 / 2.0) - M)) * Math.exp((m * (M - (n * 0.5))));
}
return tmp;
}
def code(K, m, n, M, l): t_0 = (m + n) * K tmp = 0 if M <= -41000000000.0: tmp = math.cos((0.5 * t_0)) * math.exp((m - (n + l))) elif M <= 1.08e+96: tmp = math.cos(M) * math.exp(((m - n) + ((M * (M + m)) - l))) else: tmp = math.cos(((t_0 / 2.0) - M)) * math.exp((m * (M - (n * 0.5)))) return tmp
function code(K, m, n, M, l) t_0 = Float64(Float64(m + n) * K) tmp = 0.0 if (M <= -41000000000.0) tmp = Float64(cos(Float64(0.5 * t_0)) * exp(Float64(m - Float64(n + l)))); elseif (M <= 1.08e+96) tmp = Float64(cos(M) * exp(Float64(Float64(m - n) + Float64(Float64(M * Float64(M + m)) - l)))); else tmp = Float64(cos(Float64(Float64(t_0 / 2.0) - M)) * exp(Float64(m * Float64(M - Float64(n * 0.5))))); end return tmp end
function tmp_2 = code(K, m, n, M, l) t_0 = (m + n) * K; tmp = 0.0; if (M <= -41000000000.0) tmp = cos((0.5 * t_0)) * exp((m - (n + l))); elseif (M <= 1.08e+96) tmp = cos(M) * exp(((m - n) + ((M * (M + m)) - l))); else tmp = cos(((t_0 / 2.0) - M)) * exp((m * (M - (n * 0.5)))); end tmp_2 = tmp; end
code[K_, m_, n_, M_, l_] := Block[{t$95$0 = N[(N[(m + n), $MachinePrecision] * K), $MachinePrecision]}, If[LessEqual[M, -41000000000.0], N[(N[Cos[N[(0.5 * t$95$0), $MachinePrecision]], $MachinePrecision] * N[Exp[N[(m - N[(n + l), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[M, 1.08e+96], N[(N[Cos[M], $MachinePrecision] * N[Exp[N[(N[(m - n), $MachinePrecision] + N[(N[(M * N[(M + m), $MachinePrecision]), $MachinePrecision] - l), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(N[Cos[N[(N[(t$95$0 / 2.0), $MachinePrecision] - M), $MachinePrecision]], $MachinePrecision] * N[Exp[N[(m * N[(M - N[(n * 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(m + n\right) \cdot K\\
\mathbf{if}\;M \leq -41000000000:\\
\;\;\;\;\cos \left(0.5 \cdot t\_0\right) \cdot e^{m - \left(n + \ell\right)}\\
\mathbf{elif}\;M \leq 1.08 \cdot 10^{+96}:\\
\;\;\;\;\cos M \cdot e^{\left(m - n\right) + \left(M \cdot \left(M + m\right) - \ell\right)}\\
\mathbf{else}:\\
\;\;\;\;\cos \left(\frac{t\_0}{2} - M\right) \cdot e^{m \cdot \left(M - n \cdot 0.5\right)}\\
\end{array}
\end{array}
if M < -4.1e10Initial program 76.3%
Taylor expanded in m around 0 62.8%
+-commutative62.8%
unpow262.8%
distribute-rgt-out66.3%
*-commutative66.3%
*-commutative66.3%
Simplified66.3%
Taylor expanded in n around 0 62.9%
associate--r+62.9%
associate-*r*62.9%
neg-mul-162.9%
cancel-sign-sub62.9%
Simplified62.9%
associate-+l-62.9%
add-sqr-sqrt35.6%
fabs-sqr35.6%
add-sqr-sqrt62.9%
sub-neg62.9%
add-sqr-sqrt62.9%
sqrt-unprod66.3%
sqr-neg66.3%
sqrt-unprod0.0%
add-sqr-sqrt11.2%
Applied egg-rr11.2%
Taylor expanded in M around 0 39.7%
+-commutative39.7%
Simplified39.7%
if -4.1e10 < M < 1.08e96Initial program 72.7%
Taylor expanded in m around 0 52.5%
+-commutative52.5%
unpow252.5%
distribute-rgt-out52.5%
*-commutative52.5%
*-commutative52.5%
Simplified52.5%
Taylor expanded in n around 0 32.4%
associate--r+32.4%
associate-*r*32.4%
neg-mul-132.4%
cancel-sign-sub32.4%
Simplified32.4%
associate-+l-32.4%
add-sqr-sqrt16.5%
fabs-sqr16.5%
add-sqr-sqrt51.9%
sub-neg51.9%
add-sqr-sqrt22.3%
sqrt-unprod49.4%
sqr-neg49.4%
sqrt-unprod27.1%
add-sqr-sqrt49.4%
Applied egg-rr49.4%
Taylor expanded in K around 0 61.2%
cos-neg61.2%
Simplified61.2%
if 1.08e96 < M Initial program 78.0%
Taylor expanded in m around 0 70.7%
+-commutative70.7%
unpow270.7%
distribute-rgt-out73.2%
*-commutative73.2%
*-commutative73.2%
Simplified73.2%
Taylor expanded in m around inf 32.6%
Final simplification51.7%
(FPCore (K m n M l) :precision binary64 (if (or (<= M -780000000000.0) (not (<= M 2.6e+95))) (* (cos (* 0.5 (* (+ m n) K))) (exp (- m (+ n l)))) (* (cos M) (exp (+ (- m n) (- (* M (+ M m)) l))))))
double code(double K, double m, double n, double M, double l) {
double tmp;
if ((M <= -780000000000.0) || !(M <= 2.6e+95)) {
tmp = cos((0.5 * ((m + n) * K))) * exp((m - (n + l)));
} else {
tmp = cos(M) * exp(((m - n) + ((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) :: tmp
if ((m_1 <= (-780000000000.0d0)) .or. (.not. (m_1 <= 2.6d+95))) then
tmp = cos((0.5d0 * ((m + n) * k))) * exp((m - (n + l)))
else
tmp = cos(m_1) * exp(((m - n) + ((m_1 * (m_1 + m)) - 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 <= -780000000000.0) || !(M <= 2.6e+95)) {
tmp = Math.cos((0.5 * ((m + n) * K))) * Math.exp((m - (n + l)));
} else {
tmp = Math.cos(M) * Math.exp(((m - n) + ((M * (M + m)) - l)));
}
return tmp;
}
def code(K, m, n, M, l): tmp = 0 if (M <= -780000000000.0) or not (M <= 2.6e+95): tmp = math.cos((0.5 * ((m + n) * K))) * math.exp((m - (n + l))) else: tmp = math.cos(M) * math.exp(((m - n) + ((M * (M + m)) - l))) return tmp
function code(K, m, n, M, l) tmp = 0.0 if ((M <= -780000000000.0) || !(M <= 2.6e+95)) tmp = Float64(cos(Float64(0.5 * Float64(Float64(m + n) * K))) * exp(Float64(m - Float64(n + l)))); else tmp = Float64(cos(M) * exp(Float64(Float64(m - n) + Float64(Float64(M * Float64(M + m)) - l)))); end return tmp end
function tmp_2 = code(K, m, n, M, l) tmp = 0.0; if ((M <= -780000000000.0) || ~((M <= 2.6e+95))) tmp = cos((0.5 * ((m + n) * K))) * exp((m - (n + l))); else tmp = cos(M) * exp(((m - n) + ((M * (M + m)) - l))); end tmp_2 = tmp; end
code[K_, m_, n_, M_, l_] := If[Or[LessEqual[M, -780000000000.0], N[Not[LessEqual[M, 2.6e+95]], $MachinePrecision]], N[(N[Cos[N[(0.5 * N[(N[(m + n), $MachinePrecision] * K), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * N[Exp[N[(m - N[(n + l), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(N[Cos[M], $MachinePrecision] * N[Exp[N[(N[(m - n), $MachinePrecision] + N[(N[(M * N[(M + m), $MachinePrecision]), $MachinePrecision] - l), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;M \leq -780000000000 \lor \neg \left(M \leq 2.6 \cdot 10^{+95}\right):\\
\;\;\;\;\cos \left(0.5 \cdot \left(\left(m + n\right) \cdot K\right)\right) \cdot e^{m - \left(n + \ell\right)}\\
\mathbf{else}:\\
\;\;\;\;\cos M \cdot e^{\left(m - n\right) + \left(M \cdot \left(M + m\right) - \ell\right)}\\
\end{array}
\end{array}
if M < -7.8e11 or 2.5999999999999999e95 < M Initial program 77.0%
Taylor expanded in m around 0 66.1%
+-commutative66.1%
unpow266.1%
distribute-rgt-out69.1%
*-commutative69.1%
*-commutative69.1%
Simplified69.1%
Taylor expanded in n around 0 66.2%
associate--r+66.2%
associate-*r*66.2%
neg-mul-166.2%
cancel-sign-sub66.2%
Simplified66.2%
associate-+l-66.2%
add-sqr-sqrt35.1%
fabs-sqr35.1%
add-sqr-sqrt66.2%
sub-neg66.2%
add-sqr-sqrt37.1%
sqrt-unprod39.6%
sqr-neg39.6%
sqrt-unprod1.5%
add-sqr-sqrt8.1%
Applied egg-rr8.1%
Taylor expanded in M around 0 36.8%
+-commutative36.8%
Simplified36.8%
if -7.8e11 < M < 2.5999999999999999e95Initial program 72.7%
Taylor expanded in m around 0 52.5%
+-commutative52.5%
unpow252.5%
distribute-rgt-out52.5%
*-commutative52.5%
*-commutative52.5%
Simplified52.5%
Taylor expanded in n around 0 32.4%
associate--r+32.4%
associate-*r*32.4%
neg-mul-132.4%
cancel-sign-sub32.4%
Simplified32.4%
associate-+l-32.4%
add-sqr-sqrt16.5%
fabs-sqr16.5%
add-sqr-sqrt51.9%
sub-neg51.9%
add-sqr-sqrt22.3%
sqrt-unprod49.4%
sqr-neg49.4%
sqrt-unprod27.1%
add-sqr-sqrt49.4%
Applied egg-rr49.4%
Taylor expanded in K around 0 61.2%
cos-neg61.2%
Simplified61.2%
Final simplification51.7%
(FPCore (K m n M l)
:precision binary64
(let* ((t_0 (exp (- l))))
(if (<= l -2.5)
t_0
(if (<= l 1.95e-150)
(* t_0 (* -0.125 (pow (* (+ m n) K) 2.0)))
(* (cos M) t_0)))))
double code(double K, double m, double n, double M, double l) {
double t_0 = exp(-l);
double tmp;
if (l <= -2.5) {
tmp = t_0;
} else if (l <= 1.95e-150) {
tmp = t_0 * (-0.125 * pow(((m + n) * K), 2.0));
} else {
tmp = cos(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 = exp(-l)
if (l <= (-2.5d0)) then
tmp = t_0
else if (l <= 1.95d-150) then
tmp = t_0 * ((-0.125d0) * (((m + n) * k) ** 2.0d0))
else
tmp = cos(m_1) * 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.exp(-l);
double tmp;
if (l <= -2.5) {
tmp = t_0;
} else if (l <= 1.95e-150) {
tmp = t_0 * (-0.125 * Math.pow(((m + n) * K), 2.0));
} else {
tmp = Math.cos(M) * t_0;
}
return tmp;
}
def code(K, m, n, M, l): t_0 = math.exp(-l) tmp = 0 if l <= -2.5: tmp = t_0 elif l <= 1.95e-150: tmp = t_0 * (-0.125 * math.pow(((m + n) * K), 2.0)) else: tmp = math.cos(M) * t_0 return tmp
function code(K, m, n, M, l) t_0 = exp(Float64(-l)) tmp = 0.0 if (l <= -2.5) tmp = t_0; elseif (l <= 1.95e-150) tmp = Float64(t_0 * Float64(-0.125 * (Float64(Float64(m + n) * K) ^ 2.0))); else tmp = Float64(cos(M) * t_0); end return tmp end
function tmp_2 = code(K, m, n, M, l) t_0 = exp(-l); tmp = 0.0; if (l <= -2.5) tmp = t_0; elseif (l <= 1.95e-150) tmp = t_0 * (-0.125 * (((m + n) * K) ^ 2.0)); else tmp = cos(M) * t_0; end tmp_2 = tmp; end
code[K_, m_, n_, M_, l_] := Block[{t$95$0 = N[Exp[(-l)], $MachinePrecision]}, If[LessEqual[l, -2.5], t$95$0, If[LessEqual[l, 1.95e-150], N[(t$95$0 * N[(-0.125 * N[Power[N[(N[(m + n), $MachinePrecision] * K), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[Cos[M], $MachinePrecision] * t$95$0), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := e^{-\ell}\\
\mathbf{if}\;\ell \leq -2.5:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;\ell \leq 1.95 \cdot 10^{-150}:\\
\;\;\;\;t\_0 \cdot \left(-0.125 \cdot {\left(\left(m + n\right) \cdot K\right)}^{2}\right)\\
\mathbf{else}:\\
\;\;\;\;\cos M \cdot t\_0\\
\end{array}
\end{array}
if l < -2.5Initial program 75.0%
Taylor expanded in l around inf 18.8%
mul-1-neg18.8%
Simplified18.8%
Taylor expanded in M around 0 18.8%
*-commutative18.8%
associate-*r*18.8%
remove-double-neg18.8%
mul-1-neg18.8%
sub-neg18.8%
associate-*r*18.8%
*-commutative18.8%
sub-neg18.8%
mul-1-neg18.8%
remove-double-neg18.8%
+-commutative18.8%
Simplified18.8%
Taylor expanded in K around 0 20.6%
*-commutative20.6%
Simplified20.6%
Taylor expanded in K around 0 20.8%
if -2.5 < l < 1.9500000000000001e-150Initial program 73.6%
Taylor expanded in l around inf 9.7%
mul-1-neg9.7%
Simplified9.7%
Taylor expanded in M around 0 9.7%
*-commutative9.7%
associate-*r*9.7%
remove-double-neg9.7%
mul-1-neg9.7%
sub-neg9.7%
associate-*r*9.7%
*-commutative9.7%
sub-neg9.7%
mul-1-neg9.7%
remove-double-neg9.7%
+-commutative9.7%
Simplified9.7%
Taylor expanded in K around 0 8.0%
*-commutative8.0%
Simplified8.0%
Taylor expanded in K around inf 21.5%
unpow221.5%
unpow221.5%
swap-sqr19.2%
unpow219.2%
Simplified19.2%
if 1.9500000000000001e-150 < l Initial program 74.8%
Taylor expanded in K around 0 97.6%
cos-neg97.6%
sub-neg97.6%
sub-neg97.6%
associate--r+97.6%
*-commutative97.6%
associate--r+97.6%
Simplified97.6%
Taylor expanded in l around inf 68.3%
neg-mul-168.3%
Simplified68.3%
Final simplification39.9%
(FPCore (K m n M l) :precision binary64 (if (<= l 1.62) (* (cos M) (exp (+ (- m n) (- (* M (+ M m)) l)))) (* (cos M) (exp (- l)))))
double code(double K, double m, double n, double M, double l) {
double tmp;
if (l <= 1.62) {
tmp = cos(M) * exp(((m - n) + ((M * (M + m)) - l)));
} 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 (l <= 1.62d0) then
tmp = cos(m_1) * exp(((m - n) + ((m_1 * (m_1 + m)) - l)))
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 (l <= 1.62) {
tmp = Math.cos(M) * Math.exp(((m - n) + ((M * (M + m)) - l)));
} else {
tmp = Math.cos(M) * Math.exp(-l);
}
return tmp;
}
def code(K, m, n, M, l): tmp = 0 if l <= 1.62: tmp = math.cos(M) * math.exp(((m - n) + ((M * (M + m)) - l))) else: tmp = math.cos(M) * math.exp(-l) return tmp
function code(K, m, n, M, l) tmp = 0.0 if (l <= 1.62) tmp = Float64(cos(M) * exp(Float64(Float64(m - n) + Float64(Float64(M * Float64(M + m)) - l)))); else tmp = Float64(cos(M) * exp(Float64(-l))); end return tmp end
function tmp_2 = code(K, m, n, M, l) tmp = 0.0; if (l <= 1.62) tmp = cos(M) * exp(((m - n) + ((M * (M + m)) - l))); else tmp = cos(M) * exp(-l); end tmp_2 = tmp; end
code[K_, m_, n_, M_, l_] := If[LessEqual[l, 1.62], N[(N[Cos[M], $MachinePrecision] * N[Exp[N[(N[(m - n), $MachinePrecision] + N[(N[(M * N[(M + m), $MachinePrecision]), $MachinePrecision] - l), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(N[Cos[M], $MachinePrecision] * N[Exp[(-l)], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\ell \leq 1.62:\\
\;\;\;\;\cos M \cdot e^{\left(m - n\right) + \left(M \cdot \left(M + m\right) - \ell\right)}\\
\mathbf{else}:\\
\;\;\;\;\cos M \cdot e^{-\ell}\\
\end{array}
\end{array}
if l < 1.6200000000000001Initial program 74.4%
Taylor expanded in m around 0 55.9%
+-commutative55.9%
unpow255.9%
distribute-rgt-out57.0%
*-commutative57.0%
*-commutative57.0%
Simplified57.0%
Taylor expanded in n around 0 40.6%
associate--r+40.6%
associate-*r*40.6%
neg-mul-140.6%
cancel-sign-sub40.6%
Simplified40.6%
associate-+l-40.6%
add-sqr-sqrt20.3%
fabs-sqr20.3%
add-sqr-sqrt55.9%
sub-neg55.9%
add-sqr-sqrt25.7%
sqrt-unprod42.7%
sqr-neg42.7%
sqrt-unprod16.5%
add-sqr-sqrt29.5%
Applied egg-rr29.5%
Taylor expanded in K around 0 37.9%
cos-neg37.9%
Simplified37.9%
if 1.6200000000000001 < l Initial program 74.3%
Taylor expanded in K around 0 100.0%
cos-neg100.0%
sub-neg100.0%
sub-neg100.0%
associate--r+100.0%
*-commutative100.0%
associate--r+100.0%
Simplified100.0%
Taylor expanded in l around inf 98.6%
neg-mul-198.6%
Simplified98.6%
Final simplification54.5%
(FPCore (K m n M l) :precision binary64 (exp (- l)))
double code(double K, double m, double n, double M, double l) {
return 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 = exp(-l)
end function
public static double code(double K, double m, double n, double M, double l) {
return Math.exp(-l);
}
def code(K, m, n, M, l): return math.exp(-l)
function code(K, m, n, M, l) return exp(Float64(-l)) end
function tmp = code(K, m, n, M, l) tmp = exp(-l); end
code[K_, m_, n_, M_, l_] := N[Exp[(-l)], $MachinePrecision]
\begin{array}{l}
\\
e^{-\ell}
\end{array}
Initial program 74.4%
Taylor expanded in l around inf 28.8%
mul-1-neg28.8%
Simplified28.8%
Taylor expanded in M around 0 28.8%
*-commutative28.8%
associate-*r*28.8%
remove-double-neg28.8%
mul-1-neg28.8%
sub-neg28.8%
associate-*r*28.8%
*-commutative28.8%
sub-neg28.8%
mul-1-neg28.8%
remove-double-neg28.8%
+-commutative28.8%
Simplified28.8%
Taylor expanded in K around 0 18.2%
*-commutative18.2%
Simplified18.2%
Taylor expanded in K around 0 36.7%
herbie shell --seed 2024109
(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)))))))