function w = f2(z)
	w = z .^ 2;
endfunction

function w = f3(z)
	w = z .^ 3;
endfunction

function bplot(x, y, f, c)
	w = f(x+%i*y);
	subplot(1,2,1);
	plot(x,y,c + "-");
	plot(x(1),y(1),c + "x");
	plot(x($),y($),c + "o");
	subplot(1,2,2);
	plot(real(w),imag(w),c + "-");
	plot(real(w(1)),imag(w(1)),c + "x");
	plot(real(w($)),imag(w($)),c + "o");
endfunction

function arcs(theta,f)
for r = 0.4:0.2:1.4
	x = r*cos(theta);
	y = r*sin(theta);
	bplot(x, y, f, 'r');
	sleep(10);
end
endfunction

function radii(r, f)
for theta = 0:%pi/12:%pi/2,
	x = r*cos(theta);
	y = r*sin(theta);
	bplot(x, y, f, 'b');
	sleep(10);
end
endfunction

function xline(x, f)
for y = -%pi/2:%pi/12:%pi/2,
	bplot(x,y*ones(x),f,'r')
	sleep(10);
end
endfunction

function yline(y, f)
for x = -0.8:0.2:0.8,
	bplot(x*ones(y),y,f,'b')
	sleep(10);
end
endfunction

function sector(f)
	subplot(1,1,1); clf;
	subplot(1,2,1);
	plot([-3,3],[-3,3],'w.');
	title("z-plane")
	a=gca(); a.isoview="on";
	subplot(1,2,2);
	plot([-3,3],[-3,3],'w.');
	title("w-plane");
	b=gca(); b.isoview="on";
	arcs(0:%pi/40:%pi/2,f);
	radii(0.4:0.05:1.4,f);
endfunction

function grid(f)
	subplot(1,1,1); clf;
	subplot(1,2,1);
	plot([-3,3],[-3,3],'w.');
	title("z-plane")
	a=gca(); a.isoview="on";
	subplot(1,2,2);
	plot([-5,5],[-5,5],'w.');
	title("w-plane");
	b=gca(); b.isoview="on";
	xline(-%pi/2:%pi/40:%pi/2,f);
	yline(-%pi/2:%pi/40:%pi/2,f);
endfunction

sector(f2);
grid(exp);
