Question: An easy way to plot regions between two curves

    It’s a pity that Maple does not offer easy ways to plot the region between two curves in the xy-plane. The option “filled=true” can only plot the region between the curve y=f(x) and the x-axis.

    I’d like to share my experience on how to easily plot regions between any to curves. The trick is that we plot everything in the space and plot3d the region as a surface (just let z=0). If we choose orientation=[270,0], then the space curves and surfaces are just like curves and regions in the xy-plane.

    The following examples tell everything I want say.

Example 1  The region between y=x and y=x^2.

with(plots):

f:=x->x: g:=x->x^2:

F:=spacecurve([x,f(x),0],x=-0.2..1.2,color=blue, thickness=3):

G:=spacecurve([x,g(x),0],x=-0.2..1.2,color=red, thickness=3):

region:=plot3d([x,y,0],x=0..1,y=g(x)..f(x),color=grey, style=patchnogrid):

display(region,F,G,axes=normal,
orientation=[270,0],scaling=constrained);

Example 2 The region between y=sin(x) and y=cos(x).

with(plots):

f:=x->sin(x): g:=x->cos(x):

F:=spacecurve([x,f(x),0], x=-0.5..6.5,color=blue,thickness=3):

G:=spacecurve([x,g(x),0], x=-0.5..6.5,color=red,thickness=3):

Region:=plot3d([x,y,0], x=0..6, y=g(x)..f(x), color=green,style=contour):

display(Region, F, G, axes=normal, orientation=[270,0],scaling=constrained);

Example 3 The region between x=y^2/2 and x=y^4/4-y^2/2.

with(plots):

f:=y->y^2/2: g:=y->y^4/4-y^2/2:

F:=spacecurve([f(y), y, 0], y=-0.1..2.1, color=blue, thickness=3):

G:=spacecurve([g(y), y, 0], y=-0.2..2.1, color=red, thickness=3):

Region:=plot3d([x, y, 0], y=0..2, x=g(y)..f(y), color=gray, style=patch,grid=[10,10]):

display(Region, F, G, axes=normal, orientation=[270,0], scaling=constrained);

Example 4  Bird’s eye view of Example 3 (Just change the orientation.)
with(plots):

f:=y->y^2/2: g:=y->y^4/4-y^2/2:

F:=spacecurve([f(y), y, 0], y=-0.1..2.1, color=blue, thickness=3):

G:=spacecurve([g(y), y, 0], y=-0.2..2.1, color=red, thickness=3):

Region:=plot3d([x, y, 0], y=0..2, x=g(y)..f(y), color=gray, style=patch,grid=[10,10]):

display(Region, F, G, axes=normal, orientation=[300,55], scaling=constrained);

 

Please Wait...