function D=pcshft(A,B,d,N)
%PCSHFT
%	G=CHEBPC(A,B,D,N) is the vector of polynomial coefficients of length N
%	such that 
%	sum (k=1 to N) G(k) x^(k-1) = sum (k=1 to N) D(k) y^(k-1) 
%	where A < x < B  but  -1 < y < -1
%
%	From Numerical Recipes section 5.8
%
%	John Wilkin
%	26 October 92

D=d;
const = 2/(B-A);
fac = const;
for j=2:N
  D(j)=D(j)*fac;
  fac=fac*const;
end
const=(A+B)/2;
for j=1:N-1
  for k=N-1:-1:j
    D(k)=D(k)-const*D(k+1);
  end
end