Code covered by the BSD License

# Chebpack

### Damian Trif (view profile)

15 Jul 2011 (Updated )

The MATLAB package Chebpack solves specific problems for differential or integral equations.

Ex1_delay( n , alpha , K )
```function [T,Y,y_coef,sol] = Ex1_delay( n , alpha , K )
% Wright equation x'(t)=-alpha x(t-1) [1+x(t)],
%                     x(t)=x0 for t in [-1,0]
% use: [t,y_val,y_coef,sol]=Ex1_delay(64,3,50);
%
kind=2;dom=[-1,0];t(:,1)=pd(n,dom,kind);D=deriv(n,dom);
y_val(:,1)=0.1*t(:,1).^3+t(:,1)-0.5;
y_coef(:,1)=x2t(y_val(:,1),kind);dy_coef(:,1)=D*y_coef(:,1);
dy_val(:,1)=t2x(dy_coef(:,1),kind);
for k=2:K+1
dom=[dom(1)+1,dom(2)+1];
D=deriv(n,dom);
F=fact(alpha*y_coef(:,k-1),n);
A=D+F;b=-alpha*y_coef(:,k-1);
A(n,:)=cpv(n,dom(1),dom);b(n)=y_val(n,k-1);
y_coef(:,k)=A\b;t(:,k)=pd(n,dom,kind);dy_coef(:,k)=D*y_coef(:,k);
y_val(:,k)=t2x(y_coef(:,k),kind);dy_val(:,k)=t2x(dy_coef(:,k),kind);
end
T=reshape(t,n*(K+1),1);Y=reshape(y_val,n*(K+1),1);
dY=reshape(dy_val,n*(K+1),1);
sol=Ex1_delay_dde(3,K);
subplot(1,2,1);plot(T,Y);xlabel('t');ylabel('y');
axis([-5 55 -2 12]);grid;hold on;plot(sol.x,sol.y,'.r');
subplot(1,2,2);plot(Y,dY);grid;xlabel('y');ylabel('y''');
axis([-2 12 -40 20]);hold on;plot(sol.y,sol.yp,'.r');
legend('Chebpack','ddesd');```