A precise analytical solution of the problem of phase reconstruction and its mode components is obtained based on the measurements of wave-front slopes in shear interferometers and Hartmann sensors. The algorithm has been developed, and a numerical experiment on reconstruction of the phase and its expansion coefficients as a sum of the Zernike polynomials has been carried out.