Create a Pascal Matrix

Oh poor Stephen Wolfram.. no one honors his life's work by giving an answer that uses a cellular automaton. Let me fix this. Here a version for square matrices

P[n_] := #.Transpose[#] &@
  CellularAutomaton[{{i_, j_} :> i + j}, {{1}, 0}, n - 1]

Mathematica graphics

And for rectangular arrays, just truncate the above solution

P[n_, m_] := P[Max[n, m]][[;; n, ;; m]]

From here

l[n_] := SparseArray[{i_, j_} -> Binomial[i - 1, j - 1], n]
u[n_] := SparseArray[{i_, j_} -> Binomial[j - 1, i - 1], n]
s[n_] := l[n].u[n]

l[7] // MatrixForm
u[7] // MatrixForm
s[7] // MatrixForm

Mathematica graphics

Or equivalently:

l[n_] := MatrixExp@SparseArray[Band[{2, 1}] -> Range[n - 1], n]
u[n_] := MatrixExp@SparseArray[Band[{1, -n + 1}] -> Range[n - 1], n]
s[n_] := l[n].u[n]

l[7] // MatrixForm
u[7] // MatrixForm
s[7] // MatrixForm

Here is a nicely compact solution, whose proof is left to the interested reader:

pascal[n_Integer?Positive] := NestList[Accumulate, ConstantArray[1, n], n - 1]

It's surprisingly quick:

With[{n = 50},
     AbsoluteTiming[Array[Binomial[#1 + #2, #1] &, {n, n}, {0, 0}];]]
   {0.054873, Null}

AbsoluteTiming[pascal[50];]
   {0.001829, Null}

Tags:

Matrix