initialize variables and calculate error