Merton considers a continuous time market in equilibrium.
The state variable (X) follows a Brownian motion:

The investor maximizes his Von Neumann–Morgenstern utility:
![{\displaystyle E_{o}\left\{\int _{o}^{T}U[C(t),t]dt+B[W(T),T]\right\}}](//wikimedia.org/api/rest_v1/media/math/render/svg/0e613cbd824424c5d2306d6e668c4a3d1faeae1e)
where T is the time horizon and B[W(T),T] the utility from wealth (W).
The investor has the following constraint on wealth (W).
Let
be the weight invested in the asset i. Then:
![{\displaystyle W(t+dt)=[W(t)-C(t)dt]\sum _{i=0}^{n}w_{i}[1+r_{i}(t+dt)]}](//wikimedia.org/api/rest_v1/media/math/render/svg/e9b3b677781f1c972004dcd693cb5521ff476ee2)
where
is the return on asset i.
The change in wealth is:
![{\displaystyle dW=-C(t)dt+[W(t)-C(t)dt]\sum w_{i}(t)r_{i}(t+dt)}](//wikimedia.org/api/rest_v1/media/math/render/svg/cf62015ff2eb5196b6b00be413913348c5502b45)
We can use dynamic programming to solve the problem. For instance, if we consider a series of discrete time problems:
![{\displaystyle \max E_{0}\left\{\sum _{t=0}^{T-dt}\int _{t}^{t+dt}U[C(s),s]ds+B[W(T),T]\right\}}](//wikimedia.org/api/rest_v1/media/math/render/svg/4a6900036ac4577e1595b01b4b11d92ef769c74a)
Then, a Taylor expansion gives:
![{\displaystyle \int _{t}^{t+dt}U[C(s),s]ds=U[C(t),t]dt+{\frac {1}{2}}U_{t}[C(t^{*}),t^{*}]dt^{2}\approx U[C(t),t]dt}](//wikimedia.org/api/rest_v1/media/math/render/svg/9cb7e91e10b07dbc3e602f321f3157f287641939)
where
is a value between t and t+dt.
Assuming that returns follow a Brownian motion:

with:
- ;\quad E(r_{i}^{2})=var(r_{i})=\sigma _{i}^{2}dt\quad ;\quad cov(r_{i},r_{j})=\sigma _{ij}dt}

Then canceling out terms of second and higher order:
![{\displaystyle dW\approx [W(t)\sum w_{i}\alpha _{i}-C(t)]dt+W(t)\sum w_{i}\sigma _{i}dz_{i}}](//wikimedia.org/api/rest_v1/media/math/render/svg/6659388859678ed334ade93acbd9cddd97d9cf1f)
Using Bellman equation, we can restate the problem:
![{\displaystyle J(W,X,t)=max\;E_{t}\left\{\int _{t}^{t+dt}U[C(s),s]ds+J[W(t+dt),X(t+dt),t+dt]\right\}}](//wikimedia.org/api/rest_v1/media/math/render/svg/727aa63687a7522b063223cd684c70d0959c41b2)
subject to the wealth constraint previously stated.
Using Ito's lemma we can rewrite:
![{\displaystyle dJ=J[W(t+dt),X(t+dt),t+dt]-J[W(t),X(t),t+dt]=J_{t}dt+J_{W}dW+J_{X}dX+{\frac {1}{2}}J_{XX}dX^{2}+{\frac {1}{2}}J_{WW}dW^{2}+J_{WX}dXdW}](//wikimedia.org/api/rest_v1/media/math/render/svg/71ba6ca6d619cbddcf66b8685301da655be0c3cb)
and the expected value:
![{\displaystyle E_{t}J[W(t+dt),X(t+dt),t+dt]=J[W(t),X(t),t]+J_{t}dt+J_{W}E[dW]+J_{X}E(dX)+{\frac {1}{2}}J_{XX}var(dX)+{\frac {1}{2}}J_{WW}var[dW]+J_{WX}cov(dX,dW)}](//wikimedia.org/api/rest_v1/media/math/render/svg/e9effb1c061fd7713e0b61acd75bada19eb0e044)
After some algebra[2]
, we have the following objective function:
![{\displaystyle max\left\{U(C,t)+J_{t}+J_{W}W[\sum _{i=1}^{n}w_{i}(\alpha _{i}-r_{f})+r_{f}]-J_{W}C+{\frac {W^{2}}{2}}J_{WW}\sum _{i=1}^{n}\sum _{j=1}^{n}w_{i}w_{j}\sigma _{ij}+J_{X}\mu +{\frac {1}{2}}J_{XX}s^{2}+J_{WX}W\sum _{i=1}^{n}w_{i}\sigma _{iX}\right\}}](//wikimedia.org/api/rest_v1/media/math/render/svg/2b0e5f5be78e2d9c0cca2925f708cd452b50f5a6)
where
is the risk-free return.
First order conditions are:

In matrix form, we have:

where
is the vector of expected returns,
the covariance matrix of returns,
a unity vector
the covariance between returns and the state variable. The optimal weights are:

Notice that the intertemporal model provides the same weights of the CAPM. Expected returns can be expressed as follows:

where m is the market portfolio and h a portfolio to hedge the state variable.