wilkinson

Wilkinson's symmetric tridiagonal eigenvalue test matrix of order n.

Category: Mathematics > Elementary Math

Syntax

W = wilkinson(n)

Returns the n-by-n Wilkinson matrix.

Description

The diagonal runs down from (n-1)/2 to the middle and back up, so the matrix is also symmetric about its center. Its eigenvalues come in nearly equal pairs, which makes it a classic test for eigenvalue algorithms.

For odd n the diagonal holds integers, for even n it holds half-integers.

Input arguments

n
Nonnegative integer, the order of the matrix.

Output arguments

W
Symmetric tridiagonal matrix with ones on the sub- and superdiagonals and the diagonal abs(-(n-1)/2 : (n-1)/2).

Example

Orders 3 and 4

wilkinson(3)
wilkinson(4)
Output
ans = 3×3

     1     1     0
     1     0     1
     0     1     1
ans = 4×4

    1.5000    1.0000         0         0
    1.0000    0.5000    1.0000         0
         0    1.0000    0.5000    1.0000
         0         0    1.0000    1.5000

See also

eig toeplitz diag hilb magic