
(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)) (+ (pow (- (/ (+ m n) 2.0) M) 2.0) l)))))
double code(double K, double m, double n, double M, double l) {
return cos(M) * exp((fabs((n - m)) - (pow((((m + n) / 2.0) - 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((n - m)) - (((((m + n) / 2.0d0) - 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((n - m)) - (Math.pow((((m + n) / 2.0) - M), 2.0) + l)));
}
def code(K, m, n, M, l): return math.cos(M) * math.exp((math.fabs((n - m)) - (math.pow((((m + n) / 2.0) - M), 2.0) + l)))
function code(K, m, n, M, l) return Float64(cos(M) * exp(Float64(abs(Float64(n - m)) - Float64((Float64(Float64(Float64(m + n) / 2.0) - M) ^ 2.0) + l)))) end
function tmp = code(K, m, n, M, l) tmp = cos(M) * exp((abs((n - m)) - (((((m + n) / 2.0) - M) ^ 2.0) + l))); end
code[K_, m_, n_, M_, l_] := N[(N[Cos[M], $MachinePrecision] * N[Exp[N[(N[Abs[N[(n - m), $MachinePrecision]], $MachinePrecision] - N[(N[Power[N[(N[(N[(m + n), $MachinePrecision] / 2.0), $MachinePrecision] - M), $MachinePrecision], 2.0], $MachinePrecision] + l), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\cos M \cdot e^{\left|n - m\right| - \left({\left(\frac{m + n}{2} - M\right)}^{2} + \ell\right)}
\end{array}
Initial program 75.2%
associate-/l*75.6%
+-commutative75.6%
associate-/l*75.2%
associate-/l*75.6%
+-commutative75.6%
exp-diff29.5%
sub-neg29.5%
exp-sum22.8%
associate-/r*22.8%
exp-diff25.2%
Simplified75.6%
Taylor expanded in K around 0 96.8%
cos-neg96.8%
Simplified96.8%
Final simplification96.8%
(FPCore (K m n M l)
:precision binary64
(if (<= m -16500.0)
(* (cos M) (exp (* (pow m 2.0) -0.25)))
(if (or (<= m -5.5e-83) (not (<= m -3.8e-124)))
(*
-0.5
(*
K
(*
n
(*
(exp
(+ (fabs (- n m)) (- (* (- (* n 0.5) M) (- (- M (* n 0.5)) m)) l)))
(sin (- (* 0.5 (* m K)) M))))))
(* (cos (- (pow (cbrt (* K (* (+ m n) 0.5))) 3.0) M)) (exp (- l))))))
double code(double K, double m, double n, double M, double l) {
double tmp;
if (m <= -16500.0) {
tmp = cos(M) * exp((pow(m, 2.0) * -0.25));
} else if ((m <= -5.5e-83) || !(m <= -3.8e-124)) {
tmp = -0.5 * (K * (n * (exp((fabs((n - m)) + ((((n * 0.5) - M) * ((M - (n * 0.5)) - m)) - l))) * sin(((0.5 * (m * K)) - M)))));
} else {
tmp = cos((pow(cbrt((K * ((m + n) * 0.5))), 3.0) - M)) * exp(-l);
}
return tmp;
}
public static double code(double K, double m, double n, double M, double l) {
double tmp;
if (m <= -16500.0) {
tmp = Math.cos(M) * Math.exp((Math.pow(m, 2.0) * -0.25));
} else if ((m <= -5.5e-83) || !(m <= -3.8e-124)) {
tmp = -0.5 * (K * (n * (Math.exp((Math.abs((n - m)) + ((((n * 0.5) - M) * ((M - (n * 0.5)) - m)) - l))) * Math.sin(((0.5 * (m * K)) - M)))));
} else {
tmp = Math.cos((Math.pow(Math.cbrt((K * ((m + n) * 0.5))), 3.0) - M)) * Math.exp(-l);
}
return tmp;
}
function code(K, m, n, M, l) tmp = 0.0 if (m <= -16500.0) tmp = Float64(cos(M) * exp(Float64((m ^ 2.0) * -0.25))); elseif ((m <= -5.5e-83) || !(m <= -3.8e-124)) tmp = Float64(-0.5 * Float64(K * Float64(n * Float64(exp(Float64(abs(Float64(n - m)) + Float64(Float64(Float64(Float64(n * 0.5) - M) * Float64(Float64(M - Float64(n * 0.5)) - m)) - l))) * sin(Float64(Float64(0.5 * Float64(m * K)) - M)))))); else tmp = Float64(cos(Float64((cbrt(Float64(K * Float64(Float64(m + n) * 0.5))) ^ 3.0) - M)) * exp(Float64(-l))); end return tmp end
code[K_, m_, n_, M_, l_] := If[LessEqual[m, -16500.0], N[(N[Cos[M], $MachinePrecision] * N[Exp[N[(N[Power[m, 2.0], $MachinePrecision] * -0.25), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[Or[LessEqual[m, -5.5e-83], N[Not[LessEqual[m, -3.8e-124]], $MachinePrecision]], N[(-0.5 * N[(K * N[(n * N[(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] * N[Sin[N[(N[(0.5 * N[(m * K), $MachinePrecision]), $MachinePrecision] - M), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[Cos[N[(N[Power[N[Power[N[(K * N[(N[(m + n), $MachinePrecision] * 0.5), $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision], 3.0], $MachinePrecision] - M), $MachinePrecision]], $MachinePrecision] * N[Exp[(-l)], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;m \leq -16500:\\
\;\;\;\;\cos M \cdot e^{{m}^{2} \cdot -0.25}\\
\mathbf{elif}\;m \leq -5.5 \cdot 10^{-83} \lor \neg \left(m \leq -3.8 \cdot 10^{-124}\right):\\
\;\;\;\;-0.5 \cdot \left(K \cdot \left(n \cdot \left(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)} \cdot \sin \left(0.5 \cdot \left(m \cdot K\right) - M\right)\right)\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\cos \left({\left(\sqrt[3]{K \cdot \left(\left(m + n\right) \cdot 0.5\right)}\right)}^{3} - M\right) \cdot e^{-\ell}\\
\end{array}
\end{array}
if m < -16500Initial program 71.7%
associate-/l*71.7%
+-commutative71.7%
associate-/l*71.7%
associate-/l*71.7%
+-commutative71.7%
exp-diff5.0%
sub-neg5.0%
exp-sum0.0%
associate-/r*0.0%
exp-diff0.0%
Simplified71.7%
Taylor expanded in K around 0 100.0%
cos-neg100.0%
Simplified100.0%
Taylor expanded in m around inf 100.0%
*-commutative100.0%
Simplified100.0%
if -16500 < m < -5.49999999999999964e-83 or -3.80000000000000012e-124 < m Initial program 76.3%
associate-/l*76.9%
+-commutative76.9%
associate-/l*76.3%
associate-/l*76.9%
+-commutative76.9%
exp-diff36.6%
sub-neg36.6%
exp-sum29.2%
associate-/r*29.2%
exp-diff32.4%
Simplified76.9%
Taylor expanded in n around 0 79.4%
Taylor expanded in K around inf 82.3%
Taylor expanded in m around 0 72.3%
+-commutative72.3%
unpow272.3%
distribute-rgt-out76.0%
Simplified76.0%
if -5.49999999999999964e-83 < m < -3.80000000000000012e-124Initial program 74.0%
associate-/l*74.0%
+-commutative74.0%
associate-/l*74.0%
associate-/l*74.0%
+-commutative74.0%
exp-diff45.4%
sub-neg45.4%
exp-sum45.4%
associate-/r*45.4%
exp-diff45.4%
Simplified74.0%
Taylor expanded in l around inf 46.1%
mul-1-neg46.1%
Simplified46.1%
add-cube-cbrt43.8%
pow343.8%
div-inv43.8%
metadata-eval43.8%
Applied egg-rr43.8%
Final simplification80.8%
(FPCore (K m n M l)
:precision binary64
(if (<= m -108000.0)
(* (cos M) (exp (* (pow m 2.0) -0.25)))
(if (or (<= m -5.5e-83) (not (<= m -3.8e-124)))
(*
-0.5
(*
K
(*
n
(*
(exp
(+ (fabs (- n m)) (- (* (- (* n 0.5) M) (- (- M (* n 0.5)) m)) l)))
(sin (- (* 0.5 (* m K)) M))))))
(* (exp (- l)) (cos (* 0.5 (* n K)))))))
double code(double K, double m, double n, double M, double l) {
double tmp;
if (m <= -108000.0) {
tmp = cos(M) * exp((pow(m, 2.0) * -0.25));
} else if ((m <= -5.5e-83) || !(m <= -3.8e-124)) {
tmp = -0.5 * (K * (n * (exp((fabs((n - m)) + ((((n * 0.5) - M) * ((M - (n * 0.5)) - m)) - l))) * sin(((0.5 * (m * K)) - M)))));
} else {
tmp = exp(-l) * cos((0.5 * (n * K)));
}
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 <= (-108000.0d0)) then
tmp = cos(m_1) * exp(((m ** 2.0d0) * (-0.25d0)))
else if ((m <= (-5.5d-83)) .or. (.not. (m <= (-3.8d-124)))) then
tmp = (-0.5d0) * (k * (n * (exp((abs((n - m)) + ((((n * 0.5d0) - m_1) * ((m_1 - (n * 0.5d0)) - m)) - l))) * sin(((0.5d0 * (m * k)) - m_1)))))
else
tmp = exp(-l) * cos((0.5d0 * (n * k)))
end if
code = tmp
end function
public static double code(double K, double m, double n, double M, double l) {
double tmp;
if (m <= -108000.0) {
tmp = Math.cos(M) * Math.exp((Math.pow(m, 2.0) * -0.25));
} else if ((m <= -5.5e-83) || !(m <= -3.8e-124)) {
tmp = -0.5 * (K * (n * (Math.exp((Math.abs((n - m)) + ((((n * 0.5) - M) * ((M - (n * 0.5)) - m)) - l))) * Math.sin(((0.5 * (m * K)) - M)))));
} else {
tmp = Math.exp(-l) * Math.cos((0.5 * (n * K)));
}
return tmp;
}
def code(K, m, n, M, l): tmp = 0 if m <= -108000.0: tmp = math.cos(M) * math.exp((math.pow(m, 2.0) * -0.25)) elif (m <= -5.5e-83) or not (m <= -3.8e-124): tmp = -0.5 * (K * (n * (math.exp((math.fabs((n - m)) + ((((n * 0.5) - M) * ((M - (n * 0.5)) - m)) - l))) * math.sin(((0.5 * (m * K)) - M))))) else: tmp = math.exp(-l) * math.cos((0.5 * (n * K))) return tmp
function code(K, m, n, M, l) tmp = 0.0 if (m <= -108000.0) tmp = Float64(cos(M) * exp(Float64((m ^ 2.0) * -0.25))); elseif ((m <= -5.5e-83) || !(m <= -3.8e-124)) tmp = Float64(-0.5 * Float64(K * Float64(n * Float64(exp(Float64(abs(Float64(n - m)) + Float64(Float64(Float64(Float64(n * 0.5) - M) * Float64(Float64(M - Float64(n * 0.5)) - m)) - l))) * sin(Float64(Float64(0.5 * Float64(m * K)) - M)))))); else tmp = Float64(exp(Float64(-l)) * cos(Float64(0.5 * Float64(n * K)))); end return tmp end
function tmp_2 = code(K, m, n, M, l) tmp = 0.0; if (m <= -108000.0) tmp = cos(M) * exp(((m ^ 2.0) * -0.25)); elseif ((m <= -5.5e-83) || ~((m <= -3.8e-124))) tmp = -0.5 * (K * (n * (exp((abs((n - m)) + ((((n * 0.5) - M) * ((M - (n * 0.5)) - m)) - l))) * sin(((0.5 * (m * K)) - M))))); else tmp = exp(-l) * cos((0.5 * (n * K))); end tmp_2 = tmp; end
code[K_, m_, n_, M_, l_] := If[LessEqual[m, -108000.0], N[(N[Cos[M], $MachinePrecision] * N[Exp[N[(N[Power[m, 2.0], $MachinePrecision] * -0.25), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[Or[LessEqual[m, -5.5e-83], N[Not[LessEqual[m, -3.8e-124]], $MachinePrecision]], N[(-0.5 * N[(K * N[(n * N[(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] * N[Sin[N[(N[(0.5 * N[(m * K), $MachinePrecision]), $MachinePrecision] - M), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[Exp[(-l)], $MachinePrecision] * N[Cos[N[(0.5 * N[(n * K), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;m \leq -108000:\\
\;\;\;\;\cos M \cdot e^{{m}^{2} \cdot -0.25}\\
\mathbf{elif}\;m \leq -5.5 \cdot 10^{-83} \lor \neg \left(m \leq -3.8 \cdot 10^{-124}\right):\\
\;\;\;\;-0.5 \cdot \left(K \cdot \left(n \cdot \left(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)} \cdot \sin \left(0.5 \cdot \left(m \cdot K\right) - M\right)\right)\right)\right)\\
\mathbf{else}:\\
\;\;\;\;e^{-\ell} \cdot \cos \left(0.5 \cdot \left(n \cdot K\right)\right)\\
\end{array}
\end{array}
if m < -108000Initial program 71.7%
associate-/l*71.7%
+-commutative71.7%
associate-/l*71.7%
associate-/l*71.7%
+-commutative71.7%
exp-diff5.0%
sub-neg5.0%
exp-sum0.0%
associate-/r*0.0%
exp-diff0.0%
Simplified71.7%
Taylor expanded in K around 0 100.0%
cos-neg100.0%
Simplified100.0%
Taylor expanded in m around inf 100.0%
*-commutative100.0%
Simplified100.0%
if -108000 < m < -5.49999999999999964e-83 or -3.80000000000000012e-124 < m Initial program 76.3%
associate-/l*76.9%
+-commutative76.9%
associate-/l*76.3%
associate-/l*76.9%
+-commutative76.9%
exp-diff36.6%
sub-neg36.6%
exp-sum29.2%
associate-/r*29.2%
exp-diff32.4%
Simplified76.9%
Taylor expanded in n around 0 79.4%
Taylor expanded in K around inf 82.3%
Taylor expanded in m around 0 72.3%
+-commutative72.3%
unpow272.3%
distribute-rgt-out76.0%
Simplified76.0%
if -5.49999999999999964e-83 < m < -3.80000000000000012e-124Initial program 74.0%
associate-/l*74.0%
+-commutative74.0%
associate-/l*74.0%
associate-/l*74.0%
+-commutative74.0%
exp-diff45.4%
sub-neg45.4%
exp-sum45.4%
associate-/r*45.4%
exp-diff45.4%
Simplified74.0%
Taylor expanded in l around inf 46.1%
mul-1-neg46.1%
Simplified46.1%
Taylor expanded in n around inf 46.1%
*-commutative46.1%
Simplified46.1%
Final simplification80.8%
(FPCore (K m n M l)
:precision binary64
(let* ((t_0 (* (cos M) (exp (- (pow M 2.0)))))
(t_1 (* (cos M) (exp (* (pow m 2.0) -0.25))))
(t_2 (exp (- l))))
(if (<= m -14500.0)
t_1
(if (<= m -1.7e-30)
t_0
(if (<= m -8.2e-194)
(* (cos M) t_2)
(if (<= m 3.5e-221)
t_0
(if (<= m 55.0) (* t_2 (cos (* K (* m 0.5)))) t_1)))))))
double code(double K, double m, double n, double M, double l) {
double t_0 = cos(M) * exp(-pow(M, 2.0));
double t_1 = cos(M) * exp((pow(m, 2.0) * -0.25));
double t_2 = exp(-l);
double tmp;
if (m <= -14500.0) {
tmp = t_1;
} else if (m <= -1.7e-30) {
tmp = t_0;
} else if (m <= -8.2e-194) {
tmp = cos(M) * t_2;
} else if (m <= 3.5e-221) {
tmp = t_0;
} else if (m <= 55.0) {
tmp = t_2 * cos((K * (m * 0.5)));
} else {
tmp = t_1;
}
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) :: t_1
real(8) :: t_2
real(8) :: tmp
t_0 = cos(m_1) * exp(-(m_1 ** 2.0d0))
t_1 = cos(m_1) * exp(((m ** 2.0d0) * (-0.25d0)))
t_2 = exp(-l)
if (m <= (-14500.0d0)) then
tmp = t_1
else if (m <= (-1.7d-30)) then
tmp = t_0
else if (m <= (-8.2d-194)) then
tmp = cos(m_1) * t_2
else if (m <= 3.5d-221) then
tmp = t_0
else if (m <= 55.0d0) then
tmp = t_2 * cos((k * (m * 0.5d0)))
else
tmp = t_1
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 t_1 = Math.cos(M) * Math.exp((Math.pow(m, 2.0) * -0.25));
double t_2 = Math.exp(-l);
double tmp;
if (m <= -14500.0) {
tmp = t_1;
} else if (m <= -1.7e-30) {
tmp = t_0;
} else if (m <= -8.2e-194) {
tmp = Math.cos(M) * t_2;
} else if (m <= 3.5e-221) {
tmp = t_0;
} else if (m <= 55.0) {
tmp = t_2 * Math.cos((K * (m * 0.5)));
} else {
tmp = t_1;
}
return tmp;
}
def code(K, m, n, M, l): t_0 = math.cos(M) * math.exp(-math.pow(M, 2.0)) t_1 = math.cos(M) * math.exp((math.pow(m, 2.0) * -0.25)) t_2 = math.exp(-l) tmp = 0 if m <= -14500.0: tmp = t_1 elif m <= -1.7e-30: tmp = t_0 elif m <= -8.2e-194: tmp = math.cos(M) * t_2 elif m <= 3.5e-221: tmp = t_0 elif m <= 55.0: tmp = t_2 * math.cos((K * (m * 0.5))) else: tmp = t_1 return tmp
function code(K, m, n, M, l) t_0 = Float64(cos(M) * exp(Float64(-(M ^ 2.0)))) t_1 = Float64(cos(M) * exp(Float64((m ^ 2.0) * -0.25))) t_2 = exp(Float64(-l)) tmp = 0.0 if (m <= -14500.0) tmp = t_1; elseif (m <= -1.7e-30) tmp = t_0; elseif (m <= -8.2e-194) tmp = Float64(cos(M) * t_2); elseif (m <= 3.5e-221) tmp = t_0; elseif (m <= 55.0) tmp = Float64(t_2 * cos(Float64(K * Float64(m * 0.5)))); else tmp = t_1; end return tmp end
function tmp_2 = code(K, m, n, M, l) t_0 = cos(M) * exp(-(M ^ 2.0)); t_1 = cos(M) * exp(((m ^ 2.0) * -0.25)); t_2 = exp(-l); tmp = 0.0; if (m <= -14500.0) tmp = t_1; elseif (m <= -1.7e-30) tmp = t_0; elseif (m <= -8.2e-194) tmp = cos(M) * t_2; elseif (m <= 3.5e-221) tmp = t_0; elseif (m <= 55.0) tmp = t_2 * cos((K * (m * 0.5))); else tmp = t_1; 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]}, Block[{t$95$1 = N[(N[Cos[M], $MachinePrecision] * N[Exp[N[(N[Power[m, 2.0], $MachinePrecision] * -0.25), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[Exp[(-l)], $MachinePrecision]}, If[LessEqual[m, -14500.0], t$95$1, If[LessEqual[m, -1.7e-30], t$95$0, If[LessEqual[m, -8.2e-194], N[(N[Cos[M], $MachinePrecision] * t$95$2), $MachinePrecision], If[LessEqual[m, 3.5e-221], t$95$0, If[LessEqual[m, 55.0], N[(t$95$2 * N[Cos[N[(K * N[(m * 0.5), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], t$95$1]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos M \cdot e^{-{M}^{2}}\\
t_1 := \cos M \cdot e^{{m}^{2} \cdot -0.25}\\
t_2 := e^{-\ell}\\
\mathbf{if}\;m \leq -14500:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;m \leq -1.7 \cdot 10^{-30}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;m \leq -8.2 \cdot 10^{-194}:\\
\;\;\;\;\cos M \cdot t\_2\\
\mathbf{elif}\;m \leq 3.5 \cdot 10^{-221}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;m \leq 55:\\
\;\;\;\;t\_2 \cdot \cos \left(K \cdot \left(m \cdot 0.5\right)\right)\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if m < -14500 or 55 < m Initial program 68.7%
associate-/l*69.6%
+-commutative69.6%
associate-/l*68.7%
associate-/l*69.6%
+-commutative69.6%
exp-diff6.1%
sub-neg6.1%
exp-sum0.0%
associate-/r*0.0%
exp-diff0.0%
Simplified69.6%
Taylor expanded in K around 0 99.1%
cos-neg99.1%
Simplified99.1%
Taylor expanded in m around inf 99.1%
*-commutative99.1%
Simplified99.1%
if -14500 < m < -1.7000000000000001e-30 or -8.2000000000000005e-194 < m < 3.4999999999999999e-221Initial program 90.4%
associate-/l*90.4%
+-commutative90.4%
associate-/l*90.4%
associate-/l*90.4%
+-commutative90.4%
exp-diff53.9%
sub-neg53.9%
exp-sum50.1%
associate-/r*50.1%
exp-diff55.8%
Simplified90.4%
Taylor expanded in K around 0 96.6%
cos-neg96.6%
Simplified96.6%
Taylor expanded in M around inf 59.3%
mul-1-neg59.3%
Simplified59.3%
if -1.7000000000000001e-30 < m < -8.2000000000000005e-194Initial program 86.8%
associate-/l*86.8%
+-commutative86.8%
associate-/l*86.8%
associate-/l*86.8%
+-commutative86.8%
exp-diff50.4%
sub-neg50.4%
exp-sum41.3%
associate-/r*41.3%
exp-diff45.9%
Simplified86.8%
Taylor expanded in l around inf 51.4%
mul-1-neg51.4%
Simplified51.4%
Taylor expanded in K around 0 54.1%
cos-neg54.1%
Simplified54.1%
if 3.4999999999999999e-221 < m < 55Initial program 62.7%
associate-/l*62.7%
+-commutative62.7%
associate-/l*62.7%
associate-/l*62.7%
+-commutative62.7%
exp-diff40.5%
sub-neg40.5%
exp-sum31.6%
associate-/r*31.6%
exp-diff33.8%
Simplified62.7%
Taylor expanded in l around inf 41.1%
mul-1-neg41.1%
Simplified41.1%
Taylor expanded in m around inf 59.3%
*-commutative59.3%
associate-*r*59.3%
Simplified59.3%
Final simplification76.3%
(FPCore (K m n M l)
:precision binary64
(let* ((t_0 (* (cos M) (exp (- (pow M 2.0))))))
(if (<= m -14500.0)
(* (cos M) (exp (* (pow m 2.0) -0.25)))
(if (<= m -1.15e-30)
t_0
(if (<= m -5.2e-194)
(* (cos M) (exp (- l)))
(if (<= m 4.6e-222) t_0 (* (cos M) (exp (* -0.25 (pow n 2.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 <= -14500.0) {
tmp = cos(M) * exp((pow(m, 2.0) * -0.25));
} else if (m <= -1.15e-30) {
tmp = t_0;
} else if (m <= -5.2e-194) {
tmp = cos(M) * exp(-l);
} else if (m <= 4.6e-222) {
tmp = t_0;
} else {
tmp = cos(M) * 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 = cos(m_1) * exp(-(m_1 ** 2.0d0))
if (m <= (-14500.0d0)) then
tmp = cos(m_1) * exp(((m ** 2.0d0) * (-0.25d0)))
else if (m <= (-1.15d-30)) then
tmp = t_0
else if (m <= (-5.2d-194)) then
tmp = cos(m_1) * exp(-l)
else if (m <= 4.6d-222) then
tmp = t_0
else
tmp = cos(m_1) * 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 = Math.cos(M) * Math.exp(-Math.pow(M, 2.0));
double tmp;
if (m <= -14500.0) {
tmp = Math.cos(M) * Math.exp((Math.pow(m, 2.0) * -0.25));
} else if (m <= -1.15e-30) {
tmp = t_0;
} else if (m <= -5.2e-194) {
tmp = Math.cos(M) * Math.exp(-l);
} else if (m <= 4.6e-222) {
tmp = t_0;
} else {
tmp = Math.cos(M) * Math.exp((-0.25 * Math.pow(n, 2.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 <= -14500.0: tmp = math.cos(M) * math.exp((math.pow(m, 2.0) * -0.25)) elif m <= -1.15e-30: tmp = t_0 elif m <= -5.2e-194: tmp = math.cos(M) * math.exp(-l) elif m <= 4.6e-222: tmp = t_0 else: tmp = math.cos(M) * math.exp((-0.25 * math.pow(n, 2.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 <= -14500.0) tmp = Float64(cos(M) * exp(Float64((m ^ 2.0) * -0.25))); elseif (m <= -1.15e-30) tmp = t_0; elseif (m <= -5.2e-194) tmp = Float64(cos(M) * exp(Float64(-l))); elseif (m <= 4.6e-222) tmp = t_0; else tmp = Float64(cos(M) * exp(Float64(-0.25 * (n ^ 2.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 <= -14500.0) tmp = cos(M) * exp(((m ^ 2.0) * -0.25)); elseif (m <= -1.15e-30) tmp = t_0; elseif (m <= -5.2e-194) tmp = cos(M) * exp(-l); elseif (m <= 4.6e-222) tmp = t_0; else tmp = cos(M) * exp((-0.25 * (n ^ 2.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, -14500.0], N[(N[Cos[M], $MachinePrecision] * N[Exp[N[(N[Power[m, 2.0], $MachinePrecision] * -0.25), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[m, -1.15e-30], t$95$0, If[LessEqual[m, -5.2e-194], N[(N[Cos[M], $MachinePrecision] * N[Exp[(-l)], $MachinePrecision]), $MachinePrecision], If[LessEqual[m, 4.6e-222], t$95$0, N[(N[Cos[M], $MachinePrecision] * N[Exp[N[(-0.25 * N[Power[n, 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos M \cdot e^{-{M}^{2}}\\
\mathbf{if}\;m \leq -14500:\\
\;\;\;\;\cos M \cdot e^{{m}^{2} \cdot -0.25}\\
\mathbf{elif}\;m \leq -1.15 \cdot 10^{-30}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;m \leq -5.2 \cdot 10^{-194}:\\
\;\;\;\;\cos M \cdot e^{-\ell}\\
\mathbf{elif}\;m \leq 4.6 \cdot 10^{-222}:\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;\cos M \cdot e^{-0.25 \cdot {n}^{2}}\\
\end{array}
\end{array}
if m < -14500Initial program 71.7%
associate-/l*71.7%
+-commutative71.7%
associate-/l*71.7%
associate-/l*71.7%
+-commutative71.7%
exp-diff5.0%
sub-neg5.0%
exp-sum0.0%
associate-/r*0.0%
exp-diff0.0%
Simplified71.7%
Taylor expanded in K around 0 100.0%
cos-neg100.0%
Simplified100.0%
Taylor expanded in m around inf 100.0%
*-commutative100.0%
Simplified100.0%
if -14500 < m < -1.14999999999999992e-30 or -5.20000000000000003e-194 < m < 4.6000000000000003e-222Initial program 90.4%
associate-/l*90.4%
+-commutative90.4%
associate-/l*90.4%
associate-/l*90.4%
+-commutative90.4%
exp-diff53.9%
sub-neg53.9%
exp-sum50.1%
associate-/r*50.1%
exp-diff55.8%
Simplified90.4%
Taylor expanded in K around 0 96.6%
cos-neg96.6%
Simplified96.6%
Taylor expanded in M around inf 59.3%
mul-1-neg59.3%
Simplified59.3%
if -1.14999999999999992e-30 < m < -5.20000000000000003e-194Initial program 86.8%
associate-/l*86.8%
+-commutative86.8%
associate-/l*86.8%
associate-/l*86.8%
+-commutative86.8%
exp-diff50.4%
sub-neg50.4%
exp-sum41.3%
associate-/r*41.3%
exp-diff45.9%
Simplified86.8%
Taylor expanded in l around inf 51.4%
mul-1-neg51.4%
Simplified51.4%
Taylor expanded in K around 0 54.1%
cos-neg54.1%
Simplified54.1%
if 4.6000000000000003e-222 < m Initial program 64.2%
associate-/l*65.2%
+-commutative65.2%
associate-/l*64.2%
associate-/l*65.2%
+-commutative65.2%
exp-diff22.2%
sub-neg22.2%
exp-sum14.2%
associate-/r*14.2%
exp-diff15.2%
Simplified65.2%
Taylor expanded in K around 0 95.2%
cos-neg95.2%
Simplified95.2%
Taylor expanded in n around inf 52.6%
*-commutative32.3%
Simplified52.6%
Final simplification65.3%
(FPCore (K m n M l) :precision binary64 (if (or (<= M -9.5e-9) (not (<= M 6.8))) (* (cos M) (exp (- (pow M 2.0)))) (* (cos M) (exp (- l)))))
double code(double K, double m, double n, double M, double l) {
double tmp;
if ((M <= -9.5e-9) || !(M <= 6.8)) {
tmp = cos(M) * exp(-pow(M, 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 ((m_1 <= (-9.5d-9)) .or. (.not. (m_1 <= 6.8d0))) then
tmp = cos(m_1) * exp(-(m_1 ** 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 ((M <= -9.5e-9) || !(M <= 6.8)) {
tmp = Math.cos(M) * Math.exp(-Math.pow(M, 2.0));
} else {
tmp = Math.cos(M) * Math.exp(-l);
}
return tmp;
}
def code(K, m, n, M, l): tmp = 0 if (M <= -9.5e-9) or not (M <= 6.8): tmp = math.cos(M) * math.exp(-math.pow(M, 2.0)) else: tmp = math.cos(M) * math.exp(-l) return tmp
function code(K, m, n, M, l) tmp = 0.0 if ((M <= -9.5e-9) || !(M <= 6.8)) tmp = Float64(cos(M) * exp(Float64(-(M ^ 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 ((M <= -9.5e-9) || ~((M <= 6.8))) tmp = cos(M) * exp(-(M ^ 2.0)); else tmp = cos(M) * exp(-l); end tmp_2 = tmp; end
code[K_, m_, n_, M_, l_] := If[Or[LessEqual[M, -9.5e-9], N[Not[LessEqual[M, 6.8]], $MachinePrecision]], N[(N[Cos[M], $MachinePrecision] * N[Exp[(-N[Power[M, 2.0], $MachinePrecision])], $MachinePrecision]), $MachinePrecision], N[(N[Cos[M], $MachinePrecision] * N[Exp[(-l)], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;M \leq -9.5 \cdot 10^{-9} \lor \neg \left(M \leq 6.8\right):\\
\;\;\;\;\cos M \cdot e^{-{M}^{2}}\\
\mathbf{else}:\\
\;\;\;\;\cos M \cdot e^{-\ell}\\
\end{array}
\end{array}
if M < -9.5000000000000007e-9 or 6.79999999999999982 < M Initial program 76.3%
associate-/l*77.1%
+-commutative77.1%
associate-/l*76.3%
associate-/l*77.1%
+-commutative77.1%
exp-diff30.5%
sub-neg30.5%
exp-sum24.6%
associate-/r*24.6%
exp-diff28.8%
Simplified77.1%
Taylor expanded in K around 0 98.3%
cos-neg98.3%
Simplified98.3%
Taylor expanded in M around inf 96.7%
mul-1-neg96.7%
Simplified96.7%
if -9.5000000000000007e-9 < M < 6.79999999999999982Initial program 74.2%
associate-/l*74.2%
+-commutative74.2%
associate-/l*74.2%
associate-/l*74.2%
+-commutative74.2%
exp-diff28.6%
sub-neg28.6%
exp-sum21.3%
associate-/r*21.3%
exp-diff22.0%
Simplified74.2%
Taylor expanded in l around inf 38.2%
mul-1-neg38.2%
Simplified38.2%
Taylor expanded in K around 0 47.3%
cos-neg47.3%
Simplified47.3%
Final simplification70.1%
(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 75.2%
associate-/l*75.6%
+-commutative75.6%
associate-/l*75.2%
associate-/l*75.6%
+-commutative75.6%
exp-diff29.5%
sub-neg29.5%
exp-sum22.8%
associate-/r*22.8%
exp-diff25.2%
Simplified75.6%
Taylor expanded in l around inf 32.5%
mul-1-neg32.5%
Simplified32.5%
Taylor expanded in K around 0 40.0%
cos-neg40.0%
Simplified40.0%
Final simplification40.0%
(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 75.2%
associate-/l*75.6%
+-commutative75.6%
associate-/l*75.2%
associate-/l*75.6%
+-commutative75.6%
exp-diff29.5%
sub-neg29.5%
exp-sum22.8%
associate-/r*22.8%
exp-diff25.2%
Simplified75.6%
Taylor expanded in n around inf 40.4%
*-commutative40.4%
Simplified40.4%
Taylor expanded in n around 0 7.5%
*-commutative7.5%
associate-*r*7.5%
Simplified7.5%
Taylor expanded in m around 0 7.8%
cos-neg7.8%
Simplified7.8%
Final simplification7.8%
herbie shell --seed 2024080
(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)))))))