This discussion is a computer laboratory designed to develop a geometric understanding of the notion of local linearity for functions of two variables. The text of this discussion is in the form of a Maple worksheet which contains the necessary plotting commands. The lab should be preceded by a brief discussion of the idea of ``zooming-in'' on a location on the graph of a function and of the structure of the Maple commands that are used to zoom-in on the graph of a function of two variables.
The Maple worksheet for this lab should be made available to the
students electronically. The lab employs two user-defined commands,
fplot
and splot
, which allow the user to zoom-in on a
point on the graph of a function and on a vertical slice of the graph
of the function respectively. Used in combination, these commands will
zoom-in on the graph and on a slice of the graph so that the students
can determine by observation whether or not a function is locally
linear at a point. The first exercise asks the students to determine
whether the graph of a quadratic polynomial is locally linear. The
second exercise asks the students to analyze three functions which
fail to be locally linear at a particular point and to characterize
their behavior at these points. The third exercise asks the students
to relate their observations to the existence of the partial
derivatives and to the differentiability of a function at a point.
Students should be able to complete most of this lab in a single class
period.
startsection section10mm-.5 Maple for Multivariable Calculus:
A Summary of Useful Commands
This document will provide you with basic information about Maple
commands and syntax and particular information about creating
plots for functions of two variables in Maple.
Getting in and Out of Maple
To run Maple on the SUN workstations, type
xmaple&
at the prompt in a terminal or console window . This will open a
Maple window. Initially the workspace of the window will contain a
single Maple worksheet called Untitled. You can have more than
one worksheet appear in the workspace at one time. A worksheet (not
the workspace) is where you can enter Maple commands, receive Maple
output responses, type in text or display graphics.
There are eight pull-down menus across the top of the Maple workspace,
including the File menu, the Edit menu and the Help
menu. The File menu contains buttons for manipulating entire
worksheets: New for creating a blank worksheet, Open for
opening an existing worksheet, Save for saving an existing
worksheet, Save As... for saving a new worksheet, Close for
exiting a worksheet, and Print for printing a worksheet. It
also contains the Exit button for exiting Maple altogether. The
Edit menu includes commands for editing highlighted text regions
and paragraphs. The Help menu includes the options Contents for browsing through the entire Help utility, Help on
for finding the help page on a highlighted term, and Topic
Search for help on a particular topic. You should regularly use
these help options to investigate Maple commands and syntax.
Basic Maple Syntax
+
, -
, *
, and /
for addition,
subtraction, multiplication and division, ^
for exponentiation
and !
for factorial. The order in which operations are
executed follows the standard mathematical rules. If there are any
ambiguities, uses parentheses.
Note: * cannot be omitted. For example, you must
enter 5*x
for 5x
.
commandname(parameter 1, parameter 2, . . .);Maple is case-sensitive so it is important to be careful when entering the command name. The parameters for the command can be Maple expressions, numbers, other Maple commands or previously generated Maple output. If you are uncertain about a particular command, you should use the Help to determine the appropriate usage of the command. The Help page on a command usually contains several examples of its use.
x = a..b
denotes x from a to b. This can be used to enter a domain or
range in a plot
command or endpoints of integration for a
definite integral in the int
command as well as in other
contexts.
with(packagename);After the package is loaded, any command in the package can be accessed as above.
:=
operator can be used to assign a
Maple expression to a variable name. This expression could be anything
from a constant to the output of a Maple command. This is particularly
useful if the output will be used in subsequent Maple commands. For
example, the
command
x:= 5;assigns the value 5 to the variable x. The command
area:= int(1/x, x = 1..3);computes the definite integral
You should be cautious when choosing names that you do not use a name which represents a Maple command, function or constant. If you do, the standard meaning of the command name is temporarily lost which may lead to errors. In order to unassign a previously assigned variable use a command of the form
x:= 'x';
->
which is built up
from -
and >
. For example, to define
f:= x->x^2*sin(x);To define g(x,y) = e-(x2+y2) enter
g:= (x,y)->exp(-(x^2 + y^2));
After these functions have been defined, they can be evaluated at a point or used in a subsequent Maple command.
Some useful Maple commands
The following commands are briefly summarized for your use. For further information about any of these commands, as well as examples of their usage, use the on-line Help. Note: Plotting commands are described in the next section.
array( bounds,[list]);All parameters to the array function are optional and may appear in any order. For example,
V := array(1..10);
creates a one
dimensional array (a Maple list) of length 10, but with no explicit
entries. The command array(1..3,[1,2,3]);
creates the vector
(1,2,3).
The command A := array(1..m,1..n);
creates a two dimensional
array (a matrix) with m rows and n columns.
evalf(expr, n);
simplify(expr);
solve
. To find a solution by
numerical methods use fsolve
. The syntax is
solve({equations},{variables}); fsolve({equations},{variables});
student
package,
which is loaded with the command
with(student):The
completesquare
command completes the square of a polynomial
of degree 2 in a variable by rewriting the polynomial as a perfect
square plus a remainder. You should specify the variable that you are
using to complete the square. The syntax of the command is
completesquare(f,x);where f is an algebraic expression.
The following commands are used to do calculus in Maple.
limit(f,x=a);
To compute a one-sided limit use
limit(f,x=a,dir);where
dir
is left
or right
diff(f, x1, x2, ..., xn);
int(f, x);To evaluate the definite integral symbolically use
int(f, x=a..b);To evaluate the definite integral numerically, use
evalf(Int(f, x=a..b));
Plotting with Maple
Maple provides plotting commands for a variety of different types
of objects in two and three dimensions. For a more comprehensive list
of commands, a detailed discussion of their syntax and features,
and numerous examples, see the on-line Help in Maple.
Each plotting command requires an expression (or expressions) in one, two, or three unknowns, and the domain for these unknowns. Maple then samples a meaningful set (or grid) of points in the domain and displays the results for you according to the routine of the particular plotting command. These expressions can be symbolic formulas in the plotting variables, function definitions that you have made, or sets of data. For example, if you have made the function definition in Maple
f:=x -> 3*x^2 - sin(x);you could use
f(x)
in any Maple routine in which you wanted
to evaluate, manipulate, or plot the function
f:= (x,y) -> x^2 - 3*y^2;defines the function f(x,y) = x2 - 3y2. Below we will use symbols f(x), f(x,y), g(x), etc. for expressions in Maple rather than particular expressions in the variables. Remember, Maple will not evaluate any expression involving these symbols if they have not been defined prior to their use.
Each plotting command requires the domain of the independent
variables. We will express these in the form x = a..b
where
a
and b
can either be explicit numerical values or
constants whose values have been assigned prior to their use.
By default, each time you execute a Maple plot command, Maple places
the plot in-line after the plot command in the worksheet. It is
possible to plot in a separate window by changing the setting of Plot Display in the Options menu for the Maple workspace.
Note: Displaying too many plots at one time in a Maple worksheet might impede Maple's performance.
Note: All the plotting commands except for
plot
andplot3d
are contained in the external packageplots
, which must be loaded usingwith(plots);before you can use its plotting commands.
Two-Dimensional Plots
There are several types of two-dimensional plots in Maple. They
provide for the plotting of the graph of a function of one variable,
of a data set, of a parametrically defined curve, and of an implicitly
defined curve. Note: The location of the cursor in the plot is
displayed in the upper left-hand corner of the Maple window.
Here are the most frequently used two-dimensional plotting commands.
plot(f(x),x=a..b);
plot({f(x),g(x),...,h(x)},x=a..b);Notice that the functions are separated by commas and the list is enclosed in braces.
plot([f(t),g(t),t=a..b]);
plot([x1,y1,x2,y2,...,xn,yn],x=a..b);Notice that the coordinates of the n points are written in order as a list of 2n entries separated by commas and enclosed in square brackets.
implicitplot(g(x,y) = h(x,y), x=a..b,y=c..d);Note that this command is in the package
plots
.
To plot a density plot of a function f of two variables on a domain in the plane, use:
densityplot(f(x,y),x=a..b,y=c..d);
:=
construction. In
particular, it allows you to combine plots generated by different plot
commands. For example, the following defines A and B to be the
data needed to plot the graph of sin(x) and a unit circle:
A:=plot(sin(x),x=-Pi..Pi): B:=implicitplot(x^2 + y^2 = 1,x=-1..1,y=-1..1):Notice that these statements end with a colon rather than a semi-colon, which suppresses the output of the data. To combine the plots, use the following:
display([A,B]);Note the square brackets enclosing the list of plots and the semi-colon at the end of the statement.
Three-Dimensional Plots
Maple provides several routines for plotting expressions in one, two, or three unknowns in space. These commands can also be found in the library package plots.
plot3d(f(x,y),x=a..b,y=c..d);Initially, Maple will plot the graph of f as a colored grid. Other plot options can be obtained by clicking on the plot, which will cause a menu bar of plot options to be displayed at the top of the Maple window. Also, three-dimensional graphics images can be rotated within the graphics window by clicking on the left mouse button on the plot, which replaces the plot by a wire-frame box that bounds the image, and then dragging the mouse. Release the mouse button and click on R button at the top of the window to redraw the plot. Note that Maple displays the viewing angles rather than mouse location when you click on the plot.
plot3d({f(x,y),g(x,y),...,h(x,y)},x=a..b,y=c..d);
plot3d([f(x,y),g(x,y),h(x,y)],x=a..b,y=c..d);
implicitplot3d(f(x,y,z) = k, x=a..b,y=c..d,z=f..g);
contourplot(f(x,y),x=a..b,y=c..d);Note that smoother curves can be obtained by including a specification for the
grid
parameter of the form
contourplot(f(x,y),x=a..b,y=c..d,grid=[k,k]);where k is an integer. The default value of k is 25.
Notice that a contour plot is a three dimensional plot of the level curves of the function viewed from above. You can see this by rotating the plot as you did with 3D graphics.
spacecurve([f(t),g(t),h(t)],t=a..b);
display
command.
If A and B have been defined to be three-dimensional plots, the
plots can be displayed with
display([A,B]);In particular, this allows you to combine plots created with different three-dimensional plotting commands.
Hard Copies
plotsetup(ps,plotoutput=`myplot.ps`): display([A,B]); plotsetup(default): system(`lp myplot.ps`);The first
plotsetup
command redirects the output of all
subsequent plot commands to the file you specify. Executing the
display
command will send the plot to the file. The file will
be placed in the directory of the worksheet. The second
plotsetup
command resets the output of all plot commands to the
worksheet. The system
command sends the command inside the
back quotes to the operating system. Note that if the directory of
the worksheet is different from the directory from which you are
running Maple, you must specify the full name of the file in the
system
command.