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.

Ex4n1pant.m
% Example 4, p=1
% eigenvalues and eigenfunction for y'(x)+xy(x)=\lambday 2x y(2x)=0, x in [0,5]
% y(0)=y(10)=0
%
n=128;q=1/2;%lambda=2; lambda=8; lambda=32
dom=[0,10];kind=2;[csi,w]=pd(n,dom,kind);D=deriv(n,dom);J=prim(n,dom);
S =dev(n,csi,dom,q*csi);T=cpv(n,dom,dom);X=mult(n,dom);
for K=1:3
    lambda=2^(2*K-1);
    A=S*D+X/2*S-lambda*X;b=zeros(n,1);
    A(n-2:n-1,:)=T;A(n,:)=(T(2,:)-T(1,:))*J;b(n)=1;   
    sol(:,K)=A\b;solnum(:,K)=t2x(sol(:,K),kind);
end
plot(csi,solnum(:,1),'-k',csi,solnum(:,2),'--k',csi,solnum(:,3),':k');
axis([0 5 -2 7]);
grid;xlabel('x');ylabel('y_{1m}(x)');
legend('y_{10}','y_{11}','y_{12}');

I12=w*(csi.*solnum(:,1).*solnum(:,2))
I13=w*(csi.*solnum(:,1).*solnum(:,3))
I23=w*(csi.*solnum(:,2).*solnum(:,3))

Contact us