 clear
 close all
disp('                   ACCELERATION              ')
clear s t; clf
t = linspace(-2,2, 201);
 plot(t, .5*t.^2)
 hold on
 axis equal
 disp('  ')
 disp(' Decomposition of acceleration into tangential and normal components ')
 disp(' for the curve (t, (1/2)t^2 )   ')
s = linspace(-1.4, 1.4, 5);
for j = 1:5
    p = [s(j), .5*s(j).^2];
    naccel = [-s(j), 1]./(1+s(j).^2);
    tanaccel = [s(j), s(j).^2]./(1+s(j).^2); 
    arrow(p, [0,1])
    arrow(p, tanaccel, 'r')
    arrow(p, naccel, 'g')
    pause
end
    hold off
    disp(' ')
    disp(' Another example: the curve (t, (t^3)/6 ) ')
    clear s t
    t = linspace( -2,2,201);
   plot(t, (t.^3)/6)
   axis equal
   hold on
  
   speed = inline('sqrt(1 + .25*t.^4)', 't');
   aT = inline('.5*t.^3./sqrt(1+ .25*t.^4)', 't');
   for j = -3:3
       s = (1.2)*j/3;
       p = [s, (s.^3)/6];
       accel = [0,s];
       tanaccel = (aT(s)./speed(s)).*[1, .5*s.^2];
       normaccel = accel - tanaccel;
       arrow(p, accel)
       arrow(p, tanaccel, 'r')
       arrow(p, normaccel, 'g')
       pause
   end
   hold off
   close
   
