Something about the x*(1+d)^(-k) formula didn't seem right, either. After a while and a lot of wrangling and testing the algebra, I figured out that, due to this step calculating de
flation, it should be -d, and to push the x value into the future instead of the present, the k should be positive. Final formula for that is
In copyable plaintext format, the formula is
((1-d)^k P(d+i))/((d-1) (-1+(1+i)^(-n) (1-d)^n))
The sad thing is, that is NOT a very pretty formula. But at least it works.
My derivation, as I explained, is based on the assumption that $1 at year 1 is equivalent to $(1+d) at year 0. It looks like you wanted that $1 at year 0 is equivalent to $(1-d) at year 1. So, let R = (1+i)/(1-d), and use the formula P_0*[(R-1)/(1-R^(-n))]*(1-d)^k.
It shouldn't matter too much, because 1/(1-d) = 1 + d + O(d^2).