Calculates Pascal's Triangle.
PASCAL(n, order)
n |
- |
An integer. |
||||||
order |
- |
Optional. An integer, the matrix order:
|
An array.
pascal(4)
{{1, 1, 1, 1},
{1, 2, 3, 4},
{1, 3, 6, 10},
{1, 4, 10, 20}}
W1: pascal(4, 1)
W2: W1^^2
W3: eye(4)
W4: inv(W1)
W1 == {{1, 0, 0, 0}
{1, -1, 0, 0}
{1, -2, 1, 0}
{1, -3, 3, -1}}
W2 == {{1, 0, 0, 0}
{0, 1, 0, 0}
{0, 0, 1, 0}
{0, 0, 0, 1}}
W3 == {{1, 0, 0, 0}
{0, 1, 0, 0}
{0, 0, 1, 0}
{0, 0, 0, 1}}
W4 == {{1, 0, 0, 0}
{1, -1, 0, 0}
{1, -2, 1, 0}
{1, -3, 3, -1}}
For order 1, the result is equal to the square root of the identity matrix. The result is also equal to the inverse itself.
W1: pascal(4, 2)
W2: W1^^3
W1 == {{-1, -1, -1, -1}
{ 3, 2, 1, 0}
{-3, -1, 0, 0}
{ 1, 0, 0, 0}}
W2 == {{ 1, 0, 0, 0}
{ 0, 1, 0, 0}
{ 0, 0, 1, 0}
{ 0, 0, 0, 1}}
For order 2, the result is equal to the cube root of the identity matrix.
PASCAL returns the lower triangle of Pascal's matrix.
For order == 1, the resulting array is the lower triangle of the CHOLESKY factor of the Pascal matrix. The result is its own inverse and is equal to the square root of the identity matrix, thus:
pascal(n, 1)^^2 == eye(n)
For order == 2, the result is the lower triangle of a the CHOLESKY factor transposed and permuted such that the result is equal to the cube root of the identity matrix. Thus:
pascal(n, 2)^^3 == eye(n)