initial value iteration code