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.

Ex3pant.m
% Example 3
% Eigenvalues and eigenfunction for y"+\lambday(x/2)=0, x in [-1 1]
% y(-1)=y(1)=0
%
n=16;q=1/2;
dom=[-1,1];kind=2;x=pd(n,dom,kind);D=deriv(n,dom);
Sdev =dev(n,x,dom,q*x);T=cpv(n,dom,dom);
A=D^2;B=-Sdev;
A(n-1:n,:)=T;B(n-1:n,:)=T/1.e8;
[V,L]=eig(full(A),full(B));
[LL,ind]=sort(diag(L));VV=V(:,ind);
lam=LL(1:5);
for s=1:5
    phi(:,s)=t2x(VV(:,s),kind);
end
 display(lam);
    xx=linspace(dom(1),dom(2),1000);
    for s=1:5
        fx(:,s) = barycheb(xx,phi(:,s),x,kind);
    end
    plot(xx,fx(:,1),'b',xx,fx(:,2),'g',xx,fx(:,3),'r',xx,fx(:,4),'m',xx,fx(:,5),'k');
    legend('\lambda_1','\lambda_2','\lambda_3','\lambda_4','\lambda_5');grid;
    %title(['\lambda ',num2str(s),' = ',num2str(lam(s))]);
    xlabel('x');ylabel('\phi');

Contact us