**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.

### Paper

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.

### Functions

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

- contents.m (: A few comments added, May 2003)

#### Differentiation Matrices (Polynomial Based)

- poldif.m (General differentiation matrices)
- chebdif.m (Chebshev differentiation matrices)(: Help comments improved, May 2003)
- herdif.m (Hermite differentiation matrices)

Requires: herroots.m, poldif.m - lagdif.m (Laguerre differentiation matrices)

Requires: lagroots.m, poldif.m

#### 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)

#### Interpolation

- 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

- legroots.m (Roots of Legendre polynomials)
- lagroots.m (Roots of Laguerre polynomials)
- herroots.m (Roots of Hermite polynomials)

#### Examples

- cerfa.m (Function file for computing complementary error function. BC y(infinity) = 0.

Requires: chebdif.m, chebint.m - cerfb.m (Function file for computing complementary error function. BC y(0) = 1

Requires: chebdif.m, chebint.m - matplot.m (Script file for plotting characteristic curves of Mathieu's equation)

Requires: fourdif.m - ce0.m (Function file for computing the Mathieu cosine elliptic function)

Requires: fourdif.m, fourint.m - sineg.m (Script file for solving the sine-Gordon equation)(: Code corrected for MATLAB R13, May 2003)

Requires: herdif.m, herroots.m, sincdif.m, fourdif.m, poldif.m, sgrhs.m, - sgrhs.m (Function file for computing the right-hand side of the sine-Gordon equation)(: Code corrected for MATLAB R13, May 2003)
- schrod.m (Script file for computing the eigenvalues of the Schrodinger equation)(: Output lines added, May 2003)

Requires: lagdif.m, lagroots.m, poldif.m - orrsom.m (Script file for computing the eigenvalues of the Orr-Sommerfeld equation) (: Output lines added, May 2003)

Requires: cheb4c.m, chebdif.m

Last updated: August 29, 2003.

**A Matlab Differentiation Matrix Suite**