# Plot a vector field on a surface in Maple

I am trying to plot several vector fields on a surface in MAPLE. It will be a random one, a tangent field, and a gradient field.

Specifically, I'm stuck trying to restrict a 3D field to the surface only. I may not have taken the right approach...

Here's a couple first tries. With a vector field :

eqn:=(x^2+3*y^2)*exp(1/2*(-x^2-y^2)):
montagne:=plot3d(eqn,x = -3 .. 3, y = -3.6 .. 3.6,shading=zgrayscale,grid=[300,300],scaling=unconstrained):
vect := VectorField(<sin(y),x,z>,cartesian[x,y,z], output=plot,view=[-3..3,-3..3,0..2.3],fieldoptions=[fieldstrength=fixed,arrows=SLIM,grid=[10,10,10],axes=none,color="Red"]):
display(montagne, vect, orientation = [30, 70]);


Here's the gradient (I know it's not elegant code, but I need the directional derivatives to make different examples) :

with(Student[MultivariateCalculus]):
f := (x, y) -> eqn:
dir1:=(x) -> DirectionalDerivative(z-f(x,y),[x,y,z],[1,0,0]):
dir2:=(y) -> DirectionalDerivative(z-f(x,y),[x,y,z],[0,1,0]):
dir3:=(z) -> DirectionalDerivative(z-f(x,y),[x,y,z],[0,0,1]):
display(montagne, gradf2, orientation = [30, 70]);


And what it looks like :

Any idea how I can "cut the field" ? Or at least draw tangent vectors on the surface in a controlled manner ? Thanks for your help

You want to draw arrows at points on the surface. The arrow command in the plots package (or the plottools package) will be useful. Something like:

with(plots): with(VectorCalculus):
SetCoordinates(cartesian[x,y,z]):
eqn:=(x^2+3*y^2)*exp(1/2*(-x^2-y^2)):
montagne:=plot3d(eqn,x = -3 .. 3, y = -3.6 .. 3.6,shading=zgrayscale,
grid=[300,300],scaling=unconstrained):

• Sure, but what I mean is they should be the same length as the ones calculated with the directionnal derivatives in $\mathbb R^3$ (since in the directions of the basis vectors, they make the partial derivatives composing the gradient vector)... Shouldn't they ? Am I missing something ? Dec 26, 2016 at 21:11