%Gerardo

function Hw6

%% Section 3.3 Problem 23

% %3u''-u'+2u=0
% 
% t_0=0; t_end=12;
% 
% N=1000;
% dt = (t_end-t_0)/N;
% 
% t_sol = zeros(N+1,1); y_sol = zeros(N+1,1);
% for it=1:N+1
%     t = t_0+dt*(it-1);
%     t_sol(it,1) = t;
%     y_sol(it,1) = 2*exp(t/6)*cos(sqrt(23)*t/6)-2/sqrt(23)*exp(t/6)*sin(sqrt(23)*t/6);
% end
% 
% clf
% figure(1)
% plot(t_sol,abs(y_sol),'r *','LineWidth',1);
% print('Graph1','-depsc',figure(1))
% stop

%% Section 3.3 Problem 26

% t_0=0; t_end=2;
% 
% N=1000;
% dt = (t_end-t_0)/N;
% 
% t_sol = zeros(N+1,1); y_sol = zeros(N+1,1);
% for it=1:N+1
%     t = t_0+dt*(it-1);
%     t_sol(it,1) = t;
%     y_sol(it,1) = exp(-t)*(cos(t)+sin(t));
% end
% 
% clf
% figure(1)
% plot(t_sol,abs(y_sol),'r *','LineWidth',1);
% print('Graph2','-depsc',figure(1))
% stop

t_0=0; t_end=8;

N=1000; a=1/4;
dt = (t_end-t_0)/N;

t_sol = zeros(N+1,1); y_sol = zeros(N+1,1);
for it=1:N+1
    t = t_0+dt*(it-1);
    t_sol(it,1) = t;
    y_sol(it,1) = exp(-a*t)*(cos(t)+a*sin(t));
end

clf
figure(1)
plot(t_sol,abs(y_sol),'r *','LineWidth',1);
print('Graph3','-depsc',figure(1))
stop

t_0=0; t_end=5;

N=1000; a=1/2;
dt = (t_end-t_0)/N;

t_sol = zeros(N+1,1); y_sol = zeros(N+1,1);
for it=1:N+1
    t = t_0+dt*(it-1);
    t_sol(it,1) = t;
    y_sol(it,1) = exp(-a*t)*(cos(t)+a*sin(t));
end

clf
figure(1)
plot(t_sol,abs(y_sol),'r *','LineWidth',1);
print('Graph4','-depsc',figure(1))
stop

t_0=0; t_end=2;

N=1000; a=2;
dt = (t_end-t_0)/N;

t_sol = zeros(N+1,1); y_sol = zeros(N+1,1);
for it=1:N+1
    t = t_0+dt*(it-1);
    t_sol(it,1) = t;
    y_sol(it,1) = exp(-a*t)*(cos(t)+a*sin(t));
end

clf
figure(1)
plot(t_sol,abs(y_sol),'r *','LineWidth',1);
print('Graph5','-depsc',figure(1))
stop