%Exercise for Section 4.4, underdamped harmonic motion
% 2*x'' + 12*x' + 32*x=0
% with solution y(t)=exp(-3*t)( c1*cos(sqrt(7*t)+c2*sin(sqrt(7*t)))
% The damping constant is c=12/4=3, 
% the natural frequency omega0=sqrt(32/2)=4.
% The constants depending on the initial conditions
c1=1;c2=2;

t = linspace(0,5,50);
y = exp(-.3*t).*( c1*cos(sqrt(7)*t) + c2*sin(sqrt(7)*t) ) ;
Amplitude=norm([c1 c2]);%sqrt(c1^2+c2^2);%
A= Amplitude*exp(-.3*t);
figure(1)
hold all
plot(t,y,'-r',t,A,':b',t,-A,':b')
legend('y(t)','amplitude(t)')
title('Underdamped harmonic motion c=3<4=\omega_0')
