x1 = (-1 - i);
x2 = 2 - i;
x3 = 2 + 2*i;
x4 = -1 + 2*i;
t = linspace(0, 1, 100);
z1 = (1 - t) * x1 + t * x2;
z2 = (1 - t) * x2 + t * x3;
z3 = (1 - t) * x3 + t * x4;
z4 = (1 - t) * x4 + t * x1;
z = x1.^2;
figure
hold on
plot(real(z1), imag(z1), '--r')
plot(real(z2), imag(z2), '--g')
plot(real(z3), imag(z3), '--m')
plot(real(z4), imag(z4), '--b')
plot(real(x1), imag(x1), 'ok')
plot(real(x2), imag(x2), 'ok')
plot(real(x3), imag(x3), 'ok')
plot(real(x4), imag(x4), 'ok')
plot(real(z), imag(z), '-c')
axis equal
ax = gca;
ax.XAxisLocation = 'origin';
ax.YAxisLocation = 'origin';
xticks(-5:1:5)
yticks(-5:1:5)
xlabel('Real');
ylabel('Imag');
legend('Square', 'z^2');
xlim([-5, 5]);
ylim([-5, 5]);
axis equal;