I'm trying to work out a method for finding the initial capital value that allows someone to run out of money at the exact time they reach mortality. Currently, I'm graphing the annual total capital values through an iterative method. I have a pre-calculated list of the annual expenses (discrete values unique to each year), and I know the growth.
The iterative method I use when I know the initial capital value is simple, and works as follows
Given an initial value $x_0$ , the next year's total capital value is the growth of the previous year's value $x_0(1 + growth)$ minus the expenses for that year. This value, $x_1$ , is then used to determine the next year's total $x_1(1+growth) - expenses$, and so on until we reach the mortality date.
I now need to find the initial value $x_0$ given that the final value must be 0. I've tried implementing a type of binary-search simulation where I try find the starting value that gives the end value closest to 0, but that is both fairly computationally expensive for a live graphing application as well as quite an ugly solution.
Is there a better method for solving this problem? Or is this simply a boundary condition that cannot be inferred from the end result?
Thanks in advance for your help