A new error compensating five sample phase shifting algorithm which is insensitive to phase shift error is proposed to retrieve the phase distribution of a fringe pattern. It includes two steps. First, the linear phase shift error is estimated using four sample images. Then, the phase distribution is calculated with error corrected by using the phase shift error estimated in the first step. As the equations of error estimation and phase calculation are simple, this new algorithm is practical as well as effective. Computer simulations were carried out to verify the effectiveness of the algorithm. Results of two other well known error compensating algorithms are also presented, which show the new algorithm is the least sensitive to phase shift error.