How to do it…

Run the following code in a Jupyter code cell:

from mpl_toolkits.mplot3d import Axes3D
from matplotlib import cm
f = lambda x,y: x**3 - 3*x*y**2
fig = plt.figure(figsize=(12,6))
ax = fig.add_subplot(1,2,1,projection='3d')
xvalues = np.linspace(-2,2,100)
yvalues = np.linspace(-2,2,100)
xgrid, ygrid = np.meshgrid(xvalues, yvalues)
zvalues = f(xgrid, ygrid)
surf = ax.plot_surface(xgrid, ygrid, zvalues,
rstride=5, cstride=5,
linewidth=0, cmap=cm.plasma)
ax = fig.add_subplot(1,2,2)
plt.contourf(xgrid, ygrid, zvalues, 30,
cmap=cm.plasma)
fig.colorbar(surf, aspect=18)
plt.tight_layout()
None

Running this code will produce a plot of the monkey saddle surface, which is a famous example of a surface with a non-standard critical point. The displayed graph is shown in the following screenshot:

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset