## 5 Numerical Examples  
In this section, some numerical examples are given to illustrate the effectiveness of the proposed method. We begin with two definitions to measure the effectiveness of the proposed method. The maximum absolute error [14] is computed by  
\[e^{\infty}=\max_{0\leq i\leq n}|\hat{y}(x_{i})-y(x_{i})|,\]  
where \(\hat{y}(x_{i})\) and \(y(x_{i})\) represent the numerical and exact solution at the node \(x_{i}\), respectively. The rate of convergence [14; 15] is computed by  
\[\rho=\frac{\ln(e_{1}^{\infty}/e_{2}^{\infty})}{\ln(n_{2}/n_{1})},\]  
where \(e_{1}^{\infty}\) and \(e_{2}^{\infty}\) are the maximum absolute errors estimated for two different grids with \(n_{1}+1\) and \(n_{2}+1\) points. **Example 1**. : _Consider the linear differential equation with variable coefficients:_  
\[y^{\prime\prime}+xy=(x^{2}+1)e^{x},-2\leq x\leq-1. \tag{20}\]  
_with boundary conditions \(y(-2)=-3e^{-2},y(-1)=-2e^{-1}\)._  
**Example 2**. : _Consider the linear differential equation with variable coefficients:_  
\[y^{\prime\prime}+(\sin x)y=2\cos x-x\sin x+x\sin^{2}x,-\frac{\pi}{6}\leq x\leq \frac{\pi}{6}. \tag{21}\]  
_with boundary conditions \(y(-\frac{\pi}{6})=y(\frac{\pi}{6})=\frac{\pi}{12}\)._  
**Example 3**. : _Consider the linear differential equation with constant coefficients:_  
\[y^{\prime\prime}+y=-1,0\leq x\leq 1. \tag{22}\]  
_with boundary conditions \(y(0)=0,y(1)=\cos 1-1\)._  
The analytic solutions of (20)-(22) are \(y=(x-1)e^{x},y=x\sin x\) and \(y=\cos x-1\), respectively. In Table 1, we list the approximate and exact solutions to (20). In Table 2, we show the maximum errors in Examples 1-3 and the rate of convergence in Examples 1 and 2. From Table 2, we can observe that the order of convergence is 2. It is evident from Tables 1 and 2 that the proposed method produces high precision numerical solutions. Especially in Example 3, the errors of numerical solutions are close to the machine accuracy. This is because the approximate Function (5) is constructed based on the analytic solutions to the linear differential equation with constant coefficients, and Equation (22) happens to be the one with constant coefficients. It is not surprising that we can yield the nearly exact solutions in Example 3. \begin{table}
\begin{tabular}{c c c c c c c c c} \hline \hline \(x\) & \(\tilde{y}(x)\) & \(y(x)\) & \(x\) & \(\tilde{y}(x)\) & \(y(x)\) & \(x\) & \(\tilde{y}(x)\) & \(y(x)\) \\ \hline \(-2.000\) & \(-0.406006\) & \(-0.406006\) & \(-1.625\) & \(-0.516883\) & \(-0.516893\) & \(-1.250\) & \(-0.644628\) & \(-0.644636\) \\ \(-1.875\) & \(-0.440891\) & \(-0.440896\) & \(-1.500\) & \(-0.557815\) & \(-0.557825\) & \(-1.125\) & \(-0.689882\) & \(-0.689886\) \\ \(-1.750\) & \(-0.477870\) & \(-0.477878\) & \(-1.375\) & \(-0.600484\) & \(-0.600494\) & \(-1.000\) & \(-0.735759\) & \(-0.735759\) \\ \hline \hline \end{tabular}
\end{table} 
Table 1: Comparison of the numerical solutions with the exact solutions in Example 1 (\(h=2^{-3}\)). \begin{table}
\begin{tabular}{c c c c c c c c} \hline \hline  & \multicolumn{2}{c}{**Example 1**} & \multicolumn{2}{c}{**Example 2**} & \multicolumn{2}{c}{**Example 3**} \\ \hline \(h\) & \(e^{\infty}\) & \(\rho\) & \(n\) & \(e^{\infty}\) & \(\rho\) & \(n\) & \(e^{\infty}\) \\ \hline \(2^{-2}\) & \(4.327\times 10^{-5}\) & – & 8 & \(3.785\times 10^{-4}\) & – & 4 & \(2.012\times 10^{-16}\) \\ \(2^{-4}\) & \(2.673\times 10^{-6}\) & \(2.0084\) & 32 & \(2.390\times 10^{-5  
In Figure 1a, we show the exact solution and the numerical results obtained by the proposed method. The corresponding error curve are also shown in Figure 1b. These results coincide with the results listed in Table 2.  
**Example 4**. : _Consider the linear differential equation with variable coefficients [3; 5]:_  
\[y^{\prime\prime}+xy=(3-x-x^{2}+x^{3})\sin x+4x\cos x,0\leq x\leq 1. \tag{23}\]  
_with boundary conditions \(y^{\prime}(0)=-1,y^{\prime}(1)=2\sin 1\)._  
The analytic solution of (23) is \(y=(x^{2}-1)\sin x\). In Table 3, we list the maximum errors and the elapsed CPU time.