> with(linalg):
Now, let us define a few Maple procedures which will help to automate the process of taking the surface integrals and the volume integrals over different surfaces.Here is a procedure for doing the surface integral over the left face of the cube:
>
intleft:=proc(F)
local intgnd, intL;
intgnd:=dotprod(F,vector([0,-1,0]));
intgnd:=subs(y=0,intgnd);
intL:=int(int(intgnd,x=0..1),z=0..1);
simplify(intL);
end;
>
intright:=proc(F)
local intgnd, intR;
intgnd:=dotprod(F,vector([0,1,0]));
intgnd:=subs(y=1,intgnd);
intR:=int(int(intgnd,x=0..1),z=0..1);
simplify(intR);
end;
>
intbak:=proc(F)
local intgnd, intBa;
intgnd:=dotprod(F,vector([-1,0,0]));
intgnd:=subs(x=0,intgnd);
intBa:=int(int(intgnd,y=0..1),z=0..1);
simplify(intBa);
end;
>
intfront:=proc(F)
local intgnd, intF;
intgnd:=dotprod(F,vector([1,0,0]));
intgnd:=subs(x=1,intgnd);
intF:=int(int(intgnd,y=0..1),z=0..1);
simplify(intF);
end;
>
intbot:=proc(F)
local intgnd, intBo;
intgnd:=dotprod(F,vector([0,0,-1]));
intgnd:=subs(z=0,intgnd);
intBo:=int(int(intgnd,x=0..1),y=0..1);
simplify(intBo);
end;
>
inttop:=proc(F)
local intgnd, intT;
intgnd:=dotprod(F,vector([0,0,1]));
intgnd:=subs(z=1,intgnd);
intT:=int(int(intgnd,x=0..1),y=0..1);
simplify(intT);
end;
>
intcube:=proc(F)
local intSurf;
intSurf:=intleft(F)+intright(F)+inttop(F)+
intbot(F)+intbak(F)+intfront(F);
simplify(intSurf);
end;
>
intvol:=proc(F)
local intgnd, intVol;
intgnd:=diverge(F,[x,y,z]);
intVol:=int(int(int(intgnd,x=0..1),y=0..1),z=0..1);
simplify(intVol);
end;
Okay, now let's test these things out on three different vector fields.
Here's the first vector field I tried:
>
F1:=vector([2*x*exp(y)*sin(Pi*z),x^2*exp(-y)*sin(Pi*z),
Pi*x^2*exp(y)*cos(Pi*z)]);
> intcube(F1);
> intvol(F1);
Both integrals have the same answer.
Here's the second vector field I tried:
> F2:=evalm(x*y*z*vector([sin(x),sin(y),sin(z)]));
> intcube(F2);
> intvol(F2);
As before, both integrals have the same answer.
Here's the third vector field I tried:
> F3:=vector([y^2+z^2,y*(x^3+z^3),z^2*(x^4+y^4)]);
> intcube(F3);
> intvol(F3);
And once again, both integrals have the same answer.