Sure, figuring the future tax pmt involves a bit of guesswork & there's no way we could really know without a time machine. But it can at least be estimated & I'd say its worth plugging in - even if it has to be projected using assumptions. After all, the entire reason any of these formulas or models exist is to help us nerds plan for an uncertain future.

I agree. The modification I'd propose would include an offsetting amount for capital gains & dividends taxes. So instead of subtracting (PV of future tax payments from 401k loan interest), I'd subtract:

(PV of future tax payments from 401k loan interest) - (PV of future tax payments of invested sum outside 401k)

For a $4000 401k loan interest amount, assuming no short term capital gains, this can be approximated for short time periods by:

(n) * (average dividends * dividend tax rate) + $4000 * [(1 + r)^n - 1] * marginal tax rate in retirement

where r = annual rate of return

n = number of years

Using current dividends would understate the amount over 20 years because dividends will increase substantially, but this can be fixed using an average:

If we assume a constant dividend yield = 2%, then average dividends can be approximated (but understated) as:

average dividends = dividend yield * $4000 * (1+r)^(n/2)

Plugging in numbers, we get:

dividend tax rate = 15%

r = 9% (remember this is nominal returns)

n = 20

marginal tax rate in retirement = 15%

then

20* (.15 * .02 * $4000 * (1.09)^10) + 4000 * (1.09^20 - 1) * .15

=568 + 2762

= 3330

Which isn't comparable because it's not a PV and also because you didn't assume any growth in the excess amount added to the 401k. The first concern can be addressed by converting the $3330 to a present value, which I'm going to ballpark (±10%) at $2200. The second concern can be addressed by re-figuring the PV of the future tax payment of the 401k by adding growth. So:

PV of future tax payment = discounted (marginal tax rate in retirement * $4000 * (1 + r)^n]

gives discounted(.15 * 22417) = 3362.

A future value of $3362 discounts to ~ $2242.

Now the number can be compared, so -(2242 - 2200) becomes -42.

The assumptions—or someone's individual tax situation—can make that value significantly different, though, so you can plug in your own numbers to see.