var('t,s,u,v,z,y,z')
f=-x^2/5-3*y^3/8
@interact
def _(sb=selector(['Vector Field 1','Vector Field 2','Vector Field 3','Vector Field 4','Vector Field 5'],label="Vector Field:")):
plot1=plot3d(f,(x,-1,1),(y,-1,1),frame=False,opacity=.3,aspect_ratio=1)
for i in range(0,5):
plot1+=parametric_plot3d((s,-1+i/2,f(x=s,y=-1+i/2)),(s,-1,1),color="gray")
plot1+=parametric_plot3d((-1+i/2,s,f(y=s,x=-1+i/2)),(s,-1,1),color="gray")
if sb=='Vector Field 1':
Fx=x
Fy=y
Fz=z-x
if sb=='Vector Field 2':
Fx=(y-z)*x
Fy=sin(x*z)
Fz=-abs(y)+x*z+.2
if sb=='Vector Field 3':
Fx=x
Fy=y+x*z
Fz=-y-(x*z)/2
if sb=='Vector Field 4':
Fx=cos(z)
Fy=sin(x*y)
Fz=-cos(y+x)
if sb=='Vector Field 5':
Fx=abs(x)-x*y
Fy=x-y
Fz=1.5-x*z
for i in range(0,5):
for j in range (0,5):
posx=-1+i/2
posy=-1+j/2
posz=f(x=posx,y=posy)
F1=Fx(x=posx,y=posy,z=posz)
F2=Fy(x=posx,y=posy,z=posz)
F3=Fz(x=posx,y=posy,z=posz)
plot1+=arrow3d((posx,posy,posz),(posx+F1,posy+F2, posz+F3),color="#1E88E5")
N=(-diff(f,x)(x=posx,y=posy)/2,-diff(f,y)(x=posx,y=posy)/2,1/2)
Nfrac=(F1*N[0]+F2*N[1]+F3*N[2])/(N[0]^2+N[1]^2+N[2]^2)
FNx=Nfrac*N[0]
FNy=Nfrac*N[1]
FNz=Nfrac*N[2]
plot1+=arrow3d((posx,posy,posz),(posx+FNx,posy+FNy,posz+FNz),color="#004D40")
plot1+=arrow3d((posx+FNx,posy+FNy,posz+FNz),(posx+F1,posy+F2,posz+F3),color="#D81B60")
plot1+=arrow3d((.25,.25,-.2),(.3,.2,.3),color="#FFC107")
show(plot1)