This paper introduces two algorithms of the phase retrieval, Gerchberg–Saxton algorithm and gradient search algorithm. We respectively get the function of the object of gradient search algorithm about the generalized pupil, wavefront and the zernike coefficients of the partial derivatives when double-frame images and their defocus as the input. The relationship between GS algorithm and the gradient search algorithm are revealed. This paper designs the simulation experiment with GS algorithm and gradient search algorithm when single-frame images and double-frame images are used as input. The experiment results show that the gradient search algorithm is superior to GS algorithm for a single-frame image as input. Both GS algorithm and gradient search algorithm can primely work out wavefront for double-frame images of different defocus as the input, but the convergence rate of gradient search algorithm is evidently better than GS algorithm.