
(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 68.3%
Taylor expanded in K around 0 97.0%
cos-neg97.0%
Simplified97.0%
Final simplification97.0%
(FPCore (K m n M l) :precision binary64 (if (or (<= M -0.04) (not (<= M 27.0))) (* (cos M) (exp (* M (- M)))) (* (cos M) (exp (- (- (fabs (- m n)) l) (* (* m m) 0.25))))))
double code(double K, double m, double n, double M, double l) {
double tmp;
if ((M <= -0.04) || !(M <= 27.0)) {
tmp = cos(M) * exp((M * -M));
} else {
tmp = cos(M) * exp(((fabs((m - n)) - l) - ((m * m) * 0.25)));
}
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 <= (-0.04d0)) .or. (.not. (m_1 <= 27.0d0))) then
tmp = cos(m_1) * exp((m_1 * -m_1))
else
tmp = cos(m_1) * exp(((abs((m - n)) - l) - ((m * m) * 0.25d0)))
end if
code = tmp
end function
public static double code(double K, double m, double n, double M, double l) {
double tmp;
if ((M <= -0.04) || !(M <= 27.0)) {
tmp = Math.cos(M) * Math.exp((M * -M));
} else {
tmp = Math.cos(M) * Math.exp(((Math.abs((m - n)) - l) - ((m * m) * 0.25)));
}
return tmp;
}
def code(K, m, n, M, l): tmp = 0 if (M <= -0.04) or not (M <= 27.0): tmp = math.cos(M) * math.exp((M * -M)) else: tmp = math.cos(M) * math.exp(((math.fabs((m - n)) - l) - ((m * m) * 0.25))) return tmp
function code(K, m, n, M, l) tmp = 0.0 if ((M <= -0.04) || !(M <= 27.0)) tmp = Float64(cos(M) * exp(Float64(M * Float64(-M)))); else tmp = Float64(cos(M) * exp(Float64(Float64(abs(Float64(m - n)) - l) - Float64(Float64(m * m) * 0.25)))); end return tmp end
function tmp_2 = code(K, m, n, M, l) tmp = 0.0; if ((M <= -0.04) || ~((M <= 27.0))) tmp = cos(M) * exp((M * -M)); else tmp = cos(M) * exp(((abs((m - n)) - l) - ((m * m) * 0.25))); end tmp_2 = tmp; end
code[K_, m_, n_, M_, l_] := If[Or[LessEqual[M, -0.04], N[Not[LessEqual[M, 27.0]], $MachinePrecision]], N[(N[Cos[M], $MachinePrecision] * N[Exp[N[(M * (-M)), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(N[Cos[M], $MachinePrecision] * N[Exp[N[(N[(N[Abs[N[(m - n), $MachinePrecision]], $MachinePrecision] - l), $MachinePrecision] - N[(N[(m * m), $MachinePrecision] * 0.25), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;M \leq -0.04 \lor \neg \left(M \leq 27\right):\\
\;\;\;\;\cos M \cdot e^{M \cdot \left(-M\right)}\\
\mathbf{else}:\\
\;\;\;\;\cos M \cdot e^{\left(\left|m - n\right| - \ell\right) - \left(m \cdot m\right) \cdot 0.25}\\
\end{array}
\end{array}
if M < -0.0400000000000000008 or 27 < M Initial program 68.2%
Taylor expanded in M around inf 58.1%
unpow258.1%
Simplified58.1%
Taylor expanded in K around 0 59.2%
cos-neg59.2%
+-commutative59.2%
associate-*r*59.2%
sin-neg59.2%
Simplified59.2%
Taylor expanded in K around 0 77.0%
cos-neg77.0%
*-commutative77.0%
cos-neg77.0%
exp-diff27.2%
fabs-sub27.2%
sub-neg27.2%
mul-1-neg27.2%
fabs-neg27.2%
exp-diff77.0%
fabs-neg77.0%
mul-1-neg77.0%
sub-neg77.0%
+-commutative77.0%
unpow277.0%
Simplified77.0%
Taylor expanded in M around inf 99.1%
unpow299.1%
mul-1-neg99.1%
distribute-rgt-neg-in99.1%
Simplified99.1%
if -0.0400000000000000008 < M < 27Initial program 68.3%
Taylor expanded in K around 0 95.5%
cos-neg95.5%
Simplified95.5%
Taylor expanded in m around inf 60.5%
*-commutative60.5%
unpow260.5%
Simplified60.5%
Final simplification76.6%
(FPCore (K m n M l)
:precision binary64
(let* ((t_0 (- (fabs (- m n)) l)))
(if (<= n 2.1e-157)
(* (cos M) (exp (- t_0 (* (* m m) 0.25))))
(if (<= n 6700000000000.0)
(* (cos (* n (* 0.5 K))) (exp (* M (- M))))
(* (cos M) (exp (- t_0 (* 0.25 (* n n)))))))))
double code(double K, double m, double n, double M, double l) {
double t_0 = fabs((m - n)) - l;
double tmp;
if (n <= 2.1e-157) {
tmp = cos(M) * exp((t_0 - ((m * m) * 0.25)));
} else if (n <= 6700000000000.0) {
tmp = cos((n * (0.5 * K))) * exp((M * -M));
} else {
tmp = cos(M) * exp((t_0 - (0.25 * (n * 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)) - l
if (n <= 2.1d-157) then
tmp = cos(m_1) * exp((t_0 - ((m * m) * 0.25d0)))
else if (n <= 6700000000000.0d0) then
tmp = cos((n * (0.5d0 * k))) * exp((m_1 * -m_1))
else
tmp = cos(m_1) * exp((t_0 - (0.25d0 * (n * 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)) - l;
double tmp;
if (n <= 2.1e-157) {
tmp = Math.cos(M) * Math.exp((t_0 - ((m * m) * 0.25)));
} else if (n <= 6700000000000.0) {
tmp = Math.cos((n * (0.5 * K))) * Math.exp((M * -M));
} else {
tmp = Math.cos(M) * Math.exp((t_0 - (0.25 * (n * n))));
}
return tmp;
}
def code(K, m, n, M, l): t_0 = math.fabs((m - n)) - l tmp = 0 if n <= 2.1e-157: tmp = math.cos(M) * math.exp((t_0 - ((m * m) * 0.25))) elif n <= 6700000000000.0: tmp = math.cos((n * (0.5 * K))) * math.exp((M * -M)) else: tmp = math.cos(M) * math.exp((t_0 - (0.25 * (n * n)))) return tmp
function code(K, m, n, M, l) t_0 = Float64(abs(Float64(m - n)) - l) tmp = 0.0 if (n <= 2.1e-157) tmp = Float64(cos(M) * exp(Float64(t_0 - Float64(Float64(m * m) * 0.25)))); elseif (n <= 6700000000000.0) tmp = Float64(cos(Float64(n * Float64(0.5 * K))) * exp(Float64(M * Float64(-M)))); else tmp = Float64(cos(M) * exp(Float64(t_0 - Float64(0.25 * Float64(n * n))))); end return tmp end
function tmp_2 = code(K, m, n, M, l) t_0 = abs((m - n)) - l; tmp = 0.0; if (n <= 2.1e-157) tmp = cos(M) * exp((t_0 - ((m * m) * 0.25))); elseif (n <= 6700000000000.0) tmp = cos((n * (0.5 * K))) * exp((M * -M)); else tmp = cos(M) * exp((t_0 - (0.25 * (n * n)))); end tmp_2 = tmp; end
code[K_, m_, n_, M_, l_] := Block[{t$95$0 = N[(N[Abs[N[(m - n), $MachinePrecision]], $MachinePrecision] - l), $MachinePrecision]}, If[LessEqual[n, 2.1e-157], N[(N[Cos[M], $MachinePrecision] * N[Exp[N[(t$95$0 - N[(N[(m * m), $MachinePrecision] * 0.25), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[n, 6700000000000.0], N[(N[Cos[N[(n * N[(0.5 * K), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * N[Exp[N[(M * (-M)), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(N[Cos[M], $MachinePrecision] * N[Exp[N[(t$95$0 - N[(0.25 * N[(n * n), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left|m - n\right| - \ell\\
\mathbf{if}\;n \leq 2.1 \cdot 10^{-157}:\\
\;\;\;\;\cos M \cdot e^{t_0 - \left(m \cdot m\right) \cdot 0.25}\\
\mathbf{elif}\;n \leq 6700000000000:\\
\;\;\;\;\cos \left(n \cdot \left(0.5 \cdot K\right)\right) \cdot e^{M \cdot \left(-M\right)}\\
\mathbf{else}:\\
\;\;\;\;\cos M \cdot e^{t_0 - 0.25 \cdot \left(n \cdot n\right)}\\
\end{array}
\end{array}
if n < 2.1e-157Initial program 71.1%
Taylor expanded in K around 0 95.7%
cos-neg95.7%
Simplified95.7%
Taylor expanded in m around inf 61.3%
*-commutative61.3%
unpow261.3%
Simplified61.3%
if 2.1e-157 < n < 6.7e12Initial program 69.7%
Taylor expanded in M around inf 59.6%
unpow259.6%
Simplified59.6%
Taylor expanded in M around inf 57.3%
unpow257.3%
mul-1-neg57.3%
distribute-rgt-neg-out57.3%
Simplified57.3%
Taylor expanded in n around inf 80.5%
*-commutative80.5%
associate-*l*80.5%
*-commutative80.5%
Simplified80.5%
if 6.7e12 < n Initial program 60.0%
Taylor expanded in K around 0 100.0%
cos-neg100.0%
Simplified100.0%
Taylor expanded in n around inf 88.5%
*-commutative55.1%
unpow255.1%
Simplified88.5%
Final simplification70.6%
(FPCore (K m n M l)
:precision binary64
(let* ((t_0 (* (cos M) (exp (* M (- M))))))
(if (<= M -1.25e-10)
t_0
(if (<= M -2.1e-231)
(* (cos (- (/ (* (+ m n) K) 2.0) M)) (exp (* n (* n -0.25))))
(if (<= M 2.6e-26) (* (cos M) (exp (- l))) t_0)))))
double code(double K, double m, double n, double M, double l) {
double t_0 = cos(M) * exp((M * -M));
double tmp;
if (M <= -1.25e-10) {
tmp = t_0;
} else if (M <= -2.1e-231) {
tmp = cos(((((m + n) * K) / 2.0) - M)) * exp((n * (n * -0.25)));
} else if (M <= 2.6e-26) {
tmp = cos(M) * exp(-l);
} else {
tmp = 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 = cos(m_1) * exp((m_1 * -m_1))
if (m_1 <= (-1.25d-10)) then
tmp = t_0
else if (m_1 <= (-2.1d-231)) then
tmp = cos(((((m + n) * k) / 2.0d0) - m_1)) * exp((n * (n * (-0.25d0))))
else if (m_1 <= 2.6d-26) then
tmp = cos(m_1) * exp(-l)
else
tmp = 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.cos(M) * Math.exp((M * -M));
double tmp;
if (M <= -1.25e-10) {
tmp = t_0;
} else if (M <= -2.1e-231) {
tmp = Math.cos(((((m + n) * K) / 2.0) - M)) * Math.exp((n * (n * -0.25)));
} else if (M <= 2.6e-26) {
tmp = Math.cos(M) * Math.exp(-l);
} else {
tmp = t_0;
}
return tmp;
}
def code(K, m, n, M, l): t_0 = math.cos(M) * math.exp((M * -M)) tmp = 0 if M <= -1.25e-10: tmp = t_0 elif M <= -2.1e-231: tmp = math.cos(((((m + n) * K) / 2.0) - M)) * math.exp((n * (n * -0.25))) elif M <= 2.6e-26: tmp = math.cos(M) * math.exp(-l) else: tmp = t_0 return tmp
function code(K, m, n, M, l) t_0 = Float64(cos(M) * exp(Float64(M * Float64(-M)))) tmp = 0.0 if (M <= -1.25e-10) tmp = t_0; elseif (M <= -2.1e-231) tmp = Float64(cos(Float64(Float64(Float64(Float64(m + n) * K) / 2.0) - M)) * exp(Float64(n * Float64(n * -0.25)))); elseif (M <= 2.6e-26) tmp = Float64(cos(M) * exp(Float64(-l))); else tmp = t_0; end return tmp end
function tmp_2 = code(K, m, n, M, l) t_0 = cos(M) * exp((M * -M)); tmp = 0.0; if (M <= -1.25e-10) tmp = t_0; elseif (M <= -2.1e-231) tmp = cos(((((m + n) * K) / 2.0) - M)) * exp((n * (n * -0.25))); elseif (M <= 2.6e-26) tmp = cos(M) * exp(-l); else tmp = t_0; end tmp_2 = tmp; end
code[K_, m_, n_, M_, l_] := Block[{t$95$0 = N[(N[Cos[M], $MachinePrecision] * N[Exp[N[(M * (-M)), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[M, -1.25e-10], t$95$0, If[LessEqual[M, -2.1e-231], N[(N[Cos[N[(N[(N[(N[(m + n), $MachinePrecision] * K), $MachinePrecision] / 2.0), $MachinePrecision] - M), $MachinePrecision]], $MachinePrecision] * N[Exp[N[(n * N[(n * -0.25), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[M, 2.6e-26], N[(N[Cos[M], $MachinePrecision] * N[Exp[(-l)], $MachinePrecision]), $MachinePrecision], t$95$0]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos M \cdot e^{M \cdot \left(-M\right)}\\
\mathbf{if}\;M \leq -1.25 \cdot 10^{-10}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;M \leq -2.1 \cdot 10^{-231}:\\
\;\;\;\;\cos \left(\frac{\left(m + n\right) \cdot K}{2} - M\right) \cdot e^{n \cdot \left(n \cdot -0.25\right)}\\
\mathbf{elif}\;M \leq 2.6 \cdot 10^{-26}:\\
\;\;\;\;\cos M \cdot e^{-\ell}\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\end{array}
if M < -1.25000000000000008e-10 or 2.6000000000000001e-26 < M Initial program 68.7%
Taylor expanded in M around inf 55.9%
unpow255.9%
Simplified55.9%
Taylor expanded in K around 0 56.1%
cos-neg56.1%
+-commutative56.1%
associate-*r*56.1%
sin-neg56.1%
Simplified56.1%
Taylor expanded in K around 0 72.6%
cos-neg72.6%
*-commutative72.6%
cos-neg72.6%
exp-diff26.2%
fabs-sub26.2%
sub-neg26.2%
mul-1-neg26.2%
fabs-neg26.2%
exp-diff72.6%
fabs-neg72.6%
mul-1-neg72.6%
sub-neg72.6%
+-commutative72.6%
unpow272.6%
Simplified72.6%
Taylor expanded in M around inf 93.2%
unpow293.2%
mul-1-neg93.2%
distribute-rgt-neg-in93.2%
Simplified93.2%
if -1.25000000000000008e-10 < M < -2.09999999999999989e-231Initial program 63.7%
Taylor expanded in n around inf 45.4%
*-commutative45.4%
unpow245.4%
Simplified45.4%
Taylor expanded in n around inf 41.7%
unpow241.7%
*-commutative41.7%
associate-*l*41.7%
Simplified41.7%
if -2.09999999999999989e-231 < M < 2.6000000000000001e-26Initial program 70.6%
Taylor expanded in M around inf 35.5%
unpow235.5%
Simplified35.5%
Taylor expanded in l around inf 42.7%
mul-1-neg42.7%
Simplified42.7%
Taylor expanded in K around 0 50.8%
*-commutative50.8%
cos-neg50.8%
Simplified50.8%
Final simplification67.9%
(FPCore (K m n M l) :precision binary64 (if (or (<= M -15.0) (not (<= M 2.6e-26))) (* (cos M) (exp (* M (- M)))) (* (cos M) (exp (- l)))))
double code(double K, double m, double n, double M, double l) {
double tmp;
if ((M <= -15.0) || !(M <= 2.6e-26)) {
tmp = cos(M) * exp((M * -M));
} 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 ((m_1 <= (-15.0d0)) .or. (.not. (m_1 <= 2.6d-26))) then
tmp = cos(m_1) * exp((m_1 * -m_1))
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 ((M <= -15.0) || !(M <= 2.6e-26)) {
tmp = Math.cos(M) * Math.exp((M * -M));
} else {
tmp = Math.cos(M) * Math.exp(-l);
}
return tmp;
}
def code(K, m, n, M, l): tmp = 0 if (M <= -15.0) or not (M <= 2.6e-26): tmp = math.cos(M) * math.exp((M * -M)) else: tmp = math.cos(M) * math.exp(-l) return tmp
function code(K, m, n, M, l) tmp = 0.0 if ((M <= -15.0) || !(M <= 2.6e-26)) tmp = Float64(cos(M) * exp(Float64(M * Float64(-M)))); 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 ((M <= -15.0) || ~((M <= 2.6e-26))) tmp = cos(M) * exp((M * -M)); else tmp = cos(M) * exp(-l); end tmp_2 = tmp; end
code[K_, m_, n_, M_, l_] := If[Or[LessEqual[M, -15.0], N[Not[LessEqual[M, 2.6e-26]], $MachinePrecision]], N[(N[Cos[M], $MachinePrecision] * N[Exp[N[(M * (-M)), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(N[Cos[M], $MachinePrecision] * N[Exp[(-l)], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;M \leq -15 \lor \neg \left(M \leq 2.6 \cdot 10^{-26}\right):\\
\;\;\;\;\cos M \cdot e^{M \cdot \left(-M\right)}\\
\mathbf{else}:\\
\;\;\;\;\cos M \cdot e^{-\ell}\\
\end{array}
\end{array}
if M < -15 or 2.6000000000000001e-26 < M Initial program 69.3%
Taylor expanded in M around inf 56.3%
unpow256.3%
Simplified56.3%
Taylor expanded in K around 0 56.5%
cos-neg56.5%
+-commutative56.5%
associate-*r*56.5%
sin-neg56.5%
Simplified56.5%
Taylor expanded in K around 0 73.2%
cos-neg73.2%
*-commutative73.2%
cos-neg73.2%
exp-diff26.5%
fabs-sub26.5%
sub-neg26.5%
mul-1-neg26.5%
fabs-neg26.5%
exp-diff73.2%
fabs-neg73.2%
mul-1-neg73.2%
sub-neg73.2%
+-commutative73.2%
unpow273.2%
Simplified73.2%
Taylor expanded in M around inf 94.0%
unpow294.0%
mul-1-neg94.0%
distribute-rgt-neg-in94.0%
Simplified94.0%
if -15 < M < 2.6000000000000001e-26Initial program 67.5%
Taylor expanded in M around inf 25.9%
unpow225.9%
Simplified25.9%
Taylor expanded in l around inf 32.6%
mul-1-neg32.6%
Simplified32.6%
Taylor expanded in K around 0 41.2%
*-commutative41.2%
cos-neg41.2%
Simplified41.2%
Final simplification64.7%
(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 68.3%
Taylor expanded in M around inf 39.4%
unpow239.4%
Simplified39.4%
Taylor expanded in l around inf 23.8%
mul-1-neg23.8%
Simplified23.8%
Taylor expanded in K around 0 32.0%
*-commutative32.0%
cos-neg32.0%
Simplified32.0%
Final simplification32.0%
herbie shell --seed 2023274
(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)))))))