%
% Solving y'(t) = -y(t-1)/5 with 
% y(t) = (-1)^floor(-4t) on -1 <= t <= 0
% By the method of steps with chebfun
%
% RMC January 2011
clear all
close all
ex = chebfun( 'x', [-1,0] )
hist = (-1).^floor( -4*ex )
y0 = cumsum(-hist/5) + feval(hist,0)
y1 = cumsum( -y0/5 ) + feval(y0,0)
y2 = cumsum( -y1/5 ) + feval(y1,0)
y3 = cumsum( -y2/5 ) + feval(y2,0)
y4 = cumsum( -y3/5 ) + feval(y3,0)
z = [hist;y0;y1;y2;y3;y4]
figure
plot( z, 'k' )
hold on
xlabel('t','fontsize',16)
ylabel('y and y''','fontsize',16)
plot( diff(z), 'k' )
axis([-1,5,-1.5,1.5])
set(gca,'fontsize',16);
