## 3 Controller Design
### Neural Network Control
When the cost function is greater than \(\varepsilon_{si}\), the adjusted gains for driving the state trajectory towards the sliding surface are updated, and when the error is greater than \(\varepsilon_{ei}\), the slope of the sliding surface \(\lambda\) is adjusted based on the chain-rules:  
\[k_{i1}(t+1)=k_{i1}(t)+\eta_{k_{i1}}\frac{\partial E_{i}(t)}{\partial k_{i1}} \tag{25}\]  
\[k_{i2}(t+1)=k_{i2}(t)+\eta_{k_{i2}}\frac{\partial E_{i}(t)}{\partial k_{i2}} \tag{26}\]  
\[k_{i3}(t+1)=k_{i3}(t)+\eta_{k_{i3}}\frac{\partial E_{i}(t)}{\partial k_{i3}} \tag{27}\]  
\[\lambda_{i1}(t+1)=\lambda_{i1}(t)+\eta_{\lambda_{i1}}\frac{\partial E_{i}(t)} {\partial\lambda_{i1}} \tag{28}\]  
\[\lambda_{i2}(t+1)=\lambda_{i2}(t)+\eta_{\lambda_{i2}}\frac{\partial E_{i}(t)} {\partial\lambda_{i2}} \tag{29}\]  
where \(\eta_{k_{im}}\) (\(m\) = 1,2,3) and \(\eta_{\lambda_{in}}\) (\(n\) = 1,2) are the learning rate of each gain and factors of the sliding surface. Both \(\eta_{k_{im}}\) and \(\eta_{\lambda_{in}}\) are positive constants. Figure 4: An architecture of the proposed neural network based sliding mode control. The change of each gain is computed using gradient descent:  
\[\frac{\partial E_{i}(t)}{\partial k_{l1}(i)}=\frac{\partial E_{i}(t)}{\partial q _{i}(t)}\frac{\partial q_{i}(t)}{\partial\tau_{i}(t)}\frac{\partial\tau_{i}(t)} {\partial u_{i}(t)}\frac{\partial u(t)}{\partial k_{l1}(t)}=-e_{i}\frac{ \Delta q_{i}(t)}{\Delta\tau_{i}(i)}1(-s_{i}) \tag{30}\]  
\[\tau_{robust\_i}=f_{i2}(u_{i})=u_{i}. \tag{23}\]0  
\[\tau_{robust\_i}=f_{i2}(u_{i})=u_{i}. \tag{23}\]1  
After updating the controller gains, the slope of the sliding surface is then tuned due to the back-propagation process to satisfy the performance. The change of the slope is computed as:  
\[ \begin{array}{rl}\frac{\partial E_{i}(t)}{\partial\lambda_{l1}(t)}&=\frac{ \partial E_{i}(t)}{\partial q_{l1}(t)}\frac{\partial q_{i}(t)}{\partial\tau_{ i}(t)}\frac{\partial\tau_{i}(t)}{\partial u_{i}(t)}\frac{\partial u_{i}(t)}{ \partial s_{i}(t)}\frac{\partial s_{i}(t)}{\partial y_{i}(t)}\frac{\partial y _{i}(t)}{\partial\lambda_{l1}(t)}\\ &=-e_{i}\frac{\Delta q_{i}(t)}{\Delta\tau_{i}(t)}1\!\!\left(-k_{l1}-k_{l2} \frac{\partial(\tanh(s_{i}(t)))}{\partial s_{i}(t)}\right)\!\!\!f^{\prime}_{i1 }e_{i}\ =-e_{i}\frac{\Delta q_{i}(t)}{\Delta\tau_{i}(t)}1\!\!\left(-k_{l1}-k_{l2} \frac{4e^{-2s_{i}}}{(1+e^{-2s_{i}})^{2}}\right)\!\!1e_{i}\\ \frac{\partial E_{i}(t)}{\partial\lambda_{l2}(t)}&=\frac{\partial E_{i}(t)}{ \partial q_{i}(t)}\frac{\partial q_{i}(t)}{\partial\tau_{i}(t)}\frac{\partial u _{i}(t)}{\partial u_{i}(t)}\frac{\partial u_{i}(t)}{\partial s_{i}(t)}\frac{ \partial s_{i}(t)}{\partial y_{i}(t)}\frac{\partial y_{i}(t)}{\partial\lambda _{l2}(t)}\\ &=-e_{i}\frac{\Delta q_{i}(t)}{\Delta\tau_{i}(t)}1\!\!\left(-k_{l1}-k_{l2} \frac{\partial(\tanh(s_{i}(t)))}{\partial s_{i}(t)}\right)\!\!\!f^{\prime}_{i1 }\dot{e}_{i}=-e_{i}\frac{\Delta q_{i}(t)}{\Delta\tau_{i}(t)}1\!\!\left(-k_{l1} -k_{l2}\frac{4e^{-2s_{i}}}{(1+e^{-2s_{i}})^{2}}\right)\!1\!\dot{e}_{i}\end{array}  \tag{33}\]  
Hence:  
\[k_{l1}(t+1)=k_{l1}(t)+\eta_{k_{l1}}e_{i}\frac{\Delta q_{i}(t)}{\Delta\tau_{i}( t)}s_{i} \tag{35}\]  
\[k_{l2}(t+1)=k_{l2}(t)+\eta_{k2}e_{i}\frac{\Delta q_{i}(t)}{\Delta\tau_{i}(t)} \tanh(s_{i}) \tag{36}\]  
\[k_{l3}(t+1)=k_{l3}(t)+\eta_{k_{l2}}e_{i}\frac{\Delta q_{i}(t)}{\Delta\tau_{i}( t)} \tag{37}\]  
\[\lambda_{i1}(t+1)=\lambda_{i1}(t)-\eta_{\lambda_{i1}}e_{i}\frac{\Delta q_{i}( t)}{\Delta\tau_{i}(t)}1\!\!\left(-k_{l1}-k_{l2}\frac{4e^{-2s_{i}}}{(1+e^{-2s_{i}})^ {2}}\right)\!e_{i} \tag{38}\]  
\[\lambda_{i2}(t+1)=\lambda_{i2}(t)-\eta_{\lambda_{i2}}e_{i}\frac{\Delta q_{i}( t)}{\Delta\tau_{i}(t)}1\!\!\left(-k_{l1}-k_{l2}\frac{4e^{-2s_{i}}}{(1+e^{-2s_{i}})^ {2}}\right)\!\!\dot{e}_{i}. \tag{39}\]