
(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 8 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 (- n m)) (+ 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((n - m)) - (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((n - m)) - (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((n - m)) - (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((n - m)) - (l + math.pow((((m + n) / 2.0) - M), 2.0))))
function code(K, m, n, M, l) return Float64(cos(M) * exp(Float64(abs(Float64(n - m)) - Float64(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((n - m)) - (l + ((((m + n) / 2.0) - M) ^ 2.0)))); end
code[K_, m_, n_, M_, l_] := N[(N[Cos[M], $MachinePrecision] * N[Exp[N[(N[Abs[N[(n - m), $MachinePrecision]], $MachinePrecision] - N[(l + N[Power[N[(N[(N[(m + n), $MachinePrecision] / 2.0), $MachinePrecision] - M), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\cos M \cdot e^{\left|n - m\right| - \left(\ell + {\left(\frac{m + n}{2} - M\right)}^{2}\right)}
\end{array}
Initial program 76.6%
associate-/l*77.0%
+-commutative77.0%
associate-/l*76.6%
associate-/l*77.0%
+-commutative77.0%
exp-diff28.5%
sub-neg28.5%
exp-sum21.5%
associate-/r*21.5%
exp-diff26.6%
Simplified77.0%
Taylor expanded in K around 0 97.1%
cos-neg97.1%
Simplified97.1%
Final simplification97.1%
(FPCore (K m n M l)
:precision binary64
(let* ((t_0 (- M (* m 0.5))))
(if (<= n -2.55e-132)
(* (cos M) (exp (* -0.25 (pow m 2.0))))
(if (<= n 140000.0)
(*
(cos (- (* (/ (+ m n) 2.0) K) M))
(exp (- (fabs (- n m)) (+ l (* t_0 (- t_0 n))))))
(exp (* -0.25 (pow n 2.0)))))))
double code(double K, double m, double n, double M, double l) {
double t_0 = M - (m * 0.5);
double tmp;
if (n <= -2.55e-132) {
tmp = cos(M) * exp((-0.25 * pow(m, 2.0)));
} else if (n <= 140000.0) {
tmp = cos(((((m + n) / 2.0) * K) - M)) * exp((fabs((n - m)) - (l + (t_0 * (t_0 - n)))));
} 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) :: t_0
real(8) :: tmp
t_0 = m_1 - (m * 0.5d0)
if (n <= (-2.55d-132)) then
tmp = cos(m_1) * exp(((-0.25d0) * (m ** 2.0d0)))
else if (n <= 140000.0d0) then
tmp = cos(((((m + n) / 2.0d0) * k) - m_1)) * exp((abs((n - m)) - (l + (t_0 * (t_0 - n)))))
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 t_0 = M - (m * 0.5);
double tmp;
if (n <= -2.55e-132) {
tmp = Math.cos(M) * Math.exp((-0.25 * Math.pow(m, 2.0)));
} else if (n <= 140000.0) {
tmp = Math.cos(((((m + n) / 2.0) * K) - M)) * Math.exp((Math.abs((n - m)) - (l + (t_0 * (t_0 - n)))));
} else {
tmp = Math.exp((-0.25 * Math.pow(n, 2.0)));
}
return tmp;
}
def code(K, m, n, M, l): t_0 = M - (m * 0.5) tmp = 0 if n <= -2.55e-132: tmp = math.cos(M) * math.exp((-0.25 * math.pow(m, 2.0))) elif n <= 140000.0: tmp = math.cos(((((m + n) / 2.0) * K) - M)) * math.exp((math.fabs((n - m)) - (l + (t_0 * (t_0 - n))))) else: tmp = math.exp((-0.25 * math.pow(n, 2.0))) return tmp
function code(K, m, n, M, l) t_0 = Float64(M - Float64(m * 0.5)) tmp = 0.0 if (n <= -2.55e-132) tmp = Float64(cos(M) * exp(Float64(-0.25 * (m ^ 2.0)))); elseif (n <= 140000.0) tmp = Float64(cos(Float64(Float64(Float64(Float64(m + n) / 2.0) * K) - M)) * exp(Float64(abs(Float64(n - m)) - Float64(l + Float64(t_0 * Float64(t_0 - n)))))); else tmp = exp(Float64(-0.25 * (n ^ 2.0))); end return tmp end
function tmp_2 = code(K, m, n, M, l) t_0 = M - (m * 0.5); tmp = 0.0; if (n <= -2.55e-132) tmp = cos(M) * exp((-0.25 * (m ^ 2.0))); elseif (n <= 140000.0) tmp = cos(((((m + n) / 2.0) * K) - M)) * exp((abs((n - m)) - (l + (t_0 * (t_0 - n))))); else tmp = exp((-0.25 * (n ^ 2.0))); end tmp_2 = tmp; end
code[K_, m_, n_, M_, l_] := Block[{t$95$0 = N[(M - N[(m * 0.5), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[n, -2.55e-132], N[(N[Cos[M], $MachinePrecision] * N[Exp[N[(-0.25 * N[Power[m, 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[n, 140000.0], N[(N[Cos[N[(N[(N[(N[(m + n), $MachinePrecision] / 2.0), $MachinePrecision] * K), $MachinePrecision] - M), $MachinePrecision]], $MachinePrecision] * N[Exp[N[(N[Abs[N[(n - m), $MachinePrecision]], $MachinePrecision] - N[(l + N[(t$95$0 * N[(t$95$0 - n), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[Exp[N[(-0.25 * N[Power[n, 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := M - m \cdot 0.5\\
\mathbf{if}\;n \leq -2.55 \cdot 10^{-132}:\\
\;\;\;\;\cos M \cdot e^{-0.25 \cdot {m}^{2}}\\
\mathbf{elif}\;n \leq 140000:\\
\;\;\;\;\cos \left(\frac{m + n}{2} \cdot K - M\right) \cdot e^{\left|n - m\right| - \left(\ell + t\_0 \cdot \left(t\_0 - n\right)\right)}\\
\mathbf{else}:\\
\;\;\;\;e^{-0.25 \cdot {n}^{2}}\\
\end{array}
\end{array}
if n < -2.55000000000000003e-132Initial program 71.6%
associate-/l*72.7%
+-commutative72.7%
associate-/l*71.6%
associate-/l*72.7%
+-commutative72.7%
exp-diff25.6%
sub-neg25.6%
exp-sum14.1%
associate-/r*14.1%
exp-diff17.5%
Simplified72.7%
Taylor expanded in K around 0 97.9%
cos-neg97.9%
Simplified97.9%
Taylor expanded in m around inf 64.5%
if -2.55000000000000003e-132 < n < 1.4e5Initial program 86.7%
associate-/l*86.7%
+-commutative86.7%
associate-/l*86.7%
associate-/l*86.7%
+-commutative86.7%
exp-diff41.5%
sub-neg41.5%
exp-sum37.2%
associate-/r*37.2%
exp-diff44.1%
Simplified86.7%
Taylor expanded in n around 0 86.7%
+-commutative86.7%
unpow286.7%
distribute-rgt-out86.7%
*-commutative86.7%
*-commutative86.7%
Simplified86.7%
if 1.4e5 < n Initial program 63.0%
associate-/l*63.0%
+-commutative63.0%
associate-/l*63.0%
associate-/l*63.0%
+-commutative63.0%
exp-diff5.6%
sub-neg5.6%
exp-sum0.0%
associate-/r*0.0%
exp-diff3.7%
Simplified63.0%
Taylor expanded in K around 0 96.3%
cos-neg96.3%
Simplified96.3%
Taylor expanded in n around inf 96.4%
Taylor expanded in M around 0 96.4%
Final simplification81.2%
(FPCore (K m n M l)
:precision binary64
(if (<= m -20000000000.0)
(* (cos M) (exp (* -0.25 (pow m 2.0))))
(if (<= m 4.7e-32)
(*
(cos (- (* (/ (+ m n) 2.0) K) M))
(exp (+ (fabs (- n m)) (- (* (- (* n 0.5) M) (- (- M (* n 0.5)) m)) l))))
(exp (* -0.25 (pow n 2.0))))))
double code(double K, double m, double n, double M, double l) {
double tmp;
if (m <= -20000000000.0) {
tmp = cos(M) * exp((-0.25 * pow(m, 2.0)));
} else if (m <= 4.7e-32) {
tmp = cos(((((m + n) / 2.0) * K) - M)) * exp((fabs((n - m)) + ((((n * 0.5) - M) * ((M - (n * 0.5)) - m)) - 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 (m <= (-20000000000.0d0)) then
tmp = cos(m_1) * exp(((-0.25d0) * (m ** 2.0d0)))
else if (m <= 4.7d-32) then
tmp = cos(((((m + n) / 2.0d0) * k) - m_1)) * exp((abs((n - m)) + ((((n * 0.5d0) - m_1) * ((m_1 - (n * 0.5d0)) - m)) - 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 (m <= -20000000000.0) {
tmp = Math.cos(M) * Math.exp((-0.25 * Math.pow(m, 2.0)));
} else if (m <= 4.7e-32) {
tmp = Math.cos(((((m + n) / 2.0) * K) - M)) * Math.exp((Math.abs((n - m)) + ((((n * 0.5) - M) * ((M - (n * 0.5)) - m)) - l)));
} else {
tmp = Math.exp((-0.25 * Math.pow(n, 2.0)));
}
return tmp;
}
def code(K, m, n, M, l): tmp = 0 if m <= -20000000000.0: tmp = math.cos(M) * math.exp((-0.25 * math.pow(m, 2.0))) elif m <= 4.7e-32: tmp = math.cos(((((m + n) / 2.0) * K) - M)) * math.exp((math.fabs((n - m)) + ((((n * 0.5) - M) * ((M - (n * 0.5)) - m)) - 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 (m <= -20000000000.0) tmp = Float64(cos(M) * exp(Float64(-0.25 * (m ^ 2.0)))); elseif (m <= 4.7e-32) tmp = Float64(cos(Float64(Float64(Float64(Float64(m + n) / 2.0) * K) - M)) * exp(Float64(abs(Float64(n - m)) + Float64(Float64(Float64(Float64(n * 0.5) - M) * Float64(Float64(M - Float64(n * 0.5)) - m)) - 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 (m <= -20000000000.0) tmp = cos(M) * exp((-0.25 * (m ^ 2.0))); elseif (m <= 4.7e-32) tmp = cos(((((m + n) / 2.0) * K) - M)) * exp((abs((n - m)) + ((((n * 0.5) - M) * ((M - (n * 0.5)) - m)) - l))); else tmp = exp((-0.25 * (n ^ 2.0))); end tmp_2 = tmp; end
code[K_, m_, n_, M_, l_] := If[LessEqual[m, -20000000000.0], N[(N[Cos[M], $MachinePrecision] * N[Exp[N[(-0.25 * N[Power[m, 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[m, 4.7e-32], N[(N[Cos[N[(N[(N[(N[(m + n), $MachinePrecision] / 2.0), $MachinePrecision] * K), $MachinePrecision] - M), $MachinePrecision]], $MachinePrecision] * N[Exp[N[(N[Abs[N[(n - m), $MachinePrecision]], $MachinePrecision] + N[(N[(N[(N[(n * 0.5), $MachinePrecision] - M), $MachinePrecision] * N[(N[(M - N[(n * 0.5), $MachinePrecision]), $MachinePrecision] - m), $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}\;m \leq -20000000000:\\
\;\;\;\;\cos M \cdot e^{-0.25 \cdot {m}^{2}}\\
\mathbf{elif}\;m \leq 4.7 \cdot 10^{-32}:\\
\;\;\;\;\cos \left(\frac{m + n}{2} \cdot K - M\right) \cdot e^{\left|n - m\right| + \left(\left(n \cdot 0.5 - M\right) \cdot \left(\left(M - n \cdot 0.5\right) - m\right) - \ell\right)}\\
\mathbf{else}:\\
\;\;\;\;e^{-0.25 \cdot {n}^{2}}\\
\end{array}
\end{array}
if m < -2e10Initial program 65.6%
associate-/l*65.6%
+-commutative65.6%
associate-/l*65.6%
associate-/l*65.6%
+-commutative65.6%
exp-diff6.3%
sub-neg6.3%
exp-sum0.0%
associate-/r*0.0%
exp-diff0.0%
Simplified65.6%
Taylor expanded in K around 0 100.0%
cos-neg100.0%
Simplified100.0%
Taylor expanded in m around inf 98.5%
if -2e10 < m < 4.70000000000000019e-32Initial program 84.1%
associate-/l*85.1%
+-commutative85.1%
associate-/l*84.1%
associate-/l*85.1%
+-commutative85.1%
exp-diff55.1%
sub-neg55.1%
exp-sum49.5%
associate-/r*49.5%
exp-diff58.9%
Simplified85.1%
Taylor expanded in m around 0 85.1%
+-commutative85.1%
unpow285.1%
distribute-rgt-out85.1%
*-commutative85.1%
*-commutative85.1%
Simplified85.1%
if 4.70000000000000019e-32 < m Initial program 75.3%
associate-/l*75.3%
+-commutative75.3%
associate-/l*75.3%
associate-/l*75.3%
+-commutative75.3%
exp-diff11.8%
sub-neg11.8%
exp-sum2.4%
associate-/r*2.4%
exp-diff5.9%
Simplified75.3%
Taylor expanded in K around 0 98.8%
cos-neg98.8%
Simplified98.8%
Taylor expanded in n around inf 48.7%
Taylor expanded in M around 0 48.7%
Final simplification76.3%
(FPCore (K m n M l)
:precision binary64
(let* ((t_0 (* (cos M) (exp (- (pow M 2.0))))))
(if (<= M -27.0)
t_0
(if (<= M 1.4e-187)
(exp (* -0.25 (pow n 2.0)))
(if (<= M 72000000000.0) (/ (cos M) (exp l)) t_0)))))
double code(double K, double m, double n, double M, double l) {
double t_0 = cos(M) * exp(-pow(M, 2.0));
double tmp;
if (M <= -27.0) {
tmp = t_0;
} else if (M <= 1.4e-187) {
tmp = exp((-0.25 * pow(n, 2.0)));
} else if (M <= 72000000000.0) {
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 ** 2.0d0))
if (m_1 <= (-27.0d0)) then
tmp = t_0
else if (m_1 <= 1.4d-187) then
tmp = exp(((-0.25d0) * (n ** 2.0d0)))
else if (m_1 <= 72000000000.0d0) 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(-Math.pow(M, 2.0));
double tmp;
if (M <= -27.0) {
tmp = t_0;
} else if (M <= 1.4e-187) {
tmp = Math.exp((-0.25 * Math.pow(n, 2.0)));
} else if (M <= 72000000000.0) {
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(-math.pow(M, 2.0)) tmp = 0 if M <= -27.0: tmp = t_0 elif M <= 1.4e-187: tmp = math.exp((-0.25 * math.pow(n, 2.0))) elif M <= 72000000000.0: 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 ^ 2.0)))) tmp = 0.0 if (M <= -27.0) tmp = t_0; elseif (M <= 1.4e-187) tmp = exp(Float64(-0.25 * (n ^ 2.0))); elseif (M <= 72000000000.0) tmp = Float64(cos(M) / exp(l)); else tmp = t_0; end return tmp end
function tmp_2 = code(K, m, n, M, l) t_0 = cos(M) * exp(-(M ^ 2.0)); tmp = 0.0; if (M <= -27.0) tmp = t_0; elseif (M <= 1.4e-187) tmp = exp((-0.25 * (n ^ 2.0))); elseif (M <= 72000000000.0) 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[Power[M, 2.0], $MachinePrecision])], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[M, -27.0], t$95$0, If[LessEqual[M, 1.4e-187], N[Exp[N[(-0.25 * N[Power[n, 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision], If[LessEqual[M, 72000000000.0], 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}^{2}}\\
\mathbf{if}\;M \leq -27:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;M \leq 1.4 \cdot 10^{-187}:\\
\;\;\;\;e^{-0.25 \cdot {n}^{2}}\\
\mathbf{elif}\;M \leq 72000000000:\\
\;\;\;\;\frac{\cos M}{e^{\ell}}\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if M < -27 or 7.2e10 < M Initial program 74.2%
associate-/l*75.0%
+-commutative75.0%
associate-/l*74.2%
associate-/l*75.0%
+-commutative75.0%
exp-diff24.2%
sub-neg24.2%
exp-sum16.9%
associate-/r*16.9%
exp-diff23.4%
Simplified75.0%
Taylor expanded in K around 0 99.2%
cos-neg99.2%
Simplified99.2%
Taylor expanded in M around inf 97.6%
mul-1-neg97.6%
Simplified97.6%
if -27 < M < 1.4e-187Initial program 81.1%
associate-/l*81.1%
+-commutative81.1%
associate-/l*81.1%
associate-/l*81.1%
+-commutative81.1%
exp-diff29.4%
sub-neg29.4%
exp-sum23.6%
associate-/r*23.6%
exp-diff25.9%
Simplified81.1%
Taylor expanded in K around 0 95.6%
cos-neg95.6%
Simplified95.6%
Taylor expanded in n around inf 57.8%
Taylor expanded in M around 0 57.8%
if 1.4e-187 < M < 7.2e10Initial program 74.3%
associate-/l*74.3%
+-commutative74.3%
associate-/l*74.3%
associate-/l*74.3%
+-commutative74.3%
exp-diff38.8%
sub-neg38.8%
exp-sum29.9%
associate-/r*29.9%
exp-diff36.6%
Simplified74.3%
add-cbrt-cube49.8%
pow1/340.5%
pow341.0%
associate-*r/41.0%
cube-div41.0%
metadata-eval41.0%
Applied egg-rr41.0%
Taylor expanded in l around inf 38.8%
mul-1-neg38.8%
Simplified38.8%
Taylor expanded in K around 0 59.5%
exp-neg59.5%
associate-*r/59.5%
*-rgt-identity59.5%
cos-neg59.5%
Simplified59.5%
Final simplification77.4%
(FPCore (K m n M l)
:precision binary64
(if (<= n 8.2e-277)
(* (cos M) (exp (* -0.25 (pow m 2.0))))
(if (<= n 6e-209)
(/ (cos M) (exp l))
(if (<= n 88000.0)
(* (cos M) (exp (- (pow M 2.0))))
(exp (* -0.25 (pow n 2.0)))))))
double code(double K, double m, double n, double M, double l) {
double tmp;
if (n <= 8.2e-277) {
tmp = cos(M) * exp((-0.25 * pow(m, 2.0)));
} else if (n <= 6e-209) {
tmp = cos(M) / exp(l);
} else if (n <= 88000.0) {
tmp = cos(M) * exp(-pow(M, 2.0));
} 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 <= 8.2d-277) then
tmp = cos(m_1) * exp(((-0.25d0) * (m ** 2.0d0)))
else if (n <= 6d-209) then
tmp = cos(m_1) / exp(l)
else if (n <= 88000.0d0) then
tmp = cos(m_1) * exp(-(m_1 ** 2.0d0))
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 <= 8.2e-277) {
tmp = Math.cos(M) * Math.exp((-0.25 * Math.pow(m, 2.0)));
} else if (n <= 6e-209) {
tmp = Math.cos(M) / Math.exp(l);
} else if (n <= 88000.0) {
tmp = Math.cos(M) * Math.exp(-Math.pow(M, 2.0));
} else {
tmp = Math.exp((-0.25 * Math.pow(n, 2.0)));
}
return tmp;
}
def code(K, m, n, M, l): tmp = 0 if n <= 8.2e-277: tmp = math.cos(M) * math.exp((-0.25 * math.pow(m, 2.0))) elif n <= 6e-209: tmp = math.cos(M) / math.exp(l) elif n <= 88000.0: tmp = math.cos(M) * math.exp(-math.pow(M, 2.0)) 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 <= 8.2e-277) tmp = Float64(cos(M) * exp(Float64(-0.25 * (m ^ 2.0)))); elseif (n <= 6e-209) tmp = Float64(cos(M) / exp(l)); elseif (n <= 88000.0) tmp = Float64(cos(M) * exp(Float64(-(M ^ 2.0)))); 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 <= 8.2e-277) tmp = cos(M) * exp((-0.25 * (m ^ 2.0))); elseif (n <= 6e-209) tmp = cos(M) / exp(l); elseif (n <= 88000.0) tmp = cos(M) * exp(-(M ^ 2.0)); else tmp = exp((-0.25 * (n ^ 2.0))); end tmp_2 = tmp; end
code[K_, m_, n_, M_, l_] := If[LessEqual[n, 8.2e-277], N[(N[Cos[M], $MachinePrecision] * N[Exp[N[(-0.25 * N[Power[m, 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[n, 6e-209], N[(N[Cos[M], $MachinePrecision] / N[Exp[l], $MachinePrecision]), $MachinePrecision], If[LessEqual[n, 88000.0], N[(N[Cos[M], $MachinePrecision] * N[Exp[(-N[Power[M, 2.0], $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 8.2 \cdot 10^{-277}:\\
\;\;\;\;\cos M \cdot e^{-0.25 \cdot {m}^{2}}\\
\mathbf{elif}\;n \leq 6 \cdot 10^{-209}:\\
\;\;\;\;\frac{\cos M}{e^{\ell}}\\
\mathbf{elif}\;n \leq 88000:\\
\;\;\;\;\cos M \cdot e^{-{M}^{2}}\\
\mathbf{else}:\\
\;\;\;\;e^{-0.25 \cdot {n}^{2}}\\
\end{array}
\end{array}
if n < 8.19999999999999977e-277Initial program 76.2%
associate-/l*76.9%
+-commutative76.9%
associate-/l*76.2%
associate-/l*76.9%
+-commutative76.9%
exp-diff30.2%
sub-neg30.2%
exp-sum21.4%
associate-/r*21.4%
exp-diff26.5%
Simplified76.9%
Taylor expanded in K around 0 97.5%
cos-neg97.5%
Simplified97.5%
Taylor expanded in m around inf 63.7%
if 8.19999999999999977e-277 < n < 5.9999999999999997e-209Initial program 93.8%
associate-/l*93.8%
+-commutative93.8%
associate-/l*93.8%
associate-/l*93.8%
+-commutative93.8%
exp-diff43.8%
sub-neg43.8%
exp-sum43.8%
associate-/r*43.8%
exp-diff50.0%
Simplified93.8%
add-cbrt-cube81.3%
pow1/368.8%
pow368.8%
associate-*r/68.8%
cube-div68.8%
metadata-eval68.8%
Applied egg-rr68.8%
Taylor expanded in l around inf 38.3%
mul-1-neg38.3%
Simplified38.3%
Taylor expanded in K around 0 51.3%
exp-neg51.3%
associate-*r/51.3%
*-rgt-identity51.3%
cos-neg51.3%
Simplified51.3%
if 5.9999999999999997e-209 < n < 88000Initial program 86.6%
associate-/l*86.6%
+-commutative86.6%
associate-/l*86.6%
associate-/l*86.6%
+-commutative86.6%
exp-diff43.5%
sub-neg43.5%
exp-sum37.6%
associate-/r*37.6%
exp-diff43.5%
Simplified86.6%
Taylor expanded in K around 0 96.1%
cos-neg96.1%
Simplified96.1%
Taylor expanded in M around inf 67.6%
mul-1-neg67.6%
Simplified67.6%
if 88000 < n Initial program 63.0%
associate-/l*63.0%
+-commutative63.0%
associate-/l*63.0%
associate-/l*63.0%
+-commutative63.0%
exp-diff5.6%
sub-neg5.6%
exp-sum0.0%
associate-/r*0.0%
exp-diff3.7%
Simplified63.0%
Taylor expanded in K around 0 96.3%
cos-neg96.3%
Simplified96.3%
Taylor expanded in n around inf 96.4%
Taylor expanded in M around 0 96.4%
Final simplification70.6%
(FPCore (K m n M l) :precision binary64 (if (or (<= n -0.0071) (not (<= n 88000.0))) (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 <= -0.0071) || !(n <= 88000.0)) {
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 <= (-0.0071d0)) .or. (.not. (n <= 88000.0d0))) 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 <= -0.0071) || !(n <= 88000.0)) {
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 <= -0.0071) or not (n <= 88000.0): 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 <= -0.0071) || !(n <= 88000.0)) tmp = exp(Float64(-0.25 * (n ^ 2.0))); else tmp = Float64(cos(M) / exp(l)); end return tmp end
function tmp_2 = code(K, m, n, M, l) tmp = 0.0; if ((n <= -0.0071) || ~((n <= 88000.0))) 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, -0.0071], N[Not[LessEqual[n, 88000.0]], $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 -0.0071 \lor \neg \left(n \leq 88000\right):\\
\;\;\;\;e^{-0.25 \cdot {n}^{2}}\\
\mathbf{else}:\\
\;\;\;\;\frac{\cos M}{e^{\ell}}\\
\end{array}
\end{array}
if n < -0.0071000000000000004 or 88000 < n Initial program 63.6%
associate-/l*64.5%
+-commutative64.5%
associate-/l*63.6%
associate-/l*64.5%
+-commutative64.5%
exp-diff7.5%
sub-neg7.5%
exp-sum0.0%
associate-/r*0.0%
exp-diff3.7%
Simplified64.5%
Taylor expanded in K around 0 98.1%
cos-neg98.1%
Simplified98.1%
Taylor expanded in n around inf 95.4%
Taylor expanded in M around 0 95.4%
if -0.0071000000000000004 < n < 88000Initial program 85.9%
associate-/l*85.9%
+-commutative85.9%
associate-/l*85.9%
associate-/l*85.9%
+-commutative85.9%
exp-diff43.6%
sub-neg43.6%
exp-sum36.9%
associate-/r*36.9%
exp-diff43.0%
Simplified85.9%
add-cbrt-cube63.0%
pow1/353.8%
pow353.4%
associate-*r/53.4%
cube-div53.4%
metadata-eval53.4%
Applied egg-rr53.4%
Taylor expanded in l around inf 32.5%
mul-1-neg32.5%
Simplified32.5%
Taylor expanded in K around 0 45.4%
exp-neg45.4%
associate-*r/45.4%
*-rgt-identity45.4%
cos-neg45.4%
Simplified45.4%
Final simplification66.3%
(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(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}
\\
\frac{\cos M}{e^{\ell}}
\end{array}
Initial program 76.6%
associate-/l*77.0%
+-commutative77.0%
associate-/l*76.6%
associate-/l*77.0%
+-commutative77.0%
exp-diff28.5%
sub-neg28.5%
exp-sum21.5%
associate-/r*21.5%
exp-diff26.6%
Simplified77.0%
add-cbrt-cube51.5%
pow1/340.3%
pow340.1%
associate-*r/40.1%
cube-div40.1%
metadata-eval40.1%
Applied egg-rr40.1%
Taylor expanded in l around inf 21.8%
mul-1-neg21.8%
Simplified21.8%
Taylor expanded in K around 0 39.7%
exp-neg39.7%
associate-*r/39.7%
*-rgt-identity39.7%
cos-neg39.7%
Simplified39.7%
Final simplification39.7%
(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 76.6%
associate-/l*77.0%
+-commutative77.0%
associate-/l*76.6%
associate-/l*77.0%
+-commutative77.0%
exp-diff28.5%
sub-neg28.5%
exp-sum21.5%
associate-/r*21.5%
exp-diff26.6%
Simplified77.0%
Taylor expanded in K around 0 97.1%
cos-neg97.1%
Simplified97.1%
Taylor expanded in n around inf 48.7%
Taylor expanded in n around 0 9.3%
Final simplification9.3%
herbie shell --seed 2024059
(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)))))))