## Transformation of the complex plan: Conformal Mapping

### Fe21 (view profile)

on 8 Jul 2018
Latest activity Answered by abd abd1

### abd abd1 (view profile)

on 13 Sep 2019
I have to write a code in Matlab that explains a conformal mapping under the transformation w=z^2+1/z. How can I do that?(I've already read the link: Exploring a Conformal Mapping, but with this particular transformation I failed).

Anton Semechko

### Anton Semechko (view profile)

on 8 Jul 2018
I was wrong. Mobius transformations are a group of conformal transformations of a Riemann sphere. Complex plane admits a much larger group of comformal transformations. According to the reference link I posted, any complex analytic function with non-zero first derivative is also a conformal map (pp. 34). So the function w=z^2 + 1/z is a conformal map. To find its inverse you will have to solve z^3 - w*z + 1 = 0 (e.g., using 'roots' function). Unfortunately, resulting expression is a "bit" more complicated compared to the one for z^2 - 2*w*z + 1 = 0. Here it is:
syms w
r=roots([1 0 w 1]);
pretty(simplify(r))
/ w \
| #1 - ---- |
| 3 #1 |
| |
| #3 + sqrt(3) w 1i + #2 - w |
| - -------------------------- |
| 6 #1 |
| |
| w + sqrt(3) w 1i + #2 - #3 |
| -------------------------- |
\ 6 #1 /
where
/ / 3 \ \1/3
| | w 1 | 1 |
#1 == | sqrt| -- + - | - - |
\ \ 27 4 / 2 /
/ / 3 \ \2/3
| | w 1 | 1 |
#2 == sqrt(3) | sqrt| -- + - | - - | 3i
\ \ 27 4 / 2 /
/ / 3 \ \2/3
| | w 1 | 1 |
#3 == 3 | sqrt| -- + - | - - |
\ \ 27 4 / 2 /
Keep in mind that "sqrt" term inside #1, #2, and #3 can have both +ve and -ve signs.
Fe21

### Fe21 (view profile)

on 8 Jul 2018
I do not think I have the necessary requirements to understand the whole file. Then you told me that mine is not a conformal transformation, so maybe I have to change method.
I have an example of code that does the same thing, but with the transformation w=z^2. How can I adapt it for my transformation?
Anton Semechko

### Anton Semechko (view profile)

on 8 Jul 2018
Sorry about the confusion. Give me a few minutes to modify your code.

### Anton Semechko (view profile)

on 9 Jul 2018
Edited by Anton Semechko

### Anton Semechko (view profile)

on 9 Jul 2018

Modified code ('conformal_map_demo') is attached below. In principle, this piece of code should should allow you to visualize any complex analytic function. You just have to modify the 'f' function manually.
Example for f=z^2
Example for f=z^2+1/z
function conformal_map_demo
% Grid settings
XLim=5*[-1 1];
n = 20;
dX=(XLim(2)-XLim(1))/n;
% Initialize figure
figure
ha1=subplot(1, 2, 1);
title ('Grid of Squares')
axis('equal')
hold on
ha2=subplot(1, 2, 2);
title ('Image Of Grid Under w = z^2 + 1/z')
axis('equal')
hold on
% ============================== PRE-IMAGE ================================
axes(ha1)
% Draw reference square at top-right corner
% -------------------------------------------------------------------------
su=[0 0; 1 0; 1 1; 0 1]; % unit square
s=bsxfun(@plus,dX*su,XLim(2)*[1 1]-dX);
fill(s(:,1),s(:,2),[0.9 0.9 0.9])
% Draw vertical grid lines at dX intervals
% -------------------------------------------------------------------------
for x=XLim(1):dX:XLim(2)
plot(x*ones(1,2),XLim,'b')
end
% Draw horizontal grid lines at dX intervals
% -------------------------------------------------------------------------
for y=XLim(1):dX:XLim(2)
plot(XLim,y*ones(1,2), 'r')
end
% Draw Unit Tangents for the reference square
% -------------------------------------------------------------------------
x1 = XLim(2)-dX;
y1 = x1;
% 1. Draw the Unit Tangent in the i-direction
a = [x1 x1];
b = y1 + dX*[0 1];
line(a, b, 'linewidth',3, 'color', 'blue')
% 2. Draw the Unit Tangent in the r-direction
a = x1 + dX*[0 1];
b = [y1 y1];
line(a,b, 'linewidth',3, 'color', 'red')
hold off
% Set axes domain, and range
axis((XLim(2)+dX)*[-1 1 -1 1])
% ================================ IMAGE ==================================
axes(ha2)
f=@(z) z.^2 + 1./z;
% Draw the image of the reference square
% -------------------------------------------------------------------------
% Subdivide original reference square; to insert more points between corners
for i=1:8
s_new=(s+circshift(s,[-1 0]))/2;
s=reshape(cat(1,s',s_new'),2,[]);
s=s';
end
f_s=f(s(:,1)+1i*s(:,2));
fill(real(f_s),imag(f_s),[0.9 0.9 0.9])
% Draw images of the vertical lines
% -------------------------------------------------------------------------
BB=Inf*[1 -1;1 -1];
yy=linspace(XLim(1),XLim(2),1E3)';
for x = XLim(1):dX:XLim(2);
w=f(x*ones(1E3,1) + 1i*yy);
u=real(w);
v=imag(w);
plot(u,v,'-b')
if x~=0
BB(:,1)=min(BB(:,1),[min(u);min(v)]);
BB(:,2)=max(BB(:,2),[max(u);max(v)]);
end
end
% Draw the images of the horizontal lines
% -------------------------------------------------------------------------
xx=yy;
for y = XLim(1):dX:XLim(2);
w=f(xx+1i*y*ones(1E3,1));
u=real(w);
v=imag(w);
plot(u,v,'-r')
if y~=0
BB(:,1)=min(BB(:,1),[min(u);min(v)]);
BB(:,2)=max(BB(:,2),[max(u);max(v)]);
end
end
% Draw the images of the unit tangents under w
% -------------------------------------------------------------------------
% Jacobian the map
syms x y
Jxx=diff(real(f(x+1i*y)),'x');
Jxy=diff(real(f(x+1i*y)),'y');
Jyy=diff(imag(f(x+1i*y)),'y');
Jyx=diff(imag(f(x+1i*y)),'x');
J=[Jxx Jxy; Jyx Jyy];
% Evaluate Jacobian at the bottom-left corner of the reference square
c=XLim(2)*[1 1];
Jc=dX*double(subs(J,[x,y],c));
% Visualize new tangent vectors at c
[Ux,Uy]=deal([real(f_s(1)) imag(f_s(1))]);
Ux=[Ux;Ux+Jc(:,1)'];
Uy=[Uy;Uy+Jc(:,2)'];
plot(Ux(:,1),Ux(:,2),'-r','LineWidth',3)
plot(Uy(:,1),Uy(:,2),'-b','LineWidth',3)
% Set axes domain and range
BB(:,1)=min(BB(:,1),min([Ux;Uy])');
BB(:,2)=max(BB(:,2),max([Ux;Uy])');
dB=BB(:,2)-BB(:,1);
BB(:,1)=BB(:,1)-0.025*dB;
BB(:,2)=BB(:,2)+0.025*dB;
set(ha2,'XLim',BB(1,:),'YLim',BB(2,:))