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.

[xg,solnumg]=ibvp_sys_succapprox(n,dom,kind,y0)
```function [xg,solnumg]=ibvp_sys_succapprox(n,dom,kind,y0)
% solves nonlinear initial value problems for first order systems
% P(x)Y'(x)+Q(x)Y(x)=R(x,Y(x)), Y(x1) = Y1,
% using the successive approximation method
% n,kind are the same as in level0, dom=[x0,x1,...,xp];
% xg is the Chebyshev grid, solnumg is the numerical solution in physical
% space, each column for a component yk, k=1,...,m
%
tic;xg=[];solnumg=[];solg=[];p=length(dom)-1;dyg=[];contg=0;m=length(y0);
A=spalloc(m*n,m*n,10*p*m);
for i=1:p
domloc=[dom(i),dom(i+1)];
x=pd(n,domloc,kind);X=mult(n,domloc);J=prim(n,domloc);xg=[xg;x];
myDElin;y=zeros(m*n,1);cont=1;dy=1;
for k=1:m,y((k-1)*n+1)=2*y0(k);end
while dy(cont) > 1.e-12
if cont>100, break, end;
cont=cont+1;myDEnonlin;sol=A\b;dy(cont)=norm(sol-y);y=sol;
end
solnum = t2x(reshape(sol,n,m),kind);
solnumg=[solnumg;solnum];solg=[solg;sol];dyg=[dyg,dy];contg=contg+cont;
y0=solnum(end,:);
end;toc;myOUT;
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function myDElin
% describes the linear part of the differential system
% implements the initial conditions in the matrix A
% must be written by the user
end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function myDEnonlin
% describes the nonlinear part of the differential system
% implements the initial conditions in the vector b
% must be written by the user
end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function myOUT
% describes the output of the code
% must be written by the user
end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
end```