function [c,z] = chebygrid(xmin,xmax,n) %c=chebygrid(xmin,xmax,n) produces an n-element grid of points distributed according to the zeros of the Chebyshev polynomial with the first element approximately equal to xmin and the last element approximately equal to xmax>=xmin. (This way of costructing a gid places relatively more points at the extremes than an equally-spaced grid). %[c,z] = chebygrid(xmin,xmax,n) produces the vector z, containing the n zeros of the Chebyshev polinomial of the first kind of order n. N = (1:n)'; %The Chebyshev polynomial of the first kind of degree n has n zeros in the interval [-1,1] given by: z = cos(pi * (N-0.5)/n); %Rescale z to the interval [xmin,xmax] c = (1+z) / 2 * (xmax-xmin) + xmin; %sort elements of c and z c = sort(c); z = sort(z);