:

## Another way to plot the region between two curves

Maple

In a recent blog entry, I proposed an easy way to plot the region between two curves. Later I read from an earlier blog entry that “filled=true” in implicitplot can produce amazing effects for plotting regions. Inspired by the blog entry, I’d like to introduce another easy way to plot the region between two curves.

To plot the region between y=f(x) and y=g(x) (x=a..b), we just need the following code:
with(plots):

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

implicitplot(y=0, x=a..b, y=f(x)..g(x), filled=true, coloring=[green,green]);

The key to the success of this code is that Maple 8 allows
varying range for the second variable y (i.e. y=f(x)..g(x)). However I was sorry to find that this is not allowed in Maple 11 (This will be addressed later.) .

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

with(plots):

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

a:=0: b:=1:

region:=implicitplot(y=0,x=a..b,y=f(x)..g(x),filled=true,coloring=[yellow,yellow]):

F:=plot(f(x),x=a-0.2..b+0.2,thickness=3,color=red):

G:=plot(g(x),x=a-0.2..b+0.2,thickness=3,color=blue):

display(F,G,region,scaling=constrained);

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

with(plots):

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

a:=0: b:=6:

region:=implicitplot(y=0,x=a..b,y=f(x)..g(x),filled=true,coloring=[grey,grey]):

F:=plot(f(x),x=a-0.2..b+0.2,thickness=3,color=red):

G:=plot(g(x),x=a-0.2..b+0.2,thickness=3,color=blue):

display(F,G,region,scaling=constrained);

Now if we reverse the order of the range options from “x=a..b, y=f(x)..g(x)” to “y=f(x)..g(x), x=a..b”, some strange but interesting thing will happen (See Example 3.

Example 3

with(plots):

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

a:=-1: b:=6:

region:=implicitplot(y=0, y=f(x)..g(x),x=a..b, filled=true,coloring=[grey,grey]):

F:=plot(f(x),x=a-0.2..b+0.2,thickness=3,color=red):

G:=plot(g(x),x=a-0.2..b+0.2,thickness=3,color=blue):

display(F,G,region,scaling=constrained);

It can be seen that the region in Example 2 has been reflected with respect to the line y=x. But this is not bad because can use this phenomenon to plot regions between curves x=f(y) and x=g(y) (See Example 4).

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

with(plots):

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

region:=implicitplot(y=0,x=f(y)..g(y),y=0..2,filled=true,coloring=[grey,grey]):

F:=plot([f(y),y,y=-1..2.3],thickness=3):

G:=plot([g(y),y,y=-1..2.3],thickness=3,color=blue):

display(region,F,G,scaling=constrained);

Finally some questions to be answered or discussed.

1. Is “coloring” used in the examples an option in the package Plots? But I cannot find it in the Help (Typing ? coloring produces no results.) .
2. Why the strange but interesting thing happens in Example 3 ?

3. Why the above method cannot be realized in Maple 11?
If we input the following code in Maple 11,
with(plots):

implicitplot(y=0,x=0..1,y=x..x^2,filled=true,coloring=[yellow,yellow]);with(plots);
An error warning will occur:
Error, (in plots/implicitplot) invalid input: invalid range for second variable

This means varying range for the second variable y (eg. y=x..x^2) is not allowed in Maple 11 , but which is allowed in Maple 8. If this is true, then I doubt if Maple 11 is really stronger than its earlier versions in all respects.

﻿