Remember:
1) Commands always end with - ; or :
2) Use := for assignment - u:= x^2 + y^2;
3) To load the plotting package use - with(plots);
Examples
with(plots):
# Two dimensions
fieldplot([y,-x], x=-1..1, y=-1..1, arrows=THICK, grid=[8,8], color=blue);
# Three dimensions
fieldplot3d( [x,y,z], x=-1..1,y=-1..1, z=-1..1,arrows=THICK, grid=[5,5,5]);
# Plotting gradients
# First read in the Linear Algebra package
with(linalg):
f:= x^2*y^2:
V_two:=grad(f,[x,y]);
fieldplot(V_two, x=0..2,y=0..2,arrows=THICK, grid=[8,8], color=blue);
#Now in three dimensions
g:=x+sin(y*z);
V_three:=grad(g,[x,y,z]);
fieldplot3d( V_three, x=-1..1,y=0..2*Pi,z=0..2*Pi,arrows=THICK, grid=[5,5,5],axes=boxed);
#Example 1 of a spacecurve and field together
VF:=fieldplot3d([x*y,y*z,z*x], x=0..1,y=0..1,z=0..1, arrows=THICK, grid=[5,5,5],axes=boxed):
CV:=spacecurve([t,t^2,t^3], t=0..1, thickness=2, color=red):
display(VF,CV);
#Example 2 of a spacecurve and field together
VF2:=fieldplot3d([y+z,x+z,x+y], x=-1..1,y=-1..1,z=0..2*Pi, arrows=THICK, grid=[5,5,5],axes=boxed):
C1:=spacecurve([cos(t),sin(t),t], t=0..2*Pi, thickness=2, color=red):
C2:=spacecurve([1,0,t], t=0..2*Pi, thickness=2, color=blue,axes=boxed):
display(VF2,C1,C2);
#Example 3 of a surface and a field together
S:=plot3d(1-x^2-y^2, x=-1..1, y=-sqrt(1-x^2)..sqrt(1-x^2),color=blue,style=PATCHCONTOUR):
VF:=fieldplot3d([y,x,z], x=-1..1,y=-1..1,z=0..1.1, arrows=THICK, grid=[5,5,5],axes=boxed):
display(S,VF);
#Example 4 of a surface and a field together
S:=plot3d( 1, theta=0..2*Pi, phi=0..Pi,coords=spherical,color=red):
VF2:=fieldplot3d([z,y,x], x=-1..1,y=-1..1,z=-1..1, arrows=THICK, grid=[5,5,5],axes=boxed):
display(S,VF2);
#Example 5 of a surface and a field together
S:=implicitplot3d( x^2+y^2=1, x=-1..1,y=-1..1,z=-2..2,style=patchnogrid):
VF:=fieldplot3d([z,y,x], x=-1..1,y=-1..1,z=-2..2, arrows=THICK, grid=[5,5,5],axes=boxed):
display(S,VF);
#Getting fancy
S1:=implicitplot3d( x^2+y^2=1, x=-1..1,y=-1..1,z=-2..2,style=patchnogrid):
S2:=plot3d(-2, x=-1..1,y=-sqrt(1-x^2)..sqrt(1-x^2),style=patchnogrid,color=red):
S3:=plot3d(2, x=-1..1,y=-sqrt(1-x^2)..sqrt(1-x^2),style=patchnogrid,color=red):
VF:=fieldplot3d([x,y,z], x=-1..1,y=-1..1,z=-2..2, arrows=THICK, grid=[5,5,5],axes=boxed):
display(S1,S2,S3,VF);