
(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 (* (cos (- M)) (exp (- (fabs (- m n)) (+ (pow (- (* 0.5 (+ m n)) M) 2.0) l)))))
double code(double K, double m, double n, double M, double l) {
return cos(-M) * exp((fabs((m - n)) - (pow(((0.5 * (m + n)) - 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((m - n)) - ((((0.5d0 * (m + n)) - 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((m - n)) - (Math.pow(((0.5 * (m + n)) - M), 2.0) + l)));
}
def code(K, m, n, M, l): return math.cos(-M) * math.exp((math.fabs((m - n)) - (math.pow(((0.5 * (m + n)) - M), 2.0) + l)))
function code(K, m, n, M, l) return Float64(cos(Float64(-M)) * exp(Float64(abs(Float64(m - n)) - Float64((Float64(Float64(0.5 * Float64(m + n)) - M) ^ 2.0) + l)))) end
function tmp = code(K, m, n, M, l) tmp = cos(-M) * exp((abs((m - n)) - ((((0.5 * (m + n)) - M) ^ 2.0) + l))); end
code[K_, m_, n_, M_, l_] := N[(N[Cos[(-M)], $MachinePrecision] * N[Exp[N[(N[Abs[N[(m - n), $MachinePrecision]], $MachinePrecision] - N[(N[Power[N[(N[(0.5 * N[(m + n), $MachinePrecision]), $MachinePrecision] - M), $MachinePrecision], 2.0], $MachinePrecision] + l), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\cos \left(-M\right) \cdot e^{\left|m - n\right| - \left({\left(0.5 \cdot \left(m + n\right) - M\right)}^{2} + \ell\right)}
\end{array}
Initial program 78.5%
Taylor expanded in K around 0 98.1%
Final simplification98.1%
(FPCore (K m n M l) :precision binary64 (* (cos (- M)) (exp (- (- (- m n) l) (pow (- (* n 0.5) M) 2.0)))))
double code(double K, double m, double n, double M, double l) {
return cos(-M) * exp((((m - n) - l) - pow(((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((((m - n) - l) - (((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((((m - n) - l) - Math.pow(((n * 0.5) - M), 2.0)));
}
def code(K, m, n, M, l): return math.cos(-M) * math.exp((((m - n) - l) - math.pow(((n * 0.5) - M), 2.0)))
function code(K, m, n, M, l) return Float64(cos(Float64(-M)) * exp(Float64(Float64(Float64(m - n) - l) - (Float64(Float64(n * 0.5) - M) ^ 2.0)))) end
function tmp = code(K, m, n, M, l) tmp = cos(-M) * exp((((m - n) - l) - (((n * 0.5) - M) ^ 2.0))); end
code[K_, m_, n_, M_, l_] := N[(N[Cos[(-M)], $MachinePrecision] * N[Exp[N[(N[(N[(m - n), $MachinePrecision] - l), $MachinePrecision] - N[Power[N[(N[(n * 0.5), $MachinePrecision] - M), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\cos \left(-M\right) \cdot e^{\left(\left(m - n\right) - \ell\right) - {\left(n \cdot 0.5 - M\right)}^{2}}
\end{array}
Initial program 78.5%
Taylor expanded in K around 0 98.1%
Taylor expanded in m around 0 78.9%
fabs-sub78.9%
sub-neg78.9%
mul-1-neg78.9%
fabs-neg78.9%
associate--r+78.9%
fabs-neg78.9%
mul-1-neg78.9%
sub-neg78.9%
fabs-sub78.9%
rem-square-sqrt37.0%
fabs-sqr37.0%
rem-square-sqrt86.6%
Simplified86.6%
Final simplification86.6%
(FPCore (K m n M l) :precision binary64 (if (<= n 1.1e+19) (* (cos (- M)) (exp (+ (- (- m n) l) (* M (- n M))))) (exp (- m (+ (* 0.25 (pow n 2.0)) (+ n l))))))
double code(double K, double m, double n, double M, double l) {
double tmp;
if (n <= 1.1e+19) {
tmp = cos(-M) * exp((((m - n) - l) + (M * (n - M))));
} else {
tmp = exp((m - ((0.25 * pow(n, 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 <= 1.1d+19) then
tmp = cos(-m_1) * exp((((m - n) - l) + (m_1 * (n - m_1))))
else
tmp = exp((m - ((0.25d0 * (n ** 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 <= 1.1e+19) {
tmp = Math.cos(-M) * Math.exp((((m - n) - l) + (M * (n - M))));
} else {
tmp = Math.exp((m - ((0.25 * Math.pow(n, 2.0)) + (n + l))));
}
return tmp;
}
def code(K, m, n, M, l): tmp = 0 if n <= 1.1e+19: tmp = math.cos(-M) * math.exp((((m - n) - l) + (M * (n - M)))) else: tmp = math.exp((m - ((0.25 * math.pow(n, 2.0)) + (n + l)))) return tmp
function code(K, m, n, M, l) tmp = 0.0 if (n <= 1.1e+19) tmp = Float64(cos(Float64(-M)) * exp(Float64(Float64(Float64(m - n) - l) + Float64(M * Float64(n - M))))); else tmp = exp(Float64(m - Float64(Float64(0.25 * (n ^ 2.0)) + Float64(n + l)))); end return tmp end
function tmp_2 = code(K, m, n, M, l) tmp = 0.0; if (n <= 1.1e+19) tmp = cos(-M) * exp((((m - n) - l) + (M * (n - M)))); else tmp = exp((m - ((0.25 * (n ^ 2.0)) + (n + l)))); end tmp_2 = tmp; end
code[K_, m_, n_, M_, l_] := If[LessEqual[n, 1.1e+19], N[(N[Cos[(-M)], $MachinePrecision] * N[Exp[N[(N[(N[(m - n), $MachinePrecision] - l), $MachinePrecision] + N[(M * N[(n - M), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[Exp[N[(m - N[(N[(0.25 * N[Power[n, 2.0], $MachinePrecision]), $MachinePrecision] + N[(n + l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;n \leq 1.1 \cdot 10^{+19}:\\
\;\;\;\;\cos \left(-M\right) \cdot e^{\left(\left(m - n\right) - \ell\right) + M \cdot \left(n - M\right)}\\
\mathbf{else}:\\
\;\;\;\;e^{m - \left(0.25 \cdot {n}^{2} + \left(n + \ell\right)\right)}\\
\end{array}
\end{array}
if n < 1.1e19Initial program 82.0%
Taylor expanded in K around 0 97.5%
Taylor expanded in m around 0 74.0%
fabs-sub74.0%
sub-neg74.0%
mul-1-neg74.0%
fabs-neg74.0%
associate--r+74.0%
fabs-neg74.0%
mul-1-neg74.0%
sub-neg74.0%
fabs-sub74.0%
rem-square-sqrt48.5%
fabs-sqr48.5%
rem-square-sqrt82.9%
Simplified82.9%
Taylor expanded in n around 0 63.6%
+-commutative63.6%
unpow263.6%
mul-1-neg63.6%
distribute-rgt-neg-in63.6%
mul-1-neg63.6%
distribute-lft-in67.8%
mul-1-neg67.8%
sub-neg67.8%
Simplified67.8%
if 1.1e19 < n Initial program 68.7%
Taylor expanded in K around 0 100.0%
Taylor expanded in m around 0 92.7%
fabs-sub92.7%
sub-neg92.7%
mul-1-neg92.7%
fabs-neg92.7%
associate--r+92.7%
fabs-neg92.7%
mul-1-neg92.7%
sub-neg92.7%
fabs-sub92.7%
rem-square-sqrt4.5%
fabs-sqr4.5%
rem-square-sqrt97.1%
Simplified97.1%
Taylor expanded in M around 0 97.1%
associate-+r+97.1%
+-commutative97.1%
Simplified97.1%
Final simplification75.5%
(FPCore (K m n M l) :precision binary64 (if (<= n 5000000000.0) (exp (+ (- (- m n) l) (* M (- n M)))) (exp (- m (+ (* 0.25 (pow n 2.0)) (+ n l))))))
double code(double K, double m, double n, double M, double l) {
double tmp;
if (n <= 5000000000.0) {
tmp = exp((((m - n) - l) + (M * (n - M))));
} else {
tmp = exp((m - ((0.25 * pow(n, 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 <= 5000000000.0d0) then
tmp = exp((((m - n) - l) + (m_1 * (n - m_1))))
else
tmp = exp((m - ((0.25d0 * (n ** 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 <= 5000000000.0) {
tmp = Math.exp((((m - n) - l) + (M * (n - M))));
} else {
tmp = Math.exp((m - ((0.25 * Math.pow(n, 2.0)) + (n + l))));
}
return tmp;
}
def code(K, m, n, M, l): tmp = 0 if n <= 5000000000.0: tmp = math.exp((((m - n) - l) + (M * (n - M)))) else: tmp = math.exp((m - ((0.25 * math.pow(n, 2.0)) + (n + l)))) return tmp
function code(K, m, n, M, l) tmp = 0.0 if (n <= 5000000000.0) tmp = exp(Float64(Float64(Float64(m - n) - l) + Float64(M * Float64(n - M)))); else tmp = exp(Float64(m - Float64(Float64(0.25 * (n ^ 2.0)) + Float64(n + l)))); end return tmp end
function tmp_2 = code(K, m, n, M, l) tmp = 0.0; if (n <= 5000000000.0) tmp = exp((((m - n) - l) + (M * (n - M)))); else tmp = exp((m - ((0.25 * (n ^ 2.0)) + (n + l)))); end tmp_2 = tmp; end
code[K_, m_, n_, M_, l_] := If[LessEqual[n, 5000000000.0], N[Exp[N[(N[(N[(m - n), $MachinePrecision] - l), $MachinePrecision] + N[(M * N[(n - M), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[Exp[N[(m - N[(N[(0.25 * N[Power[n, 2.0], $MachinePrecision]), $MachinePrecision] + N[(n + l), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;n \leq 5000000000:\\
\;\;\;\;e^{\left(\left(m - n\right) - \ell\right) + M \cdot \left(n - M\right)}\\
\mathbf{else}:\\
\;\;\;\;e^{m - \left(0.25 \cdot {n}^{2} + \left(n + \ell\right)\right)}\\
\end{array}
\end{array}
if n < 5e9Initial program 82.2%
Taylor expanded in K around 0 97.4%
Taylor expanded in m around 0 74.2%
fabs-sub74.2%
sub-neg74.2%
mul-1-neg74.2%
fabs-neg74.2%
associate--r+74.2%
fabs-neg74.2%
mul-1-neg74.2%
sub-neg74.2%
fabs-sub74.2%
rem-square-sqrt48.2%
fabs-sqr48.2%
rem-square-sqrt83.2%
Simplified83.2%
Taylor expanded in n around 0 63.5%
+-commutative63.5%
unpow263.5%
mul-1-neg63.5%
distribute-rgt-neg-in63.5%
mul-1-neg63.5%
distribute-lft-in67.8%
mul-1-neg67.8%
sub-neg67.8%
Simplified67.8%
Taylor expanded in M around 0 66.7%
if 5e9 < n Initial program 68.6%
Taylor expanded in K around 0 100.0%
Taylor expanded in m around 0 91.6%
fabs-sub91.6%
sub-neg91.6%
mul-1-neg91.6%
fabs-neg91.6%
associate--r+91.6%
fabs-neg91.6%
mul-1-neg91.6%
sub-neg91.6%
fabs-sub91.6%
rem-square-sqrt7.2%
fabs-sqr7.2%
rem-square-sqrt95.8%
Simplified95.8%
Taylor expanded in M around 0 94.4%
associate-+r+94.4%
+-commutative94.4%
Simplified94.4%
Final simplification74.3%
(FPCore (K m n M l) :precision binary64 (if (<= n 2e+196) (exp (+ (- (- m n) l) (* M (- n M)))) (* (cos (- M)) (exp (- m (+ n l))))))
double code(double K, double m, double n, double M, double l) {
double tmp;
if (n <= 2e+196) {
tmp = exp((((m - n) - l) + (M * (n - M))));
} else {
tmp = cos(-M) * exp((m - (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 <= 2d+196) then
tmp = exp((((m - n) - l) + (m_1 * (n - m_1))))
else
tmp = cos(-m_1) * exp((m - (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 <= 2e+196) {
tmp = Math.exp((((m - n) - l) + (M * (n - M))));
} else {
tmp = Math.cos(-M) * Math.exp((m - (n + l)));
}
return tmp;
}
def code(K, m, n, M, l): tmp = 0 if n <= 2e+196: tmp = math.exp((((m - n) - l) + (M * (n - M)))) else: tmp = math.cos(-M) * math.exp((m - (n + l))) return tmp
function code(K, m, n, M, l) tmp = 0.0 if (n <= 2e+196) tmp = exp(Float64(Float64(Float64(m - n) - l) + Float64(M * Float64(n - M)))); else tmp = Float64(cos(Float64(-M)) * exp(Float64(m - Float64(n + l)))); end return tmp end
function tmp_2 = code(K, m, n, M, l) tmp = 0.0; if (n <= 2e+196) tmp = exp((((m - n) - l) + (M * (n - M)))); else tmp = cos(-M) * exp((m - (n + l))); end tmp_2 = tmp; end
code[K_, m_, n_, M_, l_] := If[LessEqual[n, 2e+196], N[Exp[N[(N[(N[(m - n), $MachinePrecision] - l), $MachinePrecision] + N[(M * N[(n - M), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[(N[Cos[(-M)], $MachinePrecision] * N[Exp[N[(m - N[(n + l), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;n \leq 2 \cdot 10^{+196}:\\
\;\;\;\;e^{\left(\left(m - n\right) - \ell\right) + M \cdot \left(n - M\right)}\\
\mathbf{else}:\\
\;\;\;\;\cos \left(-M\right) \cdot e^{m - \left(n + \ell\right)}\\
\end{array}
\end{array}
if n < 1.9999999999999999e196Initial program 81.8%
Taylor expanded in K around 0 97.9%
Taylor expanded in m around 0 76.1%
fabs-sub76.1%
sub-neg76.1%
mul-1-neg76.1%
fabs-neg76.1%
associate--r+76.1%
fabs-neg76.1%
mul-1-neg76.1%
sub-neg76.1%
fabs-sub76.1%
rem-square-sqrt41.4%
fabs-sqr41.4%
rem-square-sqrt84.8%
Simplified84.8%
Taylor expanded in n around 0 66.0%
+-commutative66.0%
unpow266.0%
mul-1-neg66.0%
distribute-rgt-neg-in66.0%
mul-1-neg66.0%
distribute-lft-in70.9%
mul-1-neg70.9%
sub-neg70.9%
Simplified70.9%
Taylor expanded in M around 0 70.0%
if 1.9999999999999999e196 < n Initial program 53.3%
Taylor expanded in K around 0 100.0%
Taylor expanded in m around 0 100.0%
fabs-sub100.0%
sub-neg100.0%
mul-1-neg100.0%
fabs-neg100.0%
associate--r+100.0%
fabs-neg100.0%
mul-1-neg100.0%
sub-neg100.0%
fabs-sub100.0%
rem-square-sqrt3.3%
fabs-sqr3.3%
rem-square-sqrt100.0%
Simplified100.0%
Taylor expanded in n around 0 86.8%
+-commutative86.8%
unpow286.8%
mul-1-neg86.8%
distribute-rgt-neg-in86.8%
mul-1-neg86.8%
distribute-lft-in86.9%
mul-1-neg86.9%
sub-neg86.9%
Simplified86.9%
Taylor expanded in M around 0 96.7%
Final simplification73.1%
(FPCore (K m n M l) :precision binary64 (if (<= m -1.2e+39) (* (cos (- M)) (exp m)) (exp (+ (- (- m n) l) (* M (- n M))))))
double code(double K, double m, double n, double M, double l) {
double tmp;
if (m <= -1.2e+39) {
tmp = cos(-M) * exp(m);
} else {
tmp = exp((((m - n) - l) + (M * (n - M))));
}
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.2d+39)) then
tmp = cos(-m_1) * exp(m)
else
tmp = exp((((m - n) - l) + (m_1 * (n - m_1))))
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.2e+39) {
tmp = Math.cos(-M) * Math.exp(m);
} else {
tmp = Math.exp((((m - n) - l) + (M * (n - M))));
}
return tmp;
}
def code(K, m, n, M, l): tmp = 0 if m <= -1.2e+39: tmp = math.cos(-M) * math.exp(m) else: tmp = math.exp((((m - n) - l) + (M * (n - M)))) return tmp
function code(K, m, n, M, l) tmp = 0.0 if (m <= -1.2e+39) tmp = Float64(cos(Float64(-M)) * exp(m)); else tmp = exp(Float64(Float64(Float64(m - n) - l) + Float64(M * Float64(n - M)))); end return tmp end
function tmp_2 = code(K, m, n, M, l) tmp = 0.0; if (m <= -1.2e+39) tmp = cos(-M) * exp(m); else tmp = exp((((m - n) - l) + (M * (n - M)))); end tmp_2 = tmp; end
code[K_, m_, n_, M_, l_] := If[LessEqual[m, -1.2e+39], N[(N[Cos[(-M)], $MachinePrecision] * N[Exp[m], $MachinePrecision]), $MachinePrecision], N[Exp[N[(N[(N[(m - n), $MachinePrecision] - l), $MachinePrecision] + N[(M * N[(n - M), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;m \leq -1.2 \cdot 10^{+39}:\\
\;\;\;\;\cos \left(-M\right) \cdot e^{m}\\
\mathbf{else}:\\
\;\;\;\;e^{\left(\left(m - n\right) - \ell\right) + M \cdot \left(n - M\right)}\\
\end{array}
\end{array}
if m < -1.2e39Initial program 73.2%
Taylor expanded in K around 0 100.0%
Taylor expanded in m around 0 63.1%
fabs-sub63.1%
sub-neg63.1%
mul-1-neg63.1%
fabs-neg63.1%
associate--r+63.1%
fabs-neg63.1%
mul-1-neg63.1%
sub-neg63.1%
fabs-sub63.1%
rem-square-sqrt14.3%
fabs-sqr14.3%
rem-square-sqrt96.5%
Simplified96.5%
Taylor expanded in n around 0 80.6%
+-commutative80.6%
unpow280.6%
mul-1-neg80.6%
distribute-rgt-neg-in80.6%
mul-1-neg80.6%
distribute-lft-in82.4%
mul-1-neg82.4%
sub-neg82.4%
Simplified82.4%
Taylor expanded in m around inf 98.2%
if -1.2e39 < m Initial program 80.0%
Taylor expanded in K around 0 97.6%
Taylor expanded in m around 0 83.3%
fabs-sub83.3%
sub-neg83.3%
mul-1-neg83.3%
fabs-neg83.3%
associate--r+83.3%
fabs-neg83.3%
mul-1-neg83.3%
sub-neg83.3%
fabs-sub83.3%
rem-square-sqrt43.3%
fabs-sqr43.3%
rem-square-sqrt83.8%
Simplified83.8%
Taylor expanded in n around 0 65.1%
+-commutative65.1%
unpow265.1%
mul-1-neg65.1%
distribute-rgt-neg-in65.1%
mul-1-neg65.1%
distribute-lft-in70.1%
mul-1-neg70.1%
sub-neg70.1%
Simplified70.1%
Taylor expanded in M around 0 69.6%
Final simplification75.8%
(FPCore (K m n M l) :precision binary64 (if (<= l 0.005) (exp (+ (- (- m n) l) (* M (- n M)))) (exp (- l))))
double code(double K, double m, double n, double M, double l) {
double tmp;
if (l <= 0.005) {
tmp = exp((((m - n) - l) + (M * (n - M))));
} else {
tmp = 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 <= 0.005d0) then
tmp = exp((((m - n) - l) + (m_1 * (n - m_1))))
else
tmp = 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 <= 0.005) {
tmp = Math.exp((((m - n) - l) + (M * (n - M))));
} else {
tmp = Math.exp(-l);
}
return tmp;
}
def code(K, m, n, M, l): tmp = 0 if l <= 0.005: tmp = math.exp((((m - n) - l) + (M * (n - M)))) else: tmp = math.exp(-l) return tmp
function code(K, m, n, M, l) tmp = 0.0 if (l <= 0.005) tmp = exp(Float64(Float64(Float64(m - n) - l) + Float64(M * Float64(n - M)))); else tmp = exp(Float64(-l)); end return tmp end
function tmp_2 = code(K, m, n, M, l) tmp = 0.0; if (l <= 0.005) tmp = exp((((m - n) - l) + (M * (n - M)))); else tmp = exp(-l); end tmp_2 = tmp; end
code[K_, m_, n_, M_, l_] := If[LessEqual[l, 0.005], N[Exp[N[(N[(N[(m - n), $MachinePrecision] - l), $MachinePrecision] + N[(M * N[(n - M), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[Exp[(-l)], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\ell \leq 0.005:\\
\;\;\;\;e^{\left(\left(m - n\right) - \ell\right) + M \cdot \left(n - M\right)}\\
\mathbf{else}:\\
\;\;\;\;e^{-\ell}\\
\end{array}
\end{array}
if l < 0.0050000000000000001Initial program 78.8%
Taylor expanded in K around 0 97.6%
Taylor expanded in m around 0 77.7%
fabs-sub77.7%
sub-neg77.7%
mul-1-neg77.7%
fabs-neg77.7%
associate--r+77.7%
fabs-neg77.7%
mul-1-neg77.7%
sub-neg77.7%
fabs-sub77.7%
rem-square-sqrt36.7%
fabs-sqr36.7%
rem-square-sqrt84.2%
Simplified84.2%
Taylor expanded in n around 0 66.7%
+-commutative66.7%
unpow266.7%
mul-1-neg66.7%
distribute-rgt-neg-in66.7%
mul-1-neg66.7%
distribute-lft-in72.2%
mul-1-neg72.2%
sub-neg72.2%
Simplified72.2%
Taylor expanded in M around 0 71.2%
if 0.0050000000000000001 < l Initial program 77.6%
Taylor expanded in l around inf 77.6%
mul-1-neg77.6%
Simplified77.6%
Taylor expanded in M around 0 77.6%
*-commutative77.6%
associate-*r*77.6%
+-commutative77.6%
*-lft-identity77.6%
metadata-eval77.6%
cancel-sign-sub-inv77.6%
associate-*r*77.6%
*-commutative77.6%
sub-neg77.6%
mul-1-neg77.6%
remove-double-neg77.6%
Simplified77.6%
Taylor expanded in K around 0 100.0%
Final simplification77.8%
(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 78.5%
Taylor expanded in l around inf 28.7%
mul-1-neg28.7%
Simplified28.7%
Taylor expanded in M around 0 28.3%
*-commutative28.3%
associate-*r*28.3%
+-commutative28.3%
*-lft-identity28.3%
metadata-eval28.3%
cancel-sign-sub-inv28.3%
associate-*r*28.3%
*-commutative28.3%
sub-neg28.3%
mul-1-neg28.3%
remove-double-neg28.3%
Simplified28.3%
Taylor expanded in K around 0 33.5%
(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 78.5%
Taylor expanded in m around inf 44.8%
*-commutative44.8%
Simplified44.8%
Taylor expanded in m around 0 9.0%
*-commutative9.0%
Simplified9.0%
Taylor expanded in n around 0 9.2%
cos-neg9.2%
Simplified9.2%
(FPCore (K m n M l) :precision binary64 1.0)
double code(double K, double m, double n, double M, double l) {
return 1.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 = 1.0d0
end function
public static double code(double K, double m, double n, double M, double l) {
return 1.0;
}
def code(K, m, n, M, l): return 1.0
function code(K, m, n, M, l) return 1.0 end
function tmp = code(K, m, n, M, l) tmp = 1.0; end
code[K_, m_, n_, M_, l_] := 1.0
\begin{array}{l}
\\
1
\end{array}
Initial program 78.5%
Taylor expanded in m around inf 44.8%
*-commutative44.8%
Simplified44.8%
Taylor expanded in m around 0 9.0%
*-commutative9.0%
Simplified9.0%
Taylor expanded in n around 0 9.2%
cos-neg9.2%
Simplified9.2%
Taylor expanded in M around 0 9.2%
herbie shell --seed 2024116
(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)))))))