# fourdif.m

Fourier spectral differentiation matrices. Computes the m'th derivative Fourier spectral differentiation matrix on grid with N equispaced points in [0,2pi).

## Syntax

    [x,DM]=fourdif(N,m)


## Arguments

    N -       size of differentiation matrix

m -       derivative order


## Outputs

    x -       equispaced points 0, 2pi/N, 4pi/N, ... , (N-1)2pi/N

DM -       m-th order differentiation matrix


## Notes

Explicit formulas are used to compute the matrices for m=1 and m=2. A discrete Fourier approach is employed for m>2. The program computes the first column and first row and then uses the toeplitz command to create the matrix.

For m=1 and 2 the code implements a "flipping trick" to improve accuracy suggested in http://dx.doi.org/10.1137/0916073