Apply the Fourier transform of a derivative twice in each spatial coordinate, and commute the time derivative with the spatial Fourier transform. For the Laplacian,
Thus
The minus sign is essential: positive thermal diffusivity damps short spatial scales rather than amplifying them. The zero Fourier mode is unchanged in the absence of a source.
A spatially uniform source changes only the zero Fourier mode. Its exact integrated increment over a time step beginning at is
The unnormalised two-dimensional discrete Fourier transform stores a constant field as in element (1,1).[ref] Keep the existing homogeneous exponential multiplication and add this source increment to that element:
for i = 1:nt
    t = (i-1)*dt;
    u_hat = u_hat .* exp(-alpha*K2*dt);
    dq = exp(-t/10) - exp(-(t+dt)/10);
    u_hat(1,1) = u_hat(1,1) + nx*ny*dq;
end
This replacement uses the original variable names and MATLAB indexing. The uniform forcing of a periodic heat equation is integrated exactly in time here. No source multiplier is applied to the other modes, and the zero-mode homogeneous multiplier equals one. Adding only dq to the unnormalised coefficient would underestimate the physical temperature increment by the factor .
Integrate over a periodic cell. Opposite boundary contributions to the Laplacian cancel, so the spatial mean obeys . With no source the mean is conserved, although the local temperature changes. The mean is the zero Fourier mode in a normalized Fourier series convention.
For a spatially constant PDE source term , subtract its time integral from . The result obeys the homogeneous heat equation with the same initial condition. This proves the displayed formula and shows that uniform heating changes only the zero Fourier mode. In an unnormalised discrete Fourier transform, a constant increment adds to the zero-frequency coefficient.