# Optimal allocation problem by finite differences

I am attempting to apply implicit finite difference to solve Merton's problem of optimal portfolio allocation for constant parameters.

The equation to solve is the Hamilton-Jacobi-Bellman equation: $$\max_{\pi\in[0, 1]}\left\{ \frac{1}{2}\pi^2\sigma^2X^2\frac{\partial^2V}{\partial X^2} + \left[ r+\pi(\mu-r) \right]X\frac{\partial V}{\partial X} + \frac{\partial V}{\partial t} \right\} = 0$$

Since $$r$$, $$\mu$$ and $$\sigma$$ are constants, then so is the optimal portfolio allocation $$\pi$$.

By discretizing $$\pi$$ and using the following parameters:

$$r=0.06, \;\; \mu=0.1, \;\; \sigma =0.35, \;\; X_0=100$$ and $$T=1$$

I want to apply an implicit finite difference scheme with the following boundary conditions: $$V(t, x) = e^{-\alpha \gamma (T-t)}\frac{x^{\gamma}}{\gamma} \;\;\;, \ X>>1$$ $$V(t, 0) = 0 \;\;\;, \ X=0$$ $$V(T, x) = \frac{x^{\gamma}}{\gamma} \;\;\;, \ t=T$$

My professor says that the equation must be solved from time $$T$$ to time $$t=0$$, but I have no previous experience working with finite differences, so I would appreciate any pointers on how to get started.

• I am not an expert on Merton's Portfolio problem, but it seems to me the solution in this case is known in closed form: $\pi=\frac{\mu-r}{\sigma^2 (1-\gamma)}$. See eqn 3.1 page 12 here duo.uio.no/bitstream/handle/10852/10798/… Is there a need for a numerical solution? – noob2 Nov 23 '18 at 0:50
• Hello, yeah the theoretical answer is straightforward, but what I want to do is learn to use finite differences. I'm not sure how I would do to discretize this equation – scrps93 Nov 23 '18 at 2:12
• I would replace $\frac{\partial V}{\partial X}$ by $\frac{V(X+h,t)-V(X,t)}{h}$, replace $\frac{\partial^2 V}{\partial X^2}$ by $= \frac{V(x+h,t) - 2 V(x,t) + V(x-h,t)}{h^{2}}$ and $\frac{\partial V}{\partial t}$ by $\frac{V(X,t)-V(X,t-g)}{g}$. but check if this works in a small (4 by 4 say) rectangular grid. – noob2 Nov 23 '18 at 3:21