function u=example2(N)

u = zeros(N,2);

%Compute N approximations to the derivative of sin(x) at x = 1. 
for k=1:N
    u(k,1) = ( sin(1+2^(-k))-sin(1))* 2^k;
    %Store the error
    u(k,2) = abs(u(k,1)-cos(1));
end

%Compute log of the error and plot k on the horizontal axis versus the
%error on the vertical axis. Note that k is proportional to the log of
%2^-k. 

v=log2(u(:,2));
%if there is only one argument to plot, plot uses index 
%for the horizontal axis and the values in v for the vertical axis. 

plot(v)