Solution (source code)

= Solution

Apply a <Fourier transform> or <discrete Fourier transform>, retain the desired low-frequency coefficients and attenuate those in the high-frequency noise band with a <low-pass filter>, then invert. For a real signal, apply matching gains at positive and negative <frequencies> to preserve <Hermitian symmetry>.

<Parseval identity for Fourier series> shows what an ideal coefficient cutoff does: the output <mean-square signal power> is the sum of the retained squared coefficients, and cannot exceed that of the unfiltered input. Much of the high-frequency noise can be removed, but a finite cutoff also removes genuine <square wave> harmonics. Its edges become less sharp, and a sharp spectral cutoff can exhibit the <Gibbs phenomenon>. There is no claim of exact recovery if the noise overlaps the retained band. Noise already folded into low frequencies by <aliasing> cannot in general be removed merely by discarding the high-frequency bins afterward.