MAT 223 Third Worksheet

681 days ago by kcrisman

Suppose you want to plot something in three dimensions.  You could use this.  Click in the cell, and then on "evaluate".  Then just type in your surface or function; don't forget to use "==" (two equals signs) and "*" and "^" where appropriate for equals, times, and powers.

var('y z') @interact def _(surface=x^2+2*y^2+z^2==9,xbounds=matrix([[-3,3]]),ybounds=matrix([[-3,3]]),zbounds=matrix([[-3,3]]),auto_update=False): implicit_plot3d(surface,(x,xbounds[0][0],xbounds[0][1]),(y,ybounds[0][0],ybounds[0][1]),(z,zbounds[0][0],zbounds[0][1])).show(aspect_ratio=1,plot_points=200) 
       

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

Or, if you have a function of two variables, just use this one.  Same rules apply, except you don't need any equals signs.

var('y z') @interact def _(function=sqrt(-x^2-2*y^2+9),xbounds=matrix([[-3.5,3.5]]),ybounds=matrix([[-3.5,3.5]]),auto_update=False): plot3d(function,(x,xbounds[0][0],xbounds[0][1]),(y,ybounds[0][0],ybounds[0][1])).show(aspect_ratio=1,plot_points=500) 
       

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

If you want a contour plot, we can get one.

var('y z') @interact def _(function=sqrt(-x^2-2*y^2+9),xbounds=matrix([[-3.5,3.5]]),ybounds=matrix([[-3.5,3.5]]),auto_update=False,fill=False): contour_plot(function,(x,xbounds[0][0],xbounds[0][1]),(y,ybounds[0][0],ybounds[0][1]),plot_points=500,labels=True,fill=fill).show(aspect_ratio=1) 
       
function 
xbounds 
ybounds 
fill 

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

Or a density plot.

var('y z') @interact def _(function=sqrt(-x^2-2*y^2+9),xbounds=matrix([[-3.5,3.5]]),ybounds=matrix([[-3.5,3.5]]),auto_update=False,colors=['jet','gray']): density_plot(function,(x,xbounds[0][0],xbounds[0][1]),(y,ybounds[0][0],ybounds[0][1]),plot_points=500,cmap=colors).show(aspect_ratio=1) 
       

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