eightyfiv

12 Reputation

2 Badges

15 years, 240 days

MaplePrimes Activity


These are replies submitted by eightyfiv

Here's yet another way to plot between two curves -- write a little procedure that shades polygons. I was quite dumbfounded to find Maple can't shade nonconvex polygons with a single command, but you can chain together small pieces like this (in this case, trapezoids). I've had success with this in Maple 9.5 and 10. 

shadebetweencurves := (f1, f2, range, numpoints, colr)->seq(plottools[polygon](eval([[tovar(stepvar-1), eval(f1, lhs(range)=tovar(stepvar-1))], [tovar(stepvar), eval(f1, lhs(range)=tovar(stepvar))], [tovar(stepvar), eval(f2, lhs(range)=tovar(stepvar))], [tovar(stepvar-1), eval(f2, lhs(range)=tovar(stepvar-1))]], tovar=(sv->(lhs(rhs(range)) + (rhs(rhs(range)) - lhs(rhs(range))) * sv / numpoints))), color=colr, style=patchnogrid), stepvar=1..numpoints);

 

plots[display](shadebetweencurves(x^2, x^3, x=-1..1, 20, blue));

 This procedure does unnecessarily evaluate its functions twice. You could optimize that out.

Page 1 of 1