<jupyter_start><jupyter_text>Calculus III - Lab 2 - Plotting surfaces<!--https://mybinder.org/v2/gh/mattsunderland/csi21S/HEAD?filepath=233%2Flabs%2Flab1.ipynb--> (B1) **EXERCISE** What is your name?<jupyter_code># My name is:<jupyter_output><empty_output><jupyter_text>(B2)  **RUN** the following. The "notebook" argument after the "%pylab" magic command switches figures from static to interactive.<jupyter_code>%pylab notebook<jupyter_output><empty_output><jupyter_text>(B3) **RUN** the following. Drag the figure around. Press the blue stop button to stop interactivity._If no figure appears, try running (B2) above again_<jupyter_code>A = r_[-1,2,1]
B = r_[ 2,1,3]
O = r_[ 0,0,0]

ax = axes(projection='3d')

ax.plot(*zip(A,B))
ax.plot(*zip(O,B-A))<jupyter_output><empty_output><jupyter_text>(B4) **RUN** the following.<jupyter_code>figure(figsize=(6,4)) # Figsize must be set BEFORE doing "ax ="

ax = axes(projection='3d')

ax.set_xlabel('x')
ax.set_ylabel('y')
ax.set_zlabel('z')
ax.set_xlim(-3,3)
ax.set_ylim(-3,3)
ax.set_zlim(-3,3)

ax.plot(*zip(A,B))
ax.plot(*zip(A-A,B-A))

ax.view_init(10,20) # Camera elevation and azimuth-angle<jupyter_output><empty_output><jupyter_text>(B5)  **RUN** the following to store all those options above into a command `make_ax` that we can call in the future. Otherwise, it would get tedius typing all those options in 3 again and again moving forward!<jupyter_code>def make_ax(lim=None):
    """
    Defines the 3D plot `ax` and labels x,y,z.
    
    Sets the camera angle so that 
    x is to the left, y to the right, and z above
    
    Optional function argument `lim`
    crops the plot to (-lim,lim) for all 3 axes x,y,z,
    which will make the plot have (roughly) equally sized x,y,z axes.
    
    Example:
        
        make_ax()
        A = r_[-1,2,1]
        B = r_[2,1,3]
        ax.plot(*zip(A,B),'r')
    
    Example using optional argument, which crops the plot to -5 < x,y,z < 5:
        
        make_ax(5)
        A = r_[-1,2,1]
        B = r_[2,1,3]
        ax.plot(*zip(A,B),'r')
    """
    
    global ax
    
    %pylab notebook

    ax = axes(projection='3d')
    
    ax.set_xlabel('x')
    ax.set_ylabel('y')
    ax.set_zlabel('z')
    
    if lim:
        ax.set_xlim(-lim,lim)
        ax.set_ylim(-lim,lim)
        ax.set_zlim(-lim,lim)
    
    ax.view_init(10,20)<jupyter_output><empty_output><jupyter_text>(B6) **RUN** the following._Getting the error "make_ax not defined"?  Run [(B5)](make_ax) above!_<jupyter_code>make_ax()

A = r_[-1,2,1]
B = r_[2,1,3]

ax.plot(*zip(A,B),'r') # 'r' means red
ax.plot(*zip(A-A,B-A),'b') # 'b' means blue

ax.text(*A,'A')
ax.text(*B,'B')
ax.text(*(A-A),'O')
ax.text(*(B-A),'B-A');<jupyter_output><empty_output><jupyter_text>Dot and cross product(B7) **RUN** the following<jupyter_code>A = r_[-1,2,1]
B = r_[2,1,3]
dot(A,B)
cross(A,B)<jupyter_output><empty_output><jupyter_text>(B8) **EXERCISE.** Compute dot(u,c) and dot(v,c) where u = , v =  and c =<jupyter_code># Type your answer below and press SHIFT+ENTER<jupyter_output><empty_output><jupyter_text>(B9) **EXERCISE.** Based on exercise 6 above, mark all that apply with an [x]<jupyter_code># Mark all that apply with an [x]
#
#   [ ]  u and v are perpendicular
#
#   [ ]  u x v = c  implies  u.c = v.c = 0
#
#   [ ]  u.c = v.c = 0  implies  u x v = c
#
#   [ ]  u.c = v.c = 0  implies  u and v are both orthogonal to c
#
#   [ ]  u.c = v.c = 0 is mere coincidence and has no implications
#<jupyter_output><empty_output><jupyter_text>(B10) **EXERCISE.** Plot u in green, v in blue, c in red.<jupyter_code>make_ax(20)

u,v,c = r_[3,-5,1], r_[3,2,-2], r_[8,9,21]
O = r_[0,0,0]

ax.text(*u,'u')
ax.text(*v,'v')
ax.text(*c,'c')

# Type your answer below and press SHIFT+ENTER<jupyter_output><empty_output><jupyter_text>Graphing planes(B11) Example. **RUN** the following, which graphs  1. u = , 1. v = ,1. the cross product of u and v, and1. the plane containing u and v and the point P(0,0,0).<jupyter_code>u = r_[2,-4,-1]
v = r_[3, 1,-2]
P = r_[0, 0, 0]

a,b,c = cross(u,v)
d = dot(cross(u,v),P)

def F(x,y): return (d - a*x - b*y)/c

make_ax(2)

[x,y] = meshgrid(r_[-2:2:1/2], r_[-2:2:1/2])

ax.plot_wireframe(x, y, F(x,y))

ax.plot(*zip(P,P+u),'r')
ax.plot(*zip(P,P+v),'r')
ax.plot(*zip(P,P+cross(u,v)),'r')<jupyter_output><empty_output><jupyter_text>(B12) **EXERCISE.** Graph the plane containing , , and the origin (0,0,0).<jupyter_code># Type your answer below and press SHIFT+ENTER<jupyter_output><empty_output><jupyter_text>(B13) Example. **RUN** the following plot of $y^2 + z^2 = 4$.<jupyter_code>def F1(x,y): return sqrt(4 - y**2)
def F2(x,y): return -sqrt(4 - y**2)

make_ax(2)

[x,y] = meshgrid(linspace(-2,2,20),linspace(-2,2,20))

ax.plot_wireframe(x, y, F1(x,y))
ax.plot_wireframe(x, y, F2(x,y))<jupyter_output><empty_output><jupyter_text>(B14) **EXERCISE.** Plot the following.    1. $z = x^2 + y^2$    1. $z = e^{x^2 + y^2}$    1. $z = 1/(x^2+y^2)$    1. $z = \sin(x^2+y^2)/(x^2+y^2)$<jupyter_code># (A) Type your answer below and press SHIFT+ENTER


# (B) Type your answer below and press SHIFT+ENTER


# (C) Type your answer below and press SHIFT+ENTER


# (D) Type your answer below and press SHIFT+ENTER<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.1816267942583732, 'fraction_numerical': 0.03291866028708134, 'mean_word_length': 4.093567251461988, 'pattern_counts': {'":': 0, '<': 60, '<?xml version=': 0, '>': 58, 'https://': 1, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '14', 'dir': 'jupyter-structured-clean-dedup', 'id': '471973', 'license': 'MIT', 'n_tokens_mistral': 2305, 'n_tokens_neox': 2244, 'n_words': 518, 'path': '233/labs/lab2.ipynb', 'repo_name': 'mattsunderland/csi21S', 'size': '5225'}