graphPaper.mws

MathClass Lesson 2:

Function Plots

In this lesson, you will learn how to create function plots with a graph-paper background, and how to add high-quality legends, titles and labels to graphs. We also show how to indicate open and closed points of discontinuity on graphs of piecewise functions.

This lesson will use several functions from the MathClass package, which we load now.

> restart;

If you have not already downloaded the MathClass package code, you may do so from the MathClass website. Once the code is in a directory of your choosing, adapt the line below to reflect its location.

> libname := "C:/mylib/MathClass", libname;

libname :=

Introduction

The Maple command plot(x^2, x=-1..1); results in the following display.

> plot(x^2, x=-1..1);

[Maple Plot]

Maple constructed this figure by actually calculating 50 "exact" points on the graph and connecting consecutive points by straight lines. We can see the points by modifying the command to

> plot(x^2, x=-1..1, style=point);

[Maple Plot]

Notice that Maple is clever in the sense that the points are not equally spaced. There are more of them when the curve has a higher degree of curvature.

The picture we see on the screen is not the way Maple "thinks" of the plot - it can't interpret geometric objects. Maple stores the plot internally as a plot structure which we can view by giving it a name. For instance if we enter

> joe:=plot(x^2,x=-1..1);

joe := INTERFACE_PLOT(CURVES([[-1., 1.], [-.9564056...
joe := INTERFACE_PLOT(CURVES([[-1., 1.], [-.9564056...
joe := INTERFACE_PLOT(CURVES([[-1., 1.], [-.9564056...
joe := INTERFACE_PLOT(CURVES([[-1., 1.], [-.9564056...
joe := INTERFACE_PLOT(CURVES([[-1., 1.], [-.9564056...
joe := INTERFACE_PLOT(CURVES([[-1., 1.], [-.9564056...
joe := INTERFACE_PLOT(CURVES([[-1., 1.], [-.9564056...
joe := INTERFACE_PLOT(CURVES([[-1., 1.], [-.9564056...
joe := INTERFACE_PLOT(CURVES([[-1., 1.], [-.9564056...
joe := INTERFACE_PLOT(CURVES([[-1., 1.], [-.9564056...
joe := INTERFACE_PLOT(CURVES([[-1., 1.], [-.9564056...
joe := INTERFACE_PLOT(CURVES([[-1., 1.], [-.9564056...
joe := INTERFACE_PLOT(CURVES([[-1., 1.], [-.9564056...
joe := INTERFACE_PLOT(CURVES([[-1., 1.], [-.9564056...
joe := INTERFACE_PLOT(CURVES([[-1., 1.], [-.9564056...
joe := INTERFACE_PLOT(CURVES([[-1., 1.], [-.9564056...
joe := INTERFACE_PLOT(CURVES([[-1., 1.], [-.9564056...
joe := INTERFACE_PLOT(CURVES([[-1., 1.], [-.9564056...
joe := INTERFACE_PLOT(CURVES([[-1., 1.], [-.9564056...
joe := INTERFACE_PLOT(CURVES([[-1., 1.], [-.9564056...
joe := INTERFACE_PLOT(CURVES([[-1., 1.], [-.9564056...
joe := INTERFACE_PLOT(CURVES([[-1., 1.], [-.9564056...

we get a look at how the software stores the information with which it generates the graph. For the moment it suffices to note that most of "joe" consists of a listing of 50 sets of coordinates for points in the plane. If we were to go to the trouble to plot those points we would get exactly the "point plot" above.

Whenever we give Maple a word or sequence of words which it can interpret, it returns a representation of the result of that interpretation in a "human readable" format - unless instructed to do otherwise. At this point Maple would recognize "joe" as a particular plot structure so if we entered the command

> joe;

[Maple Plot]

Maple provide the "people readable" interpretation we expect. Of course Maple can "know" other plot structures. For instance we may enter

> sam:=plot(x^3,x=-1..1):

We know that "sam" will look pretty much like "joe" so we use the colon ":" to suppress the display. Now the plots[display] command is used to merge two or more plot structures into a single one. Note the component "[joe, sam]" in the following makes the expression sequence "joe,sam" into a list. The commands below would actually "work" without the list conversion. However the conversion is good practice as it will allow us to specify the order in which the components are assembled. Here sam goes down first, then joe. This will be important later when portions of one component cover portions of others.

> frank:=plots[display]([joe,sam]):

> frank;

[Maple Plot]

This is what permits us to systematically construct diagrams a piece at a time, adding components as we need them. All we need is a few tools for constructing the bits and pieces and, at least to start, a few procedures for organizing our work.

Diagrams including graphs of functions

Functions are of course the most fundamental object of study in calculus so many calculus problems invlove the graphs of functions. The basic Maple tool for creating graphs is the plot command. Once we realize that Maple plots are simply plot structures it is obvious how to add text, arrows, etc. to functions to create informative illustrations.

Example: On the same diagram plot f(x) = x^3-x and its derivative on the interval [-2,2]. Label each of the graphs.

First we graph the two functions. Although we could make them individually and merge them with plots[display], Maple already graphs sets or lists of functions.

> F:=x^3-x:

> dF:=diff(F,x):

> plt1:=plot([F,dF],x=-2..2): plt1;

[Maple Plot]

The linestyle and thickness options are exactly as before. In addition we can control the colors of the graphs the color option and can control the size of the numbers on the axes with the axesfont option. For instance to make F blue, dF red, and the axes numbers 16 point, bold we can

> F:=x^3-x:

> dF:=diff(F,x):

> plt2:=plot([F,dF],x=-2..2,color=[blue,red], thickness=3,linestyle=[3,1], axesfont=[TIMES,BOLD,16]):
plt2;

[Maple Plot]

The x-axis is labeled with a faint "x" in the diagram. We can control the axes labels with the labels and labelfont options

> F:=x^3-x:

> dF:=diff(F,x):

> plt3:=plot([F,dF],x=-2..2,color=[blue,red], thickness=3,linestyle=[3,1], axesfont=[TIMES,BOLD,16],labels=[`x-axis`,`y-axis`],labelfont=[TIMES,BOLD,18]):
plt3;

[Maple Plot]

It is very common for us to want only a few special numbers to be labeled on the axes. This is controlled by the xtickmarks and ytickmarks options

> F:=x^3-x:

> dF:=diff(F,x):

> plt5:=plot([F,dF],x=-2..2,color=[blue,red], thickness=3,linestyle=[3,1], axesfont=[TIMES,BOLD,16],labels=["x-axis","y-axis"],labelfont=[TIMES,BOLD,18],xtickmarks=[-1,1],ytickmarks=[1,3]):
plt5;

[Maple Plot]

Sometimes it is convenient to indicate by color and linestyle which graph is which. This is done with the legend option

> F:=x^3-x:

> dF:=diff(F,x):

> plt6:=plot([F,dF],x=-2..2,color=[blue,red], thickness=3,linestyle=[3,1], axesfont=[TIMES,BOLD,16],labels=["x-axis","y-axis"],labelfont=[TIMES,BOLD,18],xtickmarks=[-1,1],ytickmarks=[1,3],legend=["the function f(x)","the derivative of f(x)"]):
plt6;

[Maple Plot]

We can use the title and title font options on plots, too.

See the help page for plot,options for more details on these and numerous other options

> F:=x^3-x:

> dF:=diff(F,x):

> plt7:=plot([F,dF],x=-2..2,color=[blue,red], thickness=3,linestyle=[3,1], axesfont=[TIMES,BOLD,16],labels=["x-axis","y-axis"],labelfont=[TIMES,BOLD,18],xtickmarks=[-1,1],ytickmarks=[1,3],legend=["the function f(x)","the derivative of f(x)"],title="Graphs of F and F'", titlefont=[COURIER,BOLD,18]):
plt7;

[Maple Plot]

Viewing a portion of a plot

The view plot option permits us to "focus" on a rectangular portion of a graph. Its syntax is view = [a..b, c..d] which restricts the displayed portion of the graph to that within the rectangle a <= x ` ` <= b , c <= x ` ` <= d For instance suppose we want to view only the portion of the previous plot in the window -1 <= x ` ` <= 0 , -2 <= x ` ` <= 3 . all we have to do is add a view option

> F:=x^3-x:

> dF:=diff(F,x):

> plt7:=plot([F,dF],x=-2..2,color=[blue,red], thickness=3,linestyle=[3,1], axesfont=[TIMES,BOLD,16],labels=["x-axis","y-axis"],labelfont=[TIMES,BOLD,18],xtickmarks=[-1,1],ytickmarks=[1,3],legend=["the function f(x)","the derivative of f(x)"],title="Graphs of F and F'", titlefont=[COURIER,BOLD,18],view=[-1..0,-2..3]):
plt7;

[Maple Plot]

Placing a Graph on Graph Paper

One frequently finds it convenient to place a graph on "graphpaper" rather than simply have it located relative to coordinate axes with tickmarks. The command GP (for "graph paper" ) is useful for doing this. Its syntax is:

MathClass[GP](llcorner,width, length, resolution, font_ where

llcorner = the point [a,b] which is the lower left corner of the graphpaper

width = the width of the graphpaper

length = the length of the graphpaper

resolution = number of grid squares covering the inter [0,1] (1,2,3,4) are the most common values.

font = font in which tickmarks are printed

Notes:

A fontsize of 1 gives no tickmarks. This is used very frequently

GP is primitive - it puts tickmarks only at integer values

> GPAP:=MathClass[GP]([-2,-2],4,4,2,10,orange):
GPAP;

Suppose we want to look at the function f(x) = x^2+x plotted on the graphpaper we just produced. We might begin simply by merging the graph of f(x) on the interval [-2,2] with the graphpaper using plots[display].

[Maple Plot]

> F:=x^2+x:

> plt:=plot(F,x=-2..2,color=[blue,red], thickness=3,linestyle=[3,1], title="Graph of F(x)", titlefont=[TIMES,BOLD,20]):

> plt2 := plots[display]([GPAP,plt]):
plt2;

[Maple Plot]

This happens quite often, the graph extends off the graphpaper. We can avoid this (if desired) by setting the view be the portion of the merged plots to be that corresponding to the dimensions of the graphpaper

> F:=x^2+x:

> plt:=plot(F,x=-2..2,color=[blue,red], thickness=3,linestyle=[3,1], title="Graph of F(x)", titlefont=[TIMES,BOLD,20]):

> plt3:=plots[display]([GPAP,plt2],view=[-2..2,-2..2]):

> plt3;

[Maple Plot]

Piecewise defined functions

One of the most important constructions in the study of functions is the piecewise defined function. The first one most people run into is the absolute value. Maple expresses piecewise defined functions a little differently from the way it is presented in most texts. For instance the absolute value is described as:

abs(x) = PIECEWISE([-x, x <= 0],[x, 0 <= x])

The conventional description might be written as

abs(x) = PIECEWISE([-x, `if       x` <= 0],[x, othe...

In Maple only the inequalities and corresponding values are given, in order. The convention is that the value of the function is that given by the first (from top to bottom) one of the conditions that is satisfied. Thus if we set

`f(x)` = PIECEWISE([2, x <= -1],[3, x < 0],[-1, x <...

code

> F:=x-> piecewise(x<=-1,2,x<0,3,x< 7,-1);
`f(x)` =F(x);

F := proc (x) options operator, arrow; piecewise(x ...

`f(x)` = PIECEWISE([2, x <= -1],[3, x < 0],[-1, x <...

Without the convention the value of f(-5) would not be properly defined since -5 satisfies all of the conditions. However the convention uniquely determines f(-5) to be 2 since -5 satisfties the first inequality. Similary f( -1/2 ) = 3 since the second inequality is the first satisfied by -1/2 . Note that f(7) is not defined since 7 satisfies none of the inequalities.

The form of a general piecewise function h is:

`h(x)` = PIECEWISE([p[1](x), x <= a],[p[2](x), x <=...



Where
p[1], `...`, p[n], p are functions. Note that any of the " ` ` <= ` ` " symbols could be " ` ` < ` ` " ,

To describe a piecewise defined function to Maple we use the "piecewise" command. The function f(x) described above is defined by:

f :=x -> piecewise(x<=-1,2,x<0,3,x< 7,-1);

general

> h:=x->piecewise(x<=a, p[1](x), x<=b, p[2](x) ,x<=`. . .`, `...`,x<=z, p[n](x),p(x));

h := proc (x) options operator, arrow; piecewise(x ...

If a pair of values is given at the left of the expression, e.g.

f :=x -> piecewise(x<=-1,2,x<0,3,x< 7,-1,sin(x));

`f(x)` = PIECEWISE([2, x <= -1],[3, x < 0],[-1, x <...

the leftmost value is the default - that is it gives the value of f(x) for any value of x not described by the preceeding inequalities.

code

> f :=x -> piecewise(x<=-1,2,x<0,3,x< 7,-1,sin(x));

> `f(x)`=f(x);

f := proc (x) options operator, arrow; piecewise(x ...

`f(x)` = PIECEWISE([2, x <= -1],[3, x < 0],[-1, x <...

This means that there is more than one way to describe many piecewise functions.

The absolute value function is can be described by:

f:=x-> piecewise( x<=0, -x, x<infinity, x)

`f(x)` = PIECEWISE([-x, x <= 0],[x, x < infinity])

or

f:=x-> piecewise( x<=0, -x,x);

`f(x)` = PIECEWISE([-x, x <= 0],[x, otherwise])

code

> f:=x-> piecewise( x<=0, -x,x<infinity, x);

> `f(x)`=f(x);

> f:=x-> piecewise( x<=0, -x,x);`f(x)`=f(x);

>

f := proc (x) options operator, arrow; piecewise(x ...

`f(x)` = PIECEWISE([-x, x <= 0],[x, x < infinity])

f := proc (x) options operator, arrow; piecewise(x ...

`f(x)` = PIECEWISE([-x, x <= 0],[x, otherwise])

Piecewise functions are plotted using the plot command in exactly the same fashion as those described by expressions.

f:=x->piecewise(x<=0,-x,x):
absplot:=plot(f(x),x=-2..2, thickness=3, linestyle=2,color=blue, scaline=constrained):
absplot;

[Maple Plot]

code

> f:=piecewise(x<=0,-x,x):
absplot:=plot(f(x),x=-2..2, thickness=4, linestyle=1,color=blue, scaling=constrained):
absplot;

[Maple Plot]

Discontinuous Functions:

Piecewise descriptions are the most convenient way to define discontinuous functions. For instance to describe the function which takes on the value -1 for x <=0 and 1 for x >0 we can write:

f=:=x->piecewise(x<=-1,1):
plt:=plot(f(x),x=-1..1):
plt;

However when we plot f(x) we get someting unexpected:

[Maple Plot]

There is nothing wrong with the definition of f(x). The problem is with Maple's plot routine which assumes that all functions are continuous and does its best to plot them as such. The remedy for this is to tell Maple that the function in question may be discontinuous with the "discont" option to to the plot command.

f=:=x->piecewise(x<=-1,1):
plt:=plot(f(x),x=-1..1, discont=true):
plt;

[Maple Plot]

discont code

> f:=x->piecewise(x<=0,-1,1):

> plt:=plot(f(x),x=-1..1,thickness=3,discont=true): plt;

[Maple Plot]

Example:

Piecewise linear functions have graphs which are comprised of a collection of segments of straight lines. They are by far the most common and most important piecewise defined functions. When such a function is given analytically as a piecewise-defined function the individual component functions are always linear (i.e. of the form p[n](x) = a[n]*x+b[n] ). Give an analytic description of the function whose graph is sketched below.

[Maple Plot]

The graph consists of three line segments. The leftmost passes through the points (-3,-3) and (-1,1) and is thus part of the line having equation y = 2*x+3 . The second passes through the points (-1,2) and (1,4) so it is part of the line having equation y = x+3. The third is obviously part of the line having equation y = 2.

One piecewise description of this graph is

f:=x->piecewise(x<=-1,2*x+3,x<=1,x+3,x<=3,2);

We say that this is "one" possibility because from the figure we can't really tell what happens at the end points. That is

f:=x->piecewise(x< -1,2*x+3,x< 1,x+3,x<=3,2);

is equally valid.

diagram

> f:=x->piecewise(x<=-1,2*x+3,x<=1,x+3,x<=3,2);

> gp:=MathClass[GP]([-3,-3],6,7,1,14,green):

> plt:=plot(f(x),x=-3..3,discont=true,thickness=5,axesfont=[TIMES,BOLD,12]):
plots[display]([plt,gp],scaling=constrained);

f := proc (x) options operator, arrow; piecewise(x ...

[Maple Plot]

>

End point Behavior

The reader remembering or teaching calculus will want to be able to describe the end point behavior in functions like the above. Traditionally, a solid disk at an end point on a graph indicates that the end point is indeed part of the graph while an open circle indicates that the end point is absent. We can easily reproduce this in our diagrams for plots that are constrained. That is when the scales on the x-axis and y-axis are identical. Then we can use PP and MathClass[PC] ("put point" and "put circle") tools.

PP has the syntax: PP(center, radius, color) while MathClass[PC] has the syntax: MathClass[PC](center, radius, thickness, linestyle,color)

Here is the code which produced the above diagram.

f:=x->piecewise(x<=-1,2*x+3,x<=1,x+3,x<=3,2);

gp:=MathClass[GP]([-3,-3],6,7,1,14,green):

plt:=plot(f(x),x=-3..3,discont=true,thickness=5,axesfont=[TIMES,BOLD,12]):

plots[display]([plt,gp],scaling=constrained);

We modifty it by adding points and circles of radius .1.

MathClass[PT]S:=PP([-3,-3],.1,black),PP([-1,1],.1,black),PP([1,4],.1,black),PP([3,2],.1,black):

CIRCS:=MathClass[PC]([-1,2],.1,1,1,black),MathClass[PC]([1,2],.1,1,1,black):
f:=x->piecewise(x<=-1,2*x+3,x<=1,x+3,x<=3,2);

gp:=MathClass[GP]([-3,-3],6,7,1,14,green):

plt:=plot(f(x),x=-3..3,discont=true,thickness=5,axesfont=[TIMES,BOLD,12]):
dgm:= plots[display]([CIRCS,MathClass[PT]S,plt,gp],scaling=constrained):
dgm:

[Maple Plot]

This isn't too bad but the lines clearly overlap the points and circles. This is easily remedied by adjusting the piecewise graph to shrink the lines by the radius of the circles and points. This means we have to convince Maple to skip some portions of the graph. One simple way to do this is to declare the value of the function to be complex on such invervals. Recall that I is the complex number sqrt(-1) . We assign the radius of our circles and points to the variable RADIUS and modify the piecewise declaration to be:

`f(x)` = PIECEWISE([I, x <= -3+1/2*RADIUS],[2*x+3, ...

The "RADIUS/2" in the above is accounting for the slope of the line y = 2*x+3 . In practice this adjustment is usually made visually. That is, mulipliers are substituted until the graph looks correct.

RADIUS:=.15:
MathClass[PT]S:=PP([-3,-3],RADIUS,black),PP([-1,1],RADIUS,black),PP([1,4],RADIUS,black),PP([3,2],RADIUS,black):
CIRCS:=MathClass[PC]([-1,2],RADIUS,2,1,black),MathClass[PC]([1,2],RADIUS,2,1,black):

f:=x->piecewise(x<=-3+RADIUS/2,I,x<=-1-RADIUS/2,2*x+3,x<=-1+RADIUS/2,I,x<=1-RADIUS,x+3,x<=1+RADIUS,I,x<=3-RADIUS,2);
gp:=MathClass[GP]([-3,-3],6,7,1,14,green):

plt:=plot(f(x),x=-3..3,discont=true,thickness=5,axesfont=[TIMES,BOLD,12]):

dgm:=plots[display]([CIRCS,MathClass[PT]S,plt,gp],scaling=constrained):
dgm;

[Maple Plot]

>

One final problem with the above daigram is that the points which meet the boundary may be truncated. This is caused by the limits on the function plot. It can often be corrected by ploting on a larger domain but it is generally easier to adjust the view of the plot. We change only the plots[display] command in the above, making it:

dgm:=plots[display]([CIRCS,MathClass[PT]S,plt,gp],scaling=constrained,view=[-3-RADIUS.. 3+RADIUS,-3-RADIUS.. 4+RADIUS] ):

Which yields

[Maple Plot]

Of course we don't have to be so precise with the "slack" we introduce by expanding the view. The reader should remember that the above only works for constrained plots. Unconstrained plots will cause the circles and disks to appear elliptical.

diagram for discont with points

> RADIUS:=.15:
WQPTS:=MathClass[PP]([-3,-3],RADIUS,black),MathClass[PP]([-1,1],RADIUS,black),MathClass[PP]([1,4],RADIUS,black),MathClass[PP]([3,2],RADIUS,black):
CIRCS:=MathClass[PC]([-1,2],RADIUS,2,1,black),MathClass[PC]([1,2],RADIUS,2,1,black):

f:=x->piecewise(x<=-3+RADIUS/2,I,x<=-1-RADIUS/2,2*x+3,x<=-1+RADIUS/2,I,x<=1-RADIUS,x+3,x<=1+RADIUS,I,x<=3-RADIUS,2);

> gp:=MathClass[GP]([-3,-3],6,7,1,14,green):

> gp:=MathClass[GP]([-3,-3],6,7,1,14,green):

> plt:=plot(f(x),x=-3..3,discont=true,thickness=5,axesfont=[TIMES,BOLD,12]):

dgm:=plots[display]([CIRCS,WQPTS,plt,gp],scaling=constrained,view=[-3-RADIUS.. 3+RADIUS,-3-RADIUS.. 4+RADIUS ]):
dgm;

f := proc (x) options operator, arrow; piecewise(x ...
f := proc (x) options operator, arrow; piecewise(x ...

[Maple Plot]

EXERCISES:

Exercise 1: Many calculus books use piecewise defined functions made up of straight lines and portions of circles as examples where derivatives can be calculated at most points by graphical techniques. For instance the following code produces the diagram below:

f:=x->piecewise(x<=1,x,x<=5,sqrt(4-x^2),x<=7,0):
plt:=plot(f(x),x=-1..7,thickness=3):

plt;

[Maple Plot]

Adapt the above code to produce the following diagrams. Part (d) contains a portion of the graph of sin(1/x) .

(a) [Maple Plot] (b) [Maple Plot]

(c) [Maple Plot] (d) [Maple Plot]

(e)

code for exercise 1

> f:=x->piecewise(x<=1,x-1,x<=5,sqrt(4-(x-3)^2),x<=7,0):

> plt:=plot(f(x),x=-1..7,thickness=3,scaling=constrained):

> plt;

> f:=x->piecewise(x<=1,1-x,x<=5,sqrt(4-(x-3)^2),x<=7,0):

> plt:=plot(f(x),x=-1..7,thickness=3,scaling=constrained):

> plt;

> f:=x->piecewise(x<=1,1-x,x<=3,sqrt(1-(x-2)^2),x<=5,-sqrt(1-(x-4)^2),x<=7,5-x):

> plt:=plot(f(x),x=-1..7,thickness=3,scaling=constrained,axesfont=[TIMES,BOLD,14],titlefont=[TIMES,BOLD,16],title=`This is Made of Semi-circles and Lines`):

> plt;

> RADIUS:=.075:

> PTS:=MathClass[PP]([2,-1],RADIUS,black),MathClass[PP]([4,-1],RADIUS,black):

> CIRCS:=MathClass[PC]([2,1],RADIUS,2,1,black),MathClass[PC]([4,0],RADIUS,2,1,black):

> f:=x->piecewise(x<=1,0,x<=2-RADIUS,-sqrt(1-(x-2)^2), x<=2+RADIUS,I,x<=3,sqrt(1-(x-2)^2),x<=4-RADIUS,-sqrt(1-(x-4)^2),x<=4+RADIUS,I,0):

> plt:=plot(f(x),x=0..5,thickness=3,discont=true):

diagrm:=plots[display]([plt,PTS,CIRCS],scaling=constrained,axesfont=[TIMES,BOLD,14],titlefont=[TIMES,BOLD,16],title=`This is Made of Quarter-circles and Lines`):

> diagrm;

> f:=x->piecewise(x<=0,abs(x),x<=1,x*sin(1/x)):

> plt:=plot(f(x),x=-1..1,thickness=1,discont=true):

diagrm:=plots[display]([plt],axesfont=[TIMES,BOLD,14],view=[-.25.. .5,-.25.. .25]):

> diagrm;

[Maple Plot]

[Maple Plot]

[Maple Plot]

[Maple Plot]

[Maple Plot]

Exercise 2:

Create the diagram below:

[Maple Plot]

code for exercise2

> RADIUS:=.05:

> f:=x->piecewise(x<2-RADIUS,1,x<2+RADIUS/20,I,x<4,3+sqrt(1-(x-3)^2)):

> plt:=plot(f(x),x=0..4,discont=true,color=blue,thickness=3):

> PTS:=MathClass[PP]([2,2],RADIUS,black):

> CIRCS:=MathClass[PC]([2,1],RADIUS,2,1,black),MathClass[PC]([2,3],RADIUS,2,1,black):

> ARRWS:=MathClass[ARRW]([1,2],[2-.1,3-.1],magenta,`SH`,.05,3,.1),MathClass[ARRW]([1,2],[2-.1,1+.1],magenta,`SH`,.05,3,.1),MathClass[ARRW]([4,2],[2.4,2],green,`SH`,.05,3,.1):

> TXT:=MathClass[PT]([-.7, 2.2],`Not on Graph`,16,magenta),MathClass[PT]([3.5, 1.6],`On Graph`,16,green):

>

> diagram:=plots[display]([plt,PTS,CIRCS,ARRWS,TXT],scaling=constrained,view=[-1..4,-1..4],xtickmarks=[],ytickmarks=[]):
diagram;

>

[Maple Plot]

Exercise 3:

Create the following diagram.

[Maple Plot]

code for exercise3

> RADIUS:=.05:

> f:=x->piecewise(x<2-RADIUS,3-x,x<2+RADIUS,I,x<4,x):

> plt:=plot(f(x),x=0..4,discont=true,color=blue,thickness=3):

> PTS:=MathClass[PP]([2,2],RADIUS,black):

> CIRCS:=MathClass[PC]([2,1],1.5*RADIUS,2,1,black):

> ARRWS:=MathClass[ARRW]([1,2],[2-.1,3-.1],magenta,`SH`,.05,3,.1),MathClass[ARRW]([1,2],[2-.1,1+.1],magenta,`SH`,.05,3,.1),MathClass[ARRW]([4,2],[2.4,2],green,`SH`,.05,3,.1):

> TXT:=MathClass[PT]([-.7, 2.2],`Not on Graph`,16,magenta),MathClass[PT]([3.5, 1.6],`On Graph`,16,green):

>

> diagram:=plots[display]([plt,PTS,CIRCS],scaling=constrained,view=[-1..4,-1..4],axesfont=[TIMES,BOLD,16],xtickmarks=[2],ytickmarks=[],titlefont=[TIMES,BOLD,14],title=`No local or global minimum at x=2`,view=[1..3,0..3]):
diagram;

>

[Maple Plot]