Suppose you invest R1 000 at time 0, a further R2 000 at time 4, and in return receive R4 200 at time 8. What real rate of interest have you earned, if the values of the relevant index are 100, 140 and 200 at times 0, 4 and 8 respectively?

I was going to use the formula i'=i-j/1+j but doesn't this only work if the inflation rate is constant throughout the period? What happens when the inflation rate changes during the period?