# Old Plot Region Package Version 0.8
with(plots):
# plot2d_region(x= a..b,y = f1(x) .. f2(x)) or
# plot2d_region(x= a..b,y = f1(x) .. f2(x), num_bars)
plot2d_region_old := proc(u_range,v_range)
local i,var1,a,b,ran1,ran2,var2,g1,g2,g3,g4,v_lower,v_upper,i,num_bars,ran_tmp,a_tmp,var_tmp,v_tmp,t_lower,t_upper:
num_bars := 5:
if nargs = 3 then num_bars := args[3] fi:
var1 := op(1,u_range):
var2 := op(1,v_range):
ran1 := op(2,u_range):
ran2 := op(2,v_range):
a := op(1,ran1):
b := op(2,ran1):
v_lower := op(1,ran2):
v_upper := op(2,ran2):
for i from 1 to num_bars do
t_lower[i] := subs(var1=a+(i-1)*(b-a)/(num_bars-1),v_lower):
t_upper[i] := subs(var1=a+(i-1)*(b-a)/(num_bars-1),v_upper):
if (t_upper[i] < t_lower[i]) then
printf(`CAUTION: Bounding curves reversed at %s = %g.\n`,var1,a+(i-1)*(b-a)/(num_bars-1)):
fi
od:
plot({seq([a+(i-1)*(b-a)/(num_bars-1),t,t=t_lower[i] .. t_upper[i]],i = 1..num_bars),[t,subs(var1=t,v_lower),t= a..b],[t,subs(var1=t,v_upper),t= a..b]},labels=[var1,var2])
# union {plot(v_lower,u_range,color=green,labels=[var1,var2])} union {plot(v_upper,u_range,color=blue,labels=[var1,var2])}:
end:
# P1 := plot2d_region(x=.1..1,y=x^3..x^2,8):
#display(P1);
plot2d_region := proc(u_range,v_range)
local i,var1,a,b,ran1,ran2,var2,g1,g2,g3,g4,v_lower,v_upper,i,num_bars,ran_tmp,a_tmp,var_tmp,v_tmp,t_lower,t_upper,v_lower_fcn,v_upper_fcn,gr1,gr2:
num_bars := 5:
if nargs = 3 then num_bars := args[3] fi:
var1 := op(1,u_range):
var2 := op(1,v_range):
ran1 := op(2,u_range):
ran2 := op(2,v_range):
a := op(1,ran1):
b := op(2,ran1):
v_lower := op(1,ran2):
v_upper := op(2,ran2):
v_lower_fcn := unapply(v_lower,var1):
v_upper_fcn := unapply(v_upper,var1):
for i from 1 to num_bars do
t_lower := subs(var1=a+(i-1)*(b-a)/(num_bars-1),v_lower):
t_upper := subs(var1=a+(i-1)*(b-a)/(num_bars-1),v_upper):
if (t_upper < t_lower) then
printf(`CAUTION: Bounding curves reversed at %s = %g.\n`,var1,a+(i-1)*(b-a)/(num_bars-1)):
fi
od:
gr1 := polygonplot({seq([[a+(i-1)*(b-a)/(num_bars-1),v_lower_fcn(a+(i-1)*(b-a)/(num_bars-1))],[a+(i-1)*(b-a)/(num_bars-1),v_upper_fcn(a+(i-1)*(b-a)/(num_bars-1))]],i=1..num_bars)},labels=[var1,var2],thickness=3):
gr2 := plot({[t,subs(var1=t,v_lower),t= a..b],[t,subs(var1=t,v_upper),t= a..b]},labels=[var1,var2],color=red):
{gr1,gr2}:
# plot({seq([a+(i-1)*(b-a)/(num_bars-1),t,t=t_lower[i] .. t_upper[i]],i = 1..num_bars),[t,subs(var1=t,v_lower),t= a..b],[t,subs(var1=t,v_upper),t= a..b]},labels=[var1,var2])
# union {plot(v_lower,u_range,color=green,labels=[var1,var2])} union {plot(v_upper,u_range,color=blue,labels=[var1,var2])}:
end:
printf(`Basic usage is:\n\t plot2d_region(x=a..b,y=f1(x)..f2(x),num_divisions);\n \n`);