Ass least squares cost function