Application Center - Maplesoft

App Preview:

Classroom Tips and Techniques: A Package for Graphing Solution Sets of Nonlinear Inequalities

You can switch back to the summary page by clicking here.

Learn about Maple
Download Application


 

Image 

Classroom Tips and Techniques:
A Package for Graphing Solution Sets of Nonlinear Inequalities
 

Robert J. Lopez
Emeritus Professor of Mathematics and Maple Fellow

? Maplesoft, a division of Waterloo Maple Inc., 2006
 

Introduction 

Maple's inequal command in the plots package will graph the feasible region for a set of linear inequalities.  Even though Maple's solve command can solve some nonlinear inequalities exactly, Maple does not have specific tools for graphing solution sets of nonlinear inequalities.  As we show in Example 6, the contourplot command (or even the plot3d command) can be used to graph the feasible region for an inequality of the form Typesetting:-mrow(Typesetting:-mi(  Considerably more effort must be exerted to graph the points satisfying several such inequalities.  And although Maple can shade the region between a curve and the horizontal axis, it cannot easily shade the region between two arbitrary curves.  

In October 2005 the Maple Applications Center (www.mapleapps.com) acquired  

 

A Maple Package for Solving and
Displaying Inequalities
 

Robert Ipanaqu? Chero
National University of Piura
http://www.unp.edu.pe/pers/ripanaque
E-mail: robertchero@hotmail.com
 

 

an application that addresses several of these Maple shortcomings.  
 

You may view the original application here: 

http://www.maplesoft.com/applications/app_center_view.aspx?AID=1887 


By example, some taken from the author's work itself, this month's column will illustrate the user-contributed
InequalityGraphics package and its applicability to classroom tasks.  This package provides two commands, namely, inequalityplot and complexinequalityplot. 

 

The inequalityplot command will graph the two-dimensional feasible region for a set of nonlinear inequalities in two variables, that is, inequalities of the form Typesetting:-mrow(Typesetting:-mi(  Consequently, by plotting the solution set of the inequalities Typesetting:-mrow(Typesetting:-mi(< and Typesetting:-mrow(Typesetting:-mi(the region between arbitrary plane curves can be shaded. 

 

The complexinequalityplot command will plot the solution set of one or more inequalities of the form Typesetting:-mrow(Typesetting:-mi(where Typesetting:-mrow(Typesetting:-mi( is a real-valued function and the functions Typesetting:-mrow(Typesetting:-msub(Typesetting:-mi(are complex-valued functions of the complex variable Typesetting:-mrow(Typesetting:-mi(  In essence, however, the inequality Typesetting:-mrow(Typesetting:-mi( is nothing more than Typesetting:-mrow(Typesetting:-mi( because of the definition of Typesetting:-mrow(Typesetting:-mi(. 

 

 

excludedcolor = colorname 

Color of the non-feasible region 

feasiblecolor = colorname 

Color of the feasible region 

linespoints = positive integer 

Number of points plotted along curves separating feasible and non-feasible regions 

feasiblepoints = positive integer 

Number of points computed inside feasible region 

thickness = positive integer 

Thickness of curves separating feasible and non-feasible regions 

color = colorname 

Color of curves separating feasible and non-feasible regions 

Table 1   Options for the inequalityplot and complexinequalityplot commands in the InequalityGraphics package 

 

To make it easier for perusing the functionality of the package, a working version of the the code for the InequalityGraphics package is embedded in Initializations section, below.  Too often the process of installing a third-party package is a hurdle that prevents a user from trying out the new commands.  The downloaded code for the package (www.mapleapps.com), contains the three files applications.hdb, applications.ind, and applications.lib.  Dropping these files into the LIB folder of a Maple 10 installation will give permanent access to the package.  The name "applications" can be changed to something more meaningful, like InequalityGraphics, with no ill effects.  The ".ind" and ".lib" files provide the mathematical functionality of the package, whereas the ".hdb" file provides help pages without which the command of the package will still function.  The one help page provided by the hdb file can be accessed with the command ?inequals;  We leave these matters to the reader whose interest in the package is sufficiently sparked by this article. 

The code available from the Application Center colors the non-feasible region white, by default, whereas the code embedded in this article colors it black. Hence, in this article we have  explicitly used the option excludedcolor = white. 

Initializations 

> restart;
 

> with(plots):
interface(warnlevel=0):
 

>
 

> InequalityGraphics := module()

   export  inequalityplot, complexinequalityplot;
   option package;

inequalityplot:=proc()
 local ineq,ineqset,xx,yy,phaseSelection,phase1,phase2,phases,var1,
       var2,xmin,xmax,ymin,ymax,dx,dy,jumpPrecision,
       findJump,reg,c,p,x1,y1,p1List,p2List,aux1,aux2,jump1,
       jump2,eq,cc,ops,fc,ec,ls,fb,fp,lp,llss;
 
 if nargs<3 then
   ERROR(`expecting 3 arguments, got 0.
          This commmand also incorporates the options:
           (1) exludedcolor=yellow,
           (2) feasiblecolor=red,
           (3) linespoints=350,
           (4) feasiblepoints=15 and
           (5) thickness=1.
          Examples:
           <1> inequalityplot(x^2+y^2<1,x=-1..1,y=-1..1),
           <2> inequalityplot(x^2+y^2<1,x=-1..1,y=-1..1,
                  excludedcolor=white,feasiblecolor=cyan)`)
 fi:
 
 ineq:=`if`(whattype(args[1])=set,convert(args[1],`and`),args[1]):
 xx:=args[2]:yy:=args[3]:
 
 if whattype(args[1])=set
      then ineqset:=args[1]
 elif whattype(ineq)=`<` or whattype(ineq)=`>` or
      whattype(ineq)=`<=` or whattype(ineq)=`>=`
      then ineqset:={ineq}
 else ineqset:=convert(ineq,set)
 fi:
 
 var1:=lhs(xx):var2:=lhs(yy):
 
 if not(depends(ineq,var1) and depends(ineq,var2)) then
   ERROR(ineq,`doesn't depend on`,var1,`and`,var2)
 fi:
 
 ops:=[args[4..nargs]]:
 
 if not hasoption(ops,feasiblecolor,fc,'ops')
   then fc:=COLOR(RGB,.70,.70,1.0) fi:
 if not hasoption(ops,excludedcolor,ec,'ops')
   then ec:=COLOR(RGB,.20,.20,.20) fi:
 if not hasoption(ops,feasiblepoints,fp,'ops')
   then fp:=15 fi:
 if not hasoption(ops,linespoints,lp,'ops')
   then lp:=350 fi:
 
 phaseSelection:=unapply(piecewise(ineq,1,2),var1,var2):
 phase1:=(a,b)->1:phase2:=(a,b)->0:phases:=[phase1,phase2]:
 xmin:=lhs(rhs(xx)):
 xmax:=rhs(rhs(xx)):
 ymin:=lhs(rhs(yy)):
 ymax:=rhs(rhs(yy)):
 dx:=(xmax-xmin)/(fp-1):
 dy:=(ymax-ymin)/(fp-1):
 jumpPrecision:=.02*min(dx,dy):
 findJump:=(l,r)->
  `if`(evalm((l-r)&*(l-r))<jumpPrecision^2,.5*(l+r),
    `if`(phaseSelection(op(l))=phaseSelection(op(.5*(l+r))),
      findJump(.5*(l+r),r),findJump(l,.5*(l+r))
        )
      ):
 
 reg:=[]:
 
 for y1 from ymin by dy while y1<=ymax-dy do
 for x1 from xmin by dx while x1<=xmax-dx do
 c(1):=[x1,y1]:
 c(2):=[x1+dx,y1]:
 c(3):=[x1+dx,y1+dy]:
 c(4):=[x1,y1+dy]:
 p(1):=phaseSelection(op(c(1))):
 p(2):=phaseSelection(op(c(2))):
 p(3):=phaseSelection(op(c(3))):
 p(4):=phaseSelection(op(c(4))):
 
 if p(1)=p(2) and p(2)=p(3) and p(3)=p(4)
  then
     reg:=[op(reg),
           POLYGONS(
           [seq(`if`(phases[p(1)](op(c(n)))=1,c(n),NULL),
            n=1..4)],
           op(convert(color=fc,PLOToptions)))]
 else
 p1List:=[1]:
   if p(2)=p(1) then
     p1List:=[op(p1List),2]:
     if p(3)=p(1) then
       p1List:=[op(p1List),3]
     fi
   fi:
   if p(4)=p(1) then
     p1List:=[4,op(p1List)]:
     if p(3)=p(1) then
       p1List:=[3,op(p1List)]
     fi
   fi:
 p2List:=convert({1,2,3,4} minus {op(p1List)},list):
 jump1:=findJump(c(p1List[nops(p1List)]),
                 c(p2List[1])):
 jump2:=findJump(c(p2List[nops(p2List)]),
                 c(p1List[1])):
 aux1:=[jump2,op(map(c,p1List)),jump1]:
 aux2:=[jump1,op(map(c,p2List)),jump2]:
 reg:=[op(reg),
    POLYGONS(
       [seq(
         `if`(phases[p(1)](op(aux1[i]))=1,aux1[i],NULL),
        i=1..nops(aux1))],
        op(convert(color=fc,PLOToptions))),
    POLYGONS(
       [seq(
         `if`(phases[p(p2List[1])](op(aux2[i]))=1,aux2[i],NULL),
        i=1..nops(aux2))],
        op(convert(color=fc,PLOToptions)))
      ]
 fi
 od
 od:
 
 ls:=(is)->
 piecewise(
   whattype(is)=`<` or whattype(is)=`>`,2,
   whattype(is)=`<=` or whattype(is)=`>=`,1
          ):
 llss:=map(ls,[op(ineqset)]):
 
 eq:=
 `if`(whattype(ineqset)=set,
      [seq(convert(ineqset[i],equality),i=1..nops(ineqset))],
      [convert(ineq,equality)]
     ):
 
 cc:=[seq(implicitplot(eq[i],xx,yy,color=black,numpoints=lp),
      i=1..nops(eq))]:
 PLOT(op(reg),
   seq(
    CURVES(op(op(cc[i])[1]),LINESTYLE(llss[i])),i=1..nops(cc)),
     op(convert(ops,PLOToptions)),
   POLYGONS([[xmin,ymin],[xmin,ymax],[xmax,ymax],
             [xmax,ymin],[xmin,ymin]],
     op(convert(color=ec,PLOToptions))),
 SCALING(CONSTRAINED),STYLE(PATCHNOGRID)):
 
 end proc;

complexinequalityplot:=proc()
 local ineq,var,Revar,Imvar,ops;
 
 if nargs<2 then
   ERROR(`expecting 2 arguments, got 0.
          This commmand also incorporates the options:
           (1) exludedcolor=yellow,
           (2) feasiblecolor=red,
           (3) linespoints=350,
           (4) feasiblepoints=15,
           (5) linescolor=black and
           (6) thickness=1.
          Examples:
           <1> complexinequalityplot(abs(z)<1,z=(-1..1,-1..1)),
           <2> complexinequalityplot(abs(z)<1,z=(-1..1,-1..1),
                  excludedcolor=white,feasiblecolor=cyan)`)
 fi:

 var:=lhs(args[2]):
 Revar:=rhs(args[2])[1]:
 Imvar:=rhs(args[2])[2]:
 ineq:=subs(var=x+I*y,args[1]):
 ops:=args[3..nargs]:
 
 inequalityplot(ineq,x=Revar,y=Imvar,ops)

end proc;

end module:
 

>
 

> with(InequalityGraphics);
 

[complexinequalityplot, inequalityplot]
 

>
 

Examples 

Example 0 

 

When working with the Laplace transform, the convolution product of Typesetting:-mrow(Typesetting:-mi( and Typesetting:-mrow(Typesetting:-mi( is defined by 

 

Typesetting:-mrow(Typesetting:-mfenced(Typesetting:-mrow(Typesetting:-mi( = Typesetting:-mrow(Typesetting:-msubsup(Typesetting:-mo(  

 

The convolution of the functions 

 

Heaviside(t-1)-Heaviside(t-3) (3.1.1)
 

and 

Heaviside(t-2)-Heaviside(t-5) (3.1.2)
 

 

is difficult to obtain by the definition because of the complex nature of the implied conditionals in both Typesetting:-mrow(Typesetting:-mi(Typesetting:-mrow(Typesetting:-mi(  The integrand of the convolution integral 

 

Typesetting:-mrow(Typesetting:-msubsup(Typesetting:-mo(  

 

is nonzero on the solution set of the inequalities 

 

0 < t-x-1, t-x < 3, 0 < x-2, x < 5 (3.1.3)
 

 

Figure 0.1, created with Maple's built-in inequal command from the plots package, displays this set in red.  (This command will graph only the solution set for linear inequalities.) 

 

 

> inequal({0 < t-x-1, t-x < 3, 0 < x-2, x < 5}, x = 0 .. 6, t = 0 .. 10, optionsfeasible = (color = red), optionsopen = (color = blue, thickness = 2), optionsexcluded = (color = yellow), labels = ([x, t...
inequal({0 < t-x-1, t-x < 3, 0 < x-2, x < 5}, x = 0 .. 6, t = 0 .. 10, optionsfeasible = (color = red), optionsopen = (color = blue, thickness = 2), optionsexcluded = (color = yellow), labels = ([x, t...
inequal({0 < t-x-1, t-x < 3, 0 < x-2, x < 5}, x = 0 .. 6, t = 0 .. 10, optionsfeasible = (color = red), optionsopen = (color = blue, thickness = 2), optionsexcluded = (color = yellow), labels = ([x, t...
 

Plot
 

Figure 0.1   In red, the solution set for {0 < t-x-1, t-x < 3, 0 < x-2, x < 5} 

For each fixed Typesetting:-mrow(Typesetting:-mi(, the integration is over the intersection of the line Typesetting:-mrow(Typesetting:-mi( and the red parallelogram in Figure 0.1.  Thus, we have 

 

Typesetting:-mrow(Typesetting:-mfenced(Typesetting:-mrow(Typesetting:-mi( 

 

a result extremely difficult to fathom without Figure 0.1. 

 

Example 1 

A graph of the solution set of the inequality 

 

x+y <= 1 (3.2.1)
 

 

drawn for the square Typesetting:-mrow(Typesetting:-mo(appears in Figure 1.1. 

 

inequalityplot(x+y <= 1, x = -2 .. 2, y = -2 .. 2, feasiblecolor = yellow, excludedcolor = red, color = blue, thickness = 3, labels = ([x, y]))
inequalityplot(x+y <= 1, x = -2 .. 2, y = -2 .. 2, feasiblecolor = yellow, excludedcolor = red, color = blue, thickness = 3, labels = ([x, y]))
inequalityplot(x+y <= 1, x = -2 .. 2, y = -2 .. 2, feasiblecolor = yellow, excludedcolor = red, color = blue, thickness = 3, labels = ([x, y]))
 

Plot
 

 

Figure 1.1   Solution set of x+y <= 1 graphed in yellow 

 

Example 2 

 

A graph of the solution set of the inequalities 

 

x^2-1 <= y (3.3.1)
 

and 

 

y <= 4-3*x-2*x^2 (3.3.2)
 

appears in Figure 2.1. 

 

Typesetting:-mrow(Typesetting:-mi(
Typesetting:-mrow(Typesetting:-mi(
 

Plot
 

 

Figure 2.1   Solution set of {x^2-1 <= y, y <= 4-3*x-2*x^2} shown in gray 

Example 3 

A graph of the solution set of the inequalities 

 

x^2-1 < y (3.4.1)
 

y < x+1 (3.4.2)
 

and 

y < 2-x (3.4.3)
 

 

appears in Figure 3.1.  Note that more than two inequalities are enclosed in set braces in the inequalityplot command. 

 

> inequalityplot({x^2-y < 1, y < x+1, y < 2-x}, x = -2 .. 2, y = -2 .. 2, feasiblepoints = 100, feasiblecolor = gray, excludedcolor = white, color = black, thickness = 3, linespoints = 3000)
inequalityplot({x^2-y < 1, y < x+1, y < 2-x}, x = -2 .. 2, y = -2 .. 2, feasiblepoints = 100, feasiblecolor = gray, excludedcolor = white, color = black, thickness = 3, linespoints = 3000)
 

Plot
 

Figure 3.1   Solution set of Typesetting:-mrow(Typesetting:-mfenced(Typesetting:-mrow(Typesetting:-mi(s

Example 4 

Figure 4.1 compares the solution sets of  

 

Typesetting:-mrow(Typesetting:-mn( 

and  

Typesetting:-mrow(Typesetting:-mn( 

 

the first on the left, the second on the right. 

 

 

> Typesetting:-mrow(Typesetting:-mi(
Typesetting:-mrow(Typesetting:-mi(
 

Plot
 

> Typesetting:-mrow(Typesetting:-mi(
Typesetting:-mrow(Typesetting:-mi(
Typesetting:-mrow(Typesetting:-mi(
 

Plot
 

 

Figure 4.1   In gray, the solution set of Typesetting:-mrow(Typesetting:-mn(in (a) and the solution set of Typesetting:-mrow(Typesetting:-mn(in (b) 

Example 5 

The set of points that satisfy either 

 

(x+1)^2+3*(y-2)^2 <= 1 (3.6.1)
 

Typesetting:-mrow(Typesetting:-mo( 

(x-2)^2+(y+1)^2 <= 1/4 (3.6.2)
 

 

is graphed in Figure 5.1. 

 

> inequalityplot((x+1)^2+3*(y-2)^2 <= 1 or (x-2)^2+(y+1)^2 <= 1/4, x = -3 .. 3, y = -2 .. 3, excludedcolor = white, color = black, thickness = 1, feasiblepoints = 25, linespoints = 1000)
inequalityplot((x+1)^2+3*(y-2)^2 <= 1 or (x-2)^2+(y+1)^2 <= 1/4, x = -3 .. 3, y = -2 .. 3, excludedcolor = white, color = black, thickness = 1, feasiblepoints = 25, linespoints = 1000)
 

Plot
 

Figure 5.1   Gray points satisfy either Typesetting:-mrow(Typesetting:-msup(Typesetting:-mfenced(Typesetting:-mrow(Typesetting:-mi( 

Example 6 

Drawn with the inequaltyplot command, Figure 6.1 shows the solution set of the inequality Typesetting:-mrow(Typesetting:-mi( where Typesetting:-mrow(Typesetting:-mi( is given by 

 

4-((((x^2+y^2)^(1/2)-4)^2+y^2)^(1/2)-4)^2 (3.7.1)
 

 

> inequalityplot(0 < 4-((((x^2+y^2)^(1/2)-4)^2+y^2)^(1/2)-4)^2, x = -10 .. 10, y = -6 .. 6, feasiblecolor = gray, excludedcolor = white, color = black, thickness = 3, linespoints = 3000)
inequalityplot(0 < 4-((((x^2+y^2)^(1/2)-4)^2+y^2)^(1/2)-4)^2, x = -10 .. 10, y = -6 .. 6, feasiblecolor = gray, excludedcolor = white, color = black, thickness = 3, linespoints = 3000)
 

Plot
 

Figure 6.1   Solution set for Typesetting:-mrow(Typesetting:-mn( drawn in gray 

>
 

Figure 6.2, drawn with the plot3d command, shows the surface Typesetting:-mrow(Typesetting:-mi( for Typesetting:-mrow(Typesetting:-mn(  As such, it represents that part of the surface we can identify as being above the plane Typesetting:-mrow(Typesetting:-mi(.  Rotating the graph so that it is viewed from a point sufficiently high on the Typesetting:-mrow(Typesetting:-mi(-axis gives a sketch of the feasible region similar to Figure 6.1. 

 

> plot3d(4-((((x^2+y^2)^(1/2)-4)^2+y^2)^(1/2)-4)^2, x = -10 .. 10, y = -6 .. 6, axes = box, view = 0 .. 5, scaling = constrained, title =
plot3d(4-((((x^2+y^2)^(1/2)-4)^2+y^2)^(1/2)-4)^2, x = -10 .. 10, y = -6 .. 6, axes = box, view = 0 .. 5, scaling = constrained, title =
 

Plot
 

> plot3d(4-((((x^2+y^2)^(1/2)-4)^2+y^2)^(1/2)-4)^2, x = -10 .. 10, y = -6 .. 6, axes = box, view = 0 .. 5, scaling = constrained, orientation = ([-90, 0]), style = patchnogrid, color = gray, title =
plot3d(4-((((x^2+y^2)^(1/2)-4)^2+y^2)^(1/2)-4)^2, x = -10 .. 10, y = -6 .. 6, axes = box, view = 0 .. 5, scaling = constrained, orientation = ([-90, 0]), style = patchnogrid, color = gray, title =
 

Plot
 

 

Figure 6.2   Graph of Typesetting:-mrow(Typesetting:-mi( in (a); same graph rotated and viewed from above in (b) 

>
 

Figure 6.3, drawn with Maple's contourplot command, shows the graph of the curve determined by the equation Typesetting:-mrow(Typesetting:-mi(.  This is the boundary inside or outside of which Typesetting:-mrow(Typesetting:-mi( will be satisfied. 

 

> implicitplot(4-((((x^2+y^2)^(1/2)-4)^2+y^2)^(1/2)-4)^2, x = -10 .. 10, y = -6 .. 6, color = black, scaling = constrained)
 

Plot
 

Figure 6.3   Curve determined by solution of the equation Typesetting:-mrow(Typesetting:-mi( 

>
 

The filled option in Maple's contourplot command shades in a specified color range according to the lowest and highest values along contours.  Figure 6.4 is a contour plot of Typesetting:-mrow(Typesetting:-mi( in which the color range is from white to gray, with white being assigned to any contours on which the values of Typesetting:-mrow(Typesetting:-mi( are lower than the one specified for the single contour to be drawn.  This specified contour value is zero, so any contour corresponding to a higher value will be shaded gray. 

 

> contourplot(4-((((x^2+y^2)^(1/2)-4)^2+y^2)^(1/2)-4)^2, x = -10 .. 10, y = -6 .. 6, contours = [0], thickness = 2, filled = true, coloring = ([white, gray]), scaling = constrained)
contourplot(4-((((x^2+y^2)^(1/2)-4)^2+y^2)^(1/2)-4)^2, x = -10 .. 10, y = -6 .. 6, contours = [0], thickness = 2, filled = true, coloring = ([white, gray]), scaling = constrained)
 

Plot
 

Figure 6.4    

Shaded contour plot of Typesetting:-mrow(Typesetting:-mi(  Black curve is the single contour Typesetting:-mrow(Typesetting:-mi(  Gray designates where Typesetting:-mrow(Typesetting:-mi( 

Example 7 

To shade the region between graphs of the curves Typesetting:-mrow(Typesetting:-msub(Typesetting:-mi( and Typesetting:-mrow(Typesetting:-msub(Typesetting:-mi(use the inequalityplot command as shown in Figure 7.1.  Note that an endpoint cannot be a symbol such as Typesetting:-mrow(Typesetting:-mi( or Typesetting:-mrow(Typesetting:-msqrt(Typesetting:-mrow(Typesetting:-mn(. 

 

> inequalityplot({y < sin(x), cos(x) < y}, x = 0 .. 6.28, y = -1 .. 1, excludedcolor = white, color = black, linespoints = 2000, thickness = 3)
inequalityplot({y < sin(x), cos(x) < y}, x = 0 .. 6.28, y = -1 .. 1, excludedcolor = white, color = black, linespoints = 2000, thickness = 3)
 

Plot
 

Figure 7.1   Region between Typesetting:-mrow(Typesetting:-mi( and Typesetting:-mrow(Typesetting:-mi( shaded gray 

Example 8 

Nonlinear inequalities actually arise in freshman calculus when students first meet a rigorous (Typesetting:-mrow(Typesetting:-mi() definition of the limit: 

Formal Definition of Limit 

The real number Typesetting:-mrow(Typesetting:-mi( is said to be the limit of Typesetting:-mrow(Typesetting:-mi( at Typesetting:-mrow(Typesetting:-mi( if, for any Typesetting:-mrow(Typesetting:-mi(

 

At the heart of this definition is the inequality 

 

Typesetting:-mrow(Typesetting:-mfenced(Typesetting:-mrow(Typesetting:-mi(  

 

that we would like to solve for Typesetting:-mrow(Typesetting:-mi(.  For example, to show that Typesetting:-mrow(Typesetting:-munder(Typesetting:-mo(solve the inequality  

 

abs((1+delta)^3-1) < epsilon (3.9.1)
 

 

for Typesetting:-mrow(Typesetting:-mi(The solution set is shown in Figure 8.1 where Typesetting:-mrow(Typesetting:-mi( is allowed to be both positive and negative. 

 

> inequalityplot(abs((1+delta)^3-1) < epsilon, delta = -2 .. 1, epsilon = 0 .. 2, feasiblepoints = 40, excludedcolor = white, labels = ([delta, epsilon]))
inequalityplot(abs((1+delta)^3-1) < epsilon, delta = -2 .. 1, epsilon = 0 .. 2, feasiblepoints = 40, excludedcolor = white, labels = ([delta, epsilon]))
 

Plot
 

Figure 8.1   Solution set for the inequality abs((1+delta)^3-1) < epsilon shaded in gray 

 

Although Maple cannot solve the inequality abs((1+delta)^3-1) < epsilon for Typesetting:-mrow(Typesetting:-mi(it can solve the equation Typesetting:-mrow(Typesetting:-mfenced(Typesetting:-mrow(Typesetting:-msup(Typesetting:-mfenced(Typesetting:-mrow(Typesetting:-mn( under the assumption that Typesetting:-mrow(Typesetting:-mi( The solutions, namely 

> `assuming`([solve(abs((1+delta)^3-1) = epsilon, delta)], [0 < epsilon])
 

(1-epsilon)^(1/3)-1, -1/2*(1-epsilon)^(1/3)-1/2*I*3^(1/2)*(1-epsilon)^(1/3)-1, -1/2*(1-epsilon)^(1/3)+1/2*I*3^(1/2)*(1-epsilon)^(1/3)-1, (epsilon+1)^(1/3)-1, -1/2*(epsilon+1)^(1/3)+1/2*I*3^(1/2)*(epsi...
(1-epsilon)^(1/3)-1, -1/2*(1-epsilon)^(1/3)-1/2*I*3^(1/2)*(1-epsilon)^(1/3)-1, -1/2*(1-epsilon)^(1/3)+1/2*I*3^(1/2)*(1-epsilon)^(1/3)-1, (epsilon+1)^(1/3)-1, -1/2*(epsilon+1)^(1/3)+1/2*I*3^(1/2)*(epsi...
(3.9.2)
 

>
 

are graphed in Figure 8.2 where the colors indicate which solutions assume real values.  Compare Figure 8.2 to Figure 8.1. 

 

> plot([(1-epsilon)^(1/3)-1, -1/2*(1-epsilon)^(1/3)-1/2*I*3^(1/2)*(1-epsilon)^(1/3)-1, -1/2*(1-epsilon)^(1/3)+1/2*I*3^(1/2)*(1-epsilon)^(1/3)-1, (epsilon+1)^(1/3)-1, -1/2*(epsilon+1)^(1/3)+1/2*I*3^(1/2)...
 

Plot
 

Figure 8.2   Graph of the analytic solution Typesetting:-mrow(Typesetting:-mi( for Typesetting:-mrow(Typesetting:-mfenced(Typesetting:-mrow(Typesetting:-msup(Typesetting:-mfenced(Typesetting:-mrow(Typesetting:-mn( 

 

As with Example 6, the outline of the feasible region can be obtained with Maple's implicitplot command; the feasible region, with contourplot, as shown in Figure 8.3. 

> implicitplot(abs((1+delta)^3-1) = epsilon, delta = -2 .. 1, epsilon = 0 .. 2, color = black, title =
 

Plot
 

> contourplot(abs((1+delta)^3-1)-epsilon, delta = -2 .. 1, epsilon = 0 .. 2, contours = [0], filled = true, coloring = ([gray, white]), grid = ([90, 90]), title =
contourplot(abs((1+delta)^3-1)-epsilon, delta = -2 .. 1, epsilon = 0 .. 2, contours = [0], filled = true, coloring = ([gray, white]), grid = ([90, 90]), title =
 

Plot
 

 

Figure 8.3   In (a), outline of feasible region via implicitplot; in (b), feasible region via contourplot 

 

Surprisingly, the feasible region in Figure 8.1 is not symmetric.  Figure 8.4 shows the feasible region for much smaller values of Typesetting:-mrow(Typesetting:-mi(and suggests the region might be more symmetric closer to Typesetting:-mrow(Typesetting:-mi(.  In fact, it suggests that Typesetting:-mrow(Typesetting:-mi( might be well approximated by a linear function. 

 

> inequalityplot(abs((1+delta)^3-1) < epsilon, delta = -0.4e-1 .. 0.4e-1, epsilon = 0 .. .1, excludedcolor = white, labels = ([delta, epsilon]))
 

Plot
 

Figure 8.4   Solution set for the inequality abs((1+delta)^3-1) < epsilon for "small" values of Typesetting:-mrow(Typesetting:-mi( 

 

One way to find an approximation for Typesetting:-mrow(Typesetting:-mi( when Typesetting:-mrow(Typesetting:-mi( is small is to solve Typesetting:-mrow(Typesetting:-mi( for a series solution about Typesetting:-mrow(Typesetting:-mi(.  This can be done in Maple via 

 

> remove(has, [solve(series((1+delta)^3-1, delta) = epsilon, delta)], I)[1]
 

(epsilon+1)^(1/3)-1 (3.9.3)
 

and 

> remove(has, [solve(series((1+delta)^3-1, delta) = -epsilon, delta)], I)[1]
 

(1-epsilon)^(1/3)-1 (3.9.4)
 

 

where we removed the absolute value function and created two equivalent equations.  In this case we obtained exact solutions and not the series expansions 

 

> series((epsilon+1)^(1/3)-1, epsilon = 0, 2)
 

series(1/3*epsilon+O(epsilon^2),epsilon,2) (3.9.5)
 

and 

> series((1-epsilon)^(1/3)-1, epsilon = 0, 2)
 

series(-1/3*epsilon+O(epsilon^2),epsilon,2) (3.9.6)
 

This suggests Typesetting:-mrow(Typesetting:-mfenced(Typesetting:-mrow(Typesetting:-mi(a hypothesis tested in Figure 8.5 where the lines Typesetting:-mrow(Typesetting:-mo( are drawn in green, Typesetting:-mrow(Typesetting:-msup(Typesetting:-mfenced(Typesetting:-mrow(Typesetting:-mn( is drawn in black, and Typesetting:-mrow(Typesetting:-msup(Typesetting:-mfenced(Typesetting:-mrow(Typesetting:-mn( is drawn in red. 

 

> plot([(1+1/6*e)^3-1, (1-1/6*e)^3-1, e, -e], e = 0 .. 1/10, color = ([black, red, green, green]))
 

Plot
 

Figure 8.5   The lines Typesetting:-mrow(Typesetting:-mo( in green, Typesetting:-mrow(Typesetting:-msup(Typesetting:-mfenced(Typesetting:-mrow(Typesetting:-mn( in black, and Typesetting:-mrow(Typesetting:-msup(Typesetting:-mfenced(Typesetting:-mrow(Typesetting:-mn( in red 

 

Alternatively, we let Maple deduce 

 

> `assuming`([is((1+1/6*epsilon)^3-1 < epsilon)], [epsilon::(RealRange(Open(0), 1))])
 

true (3.9.7)
 

and 

> `assuming`([is(-epsilon < (1-1/6*epsilon)^3-1)], [epsilon::(RealRange(Open(0), 1))])
 

true (3.9.8)
 

 

The function 

> Typesetting:-mrow(Typesetting:-mi(
Typesetting:-mrow(Typesetting:-mi(
 

f(x) = piecewise(x < 1, x, 3-x) (3.9.9)
 

>
 

is continuous from the right at Typesetting:-mrow(Typesetting:-mi( so that  

limit(f(x), x = 1, right) = 2.  The governing inequality is Typesetting:-mrow(Typesetting:-mfenced(Typesetting:-mrow(Typesetting:-mi(a graphical solution of which is seen in Figure 8.6. 

 

> inequalityplot(abs(f(1+delta)-2) < epsilon, delta = -1 .. 1, epsilon = 0 .. 2, excludedcolor = white, feasiblepoints = 60, labels = ([delta, epsilon]))
inequalityplot(abs(f(1+delta)-2) < epsilon, delta = -1 .. 1, epsilon = 0 .. 2, excludedcolor = white, feasiblepoints = 60, labels = ([delta, epsilon]))
 

Plot
 

Figure 8.6   Shaded gray, the feasible region for the inequality Typesetting:-mrow(Typesetting:-mfenced(Typesetting:-mrow(Typesetting:-mi( 

For Typesetting:-mrow(Typesetting:-mn(the inequality is satisfied for any positive Typesetting:-mrow(Typesetting:-mi(as Figure 8.6 suggests, and the following calculation shows. 

 

> `assuming`([solve(abs(f(1+delta)-2) < epsilon, delta)], [epsilon::(RealRange(Open(0), 1)), 0 < delta])
 

{delta < epsilon} (3.9.10)
 

Example 9 

Drawn with the complexinequalityplot command, the solution set for the inequality 

 

abs(`+`(z^3+3*z^2, -1-`*`(2, I)))^2 <= abs(z+I)^2 

 

where Typesetting:-mrow(Typesetting:-mi(, appears as the shaded region in Figure 9.1. 

 

> complexinequalityplot(abs(`+`(z^3+3*z^2, -1-`*`(2, I)))^2 <= abs(z+I)^2, z = (-1.2 .. 1, -1 .. 1), linespoints = 600, feasiblepoints = 25, excludedcolor = white, labels = ([x, y]))
complexinequalityplot(abs(`+`(z^3+3*z^2, -1-`*`(2, I)))^2 <= abs(z+I)^2, z = (-1.2 .. 1, -1 .. 1), linespoints = 600, feasiblepoints = 25, excludedcolor = white, labels = ([x, y]))
 

Plot
 

Figure 9.1   Solution set for Typesetting:-mrow(Typesetting:-mo( shaded in gray 

 

The substitution 

 

eval(abs(`+`(z^3+3*z^2, -1-`*`(2, I)))^2 <= abs(z+I)^2, z = x+I*y) 

abs((x+I*y)^3+3*(x+I*y)^2+(-1-2*I))^2 <= abs(x+I*y+I)^2 (3.10.1)
 

leads to 

 

evalc(abs((x+I*y)^3+3*(x+I*y)^2+(-1-2*I))^2 <= abs(x+I*y+I)^2) 

6*y^2+6*x*y^2-2*x^3-6*x^2+9*x^4+9*y^4+6*x*y^4+18*x^2*y^2+3*x^4*y^2+12*x^3*y^2+3*x^2*y^4+x^6+6*x^5-12*x^2*y+4*y^3-24*x*y+y^6 <= x^2+y^2+2*y-4
6*y^2+6*x*y^2-2*x^3-6*x^2+9*x^4+9*y^4+6*x*y^4+18*x^2*y^2+3*x^4*y^2+12*x^3*y^2+3*x^2*y^4+x^6+6*x^5-12*x^2*y+4*y^3-24*x*y+y^6 <= x^2+y^2+2*y-4
(3.10.2)
 

 

and hence, Figure 9.2 drawn with the inequalityplot command. 

 

> inequalityplot(6*y^2+6*x*y^2-2*x^3-6*x^2+9*x^4+9*y^4+6*x*y^4+18*x^2*y^2+3*x^4*y^2+12*x^3*y^2+3*x^2*y^4+x^6+6*x^5-12*x^2*y+4*y^3-24*x*y+y^6 <= x^2+y^2+2*y-4, x = -1.2 .. 1, y = -1 .. 1, linespoints = 6...
inequalityplot(6*y^2+6*x*y^2-2*x^3-6*x^2+9*x^4+9*y^4+6*x*y^4+18*x^2*y^2+3*x^4*y^2+12*x^3*y^2+3*x^2*y^4+x^6+6*x^5-12*x^2*y+4*y^3-24*x*y+y^6 <= x^2+y^2+2*y-4, x = -1.2 .. 1, y = -1 .. 1, linespoints = 6...
 

Plot
 

Figure 9.2   Solution set for 6*y^2+6*x*y^2-2*x^3-6*x^2+9*x^4+9*y^4+6*x*y^4+18*x^2*y^2+3*x^4*y^2+12*x^3*y^2+3*x^2*y^4+x^6+6*x^5-12*x^2*y+4*y^3-24*x*y+y^6 <= x^2+y^2+2*y-4
6*y^2+6*x*y^2-2*x^3-6*x^2+9*x^4+9*y^4+6*x*y^4+18*x^2*y^2+3*x^4*y^2+12*x^3*y^2+3*x^2*y^4+x^6+6*x^5-12*x^2*y+4*y^3-24*x*y+y^6 <= x^2+y^2+2*y-4 shaded in gray
 

 

The advantages of the complexinequalityplot command over the inequalityplot command for inequalities in the complex variable Typesetting:-mrow(Typesetting:-mi( are obvious, and need no comment. 

Example 10 

Like the inequalityplot command, the complexinequalityplot command will graph the feasible region for a set of nonlinear complex inequalities.  For example, Figure 10.1 shows the set of points simultaneously satisfying the inequalities 

 

1 < abs(z^2-z+1) (3.11.1)
 

and 

abs(z^2-z+1) < 4 (3.11.2)
 

 

> complexinequalityplot(1 < abs(z^2-z+1) and abs(z^2-z+1) < 4, z = (-2 .. 3, -3 .. 3), feasiblepoints = 25, excludedcolor = white)
complexinequalityplot(1 < abs(z^2-z+1) and abs(z^2-z+1) < 4, z = (-2 .. 3, -3 .. 3), feasiblepoints = 25, excludedcolor = white)
 

Plot
 

Figure 10.1   Solution set of Typesetting:-mrow(Typesetting:-mfenced(Typesetting:-mrow(Typesetting:-mi( shaded in gray 

 

Legal Notice: The copyright for this application is owned by Maplesoft. The application is intended to demonstrate the use of Maple to solve a particular problem. It has been made available for product evaluation purposes only and may not be used in any other context without the express permission of Maplesoft.  
 

Image