An alternative way of phrasing the potential function, which might be a little easier to understand and to manipulate, is this: Let s(i) be the smallest nonnegative integer such that 2^{s(i)} > i. (So s(0) = 0, s(1) = 1, s(2) = s(3) = 2, s(4) = s(5) = s(6) = s(7) = 3, etc.)
Define Phi(D_i) to be 2i - 2^{s(i)}. We have to show that Phi(D_i) >= Phi(D_0) for all i. Since Phi(0) = -1 and Phi(D_i) is nonnegative for all i > 0, we are OK. (It is not necessary that Phi(D_0) equal 0, it is just necessary that Phi(D_i) >= Phi(D_0).)
Note that Phi(D_i) - Phi(D_{i-1}) >= 2 - (2^{s(i)} - 2^{s(i-1)}).
Case 1: i = 2^k for some k. Then s(i) = k+1 and s(i-1) = k. So the amortized cost of the i-th operation is 2^k + 2 - (2^{k-1} - 2^k) = 2.
Case 2: i is not a power of 2. Then s(i) = s(i-1). so the amortized cost of the i-th operation is 1 + 2 - (2^{s(i)} - 2^{s(i)}) = 3.
In case (b), the "before" and "after" expressions got reversed. The argument goes like this: 2*num_i - size_i = 0 since the table is exactly half full after the contraction (remember the diagram I drew in class). Also, 2*num_{i-1} - size_{i-} equals 2*num_{i-1} - 3*num_{i-1}, since the table was 1/3 full just before the contraction. If you plug in and do the algebra, you find that the amortized cost in this case is 0.