function discretization_demo(n)
% plot discretization approx to derivative from h=1 to h=10^(-n)
x0 = 1.2;
f0 = sin(x0);
fprime = cos(x0); % true derivative of sin
i=-n:0; 
h = 10.^i;
deriv_approx = (sin(x0 + h) - f0)./h;  % note the dot for componentwise divide
actual_discr_error = abs(deriv_approx - fprime);
theoretical_discr_error = (f0/2)*h;
loglog(h, actual_discr_error,'*')
xlabel('h')
ylabel('abs error')
hold on
loglog(h, theoretical_discr_error,'r+')