next up previous
Next: Euclidean Space and Vectors Up: Multivariable Calculus: Collaborative Learning Previous: Discussion 17: Rates of

Discussion 18: Local Linearity of f(x,y)

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

Colon and Semicolon
All Maple statements must be terminated by a semicolon (;) or a colon (:). Maple will not execute a statement unless it is terminated by a semicolon or colon. Usually you should end a statement with a semicolon. If you use a colon, the Maple output from the statement is suppressed. This may be useful if the output is long or is only one step along the way to an answer.

Double Quotes
The double quote operator (") recalls the most recent output in a Maple session. This can be used to enter the output into a command. Two double quotes ("") refers to the second most previous result and three double quotes (""") to the third most previous output. In general however, if you have an output that you will want to use again in the Maple session it is better to assign that output to a variable name (see the description below) so it can be recalled later in the session.

Arithmetic Operations
Maple uses the standard arithmetic operations, +, -, *, 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.

Maple commands
Maple commands are called using the syntax
      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.

Entering a range of values
The expression 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.

Loading Packages
Not all Maple commands are immediately accessible. Some commands are found in specialized packages such as linalg, plots, geometry, etc. These packages can be loaded with the command
      with(packagename);
After the package is loaded, any command in the package can be accessed as above.

Assignment operator
The := 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 $\int_1^3 \frac{1}{x}dx$ and assigns that value to the variable area.

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';

Defining Functions
The syntax for defining functions in Maple uses the assignment operator := and the symbol -> which is built up from - and >. For example, to define $f(x) = x^2 \sin(x)$, enter
      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
The array command is used to create an array or list in Maple. This command is used to create vectors and matrices. The basic syntax is
      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
This command is used to evaluate a symbolic expression numerically to n digits accuracy.
     evalf(expr, n);

simplify
This command simplifies the expression entered. It has several options associated to it.
     simplify(expr);

solve, fsolve
These commands can be used to solve an equation or set of equations for a variable or set of variables. To find solutions by symbolic methods use solve. To find a solution by numerical methods use fsolve. The syntax is
     solve({equations},{variables});
     fsolve({equations},{variables});

completesquare
This command is in the 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
This command computes the limit of f as x approaches a.
  
     limit(f,x=a);

To compute a one-sided limit use

     limit(f,x=a,dir);
where dir is left or right

diff
This command is used to compute the (partial) derivative of a function. To differentiate a function f with respect to the variables x1, x2, $\ldots$ use
     diff(f, x1, x2, ..., xn);
int
This command can be used to calculate the indefinite or definite integral of a function f with respect to a variable x. To compute the indefinite integral use
     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) = 3x^{2} -
\sin(x)$. We can also define functions of more than one independent variable. For example,
        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 and plot3d are contained in the external package plots, which must be loaded using

      with(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

implicitplot
If a curve is defined implicitly by g(x,y) = h(x,y) (h could be a constant), that is, the curve is the set of points (x,y) in the domain that satisfy this equation, use:
        implicitplot(g(x,y) = h(x,y), x=a..b,y=c..d);
Note that this command is in the package plots.

densityplot
A density plot is a shaded plot of a region in the plane that is shaded according to the values that a function takes on the region. The default in Maple is to have the shadings range from dark to light as the values of the function increase. Although this is a two dimensional plot, it is most often used in multivariable calculus rather than one variable calculus.

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);
display
This command allows you to combine two-dimensional plots that have been defined using the := 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

implicitplot3d
To plot the surface defined implicitly by the equation f(x,y,z) = kin space, use
         implicitplot3d(f(x,y,z) = k, x=a..b,y=c..d,z=f..g);

contourplot
To plot the level sets or contours of a function z = f(x,y) on a domain in the plane use:
         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
To plot a curve in space given parametrically by (f(t),g(t),h(t)) on a domain [a,b], use the following
         spacecurve([f(t),g(t),h(t)],t=a..b);

display3d
This command allows you to combine three-dimensional plots. The syntax is identical to that of the 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.

In addition, it is possible to animate your plots. For information about animation and plotting options see the Help utility.

Hard Copies

Worksheets
To generate a hard copy of the active worksheet , bring up the Print menu by clicking on the File button and then the Print button. Select Print Command and enter lp in the box next to the Print Command button. Then click on the Print button at the bottom of the dialog box. (If you have more than one worksheet open, click anywhere on the worksheet to make it the active worksheet. The border of the active worksheet will be green.)

Plots
To print a hard copy of a plot, you must first generate a file that contains the plot and then print the plot. Here is the sequence of commands that will save the output of the display command in a file called myplot.ps.
	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.

next up previous
Next: Euclidean Space and Vectors Up: Multivariable Calculus: Collaborative Learning Previous: Discussion 17: Rates of

2000-08-31