## 2 Mathematical Model of the Plant  
The Mathematical model of the triple link inverted pendulum shown in Figure 1b is derived based on Lagrangian mechanics established by the scientist [PERSON]. The Lagrangian (\(L\)) of many mechanical systems represents the difference between their kinetic (\(T\)) and potential (\(V\)) energies  
\[L=T-V, \tag{1}\]  
For the triple inverted pendulum model of Figure 1b, the kinetic and potential energies are defined as:  
\[ \begin{array}{c}T=\frac{1}{2}\;m_{1}\bigg{[}\Big{(}\frac{d}{dt}(h_{1}\;sin \theta_{1})\Big{)}^{2}+\Big{(}\frac{d}{dt}(h_{1}\;cos\theta_{1})\Big{)}^{2} \bigg{]}+\frac{1}{2}\;I_{1}\dot{\theta}_{1}^{2}+\frac{1}{2}\;m_{2}\bigg{[} \Big{(}\frac{d}{dt}(\;I_{1}\;sin\theta_{1}+h_{2}\;sin\theta_{2})\Big{)}^{2}+ \Big{(}\frac{d}{dt}(h_{1}\;cos\theta_{1}+h_{2}\;cos\theta_{2})\Big{)}^{2} \bigg{]}+\\ \frac{1}{2}\;I_{2}\dot{\theta}_{2}^{2}+\frac{1}{2}\;m_{3}\bigg{[}\Big{(}\frac {d}{dt}(\;I_{1}\;sin\theta_{1}+l_{2}\;sin\theta_{2}+h_{3}\;sin\theta_{3}) \Big{)}^{2}+\Big{(}\frac{d}{dt}(I_{1}\;cos\theta_{1}+l_{2}\;cos\theta_{2}+h_{ 3}\;cos\theta_{3})\Big{)}^{2}\bigg{]}+\frac{1}{2}\;I_{3}\dot{\theta}_{3}^{2} \end{array}  \tag{2}\]  
\[V=M_{3}\;g\;cos\theta_{1}+M_{2}\;g\;cos\theta_{2}+M_{3}\;g\;cos\theta_{3}, \tag{3}\]  
respectively, where \(g\) represents the acceleration of gravity, and  
\[M_{1}=m_{1}\;h_{1}+m_{2}\;l_{1}+m_{3}\;l_{1}, \tag{4}\]  
\[M_{2}=m_{2}\;h_{2}+m_{3}\;l_{2}, \tag{5}\]\[M_{3}=m_{3}\;h_{3}, \tag{6}\]  
Then, by applying the stationary action principle,  
\[\frac{d}{dt}\;\left(\frac{\partial L}{\partial\dot{\rho}_{k}}\right)=\frac{ \partial L}{\partial\rho_{k}}, \tag{7}\]  
where \(\rho_{j}\) represents the \(k^{th}\) position vector in the generalized coordinates, the equations of motion of the system are obtained [1]:  
\[\left[ \begin{array}{ccc}I_{1}+I_{p1}&l_{1}\;M_{2}cos(\theta_{1}-\theta_{2})- I_{p1}&l_{1}\;M_{3}cos(\theta_{1}-\theta_{3})\\ l_{1}\;M_{2}cos(\theta_{1}-\theta_{2})-I_{p1}&j_{2}+I_{p1}+I_{p2}&l_{2}\;M_{3} cos(\theta_{2}-\theta_{3})-I_{p2}\\ l_{1}\;M_{3}cos(\theta_{1}-\theta_{3})&l_{2}\;M_{3}cos(\theta_{2}-\theta_{3})-I_{ p2}&j_{3}+I_{p2}\end{array} \right]\left[ \begin{array}{c}\ddot{\theta}_{1}\\ \dot{\theta}_{2}\\ \dot{\theta}_{3}\end{array} \right] \tag{8}\]  
\[+\left[ \begin{array}{ccc}C_{1}+C_{2}+C_{p1}&-C_{2}-C_{p1}&0\\ -C_{2}-C_{p1}&C_{p1}+C_{p2}+C_{2}+C_{3}&-C_{3}-C_{p2}\\ 0&-C_{3}-C_{p2}&C_{3}+C_{p2}\end{array} \right]\left[ \begin{array}{c}\theta_{ 1}\\ \dot{\theta}_{2}\\ \dot{\theta}_{3}\end{array} \right]\]  
\[+\left[ \begin{array}{ccc}l_{1}M_{2}\text{sin}(\theta_{1}-\theta_{2})\dot{ \theta}_{2}^{2}+l_{1}M_{3}\text{sin}(\theta_{1}-\theta_{3})\dot{\theta}_{3}^{2 }-M_{1}g\;\text{sin}(\theta_{1})\\ l_{1}M_{2}\text{sin}(\theta_{1}-\theta_{2})\dot{\theta}_{1}^{2}+l_{2}M_{3} \text{sin}(\theta_{2}-\theta_{3})\dot{\theta}_{3}^{2}-M_{2}g\;\text{sin}( \theta_{2})\\ l_{1}M_{3}\text{sin}(\theta_{1}-\theta_{3})\left(\dot{\theta}_{1}^{2}-2\;\dot{ \theta}_{1}\dot{\theta}_{3}\right)+l_{2}M_{3}\text{sin}(\theta_{2}-\theta_{3}) \left(\dot{\theta}_{2}^{2}-2\;\dot{\theta}_{2}\dot{\theta}_{3}\right)-M_{3}g \;\text{sin}(\theta_{3})\end{array} \right]\]  
\[+\left[ \begin{array}{ccc}K_{1}&0\\ -K_{1}&K_{2}\\ 0&-K_{2}\end{array} \right]\left[ \begin{array}{ccc}t_{m1}\\ t_{m2}\end{array} \right]=\left[ \begin{array}{ccc}1&-1&0\\ 0&1&-1\\ 0&0&1\end{array} \right]\left[ \begin{array}{c}d_{1}\\ d_{2}\\ d_{3}\end{array} \right]\]  
\[\text{where }\boldsymbol{\theta}= \begin{bmatrix}\theta_{1}&\theta_{2}&\theta_{3} \end{bmatrix} ^{T}\text{ represents the vector of angles of each link from the vertical line,}\]  
as depicted in Figure 1b. \[J_{1}=I_{1}+m_{1}\;h_{1}^{2}+m_{2}\;l_{1}^{2}+m_{3}\;l_{1}^{2}, \tag{9}\]  
\[J_{2}=I_{2}+m_{2}\;h_{2}^{2}+m_{3}\;l_{2}^{2}, \tag{10}\]  
\[J_{3}=I_{3}+m_{3}\;h_{3}^{2}, \tag{11}\]  
\(I_{i},\;\;m_{i},\;h_{i},\;\text{and}\;l_{i}\) represent the \(i^{th}\) link's moment of inertia around its center of gravity, mass, distance from its bottom to the its center of gravity, and length, respectively.