% Plot contours of a complex function f(z).

x1 =  -2:0.01:3    ;
y1 = (-2:0.01:2)'  ;
Nx = numel(x1)     ;
Ny = numel(y1)     ;
x = ones(Ny,1) * x1;
y = y1 * ones(1,Nx);

z = x + i*y;

%f=z.^2;
%f = sqrt(z);
f = sqrt(z.^2 - 1);
%f = log(z);
%f = sqrt(z.^2 - i);
%f=log(z+i*sqrt(1-z.^2));

hold off
contour(x1, y1, real(f), -10:0.2:10, 'LineWidth', 2)
hold on
contour(x1, y1, imag(f), -10:0.2:10, ':', 'LineWidth', 2)
axis equal
%set(gca,"FontSize",12,"LineWidth",2,"TickDir",'out',"TickLength",[0.015,0.015])
set(gca,"FontSize",16,"LineWidth",2,"TickDir",'out')
print('zplot.pdf','-dpdf','-tight','-S200,200','-F:Helvetica:4')