Many retirement account providers and individual brokerages provide some sort of calculation for how much you will need to retire and whether you are on track for your goals. However, they are often somewhat opaque and not entirely clear on how they reach the final conclusion that is presented to the user.

To this end, we can derive our own formulas to achieve a simplified version of the various calculators that are generally available, regardless of whether you are interested in a simple check on an existing estimate or learning more about how these calculations can be performed in general.

Below, we’ll derive the formulas used in “Analytic Early Retirement Calculator”.

## Setting up the problem#

In our simple calculations, there are effectively five parameters.

- Annual savings, \( s \)
- Annual expenses, \( x \)
- Current portfolio value, \( p \)
- Annual return rate (after inflation and taxes), \( r \), defaulting to 1.05
^{1} - Annual withdrawal rate in retirement, \( w \), defaulting to 0.04
^{2}

In some calculations, annual post-tax income (i.e., \( s + x \)) is used in the place of savings or expenses.

With these parameters defined, we can compute how retirement savings grow over time. Assuming annual savings are continuously invested, we have the following total at time \( T \).

$$ \begin{aligned} \text{Savings}(T) &= p \cdot r^T + \int_0^T s \cdot r^t \text{ d}t \\ &= p \cdot r^T + s \cdot \frac{r^T - 1}{\ln(r)} \end{aligned} $$

The first term represents the growing value of the current portfolio, while the second term represents the value of the continuously invested savings. Both share the same growth rate, \( r \).

Then, you should be able to retire once your withdrawal rate alone provides enough income to cover your annual expenses completely.

$$ \begin{aligned} \text{Savings}(T) \cdot w &\geq x \\ \text{Savings}(T) &\geq \frac{x}{w} \end{aligned} $$

With these equations, we can solve for any of the parameters in terms of the others.

## Calculating time until retirement#

Setting retirement savings equal to the final required portfolio value, we can find the time until retirement.

$$ \begin{aligned} \text{Savings}(T) &= \frac{x}{w} \\ p \cdot r^T + s \cdot \frac{r^T - 1}{\ln(r)} &= \frac{x}{w} \\ \left(p + \frac{s}{\ln(r)}\right) \cdot r^T - \frac{s}{\ln(r)} &= \frac{x}{w} \\ r^T &= \frac{\frac{x}{w} + \frac{s}{\ln(r)}}{p + \frac{s}{\ln(r)}} \\ r^T &= \frac{x\ln(r) + s \cdot w}{p \cdot w\ln(r) + s \cdot w} \\ T &= \frac{\ln\left[x\ln(r) + s \cdot w\right] - \ln\left[p \cdot w\ln(r) + s \cdot w\right]}{\ln(r)} \end{aligned} $$

For example, someone that makes $50k, saves $7k, and has $25k currently invested should be able to retire in ~40.6 years.

$$ \begin{aligned} T &= \frac{\ln\left[x\ln(r) + s \cdot w\right] - \ln\left[p \cdot w\ln(r) + s \cdot w\right]}{\ln(r)} \\ &= \frac{\ln\left[43000 \cdot \ln(1.05) + 7000 \cdot 0.04\right] - \ln\left[25000 \cdot 0.04 \cdot \ln(1.05) + 7000 \cdot 0.04\right]}{\ln(1.05)} \\ &\approx \frac{7.7740 - 5.7954}{0.04879} \approx 40.6 \text{ years} \end{aligned} $$

## Calculating current savings required to meet retirement goal#

In this case, let \( \text{income} = s+x \) represent the user’s income. Then, we can solve for the savings needed to retire after a specified number of years.

$$ \begin{aligned} \text{Savings}(T) &= \frac{\text{income} - s}{w} \\ p \cdot r^T + s \cdot \frac{r^T - 1}{\ln(r)} &= \frac{\text{income} - s}{w} \\ p \cdot w \cdot r^T + s \left[ \frac{w \left(r^T - 1\right)}{\ln(r)} + 1 \right] &= \text{income} \\ s &= \ln(r) \cdot \frac{\text{income} - p \cdot w \cdot r^T}{w \left(r^T - 1\right) + \ln(r)} \end{aligned} $$

For example, someone that makes $50k with $100k invested must save ~$8,785 annually to retire in 30 years.

$$ \begin{aligned} s &= \ln(r) \cdot \frac{\text{income} - p \cdot w \cdot r^T}{w \left(r^T - 1\right) + \ln(r)} \\ &= \ln(1.05) \cdot \frac{50000 - 100000 \cdot 0.04 \cdot 1.05^{30}}{0.04 \left(1.05^{30} - 1\right) + \ln(1.05)} \\ &\approx 0.04879 \cdot \frac{50000 - 17288}{0.13288 + 0.04879} \approx \$8785 \end{aligned} $$

## Calculating current portfolio required to meet retirement goal#

Lastly, we can solve for the current investment portfolio you would need to be on track for retiring in a specified number of years.

$$ \begin{aligned} \text{Savings}(T) &= \frac{x}{w} \\ p \cdot r^T + s \cdot \frac{r^T - 1}{\ln(r)} &= \frac{x}{w} \\ p &= r^{-T} \cdot \left[ s \cdot \frac{1 - r^T}{\ln(r)} + \frac{x}{w} \right] \end{aligned} $$

For example, someone that makes $50k and saves $10k would need ~$375k of current investments to retire in 15 years.

$$ \begin{aligned} p &= r^{-T} \cdot \left[ s \cdot \frac{1 - r^T}{\ln(r)} + \frac{x}{w} \right] \\ &= 1.05^{-15} \cdot \left[ 10000 \cdot \frac{1 - 1.05^{15}}{\ln(1.05)} + \frac{40000}{0.04} \right] \\ &\approx 0.48102 \left[ 10000 \cdot \frac{-1.0789}{0.04879} + 1000000 \right] \approx \$374650 \end{aligned} $$

I would highly encourage playing around with the formulas (especially in the interactive calculator) to see how small tweaks to savings can make a massive difference in your retirement timeline. Otherwise, play around with different assumptions and make the calculations more comprehensive or complicated as you see fit!

## See also and references#

- The calculator that uses the formulas discussed in this post at “Analytic Early Retirement Calculator”.
- The rationale for the default parameter choices and relevant links in the footnotes of this post.
- The Bogleheads wiki page on Retirement calculators and spending which details the various spending models used by common retirement calculators.

This default growth rate of 5% is a relatively conservative choice for historical stock/bond market returns over long periods of time after adjusting for inflation and taxes. Both NerdWallet’s articles and Investopedia’s articles suggest something closer to 6%, but it is better to err on the lower side to account for potential downturns over shorter time horizons, higher proportions of bond holdings, etc. ↩︎

This is a rough rule of thumb popularized by the “Trinity study” that suggested typical retirees can sustain withdrawing 4% of their savings every year without running out of funds. People with unusually long retirement horizons (e.g., those that retire early) often target more conservative values around 3.5% or even 3%. This is a topic of extensive ongoing debate, and you can read more in the Bogleheads wiki articles on Safe withdrawal rates and Trinity study update. ↩︎