222 - Topic 04 - Multivariate Visualization and Derivatives

2985 days ago by Professor222

Visualizing multivariate functions and calculating partial derivatives

John Travis

Mississippi College

This is a worksheet that may be used by students when they first encounter multivariate functions.

It exhibits a contour plot with variable number of contours and a simple 3D rendering of the surface.

%auto var('x,y,z') 
(x, y, z)
(x, y, z)
@interact def _(surface = input_box(default=sin(x^3*y)/(x^2+y^2),label='$f(x,y) =$'), num_contours=slider(2,100,1,2,label='Number of Contours'), legend=checkbox(), show_labels=checkbox(), show_color=checkbox()): global F # these are the ranges on which the surface is graphed. These could be included as # interactive values if desired. xmin = -3 xmax = 3 ymin = -3 ymax = 3 F = plot3d(surface,(x,xmin,xmax),(y,ymin,ymax),zoom=1.0) F.show(figsize=(6,9)) if show_color: color_choice='Spectral_r' else: color_choice='gray' G = contour_plot(surface,(x,xmin,xmax),(y,ymin,ymax),contours=num_contours,cmap=color_choice,colorbar=legend,labels=show_labels,label_fontsize=6,aspect_ratio=True) G.show(figsize=(6,9)) fx = surface.derivative(x) fy = surface.derivative(y) show(fx) show(fy) equations = [fx,fy] solns = solve(equations,x,y) show(solns) 
$f(x,y) =$ 
Number of Contours 

Click to the left again to hide and once more to show the dynamic interactive window

f = sin(x^3*y)/(x^2+y^2) # the default value from the interact 
f = (x^2*y+1)/(x^4 + y^4+1) # great problem for test 
f = (x^2*y)/(x^4 + y^2+10) # example I used to do my own paper cutout 
# evaluate whichever version of f above that you desire...or create a different one fpx=diff(f,x) fpy=diff(f,y) show(f) show(fpx) show(fpy) 


# Let's plot tangent lines in the directions parallel to the coordinate axes var('t') xmin = -3 xmax = 3 ymin = -3 ymax = 3 @interact def _(x0=slider(xmin,xmax,1/10,1),y0=slider(ymin,ymax,1/10,1)): F = plot3d(f,(x,xmin,xmax),(y,ymin,ymax),zoom=1.0,opacity=0.7) fpx=diff(f,x) fpy=diff(f,y) Lx = parametric_plot3d( (x0+t,y0,f(x=x0,y=y0)+t*fpx(x=x0,y=y0)),(t,-2,2),color="yellow",thickness = 3) Lx += point3d((x0,y0,f(x=x0,y=y0)),color="red",size=30,zorder=2) Ly = parametric_plot3d( (x0,y0+t,f(x=x0,y=y0)+t*fpy(x=x0,y=y0)), (t,-2,2),color="yellow",thickness = 3) show(F+Lx+Ly,viewer='jmol') 

Click to the left again to hide and once more to show the dynamic interactive window

var('x,y,z') # Problem number 54 in section 13.3 f = 1/sqrt(1-x^2-y^2-z^2) show(f) 


fpx=f.derivative(x) fpy=f.derivative(y) fpz=f.derivative(z) show(fpx) show(fpy) show(fpz) 
fpxx=fpx.derivative(x) fpxy=fpx.derivative(y) fpxyx=fpx.derivative(x).derivative(y).derivative(x) fpyxz=fpx.derivative(x).derivative(y).derivative(x)