# Inducing Optimality in Prescribed Performance Control for Uncertain Euler-Lagrange Systems
## 4 Methodology
### Solving the Hamilton-Jacobi-Bellman Equation  
This subsection is dedicated to finding an admissible policy (8) that minimizes (6) and guarantees predefined transient and steady-state performance specifications. Towards this direction, a successive approximation strategy is adopted similarly to [21], where the approximation of the cost function converges uniformly to the optimal cost function. In this respect, the solution to the HJB equation (i.e., the unknown cost function \(J(q,\rho,\epsilon)\)) is expanded over a set of basis functions with adjustable weights. The approximate solution assumed here is:  
\[J_{L}(q,\rho,\epsilon)=\sum_{j=1}^{L}w_{j}^{i}\sigma_{j}(q,\rho,\epsilon)=w_{L }^{T}\sigma(q,\rho,\epsilon) \tag{13}\]  
where \(J_{L}(q,\rho,\epsilon)\) denotes the approximation of the unknown cost function, \(J(q,\rho,\epsilon)\), \(\mathbf{\sigma_{L}}=\big{[}\sigma_{1},\dots,\sigma_{L}\big{]}^{T}\) includes polynomial regressor terms, and \(\mathbf{w_{L}}=\big{[}w_{1},\dots,w_{L}\big{]}^{T}\) denotes the weight vector to be successively adjusted so that the residual error may be minimized, i.e., the best-fitted solution \(J_{L}(q,\rho,\epsilon)\) to the HJB equation is extracted. Hence, if we substitute the trial solution into the HJB equation, the residual is formed as:  
\[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}\]  
where  
\[\dot{q}=\text{diag}(\rho)T^{-1}(\epsilon)-\lambda(q-\bar{q}_{d})\] \[\dot{\rho}=-l\rho+l\rho_{\infty}\] \[\dot{\epsilon}=\text{diag}(\rho)^{-1}\text{diag}(T^{-1}(\epsilon ))^{-1}(f(q,\dot{q})+g(q)\tau-T^{-1}(\epsilon)(-l\rho+l\rho_{\infty}))\]  
In order to calculate the unknown weights \(w_{L}\), the inner product of the residual and its derivative with respect to the weights is set to zero as follows:  
\[\langle\frac{de_{L}}{dw_{L}},e_{L}\rangle=0\Leftrightarrow\]  
\[w_{L}^{T}\langle\sum_{i=1}^{n}\
abla_{q_{i}}\sigma^{T}\dot{q}_{i}+ \sum_{i=1}^{n}\
abla_{\rho_{i}}\sigma^{T}\dot{\rho_{i}}+\sum_{i=1}^{n}\
abla_ {\epsilon_{i}}\sigma^{T}\dot{\epsilon}_{i},\] \[\sum_{i=1}^{n}\
abla_{q_{i}}\sigma^{T}\dot{q}_{i}+\sum_{i=1}^{n} \
abla_{\rho_{i}}\sigma^{T}\dot{\rho_{i}}+\sum_{i=1}^{n}\
abla_{\epsilon_{i}} \sigma^{T}\epsilon_{i}\rangle+\] \[\langle\alpha\|\epsilon\|^{2}+\beta\|\tau(q,\rho,\epsilon)-G(q_{ d})\|^{2},\] \[\sum_{i=1}^{n}\
abla_{q_{i}}\sigma^{T}\dot{q}_{i}+\sum_{i=1}^{n} \
abla_{\rho_{i}}\sigma^{T}\dot{\rho_{i}}+\sum_{i=1}^{n}\
abla_{\epsilon_{i}} \sigma^{T}\epsilon_{i}\rangle=0\]  
where the inner product between two vectors \(u\) and \(v\) is given by \(\langle u,v\rangle=\int_{Y}uv\,dV\) over a domain \(\mathcal{V}\). To solve the aforementioned problem with respect to \(w_{L}\), a discretization of P points \((q^{i},\rho^{i},\epsilon^{i}),\ i=1,\ldots,P\) is applied over a compact set \(\Omega_{z}\subset\Re^{3n}\) in order to obtain the following terms:  
\[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}\]0  
\[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}\]1  
Consequently, the weights \(w_{L}\) may be calculated using the least-squares method as follows:  
\[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}\]2  
and then be employed to update the optimal control policy in (8) by calculating the gradient of \(J_{L}(q,\rho,\epsilon)\) along \(\epsilon\).