# Fourdif.m

From Spinach Documentation Wiki

Fourier spectral differentiation matrices.

## Syntax

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

## Description

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

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

## See also

fdmat.m, fdvec.m, v2fplanck.m, hydrodynamics.m, fourlap.m

*Version 2.1, authors: S.C. Reddy, J.A.C. Weideman*