Math 252 HW#08 sec. 4.8 #4 Maple Work

We start by loading the "linalg" package:

> 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;

Here is a procedure for doing the surface integral over the right face of the cube:

> 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;

Here is a procedure for doing the surface integral over the back face of the cube:

> 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;

Here is a procedure for doing the surface integral over the front face of the cube:

> 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;

Here is a procedure for doing the surface integral over the bottom face of the cube:

> 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;

Here is a procedure for doing the surface integral over the top face of the cube:

> 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;

Here is a procedure for putting all six face integrals together in order to get the surface integral over the whole cube:

> intcube:=proc(F)
local intSurf;
intSurf:=intleft(F)+intright(F)+inttop(F)+
intbot(F)+intbak(F)+intfront(F);
simplify(intSurf);
end;

Here is a procedure for calculating the volume integral:

> 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)]);

[Maple Math]

> intcube(F1);

[Maple Math]

> intvol(F1);

[Maple Math]

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)]));

[Maple Math]

> intcube(F2);

[Maple Math]

> intvol(F2);

[Maple Math]

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)]);

[Maple Math]

> intcube(F3);

[Maple Math]

> intvol(F3);

[Maple Math]

And once again, both integrals have the same answer.



SFU / Math & Stats / ~hebron / math252 / assignments / sol08 / maple / 4.8.4.html

Revised 24 March 1999 by John Hebron.