The problem I'm solving is
$\begin{cases} & \dot{x}_{1} = -u \\ & \dot{x}_{2} = 4x_{1} \end{cases}$
$x_{1}(0) = x_{2}(0)=0, |u| \leq 3, t \in [0;2], u^{0}(t)\equiv0, J[u] = -2x_{1}(2) + x_{2}(2) - 4 \int_{0}^{2} x_{1}u \text{d}dt \rightarrow min$
I'm going through the gradient projection algorithm, and there is a step $\bar{u}^{k}(t) = P_{U} (u^{k}(t) + \frac{\partial H(t, x^{k}(t), \psi^{k}(t), u^{k}(t))}{\partial x})$
Where $P_{U}$ - a projection operator on U. In my case U is a set $|u| \leq 3$, and I get $\bar{u}^{k}(t) = P_{U} (-2 + 4t), t \in [0;2]$. How do I project a function on U?
actually you don't project the function on the set $U = [-3, 3]$ but the value of the function for a specific $t$.
\begin{equation*} P_U(f(t)) = \begin{cases} -3 &\text{if} & f(t) \leq -3\\ f(t) &\text{if} & -3 < f(t) < 3\\ 3 &\text{if} & 3 \leq f(t) \end{cases} \end{equation*}
see the definition of the projection for instance here (Definition 1.1.): https://www.math.washington.edu/~burke/crs/408f/notes/nlp/gpa.pdf