
(FPCore (K m n M l) :precision binary64 (* (cos (- (/ (* K (+ m n)) 2.0) M)) (exp (- (- (pow (- (/ (+ m n) 2.0) M) 2.0)) (- l (fabs (- m n)))))))
double code(double K, double m, double n, double M, double l) {
return cos((((K * (m + n)) / 2.0) - M)) * exp((-pow((((m + n) / 2.0) - M), 2.0) - (l - fabs((m - n)))));
}
real(8) function code(k, m, n, m_1, l)
real(8), intent (in) :: k
real(8), intent (in) :: m
real(8), intent (in) :: n
real(8), intent (in) :: m_1
real(8), intent (in) :: l
code = cos((((k * (m + n)) / 2.0d0) - m_1)) * exp((-((((m + n) / 2.0d0) - m_1) ** 2.0d0) - (l - abs((m - n)))))
end function
public static double code(double K, double m, double n, double M, double l) {
return Math.cos((((K * (m + n)) / 2.0) - M)) * Math.exp((-Math.pow((((m + n) / 2.0) - M), 2.0) - (l - Math.abs((m - n)))));
}
def code(K, m, n, M, l): return math.cos((((K * (m + n)) / 2.0) - M)) * math.exp((-math.pow((((m + n) / 2.0) - M), 2.0) - (l - math.fabs((m - n)))))
function code(K, m, n, M, l) return Float64(cos(Float64(Float64(Float64(K * Float64(m + n)) / 2.0) - M)) * exp(Float64(Float64(-(Float64(Float64(Float64(m + n) / 2.0) - M) ^ 2.0)) - Float64(l - abs(Float64(m - n)))))) end
function tmp = code(K, m, n, M, l) tmp = cos((((K * (m + n)) / 2.0) - M)) * exp((-((((m + n) / 2.0) - M) ^ 2.0) - (l - abs((m - n))))); end
code[K_, m_, n_, M_, l_] := N[(N[Cos[N[(N[(N[(K * N[(m + n), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision] - M), $MachinePrecision]], $MachinePrecision] * N[Exp[N[((-N[Power[N[(N[(N[(m + n), $MachinePrecision] / 2.0), $MachinePrecision] - M), $MachinePrecision], 2.0], $MachinePrecision]) - N[(l - N[Abs[N[(m - n), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\cos \left(\frac{K \cdot \left(m + n\right)}{2} - M\right) \cdot e^{\left(-{\left(\frac{m + n}{2} - M\right)}^{2}\right) - \left(\ell - \left|m - n\right|\right)}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 9 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (K m n M l) :precision binary64 (* (cos (- (/ (* K (+ m n)) 2.0) M)) (exp (- (- (pow (- (/ (+ m n) 2.0) M) 2.0)) (- l (fabs (- m n)))))))
double code(double K, double m, double n, double M, double l) {
return cos((((K * (m + n)) / 2.0) - M)) * exp((-pow((((m + n) / 2.0) - M), 2.0) - (l - fabs((m - n)))));
}
real(8) function code(k, m, n, m_1, l)
real(8), intent (in) :: k
real(8), intent (in) :: m
real(8), intent (in) :: n
real(8), intent (in) :: m_1
real(8), intent (in) :: l
code = cos((((k * (m + n)) / 2.0d0) - m_1)) * exp((-((((m + n) / 2.0d0) - m_1) ** 2.0d0) - (l - abs((m - n)))))
end function
public static double code(double K, double m, double n, double M, double l) {
return Math.cos((((K * (m + n)) / 2.0) - M)) * Math.exp((-Math.pow((((m + n) / 2.0) - M), 2.0) - (l - Math.abs((m - n)))));
}
def code(K, m, n, M, l): return math.cos((((K * (m + n)) / 2.0) - M)) * math.exp((-math.pow((((m + n) / 2.0) - M), 2.0) - (l - math.fabs((m - n)))))
function code(K, m, n, M, l) return Float64(cos(Float64(Float64(Float64(K * Float64(m + n)) / 2.0) - M)) * exp(Float64(Float64(-(Float64(Float64(Float64(m + n) / 2.0) - M) ^ 2.0)) - Float64(l - abs(Float64(m - n)))))) end
function tmp = code(K, m, n, M, l) tmp = cos((((K * (m + n)) / 2.0) - M)) * exp((-((((m + n) / 2.0) - M) ^ 2.0) - (l - abs((m - n))))); end
code[K_, m_, n_, M_, l_] := N[(N[Cos[N[(N[(N[(K * N[(m + n), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision] - M), $MachinePrecision]], $MachinePrecision] * N[Exp[N[((-N[Power[N[(N[(N[(m + n), $MachinePrecision] / 2.0), $MachinePrecision] - M), $MachinePrecision], 2.0], $MachinePrecision]) - N[(l - N[Abs[N[(m - n), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\cos \left(\frac{K \cdot \left(m + n\right)}{2} - M\right) \cdot e^{\left(-{\left(\frac{m + n}{2} - M\right)}^{2}\right) - \left(\ell - \left|m - n\right|\right)}
\end{array}
(FPCore (K m n M l) :precision binary64 (* (cos M) (exp (- (- (fabs (- 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 80.1%
Taylor expanded in K around 0 99.6%
cos-neg99.6%
Simplified99.6%
Final simplification99.6%
(FPCore (K m n M l)
:precision binary64
(if (<= n 105.0)
(*
(cos M)
(exp (+ (* (- (* m 0.5) M) (- (- M (* m 0.5)) n)) (- (fabs (- m n)) l))))
(exp (* -0.25 (pow n 2.0)))))
double code(double K, double m, double n, double M, double l) {
double tmp;
if (n <= 105.0) {
tmp = cos(M) * exp(((((m * 0.5) - M) * ((M - (m * 0.5)) - n)) + (fabs((m - n)) - l)));
} else {
tmp = exp((-0.25 * pow(n, 2.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) :: tmp
if (n <= 105.0d0) then
tmp = cos(m_1) * exp(((((m * 0.5d0) - m_1) * ((m_1 - (m * 0.5d0)) - n)) + (abs((m - n)) - l)))
else
tmp = exp(((-0.25d0) * (n ** 2.0d0)))
end if
code = tmp
end function
public static double code(double K, double m, double n, double M, double l) {
double tmp;
if (n <= 105.0) {
tmp = Math.cos(M) * Math.exp(((((m * 0.5) - M) * ((M - (m * 0.5)) - n)) + (Math.abs((m - n)) - l)));
} else {
tmp = Math.exp((-0.25 * Math.pow(n, 2.0)));
}
return tmp;
}
def code(K, m, n, M, l): tmp = 0 if n <= 105.0: tmp = math.cos(M) * math.exp(((((m * 0.5) - M) * ((M - (m * 0.5)) - n)) + (math.fabs((m - n)) - l))) else: tmp = math.exp((-0.25 * math.pow(n, 2.0))) return tmp
function code(K, m, n, M, l) tmp = 0.0 if (n <= 105.0) tmp = Float64(cos(M) * exp(Float64(Float64(Float64(Float64(m * 0.5) - M) * Float64(Float64(M - Float64(m * 0.5)) - n)) + Float64(abs(Float64(m - n)) - l)))); else tmp = exp(Float64(-0.25 * (n ^ 2.0))); end return tmp end
function tmp_2 = code(K, m, n, M, l) tmp = 0.0; if (n <= 105.0) tmp = cos(M) * exp(((((m * 0.5) - M) * ((M - (m * 0.5)) - n)) + (abs((m - n)) - l))); else tmp = exp((-0.25 * (n ^ 2.0))); end tmp_2 = tmp; end
code[K_, m_, n_, M_, l_] := If[LessEqual[n, 105.0], N[(N[Cos[M], $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[(N[Abs[N[(m - n), $MachinePrecision]], $MachinePrecision] - l), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[Exp[N[(-0.25 * N[Power[n, 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;n \leq 105:\\
\;\;\;\;\cos M \cdot e^{\left(m \cdot 0.5 - M\right) \cdot \left(\left(M - m \cdot 0.5\right) - n\right) + \left(\left|m - n\right| - \ell\right)}\\
\mathbf{else}:\\
\;\;\;\;e^{-0.25 \cdot {n}^{2}}\\
\end{array}
\end{array}
if n < 105Initial program 81.6%
Taylor expanded in K around 0 99.5%
cos-neg99.5%
Simplified99.5%
Taylor expanded in n around 0 80.6%
+-commutative80.6%
unpow280.6%
distribute-rgt-out83.2%
*-commutative83.2%
*-commutative83.2%
Simplified83.2%
if 105 < n Initial program 75.8%
Taylor expanded in m around 0 50.1%
+-commutative50.1%
unpow250.1%
distribute-rgt-out62.3%
*-commutative62.3%
*-commutative62.3%
Simplified62.3%
Taylor expanded in n around inf 75.8%
*-commutative75.8%
Simplified75.8%
Taylor expanded in n around inf 78.8%
*-commutative78.8%
associate-*l*78.8%
Simplified78.8%
Taylor expanded in K around 0 100.0%
Final simplification87.6%
(FPCore (K m n M l)
:precision binary64
(if (<= m -20000000000000.0)
(* (cos M) (exp (* (pow m 2.0) -0.25)))
(*
(cos M)
(exp (+ (* (- (* n 0.5) M) (- (- M (* n 0.5)) m)) (- (fabs (- m n)) l))))))
double code(double K, double m, double n, double M, double l) {
double tmp;
if (m <= -20000000000000.0) {
tmp = cos(M) * exp((pow(m, 2.0) * -0.25));
} else {
tmp = cos(M) * exp(((((n * 0.5) - M) * ((M - (n * 0.5)) - m)) + (fabs((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 (m <= (-20000000000000.0d0)) then
tmp = cos(m_1) * exp(((m ** 2.0d0) * (-0.25d0)))
else
tmp = cos(m_1) * exp(((((n * 0.5d0) - m_1) * ((m_1 - (n * 0.5d0)) - m)) + (abs((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 (m <= -20000000000000.0) {
tmp = Math.cos(M) * Math.exp((Math.pow(m, 2.0) * -0.25));
} else {
tmp = Math.cos(M) * Math.exp(((((n * 0.5) - M) * ((M - (n * 0.5)) - m)) + (Math.abs((m - n)) - l)));
}
return tmp;
}
def code(K, m, n, M, l): tmp = 0 if m <= -20000000000000.0: tmp = math.cos(M) * math.exp((math.pow(m, 2.0) * -0.25)) else: tmp = math.cos(M) * math.exp(((((n * 0.5) - M) * ((M - (n * 0.5)) - m)) + (math.fabs((m - n)) - l))) return tmp
function code(K, m, n, M, l) tmp = 0.0 if (m <= -20000000000000.0) tmp = Float64(cos(M) * exp(Float64((m ^ 2.0) * -0.25))); else tmp = Float64(cos(M) * exp(Float64(Float64(Float64(Float64(n * 0.5) - M) * Float64(Float64(M - Float64(n * 0.5)) - m)) + Float64(abs(Float64(m - n)) - l)))); end return tmp end
function tmp_2 = code(K, m, n, M, l) tmp = 0.0; if (m <= -20000000000000.0) tmp = cos(M) * exp(((m ^ 2.0) * -0.25)); else tmp = cos(M) * exp(((((n * 0.5) - M) * ((M - (n * 0.5)) - m)) + (abs((m - n)) - l))); end tmp_2 = tmp; end
code[K_, m_, n_, M_, l_] := If[LessEqual[m, -20000000000000.0], N[(N[Cos[M], $MachinePrecision] * N[Exp[N[(N[Power[m, 2.0], $MachinePrecision] * -0.25), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(N[Cos[M], $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] + N[(N[Abs[N[(m - n), $MachinePrecision]], $MachinePrecision] - l), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;m \leq -20000000000000:\\
\;\;\;\;\cos M \cdot e^{{m}^{2} \cdot -0.25}\\
\mathbf{else}:\\
\;\;\;\;\cos M \cdot e^{\left(n \cdot 0.5 - M\right) \cdot \left(\left(M - n \cdot 0.5\right) - m\right) + \left(\left|m - n\right| - \ell\right)}\\
\end{array}
\end{array}
if m < -2e13Initial program 78.7%
Taylor expanded in K around 0 100.0%
cos-neg100.0%
Simplified100.0%
Taylor expanded in n around 0 72.3%
+-commutative72.3%
unpow272.3%
distribute-rgt-out82.2%
*-commutative82.2%
*-commutative82.2%
Simplified82.2%
Taylor expanded in M around 0 77.4%
*-commutative77.4%
Simplified77.4%
Taylor expanded in m around inf 100.0%
*-commutative100.0%
Simplified100.0%
if -2e13 < m Initial program 80.5%
Taylor expanded in K around 0 99.5%
cos-neg99.5%
Simplified99.5%
Taylor expanded in m around 0 85.3%
+-commutative71.4%
unpow271.4%
distribute-rgt-out75.0%
*-commutative75.0%
*-commutative75.0%
Simplified89.9%
Final simplification92.3%
(FPCore (K m n M l) :precision binary64 (if (or (<= M -102000000.0) (not (<= M 0.152))) (* (cos M) (exp (- (pow M 2.0)))) (* (cos M) (exp (- (- m n) l)))))
double code(double K, double m, double n, double M, double l) {
double tmp;
if ((M <= -102000000.0) || !(M <= 0.152)) {
tmp = cos(M) * exp(-pow(M, 2.0));
} 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 ((m_1 <= (-102000000.0d0)) .or. (.not. (m_1 <= 0.152d0))) then
tmp = cos(m_1) * exp(-(m_1 ** 2.0d0))
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 ((M <= -102000000.0) || !(M <= 0.152)) {
tmp = Math.cos(M) * Math.exp(-Math.pow(M, 2.0));
} else {
tmp = Math.cos(M) * Math.exp(((m - n) - l));
}
return tmp;
}
def code(K, m, n, M, l): tmp = 0 if (M <= -102000000.0) or not (M <= 0.152): tmp = math.cos(M) * math.exp(-math.pow(M, 2.0)) else: tmp = math.cos(M) * math.exp(((m - n) - l)) return tmp
function code(K, m, n, M, l) tmp = 0.0 if ((M <= -102000000.0) || !(M <= 0.152)) tmp = Float64(cos(M) * exp(Float64(-(M ^ 2.0)))); else tmp = Float64(cos(M) * exp(Float64(Float64(m - n) - l))); end return tmp end
function tmp_2 = code(K, m, n, M, l) tmp = 0.0; if ((M <= -102000000.0) || ~((M <= 0.152))) tmp = cos(M) * exp(-(M ^ 2.0)); else tmp = cos(M) * exp(((m - n) - l)); end tmp_2 = tmp; end
code[K_, m_, n_, M_, l_] := If[Or[LessEqual[M, -102000000.0], N[Not[LessEqual[M, 0.152]], $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] - l), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;M \leq -102000000 \lor \neg \left(M \leq 0.152\right):\\
\;\;\;\;\cos M \cdot e^{-{M}^{2}}\\
\mathbf{else}:\\
\;\;\;\;\cos M \cdot e^{\left(m - n\right) - \ell}\\
\end{array}
\end{array}
if M < -1.02e8 or 0.151999999999999996 < M Initial program 81.6%
Taylor expanded in K around 0 100.0%
cos-neg100.0%
Simplified100.0%
Taylor expanded in m around 0 80.9%
+-commutative66.4%
unpow266.4%
distribute-rgt-out76.9%
*-commutative76.9%
*-commutative76.9%
Simplified93.7%
Taylor expanded in M around inf 100.0%
mul-1-neg100.0%
Simplified100.0%
if -1.02e8 < M < 0.151999999999999996Initial program 78.6%
Taylor expanded in K around 0 99.2%
cos-neg99.2%
Simplified99.2%
Taylor expanded in n around 0 65.1%
+-commutative65.1%
unpow265.1%
distribute-rgt-out67.4%
*-commutative67.4%
*-commutative67.4%
Simplified67.4%
Taylor expanded in M around 0 67.4%
*-commutative67.4%
Simplified67.4%
Taylor expanded in m around 0 35.1%
fabs-sub35.1%
sub-neg35.1%
mul-1-neg35.1%
fabs-neg35.1%
fabs-neg35.1%
mul-1-neg35.1%
sub-neg35.1%
fabs-sub35.1%
unpow135.1%
sqr-pow17.3%
fabs-sqr17.3%
sqr-pow65.0%
unpow165.0%
Simplified65.0%
Final simplification82.1%
(FPCore (K m n M l) :precision binary64 (if (or (<= M -1.7e+119) (not (<= M 7e+37))) (* (cos M) (exp (* M (+ n (- m M))))) (* (cos M) (exp (- (- m n) l)))))
double code(double K, double m, double n, double M, double l) {
double tmp;
if ((M <= -1.7e+119) || !(M <= 7e+37)) {
tmp = cos(M) * exp((M * (n + (m - 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 ((m_1 <= (-1.7d+119)) .or. (.not. (m_1 <= 7d+37))) then
tmp = cos(m_1) * exp((m_1 * (n + (m - 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 ((M <= -1.7e+119) || !(M <= 7e+37)) {
tmp = Math.cos(M) * Math.exp((M * (n + (m - M))));
} else {
tmp = Math.cos(M) * Math.exp(((m - n) - l));
}
return tmp;
}
def code(K, m, n, M, l): tmp = 0 if (M <= -1.7e+119) or not (M <= 7e+37): tmp = math.cos(M) * math.exp((M * (n + (m - M)))) else: tmp = math.cos(M) * math.exp(((m - n) - l)) return tmp
function code(K, m, n, M, l) tmp = 0.0 if ((M <= -1.7e+119) || !(M <= 7e+37)) tmp = Float64(cos(M) * exp(Float64(M * Float64(n + Float64(m - M))))); else tmp = Float64(cos(M) * exp(Float64(Float64(m - n) - l))); end return tmp end
function tmp_2 = code(K, m, n, M, l) tmp = 0.0; if ((M <= -1.7e+119) || ~((M <= 7e+37))) tmp = cos(M) * exp((M * (n + (m - M)))); else tmp = cos(M) * exp(((m - n) - l)); end tmp_2 = tmp; end
code[K_, m_, n_, M_, l_] := If[Or[LessEqual[M, -1.7e+119], N[Not[LessEqual[M, 7e+37]], $MachinePrecision]], N[(N[Cos[M], $MachinePrecision] * N[Exp[N[(M * N[(n + N[(m - M), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(N[Cos[M], $MachinePrecision] * N[Exp[N[(N[(m - n), $MachinePrecision] - l), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;M \leq -1.7 \cdot 10^{+119} \lor \neg \left(M \leq 7 \cdot 10^{+37}\right):\\
\;\;\;\;\cos M \cdot e^{M \cdot \left(n + \left(m - M\right)\right)}\\
\mathbf{else}:\\
\;\;\;\;\cos M \cdot e^{\left(m - n\right) - \ell}\\
\end{array}
\end{array}
if M < -1.70000000000000007e119 or 7e37 < M Initial program 81.1%
Taylor expanded in K around 0 100.0%
cos-neg100.0%
Simplified100.0%
Taylor expanded in m around 0 84.4%
+-commutative68.9%
unpow268.9%
distribute-rgt-out77.8%
*-commutative77.8%
*-commutative77.8%
Simplified96.7%
Taylor expanded in M around -inf 73.4%
+-commutative73.4%
distribute-lft-in71.2%
associate-+l+71.2%
mul-1-neg71.2%
unpow271.2%
distribute-rgt-neg-in71.2%
distribute-lft-in76.8%
sub-neg76.8%
distribute-lft-in88.0%
+-commutative88.0%
associate-+l-88.0%
Simplified88.0%
if -1.70000000000000007e119 < M < 7e37Initial program 79.5%
Taylor expanded in K around 0 99.4%
cos-neg99.4%
Simplified99.4%
Taylor expanded in n around 0 67.1%
+-commutative67.1%
unpow267.1%
distribute-rgt-out70.1%
*-commutative70.1%
*-commutative70.1%
Simplified70.1%
Taylor expanded in M around 0 64.4%
*-commutative64.4%
Simplified64.4%
Taylor expanded in m around 0 30.0%
fabs-sub30.0%
sub-neg30.0%
mul-1-neg30.0%
fabs-neg30.0%
fabs-neg30.0%
mul-1-neg30.0%
sub-neg30.0%
fabs-sub30.0%
unpow130.0%
sqr-pow15.8%
fabs-sqr15.8%
sqr-pow60.1%
unpow160.1%
Simplified60.1%
Final simplification69.9%
(FPCore (K m n M l) :precision binary64 (if (or (<= n -5.3e-45) (not (<= n 0.00062))) (exp (* -0.25 (pow n 2.0))) (* (cos M) (exp (- l)))))
double code(double K, double m, double n, double M, double l) {
double tmp;
if ((n <= -5.3e-45) || !(n <= 0.00062)) {
tmp = exp((-0.25 * pow(n, 2.0)));
} 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 ((n <= (-5.3d-45)) .or. (.not. (n <= 0.00062d0))) then
tmp = exp(((-0.25d0) * (n ** 2.0d0)))
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 ((n <= -5.3e-45) || !(n <= 0.00062)) {
tmp = Math.exp((-0.25 * Math.pow(n, 2.0)));
} else {
tmp = Math.cos(M) * Math.exp(-l);
}
return tmp;
}
def code(K, m, n, M, l): tmp = 0 if (n <= -5.3e-45) or not (n <= 0.00062): tmp = math.exp((-0.25 * math.pow(n, 2.0))) else: tmp = math.cos(M) * math.exp(-l) return tmp
function code(K, m, n, M, l) tmp = 0.0 if ((n <= -5.3e-45) || !(n <= 0.00062)) tmp = exp(Float64(-0.25 * (n ^ 2.0))); 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 ((n <= -5.3e-45) || ~((n <= 0.00062))) tmp = exp((-0.25 * (n ^ 2.0))); else tmp = cos(M) * exp(-l); end tmp_2 = tmp; end
code[K_, m_, n_, M_, l_] := If[Or[LessEqual[n, -5.3e-45], N[Not[LessEqual[n, 0.00062]], $MachinePrecision]], N[Exp[N[(-0.25 * N[Power[n, 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision], N[(N[Cos[M], $MachinePrecision] * N[Exp[(-l)], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;n \leq -5.3 \cdot 10^{-45} \lor \neg \left(n \leq 0.00062\right):\\
\;\;\;\;e^{-0.25 \cdot {n}^{2}}\\
\mathbf{else}:\\
\;\;\;\;\cos M \cdot e^{-\ell}\\
\end{array}
\end{array}
if n < -5.2999999999999997e-45 or 6.2e-4 < n Initial program 75.9%
Taylor expanded in m around 0 56.8%
+-commutative56.8%
unpow256.8%
distribute-rgt-out66.1%
*-commutative66.1%
*-commutative66.1%
Simplified66.1%
Taylor expanded in n around inf 69.7%
*-commutative69.7%
Simplified69.7%
Taylor expanded in n around inf 71.2%
*-commutative71.2%
associate-*l*71.2%
Simplified71.2%
Taylor expanded in K around 0 92.4%
if -5.2999999999999997e-45 < n < 6.2e-4Initial program 85.2%
Taylor expanded in m around 0 67.2%
+-commutative67.2%
unpow267.2%
distribute-rgt-out69.8%
*-commutative69.8%
*-commutative69.8%
Simplified69.8%
Taylor expanded in l around inf 42.5%
mul-1-neg42.5%
Simplified42.5%
Taylor expanded in K around 0 47.9%
cos-neg99.1%
Simplified47.9%
Final simplification72.4%
(FPCore (K m n M l) :precision binary64 (if (<= n -2.9e-129) (* (cos M) (exp (* (* m n) -0.5))) (if (<= n 0.00062) (* (cos M) (exp (- l))) (exp (* -0.25 (pow n 2.0))))))
double code(double K, double m, double n, double M, double l) {
double tmp;
if (n <= -2.9e-129) {
tmp = cos(M) * exp(((m * n) * -0.5));
} else if (n <= 0.00062) {
tmp = cos(M) * exp(-l);
} else {
tmp = exp((-0.25 * pow(n, 2.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) :: tmp
if (n <= (-2.9d-129)) then
tmp = cos(m_1) * exp(((m * n) * (-0.5d0)))
else if (n <= 0.00062d0) then
tmp = cos(m_1) * exp(-l)
else
tmp = exp(((-0.25d0) * (n ** 2.0d0)))
end if
code = tmp
end function
public static double code(double K, double m, double n, double M, double l) {
double tmp;
if (n <= -2.9e-129) {
tmp = Math.cos(M) * Math.exp(((m * n) * -0.5));
} else if (n <= 0.00062) {
tmp = Math.cos(M) * Math.exp(-l);
} else {
tmp = Math.exp((-0.25 * Math.pow(n, 2.0)));
}
return tmp;
}
def code(K, m, n, M, l): tmp = 0 if n <= -2.9e-129: tmp = math.cos(M) * math.exp(((m * n) * -0.5)) elif n <= 0.00062: tmp = math.cos(M) * math.exp(-l) else: tmp = math.exp((-0.25 * math.pow(n, 2.0))) return tmp
function code(K, m, n, M, l) tmp = 0.0 if (n <= -2.9e-129) tmp = Float64(cos(M) * exp(Float64(Float64(m * n) * -0.5))); elseif (n <= 0.00062) tmp = Float64(cos(M) * exp(Float64(-l))); else tmp = exp(Float64(-0.25 * (n ^ 2.0))); end return tmp end
function tmp_2 = code(K, m, n, M, l) tmp = 0.0; if (n <= -2.9e-129) tmp = cos(M) * exp(((m * n) * -0.5)); elseif (n <= 0.00062) tmp = cos(M) * exp(-l); else tmp = exp((-0.25 * (n ^ 2.0))); end tmp_2 = tmp; end
code[K_, m_, n_, M_, l_] := If[LessEqual[n, -2.9e-129], N[(N[Cos[M], $MachinePrecision] * N[Exp[N[(N[(m * n), $MachinePrecision] * -0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[n, 0.00062], N[(N[Cos[M], $MachinePrecision] * N[Exp[(-l)], $MachinePrecision]), $MachinePrecision], N[Exp[N[(-0.25 * N[Power[n, 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;n \leq -2.9 \cdot 10^{-129}:\\
\;\;\;\;\cos M \cdot e^{\left(m \cdot n\right) \cdot -0.5}\\
\mathbf{elif}\;n \leq 0.00062:\\
\;\;\;\;\cos M \cdot e^{-\ell}\\
\mathbf{else}:\\
\;\;\;\;e^{-0.25 \cdot {n}^{2}}\\
\end{array}
\end{array}
if n < -2.90000000000000017e-129Initial program 77.7%
Taylor expanded in K around 0 100.0%
cos-neg100.0%
Simplified100.0%
Taylor expanded in n around 0 62.1%
+-commutative62.1%
unpow262.1%
distribute-rgt-out67.5%
*-commutative67.5%
*-commutative67.5%
Simplified67.5%
Taylor expanded in M around 0 48.8%
*-commutative48.8%
Simplified48.8%
Taylor expanded in n around inf 29.4%
*-commutative29.4%
Simplified29.4%
if -2.90000000000000017e-129 < n < 6.2e-4Initial program 85.4%
Taylor expanded in m around 0 66.9%
+-commutative66.9%
unpow266.9%
distribute-rgt-out70.0%
*-commutative70.0%
*-commutative70.0%
Simplified70.0%
Taylor expanded in l around inf 42.3%
mul-1-neg42.3%
Simplified42.3%
Taylor expanded in K around 0 48.8%
cos-neg99.0%
Simplified48.8%
if 6.2e-4 < n Initial program 75.8%
Taylor expanded in m around 0 50.1%
+-commutative50.1%
unpow250.1%
distribute-rgt-out62.3%
*-commutative62.3%
*-commutative62.3%
Simplified62.3%
Taylor expanded in n around inf 75.8%
*-commutative75.8%
Simplified75.8%
Taylor expanded in n around inf 78.8%
*-commutative78.8%
associate-*l*78.8%
Simplified78.8%
Taylor expanded in K around 0 100.0%
Final simplification54.9%
(FPCore (K m n M l) :precision binary64 (if (<= n 4e+47) (* (cos M) (exp (- (- m n) l))) (exp (* -0.25 (pow n 2.0)))))
double code(double K, double m, double n, double M, double l) {
double tmp;
if (n <= 4e+47) {
tmp = cos(M) * exp(((m - n) - l));
} else {
tmp = exp((-0.25 * pow(n, 2.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) :: tmp
if (n <= 4d+47) then
tmp = cos(m_1) * exp(((m - n) - l))
else
tmp = exp(((-0.25d0) * (n ** 2.0d0)))
end if
code = tmp
end function
public static double code(double K, double m, double n, double M, double l) {
double tmp;
if (n <= 4e+47) {
tmp = Math.cos(M) * Math.exp(((m - n) - l));
} else {
tmp = Math.exp((-0.25 * Math.pow(n, 2.0)));
}
return tmp;
}
def code(K, m, n, M, l): tmp = 0 if n <= 4e+47: tmp = math.cos(M) * math.exp(((m - n) - l)) else: tmp = math.exp((-0.25 * math.pow(n, 2.0))) return tmp
function code(K, m, n, M, l) tmp = 0.0 if (n <= 4e+47) tmp = Float64(cos(M) * exp(Float64(Float64(m - n) - l))); else tmp = exp(Float64(-0.25 * (n ^ 2.0))); end return tmp end
function tmp_2 = code(K, m, n, M, l) tmp = 0.0; if (n <= 4e+47) tmp = cos(M) * exp(((m - n) - l)); else tmp = exp((-0.25 * (n ^ 2.0))); end tmp_2 = tmp; end
code[K_, m_, n_, M_, l_] := If[LessEqual[n, 4e+47], N[(N[Cos[M], $MachinePrecision] * N[Exp[N[(N[(m - n), $MachinePrecision] - l), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[Exp[N[(-0.25 * N[Power[n, 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;n \leq 4 \cdot 10^{+47}:\\
\;\;\;\;\cos M \cdot e^{\left(m - n\right) - \ell}\\
\mathbf{else}:\\
\;\;\;\;e^{-0.25 \cdot {n}^{2}}\\
\end{array}
\end{array}
if n < 4.0000000000000002e47Initial program 82.1%
Taylor expanded in K around 0 99.5%
cos-neg99.5%
Simplified99.5%
Taylor expanded in n around 0 81.1%
+-commutative81.1%
unpow281.1%
distribute-rgt-out83.7%
*-commutative83.7%
*-commutative83.7%
Simplified83.7%
Taylor expanded in M around 0 61.7%
*-commutative61.7%
Simplified61.7%
Taylor expanded in m around 0 31.4%
fabs-sub31.4%
sub-neg31.4%
mul-1-neg31.4%
fabs-neg31.4%
fabs-neg31.4%
mul-1-neg31.4%
sub-neg31.4%
fabs-sub31.4%
unpow131.4%
sqr-pow17.4%
fabs-sqr17.4%
sqr-pow43.4%
unpow143.4%
Simplified43.4%
if 4.0000000000000002e47 < n Initial program 73.8%
Taylor expanded in m around 0 49.3%
+-commutative49.3%
unpow249.3%
distribute-rgt-out60.9%
*-commutative60.9%
*-commutative60.9%
Simplified60.9%
Taylor expanded in n around inf 73.8%
*-commutative73.8%
Simplified73.8%
Taylor expanded in n around inf 77.0%
*-commutative77.0%
associate-*l*77.0%
Simplified77.0%
Taylor expanded in K around 0 100.0%
Final simplification56.9%
(FPCore (K m n M l) :precision binary64 (* (cos M) (exp (- l))))
double code(double K, double m, double n, double M, double l) {
return cos(M) * exp(-l);
}
real(8) function code(k, m, n, m_1, l)
real(8), intent (in) :: k
real(8), intent (in) :: m
real(8), intent (in) :: n
real(8), intent (in) :: m_1
real(8), intent (in) :: l
code = cos(m_1) * exp(-l)
end function
public static double code(double K, double m, double n, double M, double l) {
return Math.cos(M) * Math.exp(-l);
}
def code(K, m, n, M, l): return math.cos(M) * math.exp(-l)
function code(K, m, n, M, l) return Float64(cos(M) * exp(Float64(-l))) end
function tmp = code(K, m, n, M, l) tmp = cos(M) * exp(-l); end
code[K_, m_, n_, M_, l_] := N[(N[Cos[M], $MachinePrecision] * N[Exp[(-l)], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\cos M \cdot e^{-\ell}
\end{array}
Initial program 80.1%
Taylor expanded in m around 0 61.5%
+-commutative61.5%
unpow261.5%
distribute-rgt-out67.8%
*-commutative67.8%
*-commutative67.8%
Simplified67.8%
Taylor expanded in l around inf 30.5%
mul-1-neg30.5%
Simplified30.5%
Taylor expanded in K around 0 36.7%
cos-neg99.6%
Simplified36.7%
Final simplification36.7%
herbie shell --seed 2024052
(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)))))))