% Use Chebfun's "chebop" feature to numerically compute eigenvalues and eigenfunctions

 numeigs = 5; 
 L = chebop(0,1);              % operator on domain [0,1]
 L.op = @(u) -diff(u,2);       % Laplacian
 L.bc = 'dirichlet';           % homogeneous Dirichlet boundary conditions
 [V,D] = eigs(L,numeigs,'sm')  % compute smallest magnitude ('sm') eigenvalues/functions

 figure(1), clf
 for j=1:numeigs
    plot(V(:,j),'b-','linewidth',2)
    xlabel('$x$','fontsize',20,'interpreter','latex')
    ylabel('$\psi_n(x)$','fontsize',20,'interpreter','latex')
    title(sprintf('eigenfunction $n=%d$',j),'fontsize',24,'interpreter','latex')
    input('hit return')
 end

