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.

ElDaou.m
function lambda=ElDaou(n,interval,m)
% From M. K. El-Daou, N. R. Al-Matar, An improved Tau method for
% a class of SturmLiouville problems, Applied Mathematics and Computation,
% 216 (2010) 19231937, Example 2
% 
% -y''+exp(x)y=lambda y, in [0,1]
% y(0)=0,sqrt(lambda)*sin(sqrt(lambda))*y(1)-cos(sqrt(lambda))*y'(1)=0
%
% Call: lambda=ElDaou(96,0:10:240,64);
% Calculates the eigenvalues lambda in "interval" 
dom=[0,1];kind=2;f=zeros(m,1);E=speye(n);lambda=[];
D=deriv(n,dom);X=mult(n,dom);EX=expm(full(X));T=cpv(n,dom,dom);
p=length(interval);
for s=1:p-1
[lamw,~]=pd(m,[interval(s),interval(s+1)],kind);
for k=1:m
    A=-D^2+EX-lamw(k)*E;b=zeros(n,1);
    A(n-1,:)=T(1,:);A(n,:)=T(1,:)*D;b(n)=1;
    Y=A\b;slam=sqrt(lamw(k));
    f(k)=slam*sin(slam)*T(2,:)*Y-cos(slam)*T(2,:)*D*Y;
end
plot(lamw,f);grid;xlabel('\lambda');ylabel('F(\lambda)');hold on;
pause(0.01);lamcoef=x2t(f,kind);
lambdanew=chebroots(lamcoef,[interval(s),interval(s+1)],...
[interval(s),interval(s+1)],1.e-13);lambda=[lambda;lambdanew];
end
grid;display(lambda);plot(lambda,zeros(length(lambda)),'or');

Contact us