%
%  code03Wa.m -- djm -- 20 sept 2006
%
%  derivative limit demo
%

%  parameters
L = 2;  N = 24;  

%  initialize figure
figN = 1;  figure(figN);  clf;  hold on;

%  example 1:  f(z) = z^2
%  choose z0 HERE
z0 = 1-i;

%  plot z0
subplot(2,2,1);  hold on
plot(real(z0),imag(z0),'k*');
title('\bf z-plane');
xlabel('\bf real-axis');  ylabel('\bf imag-axis');
axis equal;  axis([-1 1 -1 1]*L)

subplot(2,2,2);  hold on
title('\bf w-plane:  (f(z)-f(z0))/(z-z0)');
xlabel('\bf real-axis');  ylabel('\bf imag-axis');
axis equal;  axis([-1 1 -1 1]*L*2)

%  for the circles
rlist = [1/2 1/4 1/8];  clist = ['k' 'b' 'r'];
angle = 0:pi/N:2*pi;

for jj = 1:3;
    %  z-plane circle (z = z0+hh) & difference quotient for f(z) HERE
    hh = rlist(jj)*exp(i*angle);  z = z0 + hh;
    dq = ( z.^2 - z0^2 ) ./ hh;

    %  plot pre-image & image
    subplot(2,2,1)
    plot(real(z),imag(z),clist(jj))
    subplot(2,2,2)
    plot(real(dq),imag(dq),clist(jj))
end
        
%  example 2:  f(z) = |z|^2
%  choose z0 HERE
z0 = 1;

%  plot z0
subplot(2,2,3);  hold on
plot(real(z0),imag(z0),'k*');
title('\bf z-plane');
xlabel('\bf real-axis');  ylabel('\bf imag-axis');
axis equal;  axis([-1 1 -1 1]*L)

subplot(2,2,4);  hold on
title('\bf w-plane:  (f(z)-f(z0))/(z-z0)');
xlabel('\bf real-axis');  ylabel('\bf imag-axis');
axis equal;  axis([-1 1 -1 1]*L*2)

%  for the circles
angle = 0:pi/N:2*pi;

for jj = 1:3;
    %  z-plane circle (z = z0+hh) & difference quotient for f(z) HERE
    hh = rlist(jj)*exp(i*angle);  z = z0 + hh;
    dq = ( abs(z).^2 - abs(z0)^2 ) ./ hh;

    %  plot pre-image & image
    subplot(2,2,3)
    plot(real(z),imag(z),clist(jj))
    subplot(2,2,4)
    plot(real(dq),imag(dq),clist(jj))
end

