Method on @sym: nchoosek (n, k)

Symbolic binomial coefficient.

Examples:

syms n k
nchoosek(n, k)
  ⇒ ans = (sym)
      ⎛n⎞
      ⎜ ⎟
      ⎝k⎠

nchoosek(101, k)
  ⇒ ans = (sym)
      ⎛101⎞
      ⎜   ⎟
      ⎝ k ⎠

nchoosek(sym(1001), sym(25))
  ⇒ (sym) 48862197129890117991367706991027565961778719519790

The binomial coefficient can be written in terms of factorials:

rewrite (nchoosek (n, k), 'factorial')
  ⇒ ans = (sym)
           n!
      ────────────
      k!⋅(-k + n)!

For inputs which are not positive integers (including complex numbers), the result is defined in terms of the gamma function:

rewrite (nchoosek (n, k), 'gamma')
  ⇒ (sym)
             Γ(n + 1)
      ──────────────────────
      Γ(k + 1)⋅Γ(-k + n + 1)

For example:

nchoosek (-sym(3), sym(2))
  ⇒ (sym) 6
nchoosek (sym(5)/2, sym(3))
  ⇒ (sym) 5/16
nchoosek (3+4i, sym(2))
  ⇒ (sym) -5 + 10⋅ⅈ

See also: @sym/factorial, @sym/gamma.

Package: symbolic