使用Python绘制二元函数f(x) = (x1)2 + (x2)2的图像。
import numpy as npimport matplotlib.pyplot as pltfrom mpl_toolkits.mplot3d import Axes3Dfig = plt.figure()ax = Axes3D(fig)x1 = np.arange(-3.0, 3.0, 0.1)x2 = np.arange(-3.0, 3.0, 0.1)X, Y = np.meshgrid(x1, x2)Z = X**2 + Y**2plt.xlabel('x1')plt.ylabel('x2')ax.plot_surface(X, Y, Z, rstride=1, cstride=1, cmap='rainbow')plt.show()