```python
from sympy import *
from sympy import abc
from IPython.display import display, Math, Latex
from sympy.interactive import printing
printing.init_printing(use_latex=True)
```

## Optimal Control Problem
Minimize $$\int_0^Tf(t,x,u)~dt$$ subject to
$$
\begin{cases}
x'(t) = b(t,x,u)\\
x(0) = x_0
\end{cases}
$$


```python
t, x, u= symbols('t x u')
Vt, Vx = symbols('V_t V_x')
f = x + 0.5 * u**2
b = x + u
```

## Hamilton-Jacobi-Bellman Equation


```python
hjbeq = r'\frac{\partial V}{\partial t} + \min_u \left[' + latex(f) + r'+\frac{\partial V}{\partial x}\left(' + latex(b)+ r'\right)\right] = 0'
display(Math(hjbeq))

hjbbd = r'V(T,x)=0'
display(Math(hjbbd))
```


$$\frac{\partial V}{\partial t} + \min_u \left[u^{2}+\frac{\partial V}{\partial x}\left(u\right)\right] = 0$$



$$V(T,x)=0$$


## Successive Approximation


```python
sahjbeq = r'\frac{\partial V_k}{\partial t} + ' + latex(f) + r'+\frac{\partial V_k}{\partial x} \left(' + latex(b) + r'\right)= 0'
display(Math(sahjbeq.replace('u', 'u_k')))

sahjbbd = r'V_k(T,x)=0'
display(Math(sahjbbd))
```


$$\frac{\partial V_k}{\partial t} + u_k^{2}+\frac{\partial V_k}{\partial x} \left(u_k\right)= 0$$



$$V_k(T,x)=0$$



```python
update = r'u_{k+1} = \arg\min_{u_k}\left[' + latex(f) + r'+\frac{\partial V_k}{\partial x} \left(' + latex(b) + r'\right)\right]'
display(Math(update))
```


$$u_{k+1} = \arg\min_{u_k}\left[u^{2}+\frac{\partial V_k}{\partial x} \left(u\right)\right]$$



```python

```

2847ac94eca15f026898d20fad4f88fab65ef0d4
ipynb
Jupyter Notebook
jupyter/HJB Equation Generator.ipynb
yoon-gu/stoc
ac23df3206d55a7c1e780813156d0c4810e92fd0
MIT
2018-01-30T00:55:25.000Z
2019-09-28T14:35:55.000Z
jupyter/HJB Equation Generator.ipynb
yoon-gu/stoc
ac23df3206d55a7c1e780813156d0c4810e92fd0
MIT
2016-08-16T07:10:06.000Z
2016-09-02T10:52:22.000Z
jupyter/HJB Equation Generator.ipynb
yoon-gu/stoc
ac23df3206d55a7c1e780813156d0c4810e92fd0
MIT
2021-11-12T14:07:07.000Z
2021-11-12T14:07:07.000Z
Qwen/Qwen-72B
1. YES
2. YES