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.

[lam,phi,x]=eig42D(n,dom,kind,numeigval)
function [lam,phi,x]=eig42D(n,dom,kind,numeigval)
% From D. Gottlieb, S. A. Orszag, Numerical Anlaysis of Spectral Methods: 
% Theory and Applications, SIAM, 1977.Chap. 13, pp. 143-144
%
% y^(4)=lambda y'', x in [-1 1]
% y(-1)=y'(-1)=y(1)=y'(1)=0
%
% Call: [lam,phi,x]=eig42D(64,[-1 1],2,64);
% Calculates numeigval eigenvalues lam and eigenfunctions phi at the grid x
% by a direct method
%
tic;T=cpv(n,dom,dom);x=pd(n,dom,kind);D=deriv(n,dom);
A=D^4;B=D^2;TT=[T(1,:);T(2,:);T(1,:)*D;T(2,:)*D];
AA=[A(1:n-4,:);TT];BB=[B(1:n-4,:);zeros(4,n)];
[V,L]=eig(full(AA),full(BB));
[LL,ind]=sort(diag(L),'descend');VV=V(:,ind);disp(LL)
lam=LL(1:numeigval);VV=VV(:,1:numeigval);phi=t2x(VV,kind);
toc;
end

Contact us