Inspired by Bret Victor's Explorable Explanations.
Merton's portfolio problem asks how an investor should divide wealth between a risky asset and a risk-free asset while choosing consumption over time. The objective is to maximize expected utility. The problem was formulated and solved by Robert C. Merton in 1969 for both finite and infinite horizons.
We will state the full problem, then focus on how its continuous-time machinery collapses into an elegantly simple rule for sizing the risky asset.
Source code is licensed under the MIT License. Essay content adapted from Wikipedia is available under CC BY-SA 4.0.