I'm stuck on this python exercise using plots Consider the hyperbolic paraboloid function: z=x^2−y^2 Create several plots of the...

Free

70.2K

Verified Solution

Question

Advance Math

I'm stuck on this python exercise using plots

Consider the hyperbolic paraboloidfunction:

z=x^2−y^2

Create several plots of the hyperbolic paraboloidfunction. Use true aspect ratio and label all axes.

Any help would be appreciated!Matlab can be used as long as thecode can be used in Python as well

Answer & Explanation Solved by verified expert
4.1 Ratings (468 Votes)

from mpl_toolkits.mplot3d import Axes3D
import matplotlib.pyplot as plt
from matplotlib import cm
from matplotlib.ticker import LinearLocator, FormatStrFormatter
import numpy as np

fig = plt.figure()
ax = fig.gca(projection='3d')

#making numbers starting from 0 to 5 (0 0.1 0.2 0.3 ............4.9 5)
t1 = np.linspace(0, 5, 51)
t2 = np.linspace(0,2*math.pi,21)
[r,the]=np.meshgrid(t1,t2);
x1=np.multiply(r,np.cos(the));
y1=np.multiply(r,np.sin(the));
z1=np.square(x1)-np.square(y1);

# Plot the surface.

surf = ax.plot_surface(x1, y1, z1, cmap=cm.coolwarm,
                       linewidth=0, antialiased=False)
ax.set_title('hyperbolic paraboloid')
ax.set_xlabel('x1')
ax.set_ylabel('y1')
ax.set_zlabel('z1')


# please see this https://matplotlib.org/mpl_toolkits/mplot3d/tutorial.html#mplot3d-tutorial
#you can use subplot also

#ax.legend()
# Customize the z axis.
#ax.set_zlim(-1.01, 1.01)
#ax.zaxis.set_major_locator(LinearLocator(10))
#ax.zaxis.set_major_formatter(FormatStrFormatter('%.02f'))

# Add a color bar which maps values to colors.
#fig.colorbar(surf, shrink=0.5, aspect=5)

plt.show()


Get Answers to Unlimited Questions

Join us to gain access to millions of questions and expert answers. Enjoy exclusive benefits tailored just for you!

Membership Benefits:
  • Unlimited Question Access with detailed Answers
  • Zin AI - 3 Million Words
  • 10 Dall-E 3 Images
  • 20 Plot Generations
  • Conversation with Dialogue Memory
  • No Ads, Ever!
  • Access to Our Best AI Platform: Flex AI - Your personal assistant for all your inquiries!
Become a Member

Other questions asked by students