We establish an algorithm that produces an optimal strategy for retirees to withdraw funds between their tax‐deferred accounts (TDAs), like traditional IRA/401(k) accounts, and their Roth IRA/401(k) accounts, in the context of a financial model based on American tax law. This optimal strategy follows a geometrically simple, intuitive approach that can be used to maximize the size of a retiree's bequest to an heir or, alternatively, to maximize a retiree's portfolio longevity. We give examples where retirees following the approach currently implemented by major investment firms, like Fidelity and Vanguard, will reduce their bequests by approximately 10% or lose 18 months of portfolio longevity compared to our optimal approach. Further, our strategy and algorithm can be extended to many cases where the retiree has additional, known yearly sources of money, such as income from part‐time work, taxable investment accounts, and Social Security.