Code covered by the BSD License  

Highlights from
Chebpack

image thumbnail

Chebpack

by

 

15 Jul 2011 (Updated )

The MATLAB package Chebpack solves specific problems for differential or integral equations.

Ex2_delay.m
% Example 3
% Eigenvalues and eigenfunctions for y"(x)+\lambda y(1-x)=0, x in [0 1]
% y(0)=y'(1)=0
% use: Ex2_delay
n=21;
dom=[0,1];kind=2;x=pd(n,dom,kind);D=deriv(n,dom);T=cpv(n,x,dom);
Tp=cpv(n,1-x,dom);S=T\Tp;
A=D^2;B=-S;
A(n-1,:)=T(1,:);B(n-1,:)=A(n-1,:)/1.e8;
A(n,:)=T(n,:)*D;B(n,:)=A(n,:)/1.e8;
[V,L]=eig(full(A),full(B));
[LL,ind]=sort(diag(L));VV=V(:,ind);
lam=LL(8:11);
for s=8:11
   phi(:,s)=t2x(VV(:,s),kind);
end
display(lam);
xx=linspace(dom(1),dom(2),1000);
for s=8:11
   fx(:,s) = barycheb(xx,phi(:,s),x,kind);
end
plot(xx,fx(:,8),'b',xx,fx(:,9),'g',xx,fx(:,10),'r',xx,fx(:,11),'m');
legend('\lambda_{-2}','\lambda_{-1}','\lambda_1','\lambda_2');
title('Eigenfunctions corresponding to displayed eigenvalues');
grid;xlabel('x');ylabel('\phi');

Contact us