In the paper "Chebyshev solution of differential, integral and integro-differential equations" (it is freely accessible and can be downloaded from the link), El-gendi uses a method to approximate the integral
$$\int_{-1}^x f(t) \,dt$$
by a Chebyshev approximation at points
$$x_j = \cos\left(\frac{j \pi}{N}\right)$$
by a matrix $B_{(N+1)\times (N+1)}$:
$$\left[\int_{-1}^x f(t) \,dt\right]=B.[f]$$
where $B$ is a function of $N$ only and that's what I am trying to find ultimately. In other words, I want to be able to produce this matrix for different values of $N$ . But I can't reproduce the example $B$ that the paper has reported for $N=4$ in Mathematica.
Here is what I have so far:
xp[ip_, np_] := Cos[ip Pi/np]
c01[rr_, np_] := If[rr == 0 || rr == np, 0.5, 1]
a[r_, np_] :=
2/np Sum[c01[k, np] f[xp[k, np]] ChebyshevT[r, xp[k, np]], {k, 0, np}]
c[kk_, nn_] :=
Which[kk == 0,
0.5 a[0, nn] +
Sum[c01[jj, nn] ((-1^(jj + 1) a[jj, nn])/(jj^2 - 1)), {jj, 2,
nn}] - 0.25 a[1, nn], kk >= 1 && kk <= nn - 2, (
a[kk - 1, nn] - a[kk + 1, nn])/(2 kk), kk == nn - 1, (
a[nn - 2, nn] - 0.5 a[nn, nn])/(2 (nn - 1)), kk == nn,
a[nn - 1, nn]/(2 (nn)), kk == nn + 1, (0.5 a[nn, nn])/(2 (nn + 1))]
Now when I produce the approximation to the integral for $N=4$ by:
ct4 = Sum[c[r, 4] ChebyshevT[r, x], {r, 0, 5}] // Simplify
and then by replacing $x$ values:
ct4 /. x -> {xp[0, 4], xp[1, 4], xp[2, 4], xp[3, 4], xp[4, 4]}
I get:
{0.129167 f[-1] + 0.8 f[0] + 0.00416667 f[1] +
0.444945 f[-(1/Sqrt[2])] + 0.621722 f[1/Sqrt[2]],
0.134763 f[-1] + 0.824264 f[0] - 0.115237 f[1] +
0.431658 f[-(1/Sqrt[2])] + 0.431658 f[1/Sqrt[2]],
0. + 0.0958333 f[-1] + 0.4 f[0] - 0.0291667 f[1] +
0.531832 f[-(1/Sqrt[2])] + 0.00150162 f[1/Sqrt[2]],
0.181904 f[-1] - 0.0242641 f[0] - 0.0680964 f[1] +
0.101675 f[-(1/Sqrt[2])] + 0.101675 f[1/Sqrt[2]],
0. + 0.0625 f[-1] - 0.0625 f[1] - 0.0883883 f[-(1/Sqrt[2])] +
0.0883883 f[1/Sqrt[2]]}
which is different from the results in the paper:
Any ideas what I'm doing wrong? I'd appreciate it if someone has a better way to derive this table too.