% Solve the ODE -u''(x) = lambda*u(x) for different lambda, with u(0) = 0.
% Look for u(1) = 0 to identify the eigenvalues of the Dirichlet-Dirichlet problem

 x = chebfun('x',[0 1]);           % chebfun "x" from which we'll build solutions

 lamvec = [0:.05:25]*pi^2;          % vary lambda from 0 to 5*pi^2

 figure(1), clf
 for j=1:length(lamvec)            % loop over lambda values
    lambda = lamvec(j);
    u = sin(sqrt(lambda)*x);       % u solves -u''(x) = lambda*u(x) with u(0)=0
    plot(u,'b-','linewidth',4)
    title(sprintf('$\\lambda = %4.2f \\pi^2$', lambda/pi^2), ...
          'interpreter','latex','fontsize',18)
    axis([0 1 -1.1 1.1])
    if (j>1) & (mod(sqrt(lambda),pi)<1e-10),
       input('eigenfunction with u(0)=u(1)=0 found.  Hit return')
    else
       pause(.01)
    end
 end

