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.

Ex3_delay( n,K )
function [t,solnum] = Ex3_delay( n,K )
% Paul tests 1.2.3 y'(t)=y(2*t-1), t in [0,1], y(t)=1, t<=0;
% reference value y(1)=2.271492555500812
% use: [t,solnum] = Ex3_delay(64,43);
% Remark: n>K
%
tic;kind=2;dom=[-1,0];t(:,1)=pd(n,dom,kind);yref=2.271492555500812
y_val(:,1)=ones(n,1);y_coef(:,1)=x2t(y_val(:,1),kind);
plot(t(:,1),y_val(:,1),'b',t(end,1),y_val(end,1),'r.');
axis([-1 1 0.5 2.5]);hold on;
for k=1:K
    dom=[dom(2),(1+dom(2))/2];t(:,k+1)=pd(n,dom,kind);T=cpv(n,dom(1),dom);
    D=deriv(n,dom);
    A=D;A(n,:)=T;b=y_coef(:,k);b(end)=y_val(end,k);
    y_coef(:,k+1)=A\b;y_val(:,k+1)=t2x(y_coef(:,k+1),kind);
    plot(t(:,k+1),y_val(:,k+1),'b',t(end,k+1),y_val(end,k+1),'r.');hold on;
end
grid;solnum=y_val;yref-y_val(end,end)
toc;
tf=t(end,end),yf=y_val(end,end)

Contact us