Programs for double integrals

This section contains Maple programs we will use. Place the cursor on the first red line below and hit return. When Maple is done processing, scroll back up to the line which reads "Programs for double integrals" close the section by clicking on the minus sign in the gray box to left.

> with(plottools): with(plots):
setwindow:=proc(xmin,xmax,ymin,ymax) global win;
if (nargs =0) then win:='win': else win:=plot( 1000, x=xmin..xmax, y=ymin..ymax): fi; end:
dxdy command
dxdy:=proc(yrange,xrange) local a,b,f,g,h,Ls,i,PP1,PP2,PPtop,PPbot;
if (nargs <> 2 ) then
RETURN(print("Give TWO integration ranges.")); fi;
if (type(yrange,`=`) and (op(1,yrange)=y) and
type(op(2,yrange),range)
and type(xrange,`=`) and (op(1,xrange)=x) and
type(op(2,xrange),range)) then
a:=op(1,op(2,yrange));
b:=op(2,op(2,yrange));
f:=op(1,op(2,xrange));
g:=op(2,op(2,xrange));
else
RETURN(print("You need to give 2 integration ranges, separated by a comma: y=a..b, x=ex1..ex2 so that the double integral would have the form", Int(Int(F(x,y),x=ex1..ex2),y=a..b))); fi;
if not(type(a,constant)) then
RETURN("Lower outside limit must be a number."); fi;
if not(type(b,constant)) then
RETURN("Upper outside limit must be a number."); fi;
if member(x,indets(f)) then
RETURN( "Lower inside limit must be in terms of y only."); fi;
if member(x,indets(g)) then
RETURN( "Upper inside limit must be in terms of y only."); fi;
h:=(b-a)/20;
print(Int(Int(F(x,y),x=f..g),y=a..b));
PP1:=plot([f,y, y=a..b]);
PP2:=plot([g,y, y=a..b]);
PPtop:=plot([x,b,x=subs(y=b,f)..subs(y=b,g)]);
PPbot:=
plot([x,a,x=subs(y=a,f)..subs(y=a,g)]); Ls:=[seq(line([subs(y=a+i*h,f), a+i*h],[subs(y=a+i*h,g),a+i*h]),i=1..19)];
if (win='win') then display(Ls,PP1,PP2,PPtop,PPbot); else display(win,Ls,PP1,PP2,PPtop,PPbot); fi; end:
dydx command
dydx:=proc(xrange,yrange) local a,b,f,g,h,Ls,i,PP1,PP2,PPleft,PPright;
if (nargs <> 2) then
RETURN(print("Give TWO integration ranges.")); fi;
if (type(yrange,`=`) and (op(1,yrange)=y) and
type(op(2,yrange),range)
and type(xrange,`=`) and (op(1,xrange)=x) and
type(op(2,xrange),range)) then
f:=op(1,op(2,yrange));
g:=op(2,op(2,yrange));
a:=op(1,op(2,xrange));
b:=op(2,op(2,xrange));
else
RETURN(print("You need to give 2 integration ranges, separated by a comma: x=a..b, y=ex1..ex2 so that the double integral would have the form", Int(Int(F(x,y),y=ex1..ex2),x=a..b))); fi;
if not(type(a,constant)) then
RETURN("Lower outside limit must be a number."); fi;
if not(type(b,constant)) then
RETURN("Upper outside limit must be a number."); fi;
if member(y,indets(f)) then
RETURN( "Lower inside limit must be in terms of x only."); fi;
if member(y,indets(g)) then
RETURN( "Upper inside limit must be in terms of x only."); fi;
h:=(b-a)/20;
print(Int(Int(F(x,y),y=f..g),x=a..b));
PP1:=plot([x,f, x=a..b]);
PP2:=plot([x,g, x=a..b]);
PPright:=plot([b,y,y=subs(x=b,f)..subs(x=b,g)]);
PPleft:=
plot([a,y,y=subs(x=a,f)..subs(x=a,g)]); Ls:=[seq(line([a+i*h, subs(x=a+i*h,f)], [a+i*h, subs(x=a+i*h,g)]),i=1..19)];
if (win='win') then display(Ls,PP1,PP2,PPleft,PPright); else display(win,Ls,PP1,PP2,PPleft,PPright); fi; end:
drdtheta command
drdtheta:=proc(thetarange,rrange) local a,b,f,g,h,Ls,i,PP1,PP2,PPtop,PPbot,pref;
if (nargs <> 2 ) then
RETURN(print("Give TWO integration ranges.")); fi;
if (type(thetarange,`=`) and (op(1,thetarange)=theta) and
type(op(2,thetarange),range)
and type(rrange,`=`) and (op(1,rrange)=r) and
type(op(2,rrange),range)) then
a:=op(1,op(2,thetarange));
b:=op(2,op(2,thetarange));
f:=op(1,op(2,rrange));
g:=op(2,op(2,rrange));
else
RETURN(print("You need to give 2 integration ranges, separated by a comma: theta=theta[1]..theta[2], r=ex1..ex2 so that the double integral would have the form", Int(Int(F(r,theta)*r,r=ex1..ex2),theta=theta[1]..theta[2]))); fi;
if is(whattype(evalf(a))<>float) then
RETURN("Lower outside limit must be a number."); fi;
if is(whattype(evalf(b))<>float) then
RETURN("Upper outside limit must be a number."); fi;
if member(r,indets(f)) then
RETURN( " Lower inside limit must be in terms of theta only."); fi;
if member(r,indets(g)) then
RETURN( "Upper inside limit must be in terms of theta only."); fi;
h:=(b-a)/20;
print(Int(Int(F(r,theta)*r ,r=f..g),theta=a..b));
PP1:=polarplot(f, theta=a..b,scaling=CONSTRAINED);
PP2:=polarplot(g,theta=a..b,scaling=CONSTRAINED);
PPtop:=polarplot([r,b,r=subs(theta=b,f)..subs(theta=b,g)],scaling=CONSTRAINED);
PPbot:=
polarplot([r,a,r=subs(theta=a,f)..subs(theta=a,g)],scaling=CONSTRAINED); Ls:=[seq(line([subs(theta=a+i*h,f)*cos(a+i*h), subs(theta=a+i*h,f)*sin(a+i*h)],[subs(theta=a+i*h,g)*cos(a+i*h),
subs(theta=a+i*h,g)*sin(a+i*h)]),i=1..19)];
pref:=polarplot(1,t=0..2*Pi,color=white, scaling=constrained);
display(PP1,PP2,PPtop,PPbot,pref,Ls,scaling=CONSTRAINED); end:
dthetadr command
dthetadr:=proc(rrange,thetarange) local a,b,f,g,h,Ls,i,PP1,PP2,PPtop,PPbot,pref;
if (nargs <> 2 ) then
RETURN(print("Give TWO integration ranges.")); fi;
if (type(thetarange,`=`) and (op(1,thetarange)=theta) and
type(op(2,thetarange),range)
and type(rrange,`=`) and (op(1,rrange)=r) and
type(op(2,rrange),range)) then
f:=op(1,op(2,thetarange));
g:=op(2,op(2,thetarange));
a:=op(1,op(2,rrange));
b:=op(2,op(2,rrange));
else
RETURN(print("You need to give 2 integration ranges, separated by a comma: r=a..b, theta=ex1..ex2 so that the double integral would have the form", Int(Int(F(r,theta)*r,theta=ex1..ex2),r=a..b))); fi;
if is(whattype(evalf(a))<>float) then
RETURN("Lower outside limit must be a number."); fi;
if is(whattype(evalf(b))<>float) then
RETURN("Upper outside limit must be a number."); fi;
if member(theta,indets(f)) then
RETURN( " Lower inside limit must be in terms of r only."); fi;
if member(theta,indets(g)) then
RETURN( "Upper inside limit must be in terms of r only."); fi;
h:=(b-a)/20;
print(Int(Int(F(r,theta)*r,theta=f..g),r=a..b));
PP1:=polarplot([r,f, r=a..b],scaling=CONSTRAINED);
PP2:=polarplot([r,g,r=a..b],scaling=CONSTRAINED);
PPtop:=
polarplot([a,t,t=subs(r=a,f)..subs(r=a,g)],scaling=CONSTRAINED);PPbot:=
polarplot([b,t,t=subs(r=b,f)..subs(r=b,g)],scaling=CONSTRAINED); Ls:=[seq(polarplot(a+i*h,t=subs(r=a+i*h,f)..subs(r=a+i*h,g),color=black),
i=1..19)];
pref:=polarplot(1,t=0..2*Pi,color=white, scaling=constrained);
display(PP1,PP2,PPtop,PPbot,pref,Ls,scaling=CONSTRAINED); end:

Scroll to top and close this section!

>