Error function. We have chosen to minimize (2)