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.

[x,solnum]=ibvp_ode_newton(n,dom,kind,M)
function [x,solnum]=ibvp_ode_newton(n,dom,kind,M)
% solves the initial/boundary value problems for second order differential 
% equations using the Newton method
% P2(x)y''(x)+P1(x)y'(x)+P0(x)y(x)=f(x,y(x),y'(x)), IC/BC, x in [a,b]
% M: order of truncation of the Chebyshev expansion in the linear part of the
% Newton method
%
tic;solnum=zeros(n,1);x=pd(n,dom,kind);X=mult(n,dom);D=deriv(n,dom);
yv=zeros(n,1);myINIT;y=x2t(yv,kind);% starting approximation in spectral space
dy=1;cont=1;
while dy(cont) > 1.e-14
    if cont>100, break, end; 
    cont=cont+1;myDElin;myDEnonlin;cor=A\b;% this is the correction
    dy(cont)=norm(cor);y=cor+y;yv=t2x(y,kind);
end;toc;solnum = yv;myOUT;
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function myINIT
    % starting approximation in the physical space
    % must be written by the user
end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%        
function myDElin
    % describes the linear part
    % implements the initial/boundary conditions in the matrix A
    % must be written by the user
end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function myDEnonlin
    % describes the nonlinear part
    % implements boundary conditions in the vector b
    % must be written by the user
end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function rez=f(x,yv)
    % describes the function f
    % must be written by the user 
end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function drez=df(x,yv)
    % describes the Jacobian of the function f
    % must be written by the user 
end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function myOUT
    % describes the output of the code
    % must be written by the user
end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
end

Contact us