# On an Optimal Quadrature Formula in a Hilbert Space of Periodic Functions
## 7 Numerical Results  
In this section, we present numerical results of comparison for absolute errors of the optimal quadrature formula of the form (4) with the \(\exp(\mathrm{i}\omega x)\) weight in the case \(m=2\) and the Midpoint formula. We note that the rate of convergence for both of these formulas is \(O(h^{2})\). Here we use the Maple to obtain numerical results. As an example, we consider calculation of the integral  
\[I=\int_{0}^{2\pi}\exp(\mathrm{i}\omega x)\varphi(x)dx \tag{53}\]  
with \(\varphi(x)=\frac{e^{\mathrm{i}-x/(2\pi)}+e^{x/(2\pi)}}{2(1-e)}\). Since for the functions \(\varphi\) we have the relation \(\varphi(0)=\varphi(2\pi)\), we can consider it as a periodic function on the interval \([0,2\pi]\). For convenience, we denote the integrand as \(f(x)\); i.e., \(f(x)=\exp(\mathrm{i}\omega x)\frac{e^{\mathrm{i}-x/(2\pi)}+e^{x/(2\pi)}}{2(1-e)}\). We approximately calculate the integral \(I\) by the Midpoint rule. Then approximate value for the integral (53) is then calculated as follows using the Midpoint rule  
\[A_{\text{mid}}=\sum_{k=1}^{N}f\left(\frac{x_{k}+x_{k-1}}{2}\right)(x_{k}-x_{k -1}), \tag{54}\]  
where \(x_{k}=kh,k=0,1,\ldots,N\) and \(h=2\pi/N\). Hence, for the function \(f(x)=\exp(\mathrm{i}\omega x)\frac{e^{\mathrm{i}-x/(2\pi)}+e^{x/(2\pi)}}{2(1-e)}\), the error of the Midpoint rule (54) is  
\[I-A_{\text{mid}}=\int_{0}^{2\pi}f(x)dx-\sum_{k=1}^{N}f\left(\frac{x_{k}+x_{k- 1}}{2}\right)(x_{k}-x_{k-1}). \tag{55}\]  
In Table 1, we give the absolute values for the real part of the error (55) of the Midpoint rule for \(N=1,\ 10,\ 100,\ 1000\) and \(\omega=1,\ 10,\ 100,\ 1000\). It can be seen from the results given in Table 1 that the Midpoint rule converges for \(N>\omega\). In Figure 1, the process of this convergence is graphically shown when \(\omega=1\) and \(N=1,\ 10,\ 100,\ 1000\) for the real part of the function \(f(x)\). In Figure 2 the graphs of numerical calculation of the integral (53) by the Midpoint rule for the case \(\omega=1,10,100,1000\) and \(N=1\) are given. Here, we can see that the Midpoint rule does not converge when \(\omega\geq N\) for the function \(f(x)\). \begin{table}
\begin{tabular}{l c c c c} \hline \hline  & \(\omega=1\) & \(\omega=10\) & \(\omega=100\) & \(\omega=1000\) \\ \hline  & \(|I-A_{\text{mid}}|\) & \(|I-A_{\text{mid}}|\) & \(|I-A_{\text{mid}}|\) & \(|I-A_{\text{mid}}|\) \\ \hline \(N=1\) & 6.184049 & 6.027234 & 6.028810 & 6.028825 \\ \hline \(N=10\) & 2.709174\((-3)\) & 6.282159 & 6.280552 & 6.280552 \\ \hline \(N=100\) & 2.618891\((-5)\) & 2.710011\((-5)\) & 6.283175 & 6.283159 \\ \hline \(N=1000\) & 2.618003\((-7)\) & 2.618898\((-7)\) & 2.710020\((-7)\) & 6.283185 \\ \hline \end{tabular}
\end{table} 
Table 1: The absolute values for the real part of the error (55) of the Midpoint rule for \(N=1\), \(10,\ 100,\ 1000\) and \(\omega=1\), \(10,\ 100,\ 1000\). Figure 1: The process of convergence for the Midpoint rule when \(\omega=1\) and \(N=1,\ 10,\ 100,\ 1000\) for the real part of the function \(f(x)\). Now, we approximate the above integral (53) using the optimal quadrature formula of the form (4) with \(\exp(\mathrm{i}\omega x)\) weight in the case \(m=2\). Then, taking into account (10), we have the approximate equality  
\[\int\limits_{0}^{2\pi}\exp(\mathrm{i}\omega x)\varphi(x)dx\cong\sum\limits_{k=1 }^{N}\dot{\mathcal{C}}_{k}\varphi\bigg{(}\frac{2\pi k}{N}\bigg{)}, \tag{56}\]  
for \(\varphi(x)=\frac{e^{1-x/(2\pi)}+e^{x/(2\pi)}}{2(1-e)}\) with the optimal coefficients  
\[\dot{\mathcal{C}}_{k}=\frac{2\pi}{N}\bigg{(}\frac{\sin(\frac{\pi\omega}{N})}{ \frac{2\pi\omega}{N}}\bigg{)}^{4}\frac{3\exp(\frac{2\pi i\omega k}{N})}{\cos( \frac{2\pi\omega}{N})+2},\ k=1,2,\ldots,N.\]  
The approximate value for the integral (53) is calculated as follows, using the optimal quadrature formula:  
\[A_{\mathrm{opt}}=\sum\limits_{k=1}^{N}\dot{\mathcal{C}}_{k}\frac{e^{1-\frac{ k}{N}}+e^{\frac{k}{N}}}{2(1-e)}.\]  
Figure 2: The Midpoint rule does not converge when \(\omega\geq N\) for the function \(f(x)\).