# Inducing Optimality in Prescribed Performance Control for Uncertain Euler-Lagrange Systems
## 4 Methodology
### Solving the Hamilton-Jacobi-Bellman Equation
However, owing to the fact that the approximation capabilities of polynomials hold locally over a compact set, when employing the optimal control policy (8) we need to ensure that the trajectories of \(q,\rho,\epsilon\) evolve strictly within the compact set where the approximation of the cost function is valid. Owing to the decreasing property of the performance function, we have that \(\rho(t)\leq\rho_{0}\ \forall t\geq 0\). Consequently, if \(\rho_{0}\) belongs to the compact set, so does the trajectory \(\rho(t)\). Here, \(\Omega_{z}\) is chosen to be symmetric in each variable \(\epsilon_{i}\) about zero, i.e., \(\epsilon_{i}\in[-c,c]\). In addition, from the proof of Proposition 1, if \(q(0)\in\Omega_{z}\), then \(q\) stays trapped inside \(\Omega_{z}\) as well. Therefore, what remains is to guarantee that the transformed error stays inside \(\Omega_{z}\), which is achieved by imposing constraints on the weights \(w_{L}\). Consider the n-dimensional cube:  
\[e_{L}(q,\rho,\epsilon)=w_{L}^{T}(\sum_{i=1}^{n}\
abla_{q,\sigma} \sigma^{T}q_{i}+\
abla_{\rho,\sigma}\sigma^{T}\phi_{i}+\
abla_{\epsilon, \sigma}\sigma^{T}\epsilon_{i})+\alpha\|\epsilon\|^{2}+\beta\|\tau(q,\rho, \epsilon)-G(\bar{q}_{d})\|^{2}=0 \tag{14}\]3  
The transformed error stays trapped inside M if for the inner product of \(\hat{\epsilon}^{T}=[\epsilon_{1}(t),\dot{\epsilon}_{2}(t),\ldots,\dot{ \epsilon}_{N}(t)]\) and \(\
abla V(\epsilon)\), it holds that \(\hat{\epsilon}^{T}\
abla V(\epsilon)\leq 0\). Essentially, this means that for each of the \(2n\) facets of the \(n\)-dimensional cube, we have \(\dot{\epsilon}_{N}\leq 0\) if \(\epsilon_{N}=c\), and \(\dot{\epsilon}_{N}\geq 0\) if \(\epsilon_{N}=-c\). Differentiating \(\epsilon_{i}\), we obtain:  
\[e_{L}(q,\rho,\epsilon)=w_{L}^{T}(\sum_{i=1}^{n}\
abla_{q,\sigma} \sigma^{T}q_{i}+\
abla_{\rho,\sigma}\sigma^{T}\phi_{i}+\
abla_{\epsilon, \sigma}\sigma^{T}\epsilon_{i})+\alpha\|\epsilon\|^{2}+\beta\|\tau(q,\rho, \epsilon)-G(\bar{q}_{d})\|^{2}=0 \tag{14}\]4  
where \(\ddot{q}_{i}=f_{i}+g_{i}^{T}\tau^{*}\), and \(f_{  
To guarantee safety [28], a discretization of \(M\) points is applied over each facet of the cube, for which:  
\[ \begin{split}\tilde{A}_{i}^{+}&=\left[A_{i}^{T}(q^{1}, \rho^{1},\epsilon^{1^{+}}),\ldots,A_{i}^{T}(q^{M},\rho^{M},\epsilon^{M^{+}}) \right]\\ \tilde{A}_{i}^{-}&=\left[A_{i}^{T}(q^{1},\rho^{1}, \epsilon^{1^{-}}),\ldots,A_{i}^{T}(q^{M},\rho^{M},\epsilon^{M^{-}})\right]\\ \tilde{B}_{i}^{+}&=\left[B_{i}(q^{1},\rho^{1}, \epsilon^{1^{+}}),\ldots,B_{i}(q^{M},\rho^{M},\epsilon^{M^{+}})\right]\\ \tilde{B}_{i}^{-}&=\left[B_{i}(q^{1},\rho^{1}, \epsilon^{1^{-}}),\ldots,B_{i}(q^{M},\rho^{M},\epsilon^{M^{-}})\right]\end{split}  \tag{21}\]  
and \(\epsilon^{j^{-}}\left(\epsilon^{j^{+}}\right)\) denotes the \(j\)th sample point where \(e_{i}\) is fixed at \(e_{i}=-c\left(e_{i}=c\right)\). Summarizing, for each \(e_{i}\), the following inequality constraints must be satisfied:  
\[ \begin{bmatrix}\tilde{A}_{i}^{+}\\ -\tilde{A}_{i}^{-}\end{bmatrix} w_{L}\leq \begin{bmatrix}-\tilde{B}_{i}^{+}\\ \tilde{B}_{i}^{-}\end{bmatrix}  \tag{22}\]  
Therefore, the weights \(w_{L}\) may be obtained by solving the constrained least-squares problem:  
\[\min_{w_{L}}\frac{1}{2}\|Xw_{L}+Y\|^{2},\text{ s.t. }\tilde{A}w_{L}\leq\tilde{B} \tag{23}\]  
where  
\[\tilde{A}= \begin{bmatrix}\tilde{A}_{1}^{+}\\ -\tilde{A}_{1}^{-}\\ \vdots\\ \tilde{A}_{N}^{+}\\ -\tilde{A}_{N}^{-}\end{bmatrix} ,\ \tilde{B}= \begin{bmatrix}-\tilde{B}_{1}^{+}\\ \tilde{B}_{1}^{-}\\ \vdots\\ -\tilde{B}_{N}^{+}\\ \tilde{B}_{N}^{-}\end{bmatrix} \]  
It should be noted that (23) can be solved as a quadratic optimization problem with linear constraints; thus, plenty of robust and computationally efficient methods to tackle it exist [29]. The aforementioned procedure that is applied iteratively to find an approximation of the optimal solution to the HJB equation is presented in Algorithm 1 and the results are summarized in the following Theorem.