% $Id: bell.tex,v 1.1.1.3 2004/10/04 17:25:16 nthiery Exp $
\begin{Mhelppage}{bell}{Torsten Metzner}
  [ImplState=stable,TestState=stable,DocState=stable]
\Mproofread{stefanw}{5.6.00}{fertig}

\begin{MInfo}
  \eng{Bell numbers}
  \de{Berechnung von Bell-Zahlen}
\end{MInfo}



\begin{MIntro}
  \eng{\Mthis(n) computes the n-th Bell number.} 
  \de{\large !! Noch keine deutsche
      Doku vorhanden !!}
\end{MIntro}

\begin{MCalls}
  \Mcall{n}
  \Mcall{expression}
\end{MCalls}

\begin{MParameters}
  \param{n} 
    \eng{nonnegative integer}
  \de{}
  \param{expression}
    \eng{An expression of type \Mup{Type::Arithmetical} which must be
    a nonnegative integer if it is a number.}
  \de{}
\end{MParameters}

\begin{MReturnValue}
   \eng{A positive integer value if \Mpar{n} was a nonnegative
     integer. Otherwise \Mthis\ returns the unevaluated
     function call.}
   \de{}
\end{MReturnValue}

\MKeywords{combinatorics}

\begin{MDetails}
  \eng{The n-th Bell number is defined by
      the exponential generating function: 
      \Mdmath{exp(exp(x) - 1) = sum(bell(n)/n! * x^n, n = 0..infinity)}
             {e^{e^{x}-1}=\sum_{n=0}^\infty \frac{bell(n)}{n!} \, x^n} 
      Often another definition is used.
      The n-th Bell number is the number of different ways of
      partitioning the set \Mmath{{1, 2, ..., n}}{\{1, 2, \ldots, n\}} into
      disjoint nonempty subsets, and \Mmath{bell(0)}{bell(0)} is defined to be 1.}
  \de{}
  
  \eng{Bell numbers are computed using the formula: 
        
    \begin{Mnohtml}
        \begin{align*}
          bell(0)   & = 1                                  & \,&   \\
          bell(n+1) & = \sum_{i=0}^n {n \choose i} bell(i) & \,& \mbox{for } n > 0
        \end{align*}
    \end{Mnohtml}

         \begin{Mhtml}
           <pre>
             bell(0)   = 1                                 
             bell(n+1) = sum(binomial(n,i)*bell(i), i=0..n), n > 0
           </pre>
         \end{Mhtml}
}
  \de{}
\end{MDetails}

\begin{MExample}{bell-ex1}
\begin{Mexin}
combinat::bell(3) 
\end{Mexin}
\begin{Mexout}
                               5
\end{Mexout}
\eng{This means that you can partition the set
  \Mmath{{1,2,3}}{\{1,2,3\}} into disjoint subsets in $5$ different
  ways.  These are $\{\{1,2,3\}\},$ $\{\{1\},\{2,3\}\},$
  $\{\{2\},\{1,3\}\},$ $\{\{3\},\{1,2\}\},$ and
  $\{\{1\},\{2\},\{3\}\}$.  Or, that you can write $105 = 3*5*7$ as $5$
  different products. These are $105 = 3*35 = 5*21 = 7*15 = 3*5*7$.}
\de{}
\end{MExample}

\begin{MExample}{bell-ex2}
  \eng{If one uses a wrong argument, an error message is returned.}
\begin{Mexin}
combinat::bell(3.4) 
\end{Mexin}
\begin{Mexout}
Error: Nonnegative integer expected [combinat::bell]
\end{Mexout}
\end{MExample}

\begin{MExample}{bell-ex3}
  \eng{It can be useful to return the unevaluated function call.}
\begin{Mexin}
a:=combinat::bell(x)
\end{Mexin}
\begin{Mexout}
                       combinat::bell(x)
\end{Mexout}
\begin{Mexin}
x :=4
\end{Mexin}
\begin{Mexout}
                               4
\end{Mexout}
\begin{Mexin}
a ; delete a:
\end{Mexin}
\begin{Mexout}
                              15
\end{Mexout}
\end{MExample}

\begin{MChanges}
  \version{2.0} 
   \eng[Return value changed]{In older \mupad{} versions
   \Mex{combinat::bell} returned  $1$ for a negative integer.  Now it
   returns an error message if it gets a negative integer as an argument.}
   \de{}
\end{MChanges}

\end{Mhelppage}
