Method of least squares