calculate error