Main Content

pascal

Description

P = pascal(n) returns a Pascal Matrix of order n. P is a symmetric positive definite matrix with integer entries taken from Pascal's triangle. The inverse of P has integer entries.

example

P = pascal(n,1) returns the lower triangular Cholesky factor (up to the signs of the columns) of the Pascal matrix. P is involutory, that is, it is its own inverse.

P = pascal(n,2) returns a transposed and permuted version of pascal(n,1). In this case, P is a cube root of the identity matrix.

P = pascal(___,classname) returns a matrix of class classname using any of the input argument combinations in previous syntaxes. classname can be "double" or "single".

Examples

collapse all

Compute the fourth-order Pascal matrix.

A = pascal(4)
A = 4×4

     1     1     1     1
     1     2     3     4
     1     3     6    10
     1     4    10    20

Compute the lower triangular Cholesky factor of the third-order Pascal matrix, and verify it is involutory.

A = pascal(3,1)
A = 3×3

     1     0     0
     1    -1     0
     1    -2     1

inv(A)
ans = 3×3

     1     0     0
     1    -1     0
     1    -2     1

Input Arguments

collapse all

Matrix order, specified as a scalar, nonnegative integer.

Example: pascal(10)

Data Types: single | double | int8 | int16 | int32 | int64 | uint8 | uint16 | uint32 | uint64 | logical | char

Matrix class, specified as either "double" or "single".

Example: pascal(10,'single')

Data Types: char

Output Arguments

collapse all

Pascal matrix, returned as a matrix.

Limitations

  • When the elements of a Pascal matrix are too large, exceeding the largest positive floating-point number, pascal returns Inf for those elements. This largest positive floating-point number is approximately 1.79e308 for double precision and approximately 3.40e38 for single precision. For example, this code returns Inf.

    P = pascal(516);
    P(end)

More About

collapse all

Extended Capabilities

expand all

C/C++ Code Generation
Generate C and C++ code using MATLAB® Coder™.

Version History

Introduced before R2006a

See Also

| |