Eigenvalues and eigenvectors of tridiagonal symmetric Toeplitz matrices (interactive visualization)

This program illustrates the eigenvalues and eigenvectores of Toeplitz matrices with entries −1, 2, −1.
The corresponding formulas are well known.

Choose the order n of the matrix:

     n = 8

Next picture shows the graph of the generating function g(x) = 4 sin(x / 2)2.
The ordinates of the yellow points are the eigenvalues of the corresponding n×n matrix.

1 0 4 π 2π θn,j λn,j

The eigenvalues λn,1, …, λn,n are numbered in the ascending order.
For each j = 1, …, n, the eigenvalue λn,j is computed as g(j π / (n + 1)).

Next figure shows the components of an eigenvector vn,j associated to λn,j.
Recall that n = 8 (the value of n can be changed above).
Choose the index j of the eigenvalue/eigenvector pair:

     j = 1