# Solution to Dynamic Programming (Bellman Equation) Problem

Could someone please provide pointers on how to solve the below? If any theoretical approximations are possible, that would be very helpful. If numerical solutions are the right approach, could you suggest how we can do this in R (restricted to free software due to limited, actually zero, funding; hence R pointers would be most welcome)?

The Bellman equation to be solved is given by,

$$V_{t}\left(Y_{t-1},Z_{t}\right)=\underset{\left\{ X_{t}\right\} }{\min}\:E_{t}\left[\max\left\{ \left(Y_{t}-Y_{t-1}\right),0\right\} Z_{t}+V_{t+1}\left(Y_{t},Z_{t+1}\right)\right]$$

Here, the notation stands for,

$V_{t}\left(Y_{t-1},Z_{t}\right)$ is the value function at time $t$.

$E_{t}$ is the Expectation taken at time $t$.

$X_{t}$, is the quantity or amount of goods acquired in period $t$ at price $Y_{t}$.

$Z_{t}$, is the number of units that we still need to acquire at time $t$.

$\bar{X}$ =$Z_{1}$, the total quantity of the good that is required.

$T$, the total number of time periods.

$X_{1},...,X_{T}$ is the list of acquisitions that we want to make and needs to be determined.

A simple law of price motion is assumed as below,

$$Y_{t}=Y_{t-1}+\theta X_{t}+\varepsilon_{t}\;,\theta>0\:,E\left[\varepsilon_{t}\left|X_{t},Y_{t-1}\right.\right]=0\;,\;\varepsilon_{t}\sim N\left(0,\sigma_{\varepsilon}^{2}\right)$$

$N\left(0,\sigma_{\varepsilon}^{2}\right)$ is a normal distribution with mean zero and variance $\sigma_{\varepsilon}^{2}$

Also, the following properties hold,

$$\sum_{t=1}^{T}X_{t}=\bar{X}\;,X_{t}\geq0\;,Z_{1}=\bar{X},\;Z_{T+1}=0\;,\;Z_{t}=Z_{t-1}-X_{t-1}$$

PS: Please note, this is not posted on the Mathematics website to solicit answers from a wider audience.

https://math.stackexchange.com/questions/2694694/solution-to-dynamic-programming-bellman-equation-problem