function out = cdemo(n,auto,m) % % April 2006. % A simple driver to run typical examples for ccf % for negative parameter values also include Alex Burnett's implementations % The value of "auto" is palnned to be used for the speed of the animations % % More basic examples: % z, conj(z), i*z, 1/z, real(z), z.^2, z.^3 % 1./(z.^2-1), (z.^2+1)./(z.^2-1) % finite Taylor and Laurent approximations % exp(z), sin(z), cos(z) % exp(1/z), sin(1/z) % sqrt(z), -sqrt(z), log(z), sqrt(z^2-1) if (nargin < 3), m = 3; end if (nargin < 2), auto = 0.3; end if (nargin < 1), n = 0; end %% polynomial and rational functions %% n=0 : k-th powers if n==0 for k=0:20; ccf([1 zeros(1,k)],3,111,0), figure(gcf), pause(0.3), end, end %% n=1 : polynomials (z^k-1) if n==1 for k=0:20; ccf([1 zeros(1,k-1) -1],3,111,0), figure(gcf), pause(auto), end, end %% n=2 : polynomial functions: merging m singularities if n==2 for k=-2:0.1:2; ccf([1 zeros(1,m-1) k^3]), figure(gcf), pause(auto/2), end, end %% n=3 : rational functions: merging m singularities if n==3 for k=-2:0.1:2; ccf([zeros(1,m) 1;1 zeros(1,m-1) k^3]), figure(gcf), pause(auto/2), end, end %% n=4 : rational functions if n==4 for k=0:5; ccf([1 zeros(1,k) 1;1 zeros(1,k) -1]), figure(gcf), pause(auto), end, end %% n=5 : pole-zero cancellation, increasing control gain k of transfer function if n==5 for k=[-10:0.5:20] ; ccf([1 0 9;1 k 9],10); figure(gcf), pause(0.01), end, end %% zoom out of elementary exp, trig, and hyperbolic functions %% n=6 : zoom out of exp if n==6 for k=1:20; ccf('exp(z)',k,111,0), figure(gcf), pause(auto), end, end %% n=7 : zoom out of sin if n==7 for k=1:20; ccf('sin(z)',k,111,0), figure(gcf), pause(auto), end, end %% n=8 : zoom out of cos if n==8 for k=1:20; ccf('cos(z)',k,111,0), figure(gcf), pause(auto), end, end %% n=9 : zoom out of sinh if n==9 for k=1:20; ccf('sinh(z)',k,111,0), figure(gcf), pause(auto), end, end %% zoom in on elementary exp, trig, and hyperbolic functions at 1/z %% n=11 : zoom out of exp if n==11 for k=1:20; ccf('exp(1./z)',100/(3/2)^k,111,0), figure(gcf), pause(auto), end, end %% n=12 : zoom out of sin if n==12 for k=1:20; ccf('sin(1./z)',100/(3/2)^k,111,0), figure(gcf), pause(auto), end, end %% n=13 : zoom out of cos if n==13 for k=1:20; ccf('cos(1./z)',100/(3/2)^k,111,0), figure(gcf), pause(auto), end, end %% n=14 : zoom out of sinh if n==14 for k=1:20; ccf('sinh(1./z)',100/(3/2)^k,111,0), figure(gcf), pause(auto), end, end %% Taylor approximations of transcendental functions %% n=21 : zoom out of exp if n==21 for N=[1:30]; ccf([fliplr(1./cumprod(1:N)),1],10,111,-3); figure(gcf), pause(auto); end; end; %% n=22 : zoom out of exp if n==22 for N=[1:30]; ccf([fliplr(real(1./cumprod(i*[1:N]))),1],10,111,-3); figure(gcf), pause(auto); end; end; %% n=23 : zoom out of exp if n==23 for N=[1:30]; ccf([fliplr(imag(1./cumprod(i*[1:N]))),0],10,111,-3); figure(gcf), pause(auto); end; end; %% n=24 : zoom out of exp % nice mistake -- lots of double roots for "obvious reasons" if n==24 for N=[1:30]; ccf([fliplr(imag(1./cumprod(i*[1:N]))),1],10,111,-3); figure(gcf), pause(auto); end; end; % %% Successive (symmetric) Laurent expansion %% series for 1/(z-1)(z-2) on the annulus if n==31 N=40;r=2;R=3;C=[[-(1/R).^[N+1:-1:1],r.^[0:N-1]];[zeros(1,N),1,zeros(1,N)]]; for k=0:N; ccf(C(:,N+1-k:N+1+k),2*abs(R)); figure(gcf), pause(auto); end; end % Remainder terms for the same: %% series for 1/(z-1)(z-2) on the annulus if n==32 N=40;r=2;R=3;C=[[-(1/R).^[N+1:-1:1],r.^[0:N-1]];[zeros(1,N),1,zeros(1,N)]]; for k=0:N; ccf(C(:,N+1-k:N+1+k),[0,1,-r-R;1,-r-R,r*R],2*abs(R)); figure(gcf), pause(auto);end; end; %% Alex Barnett's Taylor pix %% % show identity function if n==-9 clear opt opt.slice = 0.3; figure; set(gcf,'Units','normalized','Position',[.3 .1 .4 .8]); opt.func = 'z'; show_zser([], opt); pause; close all; end; %% show exp function if n==-8 clear opt opt.slice = 0.3; figure; set(gcf,'Units','normalized','Position',[.3 .1 .4 .8]); opt.func = 'exp(z)'; % show_zser([], opt); pause; close all; end; %% exponential convergence: converges everywhere if n==-7 clear opt opt.slice = 0.3; figure; set(gcf,'Units','normalized','Position',[.3 .1 .4 .8]); opt.func = 'exp(z)'; for n=1:20; show_zser([1 1./cumprod(1:n)], opt); drawnow; pause(auto); end; pause; close all; end; %% pole on real axis at 1 if n==-6 clear opt opt.slice = 0.3; opt.func = '1./(1-z)'; opt.win = 1.4; for n=1:20; show_zser(ones(1,n+1), opt); drawnow; pause(0.2); end; pause; close all; end; %% rational two simple poles if n==-5 clear opt opt.slice = 0.3; opt.func = '1./(1+z.^2)'; opt.win = 1.4; for n=1:50; show_zser([1 cos((1:n)*pi/2)], opt); drawnow; end; pause; close all; end; % log singularity at 0, expanded about 1 if n==-4 clear opt opt.slice = 0.3; opt.func = 'log(z)'; opt.z0 = 1; opt.win = 2.2; for n=1:20; show_zser([0 -cos(pi*(1:n))./(1:n)], opt); drawnow; end; pause; close all; end; return;