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.

deriv_frac_ex5.m
function [lam,y]=deriv_frac_ex5(n,dom,q,numeigval)
% Example: D^(3/2)y = lambda y, x in [0,1], 
%          y'(0)=0, y(1)=0, 
% From: S. Abbasbandy, A. Shirzadi, Numer Algor (2010) 54:521532
% Test: lambda1=-2.1103, lambda2=-13.7654, lambda3=-24.2433
% call: [lam,y]=deriv_frac_ex5(128,[0,1],3/2,3);
%
tic;[x,DF,T]=deriv_frac(n,dom,q);D=deriv(n,dom);
myDE;myBC;
[V,L]=eig(full(A),full(B));
[LL,ind]=sort(diag(L));VV=V(:,ind);
lam=LL(1:numeigval);
toc;myOUT;
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function myDE
    A=DF;B=eye(n);
end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function myBC
    A(n-1,:)=T(1,:)*D;B(n-1,:)=A(n-1,:)/1000;
    A(n,:)=T(n,:);B(n,:)=A(n,:)/1000;
end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function myOUT
display(lam);
display('Control eigenvalues');
display([-2.1103;-13.7654;-24.2433;]);
for s=1:numeigval
    y(:,s)=t2x(VV(:,s),2);
    y(:,s)=y(:,s)/y(1,s);% the eigenfunctions are normed such that y_s(1)=1
end
plot(x,y(:,1),'b--',x,y(:,2),'g-',x,y(:,3),'r:');
grid;title('The eigenfunctions');legend('y_1','y_2','y_3');
xlabel x; ylabel y(x);
end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
end

Contact us