Acknowledged, and changed. The patch is attached.
--
You received this message because you are subscribed to the Google Groups
"sympy" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/sympy?hl=en.
diff --git a/sympy/functions/combinatorial/numbers.py b/sympy/functions/combinatorial/numbers.py
index fd974b4..8e6cd94 100644
--- a/sympy/functions/combinatorial/numbers.py
+++ b/sympy/functions/combinatorial/numbers.py
@@ -507,3 +507,54 @@ def _eval_evalf(self, prec):
res = mp.eulernum(m)
mp.prec = oprec
return Expr._from_mpmath(res, prec)
+
+
+#----------------------------------------------------------------------------#
+# #
+# Catalan numbers #
+# #
+#----------------------------------------------------------------------------#
+
+class catalan(Function):
+ r"""
+ Catalan numbers
+
+ Usage
+ =====
+ catalan(n) gives the n-th Catalan number, c(n)
+
+ Examples
+ ========
+ >>> from sympy import Symbol, catalan
+ >>> [catalan(n) for n in range(10)]
+ [1, 1, 2, 5, 14, 42, 132, 429, 1430]
+
+ Mathematical description
+ ========================
+ The Catalan numbers are given by
+
+
+
+ 1 / 2n \
+ c(n) = ------- | |
+ n + 1 \ n /
+
+
+ References and further reading
+ ==============================
+ * http://en.wikipedia.org/wiki/Catalan_numbers
+ * http://mathworld.wolfram.com/CatalanNumber.html
+ * http://geometer.org/mathcircles/catalan.pdf
+ """
+
+ nargs = 1
+
+ @classmethod
+ def eval(cls, n, evaluate=True):
+ if not evaluate:
+ return
+ if n.is_Integer and n.is_nonnegative:
+ return int(C.binomial(2n, n) // (n + 1))
+
+ def _eval_rewrite_binomial(self,n):
+ return C.binomial(2n, n) // (n + 1)