function [P,x] = createcosP(N)

P = zeros(N+1,N+1);
h = 1/N;

fac = 1/sqrt(2*N);
for k = 0:N
    P(0+1,k+1) = fac;
    for j = 1:N-1
        P(j+1,k+1) = fac*2*cos(k*j*pi/N);
    end 
    P(N+1,k+1) = fac*(-1)^k;
end
P = P';
x = (0:h:1)';
