Sie sind auf Seite 1von 10

Math 263 Calculus III

Visualization using FreeMat

Math 263 Calculus III

Pierce College

MAP

Math 263 Calculus III

Table of Contents
Introduction......................................................................................................................1 Proviso ............................................................................................................................... 2 FreeMat ............................................................................................................................ 2 Scripts............................................................................................................................... 8

Pierce College

MAP

Math 263 Calculus III

Introduction
Math 263, multivariable calculus or vector calculus, extends single variable calculus (Math 261 and 262) to functions of two (or more variables). As with most math and science classes, learning and understanding course concepts is aided and facilitated through the use of pictures, graphs, and images. In single variable calculus these images typically depict the behavior of functions, their derivatives, and integrals. Since the graph of a function of one variable is a curve, it can be plotted in two-dimensions e.g. on a piece of paper using the familiar Cartesian coordinate system i.e. xy-plot. This is not the case for the functions encountered in multivariable calculus. In multivariable calculus, it will be shown that functions of two variables have graphs that are surfaces in three-dimensions. Functions of three (or more variables) correspond to hyper-surfaces in multi-dimensional spaces. As such, plotting the graphs of these functions (or visualizing them) is more challenging than with their single variable cousins. Drawing surfaces on paper requires using perspective to adequately render three dimensions on a two dimensional medium. As noted by Leonardo da Vinci:
There are three aspects to perspective. The first has to do with how the size of objects seems to diminish according to distance: the second, the manner in which colors change the farther away they are from the eye; the third defines how objects ought to be finished less carefully the farther away they are."

Except for the simplest of surfaces, the task of producing an accurate depiction is a time consuming and artistically challenging task. In fact, before computers became widely available, technical books contained few images of complex objects such as multi-variable functions. Examination of multi-variable calculus text books published prior to 1980 will illustrate this point*. Fortunately now that computers are widely available it is possible to easily and inexpensively produce high quality and accurate depictions of the surfaces corresponding to graphs of multi-variable functions. In this course, FreeMat, a software program and tool, is used to generate images of many of the functions encountered in the text and in the lecture. FreeMat, as the name implies, is free-ware and available for download and installation
*

It is interesting to note the math books published before 1980 tend to be smaller (in size and page count), in black-and white (i.e. no color), and less expensive.
MAP

Pierce College

Math 263 Calculus III via the internet. This tool will be utilized in the lecture and students are encouraged to download and install it on their personal computers as an aid to exploring and visualizing these functions. This paper discusses how to find, download, and use this tool.

Proviso
The use of FreeMat in the course is completely voluntary. As such, students are not required to download, install, or use this software as part of taking the course. Use of FreeMat is completely optional, but encouraged. As with all software, free or otherwise, licensing agreements must be respected and observed. Also, adequate virus protection should be in-place and used when installing and running any program. In addition, Math 263 is a course in mathematics, not computer programming. As such, no course (lecture time) will be devoted to writing FreeMat scripts or to programming in general. Students will be provided with free pre-written scripts for their sole and exclusive use during the course. Students are encouraged to run these scripts and to modify them, as a way of visualizing the functions and concepts presented in the course.

FreeMat
FreeMat is a free and (currently) less functional version of MATLAB. MATLAB (http://www.mathworks.com/products/matlab/) is a high-level

language and interactive environment that enables you to perform computationally intensive tasks faster than with traditional programming languages such as C, C++, and Fortran. MATLAB is widely used in industry,
and students pursuing careers in math, science, and engineering are likely to encounter this tool as they progress in both school and work. Although MATLAB is a very powerful tool it is also relatively expensive with the full student version costing approximately $1400*. FreeMat lacks much of the functionality of MATLAB but has the virtue of being inexpensive (its free)
*

A basic version of MATLAB is available for $99US. However it lacks the toolboxes that provide much of the softwares functionality.
MAP

Pierce College

Math 263 Calculus III and using the same syntax as MATLAB. In addition the software has an almost identical interface. As such, using FreeMat provides an excellent introduction to MATLAB.

FreeMat is available at http://freemat.sourceforge.net/ . Versions for Windows, Mac, and Linux are provided. Students wishing to use FreeMat should download the appropriate version for their computer. The Windows version is approximately 17MB and requires about 45MB of disk space when installed. The Windows download file (currently FreeMat-4.0-svn_rev4000win32.exe) installs FreeMat. Double click and follow the instructions. On-line documentation is also provided (http://freemat.sourceforge.net/help/index.html). Once installed, FreeMat can be run by double clicking on the desk-top icon or using the start button on the toolbar (start->Programs->FreeMat->FreeMat). Mac and Linux users, consult the documentation at http://freemat.sourceforge.net/help/introduction_install.html for installation and usage instructions. Once started, the FreeMat environment window opens, as shown in Figure 1, below.

Figure 1: FreeMat environment. The FreeMat environment consists of five windows. The first (upper left) contains a list of files in the current working directory. These are usually scripts. The History window contains a history of commands typed in the interpreter. The interpreter window (large window on right) is used for executing FreeMat commands and scripts.
Pierce College MAP

Math 263 Calculus III

The FreeMat environment contains five Windows: Filename, History, Variable, Debug, and the interpreter. The Filename window lists the files in the current working directory. The working directory is specified by using the combo-box in the right part of the toolbar. The History window shows the commands typed in the interpreter. The interpreter window is the large window on the right. The interpreter is where commands and script file names are entered into FreeMat. FreeMat will execute these commands to produce a result which will be displayed in the interpreter window or a figure window. For example typing a = 1 followed by b = 2 followed by a + b will yield 3, as shown in Figure 2.

Figure 2: Using the interpreter. The results of typing a = 1, b = 2, and a+b is shown. In this case the result is three, the result of adding one and two.

Typing the name of a script in the interpreter will cause the contents of the script to be executed by FreeMat. Scripts are files containing FreeMat commands. FreeMat scripts end with the .m extension. When typing a script name in the interpreter the .m is left off. Scripts are used when many FreeMat commands are required to perform a task and when these sequence of commands will be used over and over again. Scripts are plain text files and
Pierce College MAP

Math 263 Calculus III may be viewed and modified using a plain text editor such as notepad*. FreeMat also provides its own editor. Double clicking on a script in the Filename window will open the script in the FreeMat editor, as shown in Figure 3.

Figure 3: FreeMat Editor. FreeMat provides its own script editor. Double clicking on a FreeMat script opens the file in the editor where it can be viewed and modified.

The FreeMat editor is the preferred editor for viewing and modifying FreeMat scripts. Syntax highlighting is provided making scripts easier to read and understand. The percent symbol % is used to indicate a comment. Comments are ignored by the interpreter. All parts of a line after the percent symbol are ignored.

Note: it is important to use a plain text editor when editing a script. Use of a word-processing program like Microsoft Word will leave the script unusable.
MAP

Pierce College

Math 263 Calculus III Typing the name of a script (without the .m. extension) in the interpreter window causes the script to be executed. Figure 4 show the result for the script ex03.m.

Figure 4: Executing a script. Typing ex03 in the interpreter causes the commands in the file ex03.m to be executed. In this case, the script creates a figure window containing the graphs of four surfaces.

The script ex03.m contains commands that open a figure window and plot the graphs of four surfaces. The figure window can be moved and sized independently of the environment window. The cone symbol in the toolbar can be used to rotate the graphs. To rotate a graph, first click on the cone symbol in the toolbar and then, clicking and keeping the mouse button down on the graph, move the cursor to rotate the graph. Figure 5 shows the result of rotating the plot in the upper left of the figure window shown in Figure 4. Rotating a graph allows the surface to be viewed at different

Pierce College

MAP

Math 263 Calculus III

angles. Surfaces can be explored in this manner and various features viewed in detail.

Figure 5: Rotating a graph. The cone symbol in the toolbar is used to rotate a graph. Click on the cone symbol and then click and hold down the mouse button on the graph. Moving the cursor rotates the graph.

Pierce College

MAP

Math 263 Calculus III

Scripts
Twenty-three scripts (one per lecture) are provided to help students taking the course visualize and understand the various topics presented. Scripts will be executed during the lecture and their results discussed. Students are encouraged to run these scripts on their own and use them to explore the concepts presented in the lecture. Students are also encouraged to modify these scripts and even to write their own. It should be kept in mind however that scripts are a means to an end and not a substitute for studying the course material and working homework problems. The scripts are moderately complex to the novice programmer and students are not expected to understand (let alone master) their contents. As such students should devote their time to the course material and not to understanding the contents of these files. Students will not be tested on FreeMat, its usage, or its commands, or the writing or the contents of scripts. All tests will focus exclusively on the mathematics of the course. This said, playing with the scripts can aid in understanding various concepts and in visualizing some of the material. It can also be fun, and if not careful addicting!

Pierce College

MAP

Das könnte Ihnen auch gefallen