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.

[x,solnum]=deriv_frac_ex4(n,dom,q)
```function [x,solnum]=deriv_frac_ex4(n,dom,q)
% Example:  y''(x)+D^(3/2)y(x)+y(x)=8*(x<=1), x in [0,30],
%           y(0)=0, y'(0)=0, (Bagley-Torvik equation)
% From: I. Podlubny et.al,
%       http://www.mathworks.com/matlabcentral/fileexchange/22071
% Remark: spectral form, corresponds to the Podlubny's solution for h=0.075/4
% call: [x,solnum]=deriv_frac_ex4(256,[0,30],3/2);
%
tic;
[x,DF,T]=deriv_frac(n,dom,q);D=deriv(n,dom);
myDE;myBC;
sol=A\b;solnum=T*sol;
toc
myOUT;
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function myDE
% spectral form
A=D^2+DF+eye(n);b=T\(8*(x<=1));
end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function myBC
% the initial condition in spectral form
A(n-1,:)=T(1,:);b(n-1)=0;
A(n,:)=T(1,:)*D;b(n)=0;%
end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function myOUT
plot(x,solnum);xlabel x;ylabel y(x);title('The solution');grid;
end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
end```