x = 0:.01:4;
y = cos(x);
deriv_y = diff(y)./diff(x);
xd = x(2:length(x)); 
z = -sin(x);
subplot(2,2,1)
plot(x,y)
subplot(2,2,2)
plot(xd,deriv_y)
subplot(2,2,4)
plot(x,z)
