function bc = bcfun(z0,zf,x0,pf,n)
bc = [ z0(1:n,1)-x0 ; zf(n+1:2*n,end)-pf ];