## 2 Materials and Methods
### Controller Design  
The ball-balancing robot model given in (2) and (3) is underactuated and has uncertainties. To deal with these problems, we introduced a virtual angle that can achieve both the trajectory tracking and balancing of the robot and designed a neural-network-based controller using the DSC method step-by-step. Let us define the following errors:  
\[\mathbf{e}_{s}= \left[\mathbf{e}_{x},\mathbf{e}_{y}\right]^{\top}=\mathbf{q}_{s}-\mathbf{q}_{sr}, \tag{7}\] \[\mathbf{z}_{1}= \tanh\mathbf{q}_{b}-\mathbf{\theta}_{f},\] \[\mathbf{z}_{2}= \left[z_{21},z_{22}\right]^{\top}=\mathbf{\dot{q}}_{b}-\mathbf{\kappa}_{f}, \tag{8}\]where \(\theta_{f}\) and \(\alpha_{f}\) are the signals filtered by \(\tau_{1}^{2}\dot{\theta}_{f}+2\tau_{1}\dot{\theta}_{f}+\theta_{f}=\theta_{v}\) and \(\tau_{2}\dot{\alpha}_{f}+\alpha_{f}=\alpha\) with positive design parameters \(\tau_{1}\) and \(\tau_{2}\). In these expressions, \(\alpha\) denotes the virtual control input and \(\theta_{v}\) denotes the virtual angle for the underactuation problem given by:  
\[\theta_{v}=\lambda_{\theta}s,\quad s=\dot{e}_{s}+\lambda e_{s}, \tag{9}\]  
where \(\lambda_{\theta}\) is a diagonal matrix and \(\lambda>0\) is a design parameter. In (8), the boundedness of \(z_{1}\) implies that \(\theta_{f}\) and \(\theta_{v}\) are bounded. This leads to the boundedness of the tracking error \(e_{s}\) from (9). If the tracking error converges to zero, it is easily shown that the body angle \(\theta_{b}\) of the robot also converges to zero from (8) and (9). Therefore, we can solve the underactuation problem. The first and second derivatives of the virtual angle \(\theta_{v}\) are required to design a controller. By the definition of the virtual angle in (9), it includes the control input \(u\), which is impossible to implement the controller. To avoid this problem, we used the virtual angle \(\theta_{f}\) passed through the second-order filter. Differentiating both sides of (8) using (3) gives the following error dynamics:  
\[\dot{z}_{1}= \mathbf{H}_{1}(\mathbf{z}_{2}+\mathbf{\alpha}_{f})-\dot{\theta}_{f}, \tag{10}\] \[\dot{z}_{2}= \mathbf{F}_{b}+\Delta\mathbf{F}_{b}+\mathbf{G}_{b}u-\dot{\alpha}_{f}, \tag{11}\]  
where \(\mathbf{H}_{1}=\text{diag}(\text{sech}^{2}\theta,\text{ sech}^{2}\varphi)\) and \(\text{diag}(\cdot)\) denotes a diagonal matrix. Note that \(\mathbf{H}_{1}\) is invertible. _Step 1:_ Consider the Lyapunov function candidate as:  
\[V_{1}= \frac{1}{2}z_{1}^{\top}z_{1}. \tag{12}\]  
Let \(\varpi\) be the filter error of the virtual control input, i.e., \(\varpi=\mathbf{\alpha}-\mathbf{\alpha}_{f}\). Differentiating both sides of (12) along (10) yields:  
\[\dot{V}_{1}=z_{1}^{\top}(\mathbf{H}_{1}(\mathbf{z}_{2}+\mathbf{\alpha}-\varpi)-\dot{ \theta}_{f}). \tag{13}\]  
From (13), we chose the virtual control input vector \(\mathbf{\alpha}\) to be:  
\[\mathbf{\alpha}=\mathbf{H}_{1}^{-1}(\dot{\theta}_{f}-\mathbf{K}_{1}\mathbf{z}_{1}), \tag{14}\]  
where \(\mathbf{K}_{1}\) is a diagonal positive definite matrix. _Step 2:_ Consider the Lyapunov function candidate as:  
\[V_{2}=\frac{1}{2}(z_{2}^{\top}z_{2}+\varpi^{\top}\varpi). \tag{15}\]  
The time derivative of (15) along (11) is:  
\[\mathbf{z}_{1}= \tanh\mathbf{q}_{b}-\mathbf{\theta}_{f},\]0  
From (16), we chose the actual control vector \(\mathbf{u}\) to be:  
\[\mathbf{z}_{1}= \tanh\mathbf{q}_{b}-\mathbf{\theta}_{f},\]1  
where \(\mathbf{K}_{2}\) is a diagonal positive definite matrix and \(\widehat{\varpi}_{i}(i=1,2)\) denotes the estimate of the optimal weight vector \(\mathbf{\omega}_{i}^{*}\) for the RBFNs. **Remark 3**.