Imagine you have a pile of money. You want to invest some of it and spend some over your life. You can adjust your investments at any moment as markets shift. How much of your wealth should go into stocks, and how much should you take out to spend? This chapter shows two powerful methods—dynamic programming and martingales—that make this problem manageable and reveal a beautiful pattern behind smart investing.