Given you have an 80-year lifespan and you are trying to maximize how much money you make what is the best solution to the following: Each year you have a decision to:
- Earn 1000 dollars and save it in cash
- Invest all the money you've saved in cash into an account that compounds yearly at a rate of 2%
- Do nothing but add 0.5 years to your life expectancy
For example, you could save 3000 dollars then invest it, then earn another 2000 dollars then invest it.
What is the best order of decisions that leads to maximum money at the end of your life? I'm very interested in how one could begin to try and solve this. Any help with this question would be greatly appreciated, thanks!
You should work until you are 35 years old, then retire and enjoy life.
For the purpose of illustration, I assume that you only need to choose between (1) working and (3) resting, and that (2) is automatic: your savings always get invested and compound yearly, with no effort on your part. You could adapt the abstract method described below to any other rules.
Taking 80 decisions (one per year) is not fun enough. Let us go further and assume that you can choose to work or rest each day, so around 30 000 decisions. At this stage, we pretty much have a continuous problem, for which the theory of optimal control is very well suited.
Modeling. Thus, let us consider the following model. For a time $t \geq 0$, we denote by $x_1(t)$ your total savings and $x_2(t)$ your remaining life expectancy. This is the state of the system. We also introduce $u(t) \in \{ 0, 1 \}$ your "rest or work" status (the control). We have $$ \begin{cases} \dot{x}_1(t) = r x_1(t) + w u(t) \\ \dot{x}_2(t) = -1 + \mu(1-u(t)). \end{cases} $$ Here, $r = \ln 1.02$ models the yearly interest rate, $w = 1000$ the savings for a year of work, and $\mu = 0.5$ the life expectancy increase for a year of rest.
Your question now translates into finding your end of life time $T > 0$ as well as a function $u : [0,T] \to \{ 0,1 \}$ such that $x_2(T) = 0$ (the life expectancy at the time of death vanishes) and $x_1(T)$ is maximal (you have the most money possible at the end), given the initial state that $x_1(0) = 0$ (no money at birth) and $x_2(0) = L$ your initial life expectancy which was $L = 80$ years.
Resolution. For such problems, a very nice general tool is Pontryagin's maximum principle, which provides a necessary condition for a control to be optimal. It involves a costate $\lambda : [0,T] \to \mathbb{R}^2$. In your setting, the costate evolves according to the equations: $$ \begin{cases} \dot{\lambda}_1(t) = - r \lambda_1(t) \\ \dot{\lambda}_2(t) = 0 \end{cases} $$ and the transversality condition at the final time is $\lambda_1(T) = 1$. Hence $\lambda_1(t) = e^{r (T-t)}$ and $\lambda_2(t) \equiv \lambda_2^*$ (a constant to be determined). Pontryagin's result implies that, for each $t \in [0,T]$, the optimal control $u(t)$ is such that $$ 0 = \max_{v \in \{ 0,1 \}} H(t,x(t),v,\lambda(t)) = H(t,x(t),u(t),\lambda(t)) $$ where the Hamiltonian is $$H(t,x,u,\lambda) = \lambda_1(rx_1 + wu) + \lambda_2(-1+\mu(1-u)).$$ From this you deduce that $u(t) = 1$ when $w \lambda_1(t) > \mu \lambda_2(t)$ and $0$ otherwise. The fact that the Hamiltonian should be constant and equal to $0$ implies that $\lambda_2^* = w e^{rT}$. Eventually, you deduce that $u(t) = 1$ as long as $e^{-rt} > \mu$, i.e. $$ u(t) = \begin{cases} 1 & \text{for} \quad 0 \leq t \leq T^* \\ 0 & \text{for} \quad T^* \leq t \leq T \end{cases} \quad \text{where} \quad T^* = \frac{-\ln \mu}{r} = \frac{- \ln 0.5}{\ln 1.02} \approx 35.0 \text{ years}. $$
Comments. In this simple model, the optimal strategy was easy to guess. Indeed, working and saving money early on in your life is better for the yearly compound. So it was clear that the optimal strategy was "work then rest". The only remaining question was the value of the "switching" time. But this is a standard maximization problem of a single real variable so it could be solved using classical techniques.
Funnily, here, we see that $T^* = \frac{-\ln \mu}{r}$ depends neither on $w = 1000\$$ nor on $L = 80 \text{ years}$. For $w$, this is easy as your savings are always proportional to $w$ whatever the strategy. For $L$, it was a little less easy to guess. But here, we learn that the optimal strategy only depends on the relationship between the compound rate and the life-expectancy increase through resting.