Graphing $x^2+1$ over the complex plane I was watching this video: https://youtu.be/T647CGsuOVU?t=113
and I wanted to be able to graph the function $x^2+1$ as they have in the video (the link takes you to the moment when the graph is shown). The graph was what I found an interesting way of what the function would look like over the complex plane.
Essentially, I'd like to try and get some visual representations of the complex roots of the function. How could I go about this with matlab or geogebra (preferably the latter)?

Following @user856's comment, I tried to plot the real part of y=z^2.
$
\begin{aligned}
y &= z^2 \\
&= (a + ib)^2 \\
&= (a^2 - b^2) + i(2ab)
\end{aligned}
$
Using Python:
import numpy as np
import matplotlib.pyplot as plt
from mpl_toolkits.mplot3d import Axes3D

A = np.linspace(-5, 5, 20)
B = np.linspace(-5, 5, 20)
A, B = np.meshgrid(A, B)
Y = A**2 - B**2

C = np.linspace(-5, 5, 10)
D = np.linspace(-25, 25, 10)
C, D = np.meshgrid(C, D)

fig = plt.figure()
ax = fig.add_subplot(111, projection='3d')
ax.plot_surface(A, B, Y, zorder=2)
ax.plot_surface(A, B, np.zeros_like(A), color='red', alpha=0.5, zorder=1)
ax.plot_surface(C, np.zeros_like(C), D, color='green', alpha=0.5, zorder=1)
ax.set_xlabel('a')
ax.set_ylabel('b')
ax.set_zlabel('y')
plt.show()

I have drawn two planes:

*

*b=0, which will show the plot of $z^2$ in the real plane.

*y=0, so that you can see how $z^2$ in the real plane never crosses that plane, but outside b=0 it does.


EDIT:
After a second thought, you might get a glimpse of what the function looks like in its entirety, by coloring the plot for instance.
import numpy as np
import matplotlib.pyplot as plt
from mpl_toolkits.mplot3d import Axes3D

A = np.linspace(-10, 10, 40)
B = np.linspace(-10, 10, 40)
A, B = np.meshgrid(A, B)
Re = A**2 - B**2
Im = 2 * A * B

fig = plt.figure()
ax = fig.add_subplot(111, projection='3d')
img = ax.scatter(A, B, Re, c=Im)
ax.set_xlabel('a')
ax.set_ylabel('b')
ax.set_zlabel('Re(z^2)')
bar = fig.colorbar(img)
bar.ax.set_ylabel('Im(z^2)', rotation=0)
plt.show()


