function cplxroot(n,m)
%CPLXROOT Riemann surface for the n-th root.
%   CPLXROOT(n) renders the Riemann surface for the n-th root.
%   CPLXROOT, by itself, renders the Riemann surface for the cube root.
%   CPLXROOT(n,m) uses an m-by-m grid.  Default m = 20.

%   C. B. Moler, 8-17-89, 7-20-91.
%   Copyright (c) 1984-98 by The MathWorks, Inc.
%   $Revision: 5.3 $  $Date: 1997/11/21 23:25:27 $

% Use polar coordinates, (r,theta).
% Cover the unit disc n times.

if nargin < 1, n = 3; end
if nargin < 2, m = 20; end
r = (0:m)'/m;
theta = pi*(-n*m:n*m)/m;
z = r * exp(i*theta);
s = r.^(1/n) * exp(i*theta/n);

surf(real(z),imag(z),real(s),imag(s));
