% CONVERGE.M % % Let z be a complex number. We know z^n converges if ||z|| < 1, and that % z^n goes to infinity if ||z|| > 1. However, if ||z|| = 1, then some % interesting behavior occurs. We will examine this behavior graphically % in the complex plane. % % Jessica Bernier MATH215 Aug. 28, 2008 fprintf(['\nLet z be a complex number of the form z = a + bi,\n where a and b are real numbers and i = sqrt(-1).\n']); fprintf([' Consider a and b in the range [-1,1] so that ||z|| = 1.\n']); a = input('Enter the real component of the complex number (a): '); while abs(a)>1 a = input('Error: Please enter a value between -1 and 1: '); end b = sqrt(abs(1-a^2)); disp(['Given a = ', num2str(a), ', we need b = +/-', num2str(b), '.']); disp(['The ratio (b^2)/(a^2) = ', num2str((b/a)^2), '.']); nmax = 500; %This is the maximum value of n to use. Adjust nmax to show more or fewer points, if needed. z = zeros(nmax,1); z(1) = complex(a,b); phi = angle(z(1)); figure; title('Behavior of z^n on the complex plane, for ||z|| = 1') xlabel('Real component (a)') ylabel('Imaginary component (b)') hold on; axis equal; grid on; plot(complex(cos(0:pi/1000:2*pi),sin(0:pi/1000:2*pi)),'r'); %Plot the unit circle in red, as a guide. for n=1:nmax z(n) = exp(i*phi*n); %The radius will always be 1. if isreal(z(n))==1 %If Matlab considers z to be real, it will graph in Cartesian coordinates. We need to manually declare z to be complex. This occurs for a = 1. plot(complex(z(n)), '.'); %complex(z(n)) = z(n) + 0i for real z(n). else plot(z(n), '.'); end pause(10/nmax) %Delay updating the figure so we can observe each new point being plotted. It takes ~10 seconds to complete the figure. end hold off disp('All done!');