compute L2 error