Least square optimizing the error.