how to calculate residual - Search