% f(z) = 1/z

clear all;
rang=2;

figure(1);
clf;

subplot(1,2,1);
t=[-30:1:30]/30*pi;
v0=[0:2:10]*0.2+1e-15;
c1=1./(2.*v0);
b1=size(c1);
szx=size(t);
for i=1:b1(2),
    x=c1(i).*(1+cos(t));
    y=c1(i).*sin(t);
    plot(x,y);
    hold on;
    plot(-x,y);
end;
xlabel('x');
ylabel('y');
axis([-rang rang -rang rang]);

subplot(1,2,2);
v=[-v0 v0];
sz=size(v);
for i=1:sz(2),
    plot(v-v+v(i),10*v);
    hold on;
end;
xlabel('u');
ylabel('v');
axis([-rang rang -rang rang]);

pause;


%------------------
subplot(1,2,1);
for i=1:b1(2),
    x=c1(i).*(1+cos(t));
    y=c1(i).*sin(t);
    plot(y,x,'r');
    hold on;
    plot(y,-x,'r');
end;

subplot(1,2,2);
for i=1:sz(2),
    plot(10*v,v-v+v(i),'r');
end;
xlabel('u');
ylabel('v');

pause;

%====================================
figure(2);
clf;

zrang=2;
x=[-10:0.2:10]/5+5e-3;
y=x;
szx=size(x);
u=zeros(szx(2));v=u;
for i=1:szx(2),
    for j=1:szx(2),
        u(i,j)=x(i)/(x(i)^2+y(j)^2);
        v(i,j)=-y(j)/(x(i)^2+y(j)^2);
    end;
end;

subplot(1,2,1);
surf(x,y,u');
shading flat;
axis([-rang rang -rang rang -zrang zrang]);
caxis([-zrang zrang]);
hold on;
xlabel('x');
ylabel('y');
zlabel('u');

subplot(1,2,2);
surf(x,y,v');
shading flat;
axis([-rang rang -rang rang -zrang zrang]);
caxis([-zrang zrang]);
hold on;
xlabel('x');
ylabel('y');
zlabel('v');
pause;

%=================================
r1=1.5;
%r2=8;
figure(1);
    subplot(1,2,1);
    x=r1.*cos(t);
    y=r1.*sin(t);
    plot(x,y,'k');
%    x2=r2.*cos(t);
%    y2=r2.*sin(t);
    
    subplot(1,2,2);
    plot(x/r1^2,y/r1^2,'k');
pause;

%------------------
figure(2);
subplot(1,2,1);
u=x./(x.^2+y.^2);
%u2=x2./(x2.^2+y2.^2);
h1=plot3(x,y,u,'k');
%h2=plot3(x2,y2,u2,'r');
set(h1,'markersize',3);
%set(h2,'markersize',3);

subplot(1,2,2);
v=-y./(x.^2+y.^2);
%v2=-y2./(x2.^2+y2.^2);
h3=plot3(x,y,v,'k');
%h4=plot3(x2,y2,v2,'r');
set(h3,'markersize',3);
%set(h4,'markersize',3);





