Post · 4 min read· pp. 856–859

What Is the Second Difference Matrix?

The second difference matrix is the tridiagonal matrix TnT_n with diagonal elements 22 and sub- and superdiagonal elements −1-1:

\notag T_n = \left[ \begin{array}{@{}*{4}{r@{\mskip10mu}}r} 2 & -1 & & & \\ -1 & 2 & -1 & & \\[-5pt] & -1 & 2 & \ddots & \\ & & \ddots & \ddots & -1 \\ & & & -1 & 2 \end{array}\right] \in\mathbb{R}^{n\times n}.

It arises when a second derivative is approximated by the central second difference f′′(x)≈(f(x+h)−2f(x)+f(x−h))/h2f''(x) \approx (f(x+h) -2 f(x) + f(x-h))/h^2. (Accordingly, the second difference matrix is sometimes defined as −Tn-T_n.) In MATLAB, TnT_n can be generated by gallery('tridiag',n), which is returned as a aparse matrix.

This is Gil Strang’s favorite matrix. The photo, from his home page, shows a birthday cake representation of the matrix.

strang_second_diff_cake.jpg

The second difference matrix is symmetric positive definite. The easiest way to see this is to define the full rank rectangular matrix

Ln=[1−11−1⋱⋱1−1]∈R(n+1)×n\notag L_n = \begin{bmatrix} 1 & & & \\ -1 & 1 & & \\ & -1 & \ddots & \\ & & \ddots & 1 \\ & & & -1 \end{bmatrix} \in\mathbb{R}^{(n+1)\times n}

and note that Tn=LnTLnT_n = L_n^T L_n. The factorization corresponds to representing a central difference as the product of a forward difference and a backward difference. Other properties of the second difference matrix are that it is diagonally dominant, a Toeplitz matrix, and an MM-matrix.

Cholesky Factorization

In an LU factorization A=LUA = LU the pivots uiiu_{ii} are 22, 3/23/2, 4/34/3, …, (n+1)/n(n+1)/n. Hence the pivots form a decreasing sequence tending to 1 as n→∞n\to\infty. The diagonal of the Cholesky factor contains the square roots of the pivots. This means that in the Cholesky factorization A=R∗RA = R^*R with RR upper bidiagonal, rnn→1r_{nn} \to 1 and rn,n−1→−1r_{n,n-1}\to -1 as n→∞n\to\infty.

Determinant, Inverse, Condition Number

Since the determinant is the product of the pivots, det⁡(Tn)=n+1\det(T_n) = n+1.

The inverse of TnT_n is full, with (i,j)(i,j) element i(n−j+1)/(n+1)i(n-j+1)/(n+1) for j≥ij\ge i. For example,

T5−1=16[5432148642369632468412345].\notag T_5^{-1} = \displaystyle\frac{1}{6} \begin{bmatrix} 5 & 4 & 3 & 2 & 1\\ 4 & 8 & 6 & 4 & 2\\ 3 & 6 & 9 & 6 & 3\\ 2 & 4 & 6 & 8 & 4\\ 1 & 2 & 3 & 4 & 5 \end{bmatrix}.

The 22-norm condition number satisfies κ2(Tn)∼4n2/π2\kappa_2(T_n) \sim 4n^2/\pi^2 (as follows from the formula (1) below for the eigenvalues).

Eigenvalues and Eigenvectors

The eigenvalues of TnT_n are

μk=4sin⁡2(kϕ2),k=1:n,(1)\notag \mu_k = 4 \sin^2\Bigl(\displaystyle\frac{k \phi}{2} \Bigr), \quad k = 1:n, \qquad (1)

where ϕ=π/(n+1)\phi = \pi/(n+1), with corresponding eigenvector

vk=[sin⁡(kϕ),sin⁡(2kϕ),…,sin⁡(nkϕ)]T.\notag v_k = \begin{bmatrix} \sin(k\phi), &\sin(2k\phi), &\dots, &\sin(nk\phi) \end{bmatrix}^T.

The matrix QQ with

qij=(2n+1)1/2sin⁡(ijπn+1)\notag q_{ij} = \Bigl(\displaystyle\frac{2}{n+1}\Bigr)^{1/2} \sin\Bigl( \frac{ij\pi}{n+1} \Bigr)

is therefore an eigenvector matrix for TnT_n: Q∗AQ=diag(μk)Q^*AQ = \mathrm{diag}(\mu_k).

Variations

Various modifications of the second difference matrix arise and similar results can be derived. For example, consider the matrix obtained by changing the (n,n)(n,n) element to 11:

\notag \widetilde{T}_n = \left[ \begin{array}{@{}*{4}{r@{\mskip10mu}}r} 2 & -1 & & & \\ -1 & 2 & -1 & & \\[-5pt] & -1 & 2 & \ddots & \\ & & \ddots & \ddots & -1 \\ & & & -1 & 1 \end{array}\right] \in\mathbb{R}^{n\times n}.

It can be shown that T~n−1\widetilde{T}_n^{-1} has (i,j)(i,j) element min⁡(i,j)\min(i,j) and eigenvalues 4cos⁡(jπ/(2n+1))24\cos( j \pi/(2n+1))^2, j=1:nj=1:n.

If we perturb the (1,1)(1,1) of T~n\widetilde{T}_n to 11, we obtain a singular matrix, but suppose we perturb the (1,1)(1,1) element to 33:

\notag \widehat{T}_n = \left[ \begin{array}{@{}*{4}{r@{\mskip10mu}}r} 3 & -1 & & & \\ -1 & 2 & -1 & & \\[-5pt] & -1 & 2 & \ddots & \\ & & \ddots & \ddots & -1 \\ & & & -1 & 1 \end{array}\right] \in\mathbb{R}^{n\times n}.

The inverse is T^n−1=G/2\widehat{T}_n^{-1} = G/2, where GG with (i,j)(i,j) element 2min⁡(i,j)−12\min(i,j)-1 is a matrix of Givens, and the eigenvalues are 4cos⁡((2j−1)π/(4n))24\cos((2j-1)\pi/(4n))^2, j=1:nj=1:n.

Notes

The factorization Tn=LnTLnT_n = L_n^TL_n is noted by Strang (2012).

For a derivation of the eigenvalues and eigenvectors see Todd (1977, p. 155 ff.). For the eigenvalues of T~n\widetilde{T}_n see Fortiana and Cuadras (1997). Givens’s matrix is described by Newman and Todd (1958) and Todd (1977).

References

This is a minimal set of references, which contain further useful references within.

This article is part of the “What Is” series, available from https://nhigham.com/index-of-what-is-articles/ and in PDF form from the GitHub repository https://github.com/higham/what-is.