This Demonstration is premised on the theory of optimal control. Form a Hamiltonian

, where
u represents consumption (the control variable),
w represents wages,
r represents the interest rate,
x represents the level of assets (the state variable), and
y is a Lagrangian. Then take the variational derivative of the Hamiltonian with respect to the control variable and set it equal to zero, the variational derivative of the Hamiltonian with respect to the state variable and set it equal to the derivative of the Lagrangian, and lastly set the Lagrangian function at the terminal time to be equal to zero. With some complicated calculus and algebra facilitated by
Mathematica and its
VariationalMethods Package, the plotted expressions for optimal asset and consumption trajectories shown in this Demonstration are created. This Demonstration does not include as a complication a requirement that assets be positive at all times.