222 - Topic 07 - Tangent Planes and Directional Derivatives

145 days ago by Professor222

var('x,y') xmin=-3 xmax=3 ymin=-3 ymax=3 f(x,y) = 5 - (3*x^2+y^2+4) @interact def _(f = input_box(5 - (3*x^2+y^2+4),width=50), x0 = slider(xmin,xmax,1/10,1), y0 = slider(ymin,ymax,1/10,1), vin=input_box(([1, -4]),width=15,label='To change this, type vector([#,#])')): html('Using function $f(x,y) =%s$'%str(latex(f))) v = vector(vin) u = v/v.norm(2) html('Using direction vector $%s$'%str(latex(u))) G = plot3d(f,(x,xmin,xmax),(y,ymin,ymax),axes=true) G += point3d((x0,y0,f(x=x0,y=y0)),size=20,color='lightblue') x1=x0+u[0] y1=y0+u[1] fx = f.derivative(x)(x=x0,y=y0) fy = f.derivative(y)(x=x0,y=y0) grad = fx*u[0]+fy*u[1] # Plotting tangent vectors in x and y directions G += line3d([(x0,y0,f(x=x0,y=y0)),(x0+1,y0,f(x=x0,y=y0)+fx)],color='yellow',thickness=10) G += line3d([(x0,y0,f(x=x0,y=y0)),(x0,y0+1,f(x=x0,y=y0)+fy)],color='yellow',thickness=10) # plotting tangent vector in the v direction G += line3d([(x0,y0,f(x=x0,y=y0)),(x1,y1,f(x=x0,y=y0)+grad)],color='lightgreen',thickness=10) # Now the tangent plane tanplane = f(x=x0,y=y0)+fx*(x-x0)+fy*(y-y0) html('The Tangent plane is given by $z = %s$'%str(latex(tanplane))) G += plot3d(tanplane,(x,x0-1,x0+1),(y,y0-1,y0+1),color='pink') G.show() 
To change this, type vector([#,#]) 

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