In this section we give you examples of how you can use Mathematica for some familiar and elementary operations.

Opening a workspace and executing a Mathematica command

In the first example, we illustrate some of the algebraic and graphical capabilities of Mathematica. First first you must "open" a line to type in as follows:


You can now enter new text in the notebook window. The first example defines y, as a function of x. Type the following exactly as it is written:

y = x^3 - x^2 - 9 x + 9

The line you've just typed is called a command, or "input". When you "enter" such an input, Mathematica processes it and returns "output" (or a result). To obtain the result you must first "execute" the command by following these steps:



Once the command is completed, you will see an input line labeled In[1] that contains the original command, and an output line labeled Out[1]. Notice that the result in the output line is written differently than the way we typed it; Mathematica prefers to write polynomials in increasing powers of x.

Writing a Mathematica command

The input line above is an example of writing the definition of y as a cubic polynomial in x. There are two items you should notice in the above command that are peculiar to the Mathematica program:


Plotting a function

The command below is a very common plotting format that will soon become familiar to you. (Note: this plot command assumes the above definition of y; if you have not executed a command defining y, scroll back and do it now.) Open a new line in the notebook window and type the following command exactly as written.

Plot[y, {x,-7,7}, PlotRange -> All]

There are some items to note in this plot command that are peculiar to Mathematica:


Execute the plot command below to see what the graph of y looks like. (Select the command by locating the cursor after it, and hit Enter). You can see that the graph depicts the essential character of function y.

Modifying a command

You can now practice modifying a Mathematica command and, at the same time, get a closer look at the graph.

Follow these steps to change the domain interval for x in the plot command below:


Now execute the modified plot command. (If the command does not execute, it's always a good idea to check for typographical errors. If there are no errors and the graph still does not plot, ask for help.)

You will now see a more detailed graph of y near a point where it crosses the x-axis.

Factoring polynomials

In the above graph it looks to the eye as if the function y is equal to 0 somewhere around x = -3, x = 1, and x = ?. That is, it appears that y has roots at x = -3, x = 1, and x = 3.


To see this, open a new command line and execute the following command.

Factor[y]

It is now clear that y = 0 precisely at x=-3, x=1, and x=3.

Zooming in on a graph

Let's return to the graph of y in order to discuss an issue that will be very important throughout our study of calculus.

Again, execute:

Plot[y, {x,-4,4}, PlotRange -> All]

A recurring theme in calculus can be paraphrased: most functions are "almost linear" if you look closely enough. To illustrate this point, you can "zoom in" on the graph at x near 2:

You should see a smaller portion of the graph and note that it is starting to straighten out a bit. To further illustrate the point, modify the domain interval in the plot command to 1.99 to 2.01 and execute the command. Notice that the graph is almost linear on this restricted domain interval.

Is there anything special about the point (2, -5)? No. You may want to experiment on your own by modifying the command with any value for the domain of x that you choose, and "zoom in" as we have done. Remember the fundamental point being made:

most functions are "almost linear" if you look closely enough.

We will revisit this fundamental notion often in Calculus.


http://math.colgate.edu/mathlab/basicelts.html
Revised: March 1, 1996.
Questions to: valente@colgate.edu
Copyright 1996 © Colgate University. All rights reserved.