Sub topic 6
Computing the required nest egg
This chapter turns three inputs into one number: the amount you need to have saved on your retirement date. The inputs are your spending in today's money, your other retirement income, and a withdrawal rate. I assume you have read the earlier chapters on spending, inflation, other income, and withdrawal rates. You should be comfortable with percentages, exponents, and reading short Python functions.
The calculation in three steps
The required nest egg is the portfolio size that can pay for your spending gap through withdrawals. The calculation has three steps.
- Find the gap in today's money. Subtract other income (pensions, public benefits) from planned annual spending. This is the part your portfolio must cover.
- Move the gap to the retirement date. Multiply by
(1 + inflation) ** years. This prices the gap in future dollars, which are the dollars you will actually spend. - Divide by the withdrawal rate. A 4% rate means each year you withdraw 4% of the portfolio, so the portfolio must be 1 / 0.04 = 25 times the first year's withdrawal.
The function
Here is the code from the plan, with a worked example added at the bottom.
def nest_egg(annual_spend_today, years, inflation, other_income_today=0.0, withdrawal_rate=0.04):
"""Nest egg needed at retirement, in future dollars."""
need_today = max(annual_spend_today - other_income_today, 0.0)
need_future = need_today * (1 + inflation) ** years
return need_future / withdrawal_rate
target = nest_egg(
annual_spend_today=60_000,
years=30,
inflation=0.025,
other_income_today=18_000,
withdrawal_rate=0.04,
)
print(f"Required nest egg: ${target:,.0f}")Running it prints Required nest egg: $2,202,447. Here is the arithmetic:
- The gap in today's money is 60,000 − 18,000 = 42,000.
- The inflation factor is 1.025^30 ≈ 2.0976, so the first-year need in future dollars is about $88,098.
- Dividing by 0.04 gives about $2.20 million.
The result is in future dollars. A nest egg of $2.2 million in 30 years will not feel like $2.2 million today. That is intended, because your spending in that year will also be inflated. Future dollars are the right unit for the next chapters, where the saving target is compared with a portfolio that grows in nominal terms.
Why each step is done in this order
The max-then-inflate-then-divide order is deliberate.
- Subtract before inflating. Subtracting first assumes your other income rises with inflation, as many public benefits do. If it does not, see the fixed-pension case below.
- Inflate before dividing. The withdrawal rate applies to the portfolio at the retirement date, so it must be applied to the first-year spending at that date.
- Clamp at zero.
max(..., 0.0)stops the function from returning a negative nest egg when other income exceeds spending. Without it, a generous pension would produce a negative target and a negative saving requirement downstream.
The withdrawal rate is the biggest lever
The withdrawal rate sits in the denominator, so small changes move the answer a lot. The table uses the same $42,000 gap and 2.5% inflation over 30 years, so the first-year need is about $88,098.
| Withdrawal rate | Multiple (1 / rate) | Required nest egg |
|---|---|---|
| 3.0% | 33.3 | $2,936,595 |
| 3.5% | 28.6 | $2,517,082 |
| 4.0% | 25.0 | $2,202,447 |
| 5.0% | 20.0 | $1,761,957 |
Moving from 4% to 3% raises the target by about a third. A lower rate is more conservative: you draw less each year relative to the portfolio, which lowers the chance of running out of money. The 4% figure is a common starting point from historical US studies of a 30-year retirement. It is not a guarantee. A longer retirement, a different country's market history, or high fees can all justify a lower rate.
Inflation compounds quietly
Inflation works like interest against you, so the horizon matters as much as the rate. With the same $42,000 gap and a 4% withdrawal rate over 30 years:
| Inflation | Inflation factor | Required nest egg |
|---|---|---|
| 2.0% | 1.811 | $1,901,931 |
| 2.5% | 2.098 | $2,202,447 |
| 3.0% | 2.427 | $2,548,625 |
A one-point difference in inflation shifts the target by roughly $300,000 to $350,000. Because the exponent is the number of years, the effect grows the longer you wait to retire.
When other income does not rise with inflation
The function inflates the whole gap. That is correct if your pension or benefit is indexed to inflation. Some private pensions pay a fixed nominal amount, and then their real value shrinks each year. In that case, subtract the pension after inflating your spending, not before.
def nest_egg_fixed_pension(annual_spend_today, years, inflation, fixed_pension, withdrawal_rate=0.04):
"""Nest egg when the other income is a fixed nominal amount, not indexed."""
spend_future = annual_spend_today * (1 + inflation) ** years
need_future = max(spend_future - fixed_pension, 0.0)
return need_future / withdrawal_rate
print(f"${nest_egg_fixed_pension(60_000, 30, 0.025, 18_000):,.0f}")This prints $2,696,352, about $494,000 more than the indexed case. The pension still pays $18,000 a year, but that covers less of your spending 30 years from now.
This version assumes the pension payments start at the retirement date at the stated amount. If a fixed pension starts later, or pays out a different amount depending on when you start, you need to model it separately.
Edge cases and common errors
- Zero withdrawal rate.
withdrawal_rate=0raisesZeroDivisionError. A zero rate is not meaningful anyway. Validate that the rate is positive before calling the function. - Mixing real and nominal. Do not inflate your spending and then also use a real (after-inflation) return later. Inflating the target is only consistent with a nominal return assumption in the saving step. The next chapters cover this.
- Using today's dollars for the target. Dividing the uninflated gap by the withdrawal rate gives a target in today's dollars. Comparing that to a nominal portfolio balance will make you think you are further ahead than you are.
- Years that are not whole. The formula works with fractional years, such as 27.5, because the exponent accepts any number. Just keep the unit consistent: years, not months.
- Retirement length. The 4% rate assumes a particular retirement length, commonly 30 years. If you plan to retire at 45, a 4% rate is likely too aggressive, and you should pick a lower one.
- Taxes. The function treats spending as the amount you need to withdraw. If withdrawals from a tax-deferred account are taxed, you must withdraw more than you spend. One approach is to set your spending figure on a pre-tax basis. The accounts chapter returns to this.
What this number is and is not
The nest egg is a target, not a prediction. It depends on four assumptions: spending, inflation, other income, and the withdrawal rate. Each is uncertain, and errors in the inflation factor and the withdrawal rate multiply together. The right habit is to compute the target under a few assumption sets and treat the spread as the honest answer. The sensitivity chapter does this systematically.
For now, hold on to the single-number version. The next step is to find out how a portfolio grows over the years until the retirement date, so you can work out the monthly contribution that reaches this target.
Exercise
A person plans to spend $50,000 a year in today's money, expects $10,000 a year of inflation-indexed public benefits, retires in 20 years, assumes 3% inflation, and uses a 4% withdrawal rate. What nest egg do they need, in future dollars? Round to the nearest thousand.
Show answer
The gap in today's money is 50,000 − 10,000 = 40,000. The inflation factor is 1.03^20 ≈ 1.8061, so the first-year need in future dollars is about 40,000 × 1.8061 ≈ 72,244. Dividing by 0.04 gives about 1,806,111, so roughly $1,806,000 (about $1.81 million). In code: nestegg(50000, 20, 0.03, 10_000, 0.04).
Exercise
Using the same person, the $10,000 benefit turns out to be a fixed nominal amount that does not rise with inflation. Is the required nest egg higher or lower than in the previous exercise, and by about how much?
Show answer
It is higher. Spending in 20 years is 50,000 × 1.8061 ≈ 90,306. Subtracting the fixed $10,000 leaves about 80,306, and dividing by 0.04 gives about 2,007,639. The difference from 1,806,111 is about $201,500, because the indexed benefit would have been worth 10,000 × 1.8061 ≈ 18,061 in future dollars instead of 10,000.