A Matlab Differentiation Matrix Suite

This is a MATLAB software suite, created by JAC Weideman and SC Reddy, consisting of seventeen functions for solving differential equations by the spectral collocation (a.k.a. pseudospectral) method. It includes functions for computing differentiation matrices of arbitrary order corresponding to Chebyshev, Hermite, Laguerre, Fourier, and sinc interpolants. It also includes FFT-based routines for Fourier, Chebyshev and sinc differentiation. Auxiliary functions are included for incorporating boundary conditions, performing interpolation using barycentric formulas, and computing roots of orthogonal polynomials.

In the accompanying paper it is demonstrated how to use the package for solving eigenvalue, boundary value, and initial value problems arising in the fields of special functions, quantum mechanics, nonlinear waves, and hydrodynamic stability.


The paper has been published in ACM TOMS, Vol. 26, pp. 465--519 (2000). (TOMS Vol 26)

Note 1

The first version of the suite was tested under MATLAB Ver 5.2. Larry Shampine reported a few bugs under MATLAB 6, which were fixed in the files below as indicated. Yet we still make NO GUARANTEES about the correctness of the codes. Please contact us at weideman@dip.sun.ac.za or reddy@intergate.ca if you find further bugs or have comments. Alternatively, you may use the guest book below.

Note 2

The functions poldif.m and chebdif.m below can probably be improved a bit by the suggestions in R. Baltensperger & M.R. Trummer, "Spectral Differencing with a Twist", SIAM J Sci Computing, Vol. 24, pp. 1465-1487 (2003).

Note 3

Almost all the codes will break down if the order of the matrix becomes too large; in the case of lagdif.m it is around 100x100 or so and larger for the others. If you need to use matrices this large, it begs the question whether you should be using this particular pseudospectral method at all.


The entire set of functions can be downloaded, as a .zip file, from the MathWorks Web site ( June 2003). The MathWorks site also provides an opportunity to rate our software: please do so if you have found it useful!

Individual files can also be downloaded below as text files:

Table of Contents

Differentiation Matrices (Polynomial Based)

Differentiation Matrices (Non-Polynomial)

  • fourdif.m (Fourier differentiation matrices)(: Code corrected for MATLAB R13, May 2003)
  • sincdif.m (Sinc differentiation matrices) (: Help comments improved, May 2003)

Boundary Conditions

  • cheb2bc.m (Chebyshev 2nd derivative matrix incorporating Robin boundary conditions)
     Requires: chebdif.m
  • cheb4c.m (Chebyshev 4th derivative matrix incorporating clamped boundary conditions)


  • polint.m (Barycentric polynomial interpolation on arbitrary distinct nodes)(: Help comments improved, May 2003)
  • chebint.m (Barycentric polynomial interpolation on Chebyshev points)
  • fourint.m (Barycentric trigonometric interpolation at equidistant nodes)

Transform-Based Derivatives

  • chebdifft.m (FFT-based Chebyshev derivative)
  • fourdifft.m (FFT-based Fourier derivative)(: Code corrected for MATLAB R13, May 2003)
  • sincdifft.m (FFT-based sinc derivative)(: Code corrected for complex data, May 2003)

Roots of Orthogonal Polynomials


Last updated: August 29, 2003.

A Matlab Differentiation Matrix Suite