© 2026 NeckPinch · www.neckpinch.com · All rights reserved.
Course 6Book 6D: Diffusions, Finance and ComputationChapter 8
Stochastic Control and the HJB Equation
Dynamic programming, the Hamilton–Jacobi–Bellman equation, verification and Merton’s portfolio problem.
Read with Øksendal, Stochastic Differential Equations, chapter 11 (application to stochastic control: the HJB equation, the verification theorem and the portfolio problem), and Evans, Partial Differential Equations, section 10.3 (the deterministic case, already met in 6C.9 Hamilton–Jacobi Equations and Viscosity Solutions). Fleming and Soner, Controlled Markov Processes and Viscosity Solutions, and Pham, Continuous-time Stochastic Control and Optimization with Financial Applications, are the references; Merton, "Lifetime portfolio selection under uncertainty: the continuous-time case" (Rev. Econ. Stat. 51, 1969), is the source of the portfolio problem. This chapter derives the HJB equation, proves the verification theorem, solves Merton's problem and the linear-quadratic regulator, and derives the Kelly criterion; the dynamic programming principle and the viscosity characterisation of the value function are stated. The portfolio results are mathematics about a model, not investment advice.
In 6D.6 Black–Scholes the investor's task was to hedge: hold whatever position replicates a contract. Here the task is to choose: how much to invest, how fast to steer, how much to consume, to make some expected reward as large as possible. When the system is a diffusion and the choice can be revised continuously, the answer is governed by a nonlinear second-order PDE, the Hamilton–Jacobi–Bellman equation
the stochastic version of the first-order HJB equation of 6C.9 Hamilton–Jacobi Equations and Viscosity Solutions. The supremum over controls of a family of linear operators makes it a fully nonlinear equation of the Bellman type of 6C.10 Fully Nonlinear Equations and Monge–Ampère.
The strategy is always the same. Guess or compute a solution of the HJB equation; read off the optimal control as the maximiser in the supremum, a feedback rule depending on the current state; and confirm, by a verification theorem proved with Itô's formula, that the candidate really is optimal. We carry this out for Robert Merton's portfolio problem, whose answer, a constant fraction of wealth in the risky asset, is one of the classical results of financial economics, and for the linear-quadratic regulator of engineering.
By the end of this chapter you will be able to:
- set up a stochastic control problem, state the dynamic programming principle, and derive the HJB equation from it with Itô's formula;
- prove the verification theorem;
- solve Merton's problem for power utility, and derive the Kelly criterion as the logarithmic case;
- solve the linear-quadratic regulator through a Riccati equation;
- explain why value functions are in general viscosity solutions, and connect the Li–Yau Harnack inequality to an optimal control problem.
How much to bet
In 1956 John Kelly, an engineer at Bell Labs, asked how a gambler with an edge should size repeated bets. Maximising expected wealth says "bet everything every time", which ruins the gambler almost surely. Kelly proposed maximising the expected logarithm of wealth, equivalently the long-run growth rate, and found that the optimal fraction for a bet won with probability at even odds is . The mathematician Edward Thorp applied the criterion to blackjack, where card counting gives a small edge, published Beat the Dealer in 1962, and later used the same ideas in investment management.
In 1969 Robert Merton solved the continuous-time version for an investor choosing between a bank account and a stock following geometric Brownian motion, for a whole family of attitudes to risk. His answer is a constant fraction of wealth in the stock, , with the investor's risk aversion; the Kelly criterion is (Theorem 8.2). The formula shows how the optimal exposure falls with volatility and rises with the expected excess return. In practice the expected return is very hard to estimate, and errors in it pass straight into the optimal fraction, which is one reason why practitioners usually invest less than the formula says. The formula is a statement about a model, and this chapter treats it as mathematics.
Controlled diffusions and dynamic programming
Let be a set of control values (a subset of some ). A control is an adapted process , and the controlled state follows
with , Lipschitz in uniformly in , so that the SDE has a unique solution for each admissible control (6D.3 Stochastic Differential Equations and Feynman–Kac). The controller collects a running reward and a terminal reward , and the value function is
(Minimising a cost is the same with replaced by .)
The dynamic programming principle (statement; Fleming and Soner, chapter IV, and Pham, section 3.3): for ,
It is Bellman's principle of optimality, and its proof is the same as in the deterministic case (6C.9 Hamilton–Jacobi Equations and Viscosity Solutions) except for a measurable selection of nearly optimal controls from each intermediate state, which is technical.
Formal derivation of HJB. Suppose is . Use the constant control on in the principle, and Itô's formula (6D.2 Martingales and the Itô Integral) for :
with the generator for the fixed control (the stochastic integral has mean zero). Divide by and let : for every . For an optimal (or nearly optimal) control the inequality becomes an equality in the limit. So
The equation is degenerate elliptic in the sense of 6C.9 Hamilton–Jacobi Equations and Viscosity Solutions, and parabolic backwards in time.
The verification theorem
Let satisfy (HJB) with . Assume that for every admissible control the stochastic integral arising below is a martingale (for instance, bounded), and that the integrability needed to take expectations holds. Then:
- ;
- if there is a measurable attaining the supremum in (HJB) at every point, such that the SDE with the feedback control has a solution, then and is optimal.
Proof. Fix and an admissible control with state . By Itô's formula,
By (HJB), at every point. Taking expectations (the stochastic integral has mean zero),
Taking the supremum over gives (1). For the feedback control the inequality is an equality, so the reward of equals . Hence , so and attains the supremum.
The theorem needs a smooth solution of (HJB). When one exists (as in the examples below), it settles the problem completely and produces the optimal control in feedback form, which is how controls are implemented: measure the state, apply . When the value function is not smooth, the dynamic programming principle still shows that it is a viscosity solution of (HJB), and comparison principles of the Crandall–Ishii–Lions type (6C.9 Hamilton–Jacobi Equations and Viscosity Solutions) show it is the unique one (statement; Fleming and Soner, chapters IV–V). Pierre-Louis Lions established this framework for stochastic control in 1983. It is the reason value functions are well defined and computable (by monotone finite difference schemes, which converge to viscosity solutions by a theorem of Guy Barles and Panagiotis Souganidis, 1991) even when they have kinks.
Merton's portfolio problem
An investor has wealth , holds the amount in a stock with and the rest in a bank account at rate , with . Since in stock earns and in the bank earns ,
The investor maximises expected utility of terminal wealth, , with the power utility
Concavity of expresses risk aversion: a certain amount is preferred to a gamble with the same mean. The parameter is the relative risk aversion, constant for this family. Write for the market price of risk (6D.6 Black–Scholes).
The HJB equation for is
If (concavity in ), the supremum of the quadratic in is attained at
For power utility with , the value function is
and the optimal strategy invests the constant fraction
of current wealth in the stock. For (logarithmic utility) the optimal fraction is and .
Proof. Solving HJB. Try with . Then , , and . Substituting,
with . So .
Verification. With the constant fraction , wealth is a geometric Brownian motion, , with all moments finite, so the feedback SDE has a solution. For a general admissible strategy, apply the argument of Theorem 8.1 to : the drift is for every (the quadratic in has maximum by HJB), so is a local supermartingale, and a supermartingale under the admissibility condition (Merton's admissible strategies keep and satisfy an integrability condition; Pham, section 3.6). Hence , with equality for the constant-fraction strategy, for which is a true martingale (it is a geometric Brownian motion with zero drift, by the HJB equation). The case is the same with (Exercise 8.3).
Three features of the answer deserve comment. The fraction is constant: it does not depend on wealth or on the horizon, a consequence of the scale invariance of power utility and of the constant coefficients (Paul Samuelson proved the discrete-time analogue in 1969). It is myopic: the investor behaves as if the horizon were one instant away. And it is the mean–variance trade-off: the instantaneous excess return of the portfolio is and its variance , and maximises . With , , and , the fraction is .
The Kelly criterion
For , the investor maximises . For a constant fraction , by Itô's formula,
so almost surely as (the Brownian term grows like ). The long-run growth rate is maximised at the Kelly fraction , with . Over long horizons, the Kelly strategy's wealth eventually exceeds that of any other constant-fraction strategy, almost surely (Leo Breiman proved a general version in 1961).
The parabola shows the danger of overbetting: (Exercise 8.4), so betting twice the Kelly fraction gives no more growth than the bank account while taking large risks, and beyond the growth rate is below and eventually negative. The Itô correction is the volatility drag of 6D.2 Martingales and the Itô Integral (geometric Brownian motion there): it is why the median outcome of a leveraged position can lose money even when its mean grows.
The linear-quadratic regulator
In engineering, the standard control problem steers a linear system near a target with quadratic costs. In one dimension, with and the cost
to be minimised (), the HJB equation is , . The infimum is at , and the ansatz gives the Riccati equation
with optimal feedback (Exercise 8.6). In dimensions with , costs , the same calculation gives the matrix Riccati equation and the feedback . Rudolf Kálmán's work on this problem and on filtering (1960) became standard in aerospace guidance and control engineering; the noise affects the cost but not the optimal feedback, a form of certainty equivalence.
The Li–Yau Harnack inequality (6A.12 Entropy, Information and Diffusion) is obtained from a differential inequality by integrating along a path and optimising over paths, a deterministic control problem whose value is the Gaussian exponent (Exercise 8.8). Hamilton's Harnack inequality for the Ricci flow is used the same way (11B.2 Ancient Solutions and the Harnack Inequality), and Perelman's -length (12A.5 Reduced Distance and Reduced Volume) builds the optimisation into a definition: the reduced distance is the value function of a control problem on space-time, and its Hamilton–Jacobi inequalities (6C.9 Hamilton–Jacobi Equations and Viscosity Solutions) give the monotonicity of the reduced volume.
History
Richard Bellman formulated dynamic programming in the 1950s, and Lev Pontryagin's school developed the maximum principle for deterministic control at the same time. Wendell Fleming and others developed stochastic control in the 1960s, and Robert Merton solved the portfolio problem in 1969 (with consumption in 1971). Rudolf Kálmán's linear-quadratic theory dates from 1960, John Kelly's criterion from 1956, and Leo Breiman's optimality theorem from 1961. Pierre-Louis Lions proved in 1983 that value functions of stochastic control problems are viscosity solutions of the HJB equation, and Barles and Souganidis's convergence theorem for numerical schemes dates from 1991.
For a controlled diffusion with rewards and , dynamic programming and Itô's formula give the HJB equation , . The verification theorem: a smooth solution dominates every strategy's reward, and equals the reward of the feedback control that attains the supremum. Merton: with power utility, invest the constant fraction ; for log utility this is the Kelly fraction , maximising the growth rate , and twice Kelly grows only at . The linear-quadratic regulator reduces to a Riccati equation with linear feedback. When value functions are not smooth they are the unique viscosity solutions. 6D.9 Finite Difference Methods turns to computation: finite difference schemes for parabolic equations, their stability and convergence.
Exercises
For , try in the HJB equation. Show that and .
Solution
, , so . The equation becomes (since ), with .
With , , : (a) compute the Kelly fraction and the optimal growth rate. (b) Compute for and , and show in general that and .
Solution
(a) (that is, of wealth, borrowing the rest), , . (b) ; with , . For : . For : . Half-Kelly keeps three quarters of the excess growth with half the volatility.
For and the parameters of Exercise 8.4, compute the Merton fraction and . The certainty equivalent growth rate is the riskless rate that would give the same expected utility; show that it equals , using .
Solution
Fraction ; . Indeed .
(a) Derive and from the HJB equation for the linear-quadratic problem in the text. (b) Show that if , then , and the optimal control is the constant-gain feedback . (c) Under this feedback, is an Ornstein–Uhlenbeck process (6D.3 Stochastic Differential Equations and Feynman–Kac); find its stationary variance.
Solution
(a) With : , , , . So for all . (b) with . (c) , with stationary variance .
Steer with to minimise . Write the HJB equation and show that any smooth solution with having the sign of gives the optimal feedback : push towards the origin at full strength.
Solution
For minimisation, , i.e. , . The infimum of the linear function over is at , which is when has the sign of (as it does by symmetry and monotonicity). Optimal controls of linear-in-control problems with bounded controls take extreme values: "bang-bang".
Let solve on and satisfy the Li–Yau inequality (6A.12 Entropy, Information and Diffusion). (a) For a path , show that . (Use .) (b) Integrate and optimise over paths from to to get
(c) Identify the control problem: the control is , the running cost , and the value is the exponent. Hamilton's Harnack inequality for Ricci flow and Perelman's -length are obtained by the same optimisation with curvature terms added to the cost (11B.2 Ancient Solutions and the Harnack Inequality, 12A.5 Reduced Distance and Reduced Volume).
Solution
(a) . (b) Integrating, . By Cauchy–Schwarz, , with equality for the straight line at constant speed, the optimal control. (c) As stated: the minimal cost is the value function of a deterministic control problem, the Hopf–Lax value of 6C.9 Hamilton–Jacobi Equations and Viscosity Solutions with .
Free resources for this chapter
Chosen for what this chapter covers, and all free to read. Links checked Oct 20, 2026.
- Reference Hamilton–Jacobi–Bellman equationWikipediaThe HJB equation in deterministic and stochastic control.
- Reference Merton's portfolio problemWikipediaMerton's solution for power utility.
- Reference Kelly criterionWikipediaGrowth-optimal betting and investing.
- Reference Linear–quadratic regulatorWikipediaThe LQR problem and the Riccati equation.
© 2026 NeckPinch (www.neckpinch.com). All content in the guidebook (text, mathematics, figures and exercises) is protected by copyright. All rights reserved. No part may be copied, republished or redistributed without written permission.