how to draw a 3d surface of exp(x+iy)

Asked by Lvfan LIU

Lvfan LIU (view profile)

on 11 Sep 2019
Latest activity Commented on by Rik

Rik (view profile)

on 11 Sep 2019
exp(z）=exp(x)*(cosy+i*siny)

Fabio Freschi

Fabio Freschi (view profile)

on 11 Sep 2019
The result is a complex number: what do you want on the axes?
x,y,abs(exp(z))
x,y,real(exp(z))
x,y,imag(exp(z))
Rik

Rik (view profile)

on 11 Sep 2019
z_val=@(x,y) log(exp(x).*(cos(y)+1i*sin(y)));
[X,Y]=ndgrid(linspace(-3*pi,3*pi,100));
Z=z_val(X,Y);
figure
ax1=subplot(1,2,1);
surf(X,Y,real(Z));
title('real part')
ax2=subplot(1,2,2);
surf(X,Y,imag(Z));
title('imaginary part')
Then you can link the axes with linkprop.

Tags

Answer by Bjorn Gustavsson

Bjorn Gustavsson (view profile)

on 11 Sep 2019
Edited by Bjorn Gustavsson

Bjorn Gustavsson (view profile)

on 11 Sep 2019

Have a look at the dcolor submission to the file exchange. That should give you a good starting point for doing this.
There are all sorts of combinations to try to convey the complex-valued surface. You could put the angle as the colour for your surface and the magnitude as the z-value to the plain surf call
[x,y] = meshgrid(linspace(-2,2,1001));
z = log(exp(x).*(cos(y)+i*sin(y)));
, or the other way around, or the real and imaginary parts. When it comes to this type of plotting the best way is to try all sort of combinations you can imagine and see which works best for your purposes.
HTH

Answer by Fabio Freschi

Fabio Freschi (view profile)

on 11 Sep 2019

Suppose that you want to plot the magnitude of the exp(z)
% setup the range of your plot in x and y (-2,2) and the resolution (20 points)
x = linspace(-2,2,20);
y = linspace(-2,2,20);
% create a regular grid (X and Y are 2d matrices)
[X,Y] = meshgrid(x,y);
% evaluate your function (note that the imaginary unit is 1i, note also the operator .*)
expZ = exp(X).*(cos(Y)+1i*sin(Y))
% now the plot (here the abs, use real or imag as you like)
figure
surf(X,Y,abs(expZ));
% label as desired
xlabel('x coordinate');
ylabel('y coordinate');
zlabel('exp(Z)');