Spectral Methods in MATLAB

Our starting point is a basic question. Given a set of grid points { x j} and corresponding function values { u( x j)}, how can we use this data to approximate the derivative of u? Probably the method that immediately springs to mind is some kind of finite difference formula. It is through finite differences that we shall motivate spectral methods.
To be specific, consider a uniform grid { x 1, , x N}, with x j + 1 ? x j = h for each j, and a set of corresponding data values { u 1, , u N}:
Let W j denote the approximation to u ? ( x j), the derivative of u at x j. The standard second-order finite difference approximation is
which can be derived by considering the Taylor expansions of U( x j + 1) and u( x j ? 1). For simplicity, let us assume that the problem is periodic and take u 0 = u N and u 1 = u N + 1. Then we can represent the discrete differentiation process as a matrix-vector multiplication,

(Omitted entries here and in other sparse matrices in this book are zero.) Observe that this matrix is Toeplitz, having constant entries along diagonals; i.e., a ij depends only on i ?