add code for calculating errors in the hidden layer
adjust for machine numerical precision