Implementation of Chebyshev Sine Approximation in Octave
John Bryan
- Equations.
Chebyshev polynomial approximation,
\begin{equation}
f(x) \approx P_n(x) = \sum_{j=0}^n c_jT_j(2\frac{x-a}{b-a}-1)
\tag{eq. 1}
\end{equation}
for x $\in$ [a,b].
Polynomial node locations,
\begin{equation}
x_k=\frac{b+a}{2}+\frac{b-a}{2}\cos(\frac{2k+1}{2n+2}\pi)
\tag{eq. 2}
\end{equation}
for k=0,1,2,...,n.
Coefficients,
\begin{equation}
c_0=\frac{1}{n+1}\sum_{k=0}^nf(x_k).
\tag{eq. 3}
\end{equation}
\begin{equation}
c_j = \frac{2}{n+1}\sum_{k=0}^nf(x_k)\cos(j\frac{2k+1}{2n+2}\pi)
\tag{eq. 4}
\end{equation}
for j=1,2,...n.
Chebyshev polynomials,
\begin{equation}
T_i(z) = 2xT_{i-1}(z)-T_{i-2}(z)
\tag{eq. 5}
\end{equation}
for i=2,3,...n, with $ T_0(z)=1 $ and $T_1(z)=z$.
Approximation error upper bound,
\begin{equation}
|f(x)-P_n(x)| \le \left(\frac{b-a}{2}\right)^{n+1}\frac{B_{n+1}}{2^n(n+1)!},
\tag{eq. 6}
\end{equation}
with $B_{n+1}=\text{max}_{x\in[a,b]}|f^{(n+1)}(x)|$.
-
Octave implementation.
-
Results.
$$ f(x)=\sin(x), x \in [0,\pi/2] $$
$$
\begin{array}{c|lcr}
\text{n=7 theoretical approximation error upper bound} & 2.80 \times 10^{-8} \\
\text{n=7 Simulation approximation maximum error} & 2.11 \times 10^{-8} \\
\text{n=11 theoretical approximation error upper bound} & 5.61 \times 10^{-14} \\
\text{n=11 Simulation approximation maximum error} & 4.19 \times 10^{-14} \\
\end{array}
$$