In this lab you will get begin to use the Mathematica kernel and interface. This will include learning how to execute some commands, insert text, and change cell styles. You will also learn how to use some of Mathematica's graphics commands to visualize contours and graphs of functions of two variables.
First you must open a DECterm window. Log on to a DEC workstation, and in the console window click on `Applications.' In the resulting menu, click on `DECTERM,' which will generate a new window in your workspace. In this DECterm window, type
mathematica lab1.maThis will open a Mathematica Notebook titled `lab1.ma.' The `.ma' is the file extension Mathematica mathematica automatically uses for its notebooks.
To work in the notebook, move the cursor into the notebook space and click. As soon as you start typing, you have created a `cell,' or block of text that Mathematica will evaluate together. The default type of cell is input, which Mathematica uses to evaluate commands you give it. To see how evaluation of a cell works, type the following:
f = Exp[ 1 - x^2 - y^2 ]After you have typed the above line exactly as it appears, hit the shift and return keys simultaneously. This tells Mathematica to evaluate input in the current cell.
To enter text, move the cursor below the output from the cell you first evaluated and click. Enter some descriptive text about the output. Move the cursor over to the bar on the right hand side of the cell you are working on, and click on it. You are now in a position to edit the cell style. Click on Style from the menus at the top of the notebook, and in the resulting menu select `Cell Style.' In the resulting menu you will see a selection of styles for your cell; if you choose `Text' it will change the style to be textual. Click above the first line you entered in the notebook, enter a descriptive title for your notebook (like `Lab 1, Math 320 Honors') and change the style of that cell to `Title' to see another cell style.
Move to the bottom of your notebook and click. Enter the following in its own cell and shift-return to evaluate:
ContourPlot[f, {x,-2,2}, {y,-2,2}]Also try:
ContourPlot[f, {x,-2,2}, {y,-2,2}, PlotPoints->25, ContourShading->False]The extra arguments in this command are options, which you can set any number of.
To get a surface plot of the same function, try:
Plot3D[f, {x,-2,2}, {y,-2,2}]To alter your viewpoint on this surface plot, add the following option:
Plot3D[f, {x,-2,2}, {y,-2,2}, ViewPoint->{0,-2,0}]Try changing the shading options using command options in the hand out. Rather than type a new command each time, practice clicking on whatever cell holds a similar command, editing that command, and then re-evaluating (shift-return\!).
Try contour and surface plots of . What is the domain and range of this function? In Mathematica the natural log of something is written as
Log[ ]and the absolute value of something is written as
Abs[ ]