## Elementary Spectral Methods

The use of such methods for solving evolutionary PDEs has become increasingly common due to the availability of the required built-in commands in major computational software such as Matlab and Fortran. The idea of the method is based on the following property of the Fourier transform of a function. If f(k) is the Fourier transform off (x) with respect to x, then (—ik)mf(k) is the Fourier transform of Smf(x). Here i = \J - 1 and k is the parameter of the Fourier transform, sometimes referred to as the wave number or frequency. For example, in Matlab, fft and ifft are the commands of the Fourier transform and the inverse Fourier transform. (The entire acronym stands for Fast Fourier transform; similar commands are available in Fortran and C.) Then if k is the transform parameter properly defined within the code, then S^u can be computed for all x at once by a short command: real ( ifft(—(k.~2) .*fft(u) ) ). (Here the command real discards a very small imaginary part of the answer which arises from the round-off error, and the period before the exponentiation and multiplication symbols is part of Matlab's syntax for array multiplication.) This command can be also used in, say, IMEX methods. For example, method  (where we set D = 1 for simplicity) can be programmed as follows:

+ T * fft(3/2 * E -1/2 * Eold) )./(l + T * G * K2)));

where T = t, G = 7, and uold and Eold are the stored values of U and E at tn — j. If Sxu is present in E, it can also be computed using fft and ifft, as explained above. In addition to the coding simplicity, advantages of the above approach are that it is (1) fast (requires only on the order of M log2M operations for each of the fft and ifft, where M is the number of the discretization points in U) and (2) has very high accuracy in h provided that the solution is smooth (see below).

The main limitation of this approach is that, by the very nature of discrete Fourier transform, the discretized functions on which it is implemented must be periodic (or very close to periodic). This means that not only the values of the function but also its slopes at the endpoints of the interval must match each other. Thus, boundary conditions  are not periodic despite the fact that u(0, t) = u(X, t); the reason is that Sxu(0, t) and Sxu(X, t) are not enforced to be equal. (For example, sin(^x/X) satisfies , yet is not periodic on [0, X] since its slopes at x = 0 and x = X are opposite.) If discrete Fourier transform is used to compute a derivative of a function that is not periodic in the above sense, small-period but finite-amplitude oscillations arise at the endpoints which then propagate inside the interval and destroy the numerical solution. (In general, if Sm—1u is continuous but S"mu is discontinuous either at the endpoints or inside the interval, then the spatial accuracy of the solution is O(hm).)

Problems with periodic boundary conditions rarely arise in ecological modeling. Yet, the use of Fourier transform and its variant (see below) can be justified in the following two cases. First, the solution may be localized within a central part of the interval and be virtually zero (or tend to the same constant value) in some extended regions near the endpoints. Such a solution is very close to periodic. Second, the problem may have zero flux boundary conditions, that is,  with q(t) = b(t) = 0; also, it may asymptotically tend to different constants at the endpoints (as, e.g., the traveling wave in the Fisher-Kolmogorov-Petrovsky-Piskunov equation). The (real-valued) variant of discrete Fourier transform called discrete cosine transform can be used on such functions. The corresponding commands dct and idct are included in Matlab's version 7.0.0 and beyond; earlier versions have them in the signal processing toolbox. The key difference from the Fourier transform commands is that only even derivatives can be computed with the cosine transforms; for example, Sx2mu is computed as idct ((—k. "2). "m .*dct(u)), provided that u satisfies the zero flux boundary conditions. 