Expand in the two-dimensional Fourier basis. Applying the derivative and product rules from part (a), the coefficient of the equation is
The normalization and compatibility conditions are
Thus, on , the infinite Fourier spectral method system is
For a square spectral truncation, choose
retain equations and unknowns indexed by , and set omitted coefficients to zero. This is the Fourier–Galerkin method: it projects the residual onto the retained Fourier modes. Other finite mode sets may be used in the same way.
For consistency with the supplied wavenumbers, use an FFT grid on a periodic interval: , , and similarly for . In MATLAB, replace the endpoint-inclusive coordinate definitions by x = (0:nx-1)*Lx/nx; and y = (0:ny-1)*Ly/ny;. The supplied linspace arrays instead have spacing while the Fourier multipliers assume . Including both copies of the periodic endpoint creates a grid inconsistency, separate from high-frequency aliasing.