The Gerchberg–Saxton (GS) algorithm is an iterative algorithm for retrieving the phase of a pair of light distributions (or any other mathematically valid distribution) related via a propagating function, such as the Fourier transform, if their intensities at their respective optical planes are known.