compute positive and negative index