Question: plotting area between functions

Hi

 

In earligere versions of maple (14 and 15) I yoused this code (program) to plot the area between functions, but it does not work in maple 17 (or 16).

integralplot2:=proc(f1,f2,a,b,{[color, colour] := blue,transparency := 0.5,numpoints:=500})     

local mingr,maxgr,variable,p,c,n,pts1,pts2,polys,i,xkoor,ytop,ybottom,yvals,plotf1,plotf2;          

if evalf(a)<evalf(b) then       

mingr:=evalf(a); maxgr:=evalf(b);     

else       

mingr:=evalf(b); maxgr:=evalf(a);     

end if;       

if (nops(indets(f1))>0) then     

variable:=indets(f1);     

elif (nops(indets(f2))>0) then       

variable:=indets(f2);     

else # begge funktioner er konstante       

variable:={x};     

end if;     

p := plot([f1, f2],variable[1]=mingr..maxgr,_options['color'],_options['numpoints'],adaptive=false);     

c := select(type, p, 'specfunc'('anything', 'CURVES'));     

if nops(c) <> 2 then       

printf("error:can not fill area between func. ");       

return NULL;     

end if;       

pts1 := op([1,1], c);     

pts2 := op([2,1], c);     

n := nops(pts1);     

if n <> nops(pts2) then       

printf("error:can not fill area between func .");       

return NULL;     

end if;

polys:=NULL;     

xkoor:=Vector(n, datatype=float);     

ytop:=Vector(n, datatype=float);     

ybottom:=Vector(n, datatype=float);     

for i to n do       

xkoor[i] := op(1, pts1[i]);       

yvals := op(2, pts1[i]), op(2, pts2[i]);       

ytop[i]:=max(yvals);       

if xkoor[i]<mingr or xkoor[i]>maxgr then         

ybottom[i]:=ytop[i];       

else         

ybottom[i]:=min(yvals);       

end if;     

end do;           

plotf1:=plot(f1,_rest,_options['color']);     

plotf2:=plot(f2,_rest,_options['color']);     

polys := [seq([xkoor[i], ytop[i]], i=1..n), seq([xkoor[i], ybottom[i]], i=n..1, -1),[xkoor[1], ytop[1]]];     

plots[display](plotf1,plotf2,plottools[polygon](polys,_options['color'],_options['transparency'],_options['numpoints'])); 

end proc:

 

What is wrong? or do any of you have a simula program, it can be a lot simpler.

Regards

Please Wait...