## 3 Dynamic Optimal Control of Industrial Robot in Trajectory Tracking
### Gauss Pseudo-Spectral Method
#### 3.1.1 Lagrange Interpolation Polynomial Approximation  
In this work, the discrete approximation of state variables and control variables is completed using the Lagrange interpolation method. Given \(N+1\) sets of discrete points and their corresponding function values are \(\{(\tau_{1},y_{1}),(\tau_{2},y_{2}),\cdots,(\tau_{N+1},y_{N+1})\}\), the variable can be obtained through \(N\)-degree polynomial interpolation  
\[y(\tau)\approx Y(\tau)=\sum_{i=1}^{N+1}\hat{L}_{i}(\tau)y_{i}, \tag{9}\]  
where \(Y(\tau)\) is the \(N\)-degree polynomial approximation, \(\hat{L}_{i}(\tau)\) is the \(N\)-degree Lagrange interpolation polynomial and which can be calculated using the following formula: \(\hat{L}_{i}(\tau)=\prod\limits_{j=1,j\
eq i}^{N+1}\frac{\tau-\tau_{j}}{\tau_ {i}-\tau_{j}}\). It is defined that \(\hat{L}_{i}(\tau_{j})=\delta_{ij}\), and analysis show that the Lagrange interpolation polynomials have the following characteristics: \(\hat{L}_{i}(\tau_{j})=\delta_{ij}= \begin{cases}1,&i=j\\ 0,&i\
eq j\end{cases} \). Based on the above equation, it can be seen that the interpolation polynomial satisfies \(Y(\tau_{i})=y_{i},i=1,2,\cdots,N+1\) at discrete points, so it is necessary to select appropriate discrete points to obtain the values of \(y_{i}\). However, traditional methods generally divide the time interval into \(N\) equal segments and approximate them using a linear combination of Lagrange interpolation polynomials, but this equidistant separation can easily cause the Runge phenomenon. Therefore, the Legendre polynomial with a better approximation effect is selected for discrete point selection in the [-1, 1] interval, and its \(N\)th Legendre polynomial is  
\[ \begin{array}{l}P_{n+1}(\tau)=(\tau-\alpha_{n})P_{n}(\tau)-\beta_{n}^{2}P_{n -1}(\tau)\\ P_{0}(\tau)=1,P_{-1}(\tau)=0,n=0,1,\cdots,N\end{array} . \tag{10}\]  
Furthermore, by calculating the solution of Equation (10), \(N\) discrete points located within the open interval (-1,1) can be obtained, denoted as \(\tau_{i}(i=1,2,\ldots,N)\), which are called Legendre-Gauss (LG) collocation points. Analysis shows that it is the root of Equation (8). Given the Legendre polynomial of degree \(N\) is \( \begin{array}{l}P_{n+1}(\tau)=(\tau-\alpha_{n})P_{n}(\tau)-\beta_{n}^{2}P_{ n-1}(\tau)\\ P_{0}(\tau)=1,P_{-1}(\tau)=0,n=0,1,\cdots,N\end{array} \), its roots can be solved by the eigenvalues of matrix \(H\), where \(H= \begin{bmatrix}\alpha_{0}&\beta_{1}&&\\ \beta_{1}&\alpha_{1}&\beta_{2}&&\\ &&\ddots&&\\ &&\alpha_{n-2}&\beta_{n-1}\\ &&\beta_{n-1}&\alpha_{n-1}\end{bmatrix} \). Proof. : According to the definition, the roots of an \(N\)th Legendre polynomial are the solutions of the following equation  
\[P_{n+1}(\tau)=(\tau-\alpha_{n})P_{n}(\tau)-\beta_{n}^{2}P_{n-1}(\tau)=0, \tag{11}\]  
when \(n=0\), there is \(P_{1}(\tau)=(\tau-\alpha_{0})P_{0}(\tau)-\beta_{0}^{2}P_{-1}(\tau)\). And according to \(P_{-1}(\tau)=0\) and \(P_{0}(\tau)=1\), so it can be obtained that \(P_{1}(\tau)=(\tau-\alpha_{0})\). When \(n=1\), there is  
\[P_{2}(\tau)=(\tau-\alpha_{1})P_{1}(\tau)-\beta_{1}^{2}P_{0}(\tau). \tag{12}\]  
According to \(P_{0}(\tau)=1\), we have \(P_{2}(\tau)=(\tau-\alpha_{1})P_{1}(\tau)-\beta_{1}^{2}\), thus the root of \(P_{2}(\tau)=0\) is the solution of \((\tau-\alpha_{1})(\tau-\alpha_{0})-\beta_{1}^{2}=0\). It is defined that \(P_{0}(\tau)=1\) and \(A_{1}= \begin{bmatrix}A_{0}&\beta_{1}\\ \beta_{1}&\alpha_{1}\end{bmatrix} \), thus, the eigenvalue of \(A_{1}\) is \(|\lambda I-A_{1}|=(\lambda-A_{0})(\lambda-\alpha_{1})-\beta_{1}^{2}=0\). Analysis shows that the root of \(P_{2}(\tau)=0\) is the eigenvalue of matrix \(A_{1}\). Similarly, the root of \(P_{3}(\tau)=0\) is the solution of \((\tau-\alpha 2)\big{|}\tau I-A_{1}\big{|}-\beta_{2}^{2}\big{|}\tau I-A_{0}\big{|}=0\). So, according to \(A_{2}= \begin{bmatrix}A_{1}&\beta_{2}\\ \beta_{2}&\alpha_{2}\end{bmatrix} \), the eigenvalue of \(A_{2}\) is  
\[|\lambda I-A_{2}|= \begin{vmatrix}\lambda I-A_{1}&-\beta_{2}\\ -\beta_{2}&\lambda-\alpha_{2}\end{vmatrix} =