Vanderbilt University Computer Center

Introduction to Mathematica

Introduction to Mathematica

Karen Montefiori
Vanderbilt University Computer Center
January 1994

Structure of Mathematica ... 1

The Front End Versus the Kernel

Mathematica consists of two separate applications, the Kernel and the Front End.  The Kernel is responsible for computing results and is essentially the same on all supported platforms.  The Front End is the user interface to the Kernel and varies from platform to platform.    

There are two major types of Front Ends: Notebook Front Ends, which are designed to take advantage of graphical user interface features, and  command-line oriented Front Ends.  Both types of Front Ends enable you to enter commands and data.  Notebook Front Ends provide the additional capability of creating documents, called Notebooks, which may contain text, graphics, and Mathematica input and output. In addition, the editing capabilities of Notebook Front Ends are superior to those of command-line Front Ends.  

One benefit that results from the way Mathematica is structured is that the Kernel can be run remotely from a workstation, mainframe, or supercomputer (in order to take advantage of the remote system's additional memory and speed) and the Front End can be run locally (to capitilize on the Notebook interface that may be available on the local machine).

Introduction to Notebooks ... 1

Notebook Front Ends provide the ability to create documents, called Notebooks, which may contain text, graphics, and Mathematica input and output.  Notebooks are similar to documents created with word processors and other applications in that they may be saved to disk, opened and edited, and printed.  Notebooks, however, provide two major advantages over normal text files.  First, a Notebook can be structured hierarchically into sections which can be expanded into subsections and sub-subsections or collapsed into section headings as one works through the Notebook.  Second, Notebooks can be interactive documents in which illustrative computations and graphics are embedded in explanatory text.

Types of Cells

The basic unit of structure in a Mathematica Notebook is called a cell.  Each cell can contain either text, Mathematica input, Mathematica output, or graphics, but not combinations of these materials.  The material a cell contains determines its cell type or style which in turn determines its role in the Notebook.  For example, a cell which contains Mathematica input is defined as an  Input cell.  Input cells are active cells (cells that can be evaluated by the Mathematica Kernel).  

Mathematica is equipped with several predefined cell styles which can be applied to individual cells.  When a style is applied to a cell, the cell takes on the text and cell attributes that are specified in the style's definition.  For example, styles can be used to apply text attriubutes such as font, face, size, color and alignment to a cell.  Styles can also be used to apply cell attributes such as margin settings, and whether a cell is active or inactive.  Predefined styles have names which indicate their roles in the Notebook:  Title, Subtitle, Subsubtitle, Section, Subsection, Subsubsection, Text, Small Text, Input, Output, Graphics, etc.    

Every notebook has an associated style sheet which is the collection of currently available styles.  Predefined styles can be modified and entirely new styles can be created.

Cell Brackets

A cell bracket is the bracket located on the far right side of the window which surrounds the material in a cell.  Cell brackets have four major functions in Mathematica.  First, they are used to  indicate the extent of material contained in a cell.  As material is added to a cell, its cell bracket grows correspondingly.  Second, cell brackets are used to select entire cells.  This is accomplished by clicking on the bracket.  When a cell is selected, its bracket will become highlighted.  Many operations, including Cut, Copy, Evaluate, and Paste, can be performed on a cell once it has been selected.  Third, cell brackets are used to differentiate between cell types.  For example,  the bracket to the right of this paragraph features two horizontal tick marks at the top of the bracket.  This indicates that the bracket surrounds a text cell.  Finally, Mathematica  automatically creates hierarchical cell groups, or sequences of related cells, based on styles assigned to the cells by enclosing related cells in group brackets.  Group brackets are used by Mathematica to force a hierarchical, or tree, structure on the Notebook being created.

Creating New Cells

There are three methods that can be used to create new cells.  To create a new cell in an empty Notebook, simply start typing.  The information you type will immediately be enclosed within a cell.  To create a new cell above or below an existing cell, position the pointer accordingly and click the mouse when the pointer changes from a veritical I-beam to a horizontal I-beam.  The location of the new cell will be indicated by a  horizotal line spanning the width of the window.  As soon as you begin to type, the information will be enclosed in a cell.  Cells created using either of these two methods will automatically inherit the Input cell style, unless you indicate otherwise.    The third method provides a mechanism for copying the cell style from the cell above to a new cell.  To create a new cell which has the same style as the cell above, click within the cell whose style you wish to copy (a blinking vertical bar should appear), and press Option-Return.

Arithmetic in Mathematica ... 3

Arithmetic Operators

Mathematica can be used like an electronic calculator to perform arithmetic operations such as addition, subtraction, multiplication, division, and exponentiation.  The following table lists the operators supported by Mathematica:

Operation																																					Operator                     

Addition                                       +																																	
Subtraction                                   -                                  
Division                                        /                                  
Multiplication                               * (or a space)                                
Exponentiation                             ^                                

Note that in addition to the asterisk character, a space can also be used to denote multiplication.  Note also, that spaces are not required around an operator, but can be used to make the input easier to read.  The following Input cell provides example computations which use each of these operators.

2 + 3
20 - 5
26 * 4319
26 4319
237 / 3
2 ^ 48

Numerical and Symbolic Computations

Mathematica can do numerical, as well as symbolic, computations.  Thus, it can compute algebraic formulas as well as numerical expressions.  In Mathematica, a variable name must begin with a letter (or $) and can not include spaces.  Mathematica will treat a character string composed of a single letter, or sequence of letters, as a symbol.  The following provides an example of each type of computation.  The first expression is a numerical expression.  The second is a symbolic expression whose terms include the variables (symbols) x and y.

3 * 4 + 2 
x y + 2 x^2 y + y^2 x^2 - 2 y x

Numerical Approximations

Mathematica computes exact results unless the input includes an approximate number (for example, a number with a decimal point) or unless a numerical approximation is requested.  In Mathematica, the built-in function N[expr, n] is used to perform computations to n-digit precision. If the second argument is not specified, Mathematica will display the result in 6-digit precision even though it actually computes the result to a higher degree of precision.  The default degree of precision that Mathematica computes the result to is dependent upon the computer being used.  You can use N, however, to calculate results to a higher degree of precision than the floating point precision of the machine being used.  

In the examples that follow, note how 1) Mathematica displays exact results when working with integers, rational numbers, or symbols, 2) Mathematica displays approximate results when working with expressions involving floating point numbers, and 3) Mathematica can display results to any precision by using the function N.

1/5 + 7x + 5/2
1.5/300 + 1/3
N[Pi,30]

Complex Numbers

Mathematica  can compute results for input involving complex numbers.  You can enter complex numbers in Mathematica by including the constant I (which equals the square root of negative one).  Mathematica features several built-in functions for working with complex numbers:

Re[z] displays the real part of the complex number z
Im[z] displays the imaginary part of the complex number z
Conjugate[z] returns the complex conjugate of the complex number z

The following uses Re, Im, and Conjugate to respectively give the real part, imaginary part and conjugate of the complex number 4+3I.

Re[4 + 3I]
Im[4 + 3I]
Conjugate[4 + 3I]

Symbols and Storage ... 5

Brackets, Parantheses, and Braces

In Mathematica, brackets, parantheses, and braces are used for different purposes.  Square brackets are used to enclose agruments of functions.  For example, in the function N[expr,n], square brackets are used to enclose the two arguments, expr and n.  All built-in functions follow this syntax convention.     

Parantheses are used for grouping and serve to control the order in which calculations are performed.  For example, notice how the use of parentheses in the Input cell below affects the output.

3/4^20
(3/4)^20

Curly braces are used for indicating lists.  In Mathematica, a list is defined to be a collection of objects, separated by commas and enclosed in curly braces.  Mathematica uses lists, for example, to specify vectors and matrices (where a matrix is a list of lists).  In the following Input cell, we use a list to ask Mathematica to compute the cube of each element in the list.

{1,2,3,4}^3

Double square brackets are used for indexing.  In the Input cell below, we define a list, x, and then redefine the third element of x by using double square brackets.  Finally, we ask Mathematica to redisplay x.

x = {35, 38, 67, 63}
x[[3]] = 40
x

User-defined and Reserved Symbols

Mathematica features many built-in (reserved) symbols, or named objects, such as functions and constants.  All built-in symbols begin with a capital letter or a dollar sign.  When defining your own objects, you must be careful to avoid using a reserved name.  A common technique is to follow the convention of always using names that begin with lowercase letters.  For example, in the following Input cell, we assign the value 7 to the variable y.  Note how we first use the Clear function to remove any value previously assigned to y.

Clear[y]
y = 7

It is crucial to realize that function definitions and variable assignments are permanent.  Once a function has been defined or a value has been assigned to a variable, the definition or value will be kept until you remove it or until you begin a new Mathematica session.  Many mistakes in Mathematica are caused by not clearing old definitions. Therefore, prior to defining new functions, constants, or variables, make a practise using Clear to remove old definitions.

Assignments and Equality

Mathematica  features two different assignment operators.  The single equal sign (lhs = rhs) is referred to as the immediate assignment operator and the colon equal sign (lhs := rhs) is known as the delayed assignment operator.  The primary difference between these operators is when the expression rhs is evaluated.  If the immediate assignment operator is used, rhs is evaluated as soon as the assignment is made.  With the delayed assignment operator, rhs is only evaluated when the value of lhs is requested.  

The difference between these two operators is clarified by the following example.  We use the built-in function, Random[ ], to generate a uniformly distributed pseudorandom Real in the range 0 to 1 and the built-in function, Table[expr, {imax}], to generate a list of imax copies of expr.  We use the immediate assignment operator to define random1 and the delayed assignment operator to define random2.  Note how random1 always returns the same value whenever it is called, but random2 returns a different value each time it is called.

Clear[random1, random2]
random1 = Random[ ]
Table[random1,{5}]
random2 := Random[ ]
Table[random2, {5}]

In addition to the immediate and delayed assignment operators, Mathematica features a logical operator.  In Mathematica, the double equal sign (lhs == rhs) tests whether lhs and rhs are equal, but causes no explicit action or assignment.  When lhs == rhs is submitted to the Kernel, Mathematica returns True if lhs is equal to rhs and False if otherwise.  

In the following example, note how Mathematica returns the original expression when it is unable to evaluate whether the result should be True or False.

Clear[a]
a==7

Algebraic Manipulations in Mathematica ... 8

Mathematica provides many functions for manipulating algebraic expressions including:  Expand, Together, Apart, Factor, Simplify, and ComplexExpand.  We'll use the first five of these functions to convert the following rational expression into several different forms.

Clear[e, x]
e = (x-1)^2 (2 + x) / ((1 + x) ( x - 3)^2)

Expanding Numerators

Expand[expr] is used to expand out the products and positive integer powers in expr.  The denominator in expr will be left in factored form.  In the following Input cell, we use Expand to multiply out the products and powers of the expression we named e above.

Expand[e]

Collecting Terms over a Common Denominator

Together[expr] transforms a sum of terms into a single rational function.  In the Input cell below, we use Together to collect all terms in the previous output over a common denominator.

Together[%]

Transforming a Rational Expression into its Partial Fractions

Apart[expr] transforms a rational expression into a sum of terms with simple denominators.  Apart[expr] can be used as the inverse of Together.  We will use Apart to give the partial fraction decomposition of the preceding output.

Apart[%]

Factoring a Polynomial

Factor[poly] transforms a polynomial into a product of factors.  Note that Factor works only with integer or rational coefficients.  In the Input cell below we use Factor to reduce the preceding output to a product of factors.

Factor[%]

Simplifying Complicated Results

You can ask Mathematica to simplify a complicated result by using the built-in Simplify[expr] function.  Simplify will expand and factor parts of expr and will return the simplest transformation it can find.  In the Input cell below, we use Simplify to have Mathematica return the simplest form of the expression e that it can find.

Simplify[e]

Expanding Expressions involving Complex Numbers

ComplexExpand can be used to expand expressions involving complex numbers.  If the syntax ComplexExpand[expr] is used, Mathematica performs the expansion assuming all variables are real.  Alternatively, ComplexExpand[expr, {x1, x2, ...}] can be used to expand an expression under the assumption that the variables xi are complex.  Following is an example computation for each of these forms of ComplexExpand.

Clear[x, y]
ComplexExpand[ Sin[x + I y] ]
ComplexExpand[ Sin[x + I y], {x, y}]

Functions ... 10

Built-in Functions

Mathematica features over 700 built-in functions.  All Mathematica functions have names which begin with a capital letter.   If the name includes two or more words, the first letter of each word is capitalized.  In addition, function arguments are always enclosed in square brackets and separated by commas.  

You can obtain information (such as the usage statement) about a particular Mathematica function by using the Open Function Browser command in the Help menu or by using the ? operator.  For example, in the following Input cell, we use the ? operator to access Mathematica's on-line help for the Plot function.

?Plot

Note that the asterisk (*) wild card character can be used with the ? operator to match any alphanumeric character or sequence of characters in a partially written command name. In the case of duplicate matches, Mathematica will present a listing of all matching command names.  For example, in the follwing Input cell, we request a listing of all commands that begin with Arc.

?Arc*

Most functions feature options which can be specified in any order after the required arguments.  Options are simply rules of the form OptionName -> OptionValue, where OptionName is the name of the option and OptionValue is the option's assigned value.  If a value for an option is not specified, the default value will be used.  To obtain a listing of default values for all options of a specific function, use ?? or the Options[ ] command.  For example, in the following Input cell, we ask Mathematica to list default values for all options of the ContourPlot command.

??ContourPlot

User-Defined Functions

In addition to featuring hundreds of built-in functions, Mathematica provides the capability of creating user-defined functions.  Once a user-defined function has been created, it can be used over and over again during the Mathematica session.

For example, suppose we needed to create the function f(x) = x2 + 3x - 5.  The Mathematica command to create this function is f[x_] :=  x2 + 3x - 5.  Note the use of the underscore on the left-hand side.  The underscore is required when designating variables which are arguments for the function.  In the following Input cell, we define f (being careful to first clear any old definitions) and then compute f for x = 2 and x = a + b.  Finally, we use f as an argument to the built-in Expand function.

Clear[f, x, a, b]
f[x_] := x^2 + 3x - 5
f[2]
f[a + b]
Expand[f[(a + b)^2]]

Note that just as with built-in functions, the ? operator can be used to display the definitions of user-defined functions.

?f

Trigonometric Functions

Mathematica features built-in routines for the trigonometric functions:  Sin[z], Cos[z], Tan[z], Csc[z], Sec[z], and Cot[z].  Note that arguments to these functions are assumed to be in radians, and that degrees can be converted into radians by multiplying by Degree, a built-in constant equal to Π/180.

Sin[Pi/2]
N[ Sin[30 Degree] ]

Exponential and Logarithmic Functions

Mathematica provides built-in routines for computing ez (Exp[z]), the natural logarithm of z (Log[z]), and the logarithm of z to the base b (Log[b, z]).  Note that Mathematica will give exact results for logarithms whenever it can.  

In the Input cell below, we ask Mathematica to compute the logarithm of a complex number.

N[ Log[2 + 8 I] ]

Hyperbolic Trigonometric Functions

Mathematica features the hyperbolic functions:  Sinh[z], Cosh[z], Tanh[z], Csch[z], Sech[z], and Coth[z].

The following Input cell is used to generate a plot of the hyperbolic tangent function.

Clear[x]
Plot[ Tanh[x], {x, -8, 8} ];

Special Functions

Mathematica also features all of the common special functions of mathematical physics.  The name of each function and a brief description is listed below. 

Name                                                 Description

AiryAi[z], AiryBi[z]                          Airy functions Ai(z) and Bi(z)
AiryAiPrime[z], AiryBiPrime[z]        derivatives of Airy functions Ai'(z) and Bi'(z)
BesselJ[n, z], BesselY[n, z]              Bessel functions Jn(z) and Yn (z)
BesselI[n, z], BesselK[n, z]              modified Bessel functions In(z) and Kn(z)
Beta[a, b]                                           Euler beta function B(a,b)
Beta[z, a, b]                                       incomplete beta function Bz(a,b)
CosIntegral[z]                                    cosine integral function Ci(z)
Erf[z], Erfc[z]                                    error function erf(z), complementary error function Erfc(z)
Erf[z0, z1]                                         generalized error function erf(z1) - erf(z0)
ExpIntegralE[n, z]                             exponential integral En(z) 
ExpIntegralEi[z]                                 exponential integral Ei(z) 
Gamma[z]                                          Euler gamma function
Gamma[a, z]                                      incomplete gamma function
Gamma[a, z0, z1]                              generalized incomplete gamma function
Hypergeometric0F1[a, z]                   hypergeometric function 0F1(;a;z)
Hypergeometric1F1[a, b, z]               Kummer confluent hypergeometric function 1F1(a;b;z)
HypergeometricU[a, b, z]                  confluent hypergeometric function U(a, b, z)
Hypergeometric2F1[a, b, c, z]           hypergeometric function 2F1(a,b;c;z)
LegendreP[n, z], LegendreQ[n, z]     Legendre functions Pn(z), Qn(z) of the first, second kinds
LegendreP[n, m, z], LegendreQ[n, m, z]
                                                            associated Legendre functions 
LerchPhi[z, s, a]                                 Lerch's transcendent
LogIntegral[z]                                     logarithmic integral li(z)
Pochhammer[a, n]                              Pochhammer symbol (a)n  
PolyGamma[z]                                   digamma function
PolyGamma[n, z]                               nth derivative of the digamma function
PolyLog[n, z]                                     polylogarithm function Lin(z)
RiemannSiegelTheta[t], RiemannSiegelZ[t]
                                                           Riemann-Siegel functions
SinIntegral[z]                                     sine integral function Si(z)
Zeta[s]                                                Riemann zeta function
Zeta[s, a]                                            generalized Riemann zeta function

Equation Solving ... 14

Mathematica provides several built-in functions that can be used to solve equations.  Four of these functions will be examined:  Solve, Roots, NRoots, and FindRoots.

Solve

Solve[eqns, vars] tries to solve an equation or system of equations for the variables vars.  The equations are given in the form lhs == rhs.  Mathematica can always solve algebraic equations in one variable if the highest power of the variable is less than five.  For equations of degree five or more, it may be mathematically impossible to find explicit formulas for the solutions and in these cases Mathematica will use the function Roots to represent the solutions.  You can then use N to compute numerical values for the roots.  Note that Solve returns exact values (replacement rules involving integers, rationals and symbols).

In the following Input cell, we ask Mathematica to solve the quadratic equation 4x2 + 2x - 2 = 0.  Since it is a quadratic equation, Mathematica is able to compute explicit formulas for the solutions.

Clear[x]
Solve[4 x^2 + 2 x - 2 == 0, x]

Next, we ask Mathematica to solve an equation involving a power higher than four.  Even though Mathematica can not find explicit formulas for the solutions, we are still able to find solutions numerically by using N.

Clear[x]
Solve[x^5 - 4 x + 2 == 0, x]
N[%]

Finally, we use Solve to solve a set of simultaneous equations.

Clear[a, x, y]
Solve[{a x + y == 0, 2 x + (1 - a) y == 1}, {x, y}]

Roots

Roots[lhs==rhs, var] can be used to generate equations of the form var==ri which represent the roots of the polynomial equation lhs=rhs .  For example, in the Input cell below, we use Roots to find the roots of the equation x2 + 3x = 2.  Note the form of the resulting output (x == r1 || x == r2).  The symbol || is Mathematica's logical Or function.  Thus, the result tells us that x equals (-3 + Sqrt 17)/2 or x equals (-3 - Sqrt 17)/2.

Clear[x]
Roots[x^2 + 3x ==2, x]

NRoots

NRoots[lhs==rhs, var] gives a list of numerical approximations to the roots of the polynomial equation lhs=rhs.  In the following Input cell, we first use Roots to compute exact expressions for the roots of the equation x2 + x + 1 = 0 and then use NRoots to obtain numerical approximations to these roots.

Roots[x^2 + x + 1 == 0, x]
NRoots[x^2 + x + 1 == 0, x]

FindRoot

FindRoot[lhs==rhs, {x, x0}] searches for a numerical solution to the equation lhs = rhs, starting with x = x0.  Note that since FindRoot uses Netwon's method, it may not always find the root nearest x0.  In the Input cell below, we use FindRoot to find the unique root for sin(ex) between 1 and 1.5.

FindRoot[Sin[Exp[x]], {x, 1, 1.5}]

Calculus ... 17

Limits

Limit[expr, x -> x0] can be used to compute the limit of expr as x goes to x0.  The Direction -> 1 option can be used to compute the limit as x approaches x0 from the left.  Likewise, Direction -> -1 can be used to compute the limit as x approaches x0 from the right.  For example, we use Limit below to compute the limit of sin(x) / x as x approaches 0.

Clear[x]
Limit[Sin[x] / x, x -> 0]

Note that on occasion, the output from the Limit command may be incorrect.  Therefore it is prudent to check the result by making some plots and computing some numerical values around the limit.

Differentiation

D[f, x] computes the derivative of f with respect to x.  For example, we use D below to calculate the derivative of x2y3 with respect to x.

Clear[x, y]
D[x^2 y^3, x]

As another example, we use D below to compute the derivative of x2 y3 with respect to y, then with respect to x.  Note that the first variable listed is done last.

Clear[x, y]
D[x^2 y^3, x, y]

Integration

Mathematica can compute indefinite, definite, and multiple integrals of functions by using the built in Integrate command.  For example, Integrate[f, x] gives the indefinite integral of f with respect to x.  Use Integrate[f, {x, xmin, xmax}] to compute the definite integral of f with respect to x from x equal xmin to x equal xmax.  Finally, Integrate[f, {x, xmin, xmax}, {y, ymin, ymax}] can be used to calculate multiple integrals.  Following is an example of each type of computation.

Clear[a, x, y]
Integrate[a x^2, x]
Integrate[x^2, {x, 0, 1}]
Integrate[x^2 y^3, x, y]

Sums

Mathematica can be used to compute sums by using the command Sum[f, {i, imin, imax}]. Multiple sums can be calculated using Sum[f, {i, imin, imax}, {j, jmin, jmax}, ...].  Note that for multiple sums, the outermost sum is given first.  Examples appear below.

Clear[i]
Sum[1 / i^3, {i, 1, 20}]
Sum[x^i y^j, {i, 1, 3}, {j, 1, i}]

A third variant of the Sum command, Sum[f, {i, imin, imax, di}] can be used to compute a sum with i increasing in steps of di.

Clear[x, i]
Sum[x^i/i, {i, 1, 5, 2}]

Series

Series[f, {x, x0, n}] computes a power series expansion for f about the point x = x0, to order (x - x0)n.  For example, in the following Input cell, we compute the power series expansion for exp(x) about the point x = 0 to order x4.

Clear[x]
Series[Exp[x], {x, 1, 4}]

Products

Mathematica can be used to compute products by using the command Product[f, {i, imin, imax}]. Multiple products can be calculated using Product[f, {i, imin, imax}, {j, jmin, jmax}, ...].  Note that for multiple products, the outermost product is given first.  A third variant of the Product command, Product[f, {i, imin, imax, di}] can be used to compute a product with i increasing in steps of di. An example of a computation involving the first variant of the Product command is given below.

Product[x + i, {i, 1, 4}]

Graphics ... 20

Mathematica can be used to create plots of functions and data in two and three dimensions.

Plot

Plot[{f1, f2, ...}, {x, xmin, xmax}] can be used to create a graph which includes the plots of the functions fi(x) with x ranging from xmin to xmax.  In the Input cell below, we use Plot to create a graph of the function f(x) = x2 + 2x - 3, with x ranging from -5 to 5.

Clear[x]
Plot[x^2 + 2x - 3, {x, -5, 5}];

The Plot command features a rich selection of options for producing graphs.  We use the Options command to list default values for the options of the Plot command.

Options[Plot]

In the following Input cell, we use the Plot command with several of  its options to plot two functions, x2 + 2x - 3 and 2x + 5, on the same set of axes.  We have used 1) PlotRange  to control the range of values included in the plot, 2) AxesLabel is to specify labels for the axes, 3) PlotStyle to control the line style and color of each plot, 4) Frame  to draw a frame around the graph, and 5) PlotLabel  to add a title to the graph.

Clear[x]
Plot[{x^2 + 2x - 3, 2x + 5}, {x, -5, 5},
 PlotRange -> {-5, 20}, AxesLabel -> {" X", " "}, 
 PlotStyle -> {Dashing[{.04, .02}], 
 RGBColor[1, 0, 0]}, Frame -> True, 
 PlotLabel -> "Plot Example"];

Note that since Plot uses a finite number of sample points to produce a plot, the resulting plot may not be an accurate representation of the specified function.  In these cases, use of the PlotPoints option, which controls the number of sample points, can be used to obtain more accurate plots.

Plot3D

Plot3D[f, {x, xmin, xmax}, {y, ymin, ymax}] renders a three-dimensional plot of f as a function of x and y.  For example, we use Plot3D below to generate a three-dimensional plot of sin xy, letting x vary from 0 to 2 Pi and y vary from 0 to Pi.

Clear[x, y]
Plot3D[Sin[x y], {x, 0, 2Pi}, {y, 0, Pi}];

Many of the options for Plot3D are analogous to those provided for Plot.  Others, such as ViewPoint, are specific to the three-dimensional case.  In the Input cell below, we use Plot3D with the ViewPoint option to specify the point in space from which the preceding plot should be viewed.

Clear[x, y]
Plot3D[Sin[x y], {x, 0, 2Pi}, {y, 0, Pi},
 ViewPoint -> {3, -1, 2}];

ContourPlot

ContourPlot[f, {x, xmin, xmax}, {y, ymin, ymax}] generates a contour plot of f as a function of x and y.  Note that the contours in the plot join points on the surface that have the same height and contours representing regions of greater height are shaded more lightly than those representing shallow areas.  We use ContourPlot with the option PlotPoints to render the plot  shown below.

Clear[x, y]
ContourPlot[Exp[-Sqrt[x^2 + y^2]] Cos[ArcTan[x, y]],
 {x, -1, 1}, {y, -1, 1}, PlotPoints -> 30];

Note that the plot generated by ContourPlot may not be an accurate representation of the function if the function is a slowly varying one.  If this is the case, the ContourSmoothing option, which controls how contour lines are found, can be used to render a more accurate plot.

ParametricPlot

ParametricPlot[{fx, fy}, {t, tmin, tmax}] produces a parametric plot with x and y coordinates fx and fy generated as a function of t.  An example appears below.

Clear[t]
ParametricPlot[{Cos[t]^3, Cos[t]^2 Sin[t]},
 {t, 0, 2Pi}];

ParametricPlot3D

ParametricPlot3D[{fx, fy, fz}, {t, tmin, tmax}] generates parametric plots in three-dimensional space.  Command arguments include a domain for t, and equations for x, y, and z, specified in terms of t.  In the following Input cell, we use another form of ParametricPlot3D to create the surface shown below.  In this case, the resulting three-dimensional surface has been parametrized by two variables, t and p.

Clear[t, p]
ParametricPlot3D[(3 Cos[t]^2 -1)^2 {Sin[t] Cos[p],
Sin[t] Sin[p], Cos[t]}, {t, 0, Pi}, {p, 0, 2Pi},
PlotPoints -> 30];

Graphics Primitives

In addition to plotting functions, Mathematica can be used to plot graphic objects such as rectangles, lines, and circles.  These objects are referred to as graphics primitives and represent the basic building blocks, or elements, of graphic images in Mathematica. 

Two functions, Graphics[primitives, options] and Graphics3D[primitives, options] can be used to create two- and three-dimensional graphic images through the specification of graphics primitives.  Graphics primitives that can be specified in the Graphics command include Circle, Disk, Line, Point, Polygon, Rectangle, and Text.  Primitives that can be specified in Graphics3D include Cuboid, Line, Point, Polygon, and Text.  Both commands feature a myriad of options that can be used to control various aspects of the graphic, such as the ratio of height to width.

In the following Input cell, we use Graphics to create a circle and Graphics3D to generate a cuboid.  Note that the Show command must be used to display each image.

Show[Graphics[Circle[{0,0}, .1]]];
Show[Graphics3D[Cuboid[{0, 0, 0}]]];

GraphicsArray

GraphicsArray[{g1, g2, ...}] can be used to create an array of plots or graphic objects.  As with Graphics and Graphics3D, Show must be used to display a GraphicsArray.  In the Input cell below, we use GraphicsArray to create an array that includes a circle, filled rectangle, and filled disk.

Show[GraphicsArray[{
	Graphics[Circle[{0,0}, .1]],
	Graphics[Rectangle[{0,0}, {1,1}]],
	Graphics[Disk[{0, 0}, .1]]
}]];

Show

The Show command can be used to 1) redraw a plot with new option specifications, 2) superimpose two or more plots on the same set of axes, and 3) draw the graphics generated by Graphics, Graphics3D, and GraphicsArray.  We have already used Show to draw output generated from the Graphics, Graphics3D, and GraphicsArray commands.  Below, we use Show to draw the plots of three functions on the same set of axes.

Clear[x, f, g, h, plot1, plot2, plot3]
f[x_] := 3x^2 - 5x + 2
g[x_] := Sin[x]
h[x_] := Cos[x]
plot1 = Plot[f[x], {x, -5, 5}, 
	PlotStyle -> {RGBColor[1, 0, 0]}];
plot2 = Plot[g[x], {x, -5, 5},
	PlotStyle -> {RGBColor[0, 0, 1]}];
plot3 = Plot[h[x], {x, -5, 5},
	PlotStyle -> {RGBColor[0, 1, 0]}];
Show[plot1, plot2, plot3];

Movies

Mathematica can be used to create "movies" or animations of sequences of graphical images.  To create an animation using the Notebook front end to Mathematica, 1) generate a sequence of graphics, 2) select the cells containing the graphics, 3) specify animation settings using the Animation command in the Graph menu, and 4) select Animate Selected Graphics from the Graph menu. 

To create an animation using front end versions of Mathematica that do not support the Notebook interface, first load the animation package called Graphics`Animation`. Use the Animate[plot, {t, tmin, tmax}] command from the package to generate a sequence of plots for values of t ranging from tmin to tmax and to animate the resulting sequence.  To produce an animation from a series of graphics objects, use the ShowAnimation[{g1, g2, ...}] command in the package.

In the Input cell below we create a series of three-dimensional plots using Table and Plot3D.  To create an animation of the resulting output, first select the cell group that includes all of the plots.  Specify the speed of animation by executing the Animation command from the Graph menu and specifying the number of frames per second.  Start the animation by selecting the Animate Selected Graphics command from the Graph menu.  To stop the animation, click the mouse button.

Clear[x, y, t]
Table[Plot3D[Sin[x y], {x, 0, t/2},{y, 0, t},
	PlotPoints -> 9, Ticks -> None],
	{t, 4, 6, 3/4}];

Lists ... 31

In Mathematica, a list is a collection of elements, separated by commas and enclosed in curly braces.  Many built in commands are set up to accept lists as function arguments and to act seperately on each element included in a list.  Thus, lists provide a mechanism for doing repetitive processing.  In addition, many commands use lists to represent the solutions they return. Finally, Mathematica uses lists to represent vectors and matrices.  Several list generation and manipulation commands will be described, including Table, ColumnForm, MatrixForm, ListPlot, and ListPlot3D.

Table

Table[expr, {i, imin, imax, di}, {j, jmin, jmax, dj, ...] generates a nested list whose elements are equal to the values of expr when i runs from imin to imax in steps of di, j runs from jmin to jmax in steps of dj, etc.  Table is useful for generating lists of values or formulas and for creating vectors and matrices.  For example, we can use Table to create a list called tsquare whose elements are the squares of the first fifteen natural numbers.

Clear[tsquare, n]
tsquare = Table[n^2, {n, 1, 15, 1}]

We can also use Table to create a list of lists.

Clear[i,j]
b = Table[i^2 - 4j, {i, 1, 4}, {j, 1, 4}]

ColumnForm

ColumnForm[{e1, e2, ... }] prints the specified list as a column with e1 above e2, etc.  For example, ColumnForm is used below to display the list named tsquare above as a column.

ColumnForm[tsquare]

MatrixForm

MatrixForm[list] displays the elements of list as a rectangular array.  For example, MatrixForm is used in the following Input cell to display the matrix b created above as a rectangular array.

MatrixForm[b]

ListPlot

ListPlot[{{x1, y1}, {x2, y2}, ...}] plots the list of ordered pairs (x1, y1), (x2, y2), etc.  Another form of ListPlot, ListPlot[{y1, y2, ...}], can be used to plot y1, y2, ... at x values 1, 2, etc.  In the example below, we use ListPlot to plot the first twenty prime numbers.  The PlotJoined -> True option is used to join the plotted points with lines.  Other options including Frame -> True, GridLines -> Automatic, PlotLabel -> "First 20 Primes", and PlotStyle -> {RGBColor{0, 0, 1)} are used to enhance the plot by adding an enclosing box, vertical and horizontal gridlines, a title, and color.

Clear[n]
ListPlot[Table[Prime[n], {n, 20}], 
	PlotStyle -> {RGBColor[0, 0, 1]},
	PlotJoined -> True,
	Frame -> True,
	GridLines -> Automatic,
	PlotLabel -> "First 20 Primes"
];

ListPlot3D

ListPlot3D[array] generates a three-dimensional surface from a rectangular array of heights.  In the following example, we use Table and the built in function Mod[m,n] to generate a list of remainders on division of m by n.  ListPlot3D is then used to plot the corresponding surface.

Clear[m, n]
ListPlot3D[Table[Mod[m,n], {m, 1, 20}, {n, 1, 20}]];

Matrices ... 35

In Mathematica, a matrix is represented as a list of lists.  For example, in the Input cell below, we create a three by three matrix and use MatrixForm to display it in traditional notation.  Note the use of the PostFix operator, //, to specify that the list to the left of // should be taken as the argument of MatrixForm.

{{1,2,3}, {2,3,0}, {2,-1,1}, {-2,2,0}}//MatrixForm

Matrix Arithmetic

Mathematica can be used to perform matrix addition, subtraction, and scalar multiplication.  In the following Input cell, we define two four by four matrices, a and b, and then compute a+b, a-b, and 2a.

Clear[a, b]
a = {{1,2,3,4}, {2,3,0,-5}, {2,-1,1,1}, {-2,2,0,-5}}
b = {{1,0,1,0}, {0,0,2,4}, {5,6,7,8}, {10,3,1,0}}
MatrixForm[a + b]
MatrixForm[a - b]
MatrixForm[2 a]

The product between two matrices can be computed by using the dot operator (.).  Below we compute the product between a two by two matrix and a two by one column vector.

Clear[a, b, c, d, x, y]
{{a, b}, {c, d}} . {x, y}

Note how changing the order of the two lists causes the vector to be treated as a row vector instead of as a column vector.

Clear[a, b, c, d, x, y]
{x, y} . {{a, b}, {c, d}}

IdentityMatrix

The IdentityMatrix[n] command can be used to create an Identity matrix of order n.  Below, we use this command to create a five by five Identity matrix.

IdentityMatrix[5]//MatrixForm

DiagonalMatrix

The DiagonalMatrix[list] command can be used to create a diagonal matrix with the elements of list on the leading diagonal and zero elsewhere.

Clear[a, b, c]
DiagonalMatrix[{a, b, c}]//MatrixForm

Transpose

Transpose[list]  will interchange the rows and columns of list.

Clear[a, b, c, d]
Transpose[{{a, b}, {c, d}}]//MatrixForm

Inverse

Inverse[m] computes the inverse of the square matrix m.  Below, we compute the inverse of a two by two matrix.

Clear[a, b, c, d]
Inverse[{{a,b}, {c,d}}]//MatrixForm

Det

Det[m] computes the determinant of the square matrix m.

Clear[a, b, c, d]
Det[{{a, b}, {c, d}}]

Minors

Minors[m, k] generates a matrix composed of the determinants of all k x k submatrices of m.  For example, below we use Table to create a six by six matrix we name m and then use Minors to compute the matrix of all 2x2 minors of m.

Clear[m, i, j]
m = Table[Exp[i j], {i, 3}, {j, 3}]
Minors[m, 2]//MatrixForm

LinearSolve

LinearSolve[m, b] computes the vector x which solves the matrix equation m . x == b.  Note that m can be a square or a rectangular matrix and that LinearSolve can be used on both numerical and symbolic matrices.  In the example below, we define a two by two matrix m and then use it to generate two linear equations.  Finally we use LinearSolve to compute the vector of solutions to the set of linear equations.

Clear[m, x, y, a, b]
m = {{1, 5}, {2, 1}}
m . {x, y} == {a, b}
LinearSolve[m, {a, b}]

RowReduce

RowReduce[m] computes the row-reduced form of the matrix m.

Eigensystem

Eigensystem[m] returns a list whose first element is a list of eigenvalues and whose second element is a list eigenvectors for the square matrix m.  For example, in the Input cell below we define a matrix m and then use Eigensystem to compute the eigenvalues and eigenvectors for m.

Clear[m]
m = {{1, 1, 2}, {1, 2, 1}, {2, 1, 1}}
Eigensystem[m]

Special Operators ... 40

Mathematica features many special operators, some of which are listed in the table below.  A brief description and usage example for each one will be presented.

Operator																												Analogous Command 
	
/.                             	ReplaceAll
/;                            	Condition
//.                           	ReplaceRepeated
->                             	Rule
:>                             	RuleDelayed
!                               Not
&&                           		And
||                              Or
Xor                           	Xor
<<                            		Get
>>                            		Put

ReplaceAll Operator

The ReplaceAll operator (/.) provides a mechanism for applyng one or more transformation rules to an expression.  For example, in the following Input cell we apply the transformation rules 10y -> 3 and y -> 7 to the expression 10y - y.  Note that the transformation rules are not applied until after the expression has been evaluted.

Clear[y]
10y - y /. {10y -> 3, y -> 7}

As another example, we use the "slash-dot" operator to apply a list of rules to the same expression.

Clear[x, y]
x - y /. {x -> 1, y -> 3}

Finally, by specifying a list of lists of rules, we obtain a list of results.

Clear[x, y]
x - y /. {{x -> 3, y -> 4}, {x -> 7, y -> 6}}

Condition Operator

The Condition operator (/;), pronounced "slash-semi", "whenever", or "provided that", is used to 1) place constraints on classes of expressions, 2) conditionally apply rules, and 3) conditionally apply definitions. For example, to define a function f(x) such that f(x)  equals  1 + x2 if x is greater than or equal to 0, but less than or equal to 2, or f(x) equals 1 - x if x is greater than 2 but less than or equal to 5, we use the following Input statement.

Clear[f, x]
f[x_] := 1 + x^2 /; 0 <= x <= 2
f[x_] := 1 - x /; 2 < x <= 5

ReplaceRepeated

The ReplaceRepeated Operator (//.) is used to repeatedly apply the specified rule or rules to the expression until the expression no longer changes.  For example, note how it requires two iterations of applying the transformation rules x -> 2 + a and a -> 3 to the expression x2 + y6 before the expression no longer changes.

Clear[x, y, a]
x^2 + y^6 //. {x -> 2 + a, a -> 3}

Rules

In Mathematica the Rule operator (->) provides a mechanism for defining transformation rules for variables in expressions.  In addition, many functions such as Solve return lists whose elements are lists of transformation rules representing solutions.  ReplaceAll and ReplaceRepeated can be used in conjuntion with Rule to apply the transformation rule or rules to the specified expression.

In the Input cell below, we use Rule to define the transformation rule log[x_ y_] -> log[x] + log[y].  ReplaceRepeated is used to repeatedly apply the transformation rule to the expression Log[a b c d e].

Clear[x, y, a, b, c, d, e]
log[a b c d e] //. log[x_ y_] -> log[x] + log[y]

RuleDelayed

The RuleDelayed operator (:>) is used to define a delayed rule lhs :> rhs.  A delayed rule is a rule such that rhs is evaluated only when the rule is applied.  For example in the expression below, the rule x -> Random[ ] is applied three times and hence, Random[ ] is evaluated three times.  Note that if the Rule operator (->) had been used instead, the right-hand side of the rule x -> Random[ ] would only be evaluated once.

Clear[x]
Table[x, {3}] /. x :> Random[ ]

Logical Not

The logical Not function is represented as !expr.  It returns False if expr is True, and True if it is False.  In the example below, 2 is not equal to 3, so 2 !=  3 is True.

2 != 3

Logical And

The logical And function is represented as e1 && e2.  Arguments are evaluated from left to right and a False is returned if any are not True.  For example, in the following Input cell, since the first argument is False, Mathematica returns a False.

5 < 3 && 2 != 3

Logical Or

The logical Or function, represented as e1 || e2 || ..., evaluates arguments from left to right and returns a True if any of the arguments are True, and a False if all arguments are False.  In the Input cell below, Mathematica returns a True since the second argument is True.

5 < 3 || 2 != 3

Exclusive Or

The exclusive Or function, represented as Xor[e1,e2, ...], evaluates to True if an odd number of the ei are True, and the rest are False.  It returns a False if an even number of the ei are True, and the remaining are False.  For example, in the Input cell below, since the first three arguments are True, Mathematica returns True.

Xor[5 < 6, 6 < 7, 7 < 8, 1 > 2]

Get

A file or package can be loaded with the Get operator (<<) by specifying the appropriate directory and name for the file or package.  For example, on a Macintosh system << is used below to load the package named VectorAnalysis.m found in the Calculus folder inside the Packages folder.

<<Calculus`VectorAnalysis`<< Calculus`VectorAnalysis`

Put

Information can be written to a file by using the Put command or operator (>>).    In the example below, we use Table to generate a list of squares of the first twenty natural numbers, indexed by values of n and then use the Put operator to write the list of data points to a file named data.m.

Clear[n]
Table[{n, n^2}, {n, 1, 20}] >> data.m

Packages ... 44

Although Mathematica features over 700 built-in functions, there are times when additional functionality is required.  Mathematica provides users the ability to add functionality to the program through development of files called packages.  Packages are files intended to be used as Mathematica input.  They consist of function definitions and are written in the Mathematica programming language.  The standard packages (those distributed with the software) span such areas as algebra, calculus, discrete mathematics, geometry, graphics, linear algebra, number theory, numerical mathematics, and statistics.

Prior to using a function defined in a package, the package must be read into Mathematica.  Packages can be loaded on all platforms using the following command:

Needs["Context`"]

where the argument of Needs is a context name or list of contexts.  A context name is a string ending in a back quote and consisting of the names of the directories or folders where the package resides, concatenated with the root name of the package (that is the package name excluding the suffix .m).  For example, the package named Graphics.m, located in the Graphics folder in the Packages folder, includes functions for creating graphics such as bar and pie charts.  In the following Input cell, we load Graphics.m and then use the BarChart[ ] function to create a bar chart of the number of packages, classified by area, that are distributed with Mathematica 2.0.

Needs["Graphics`Graphics`"]
BarChart[{
        {5, "Alg."},
        {7, "Cal."},
        {8, "Dis."},
        {3, "Geo."},
        {19, "Grp."},
        {7, "Lin."},
        {8, "NumT."},
        {11, "NumM."},
        {12, "Stat."}
}];

Note that if you mistakenly refer to a function that is defined in a package prior to loading the package, you will need to execute the command Remove["name"] to delete the function before loading the package which defines it. 

Appearing below are descriptions of some of the packages supplied with Mathematica that deal with Algebra, Calculus, Graphics, and Linear Algebra.

Extending Mathematica's Algebraic Functionality

CountRoots.m

CountRoots.m can be used to compute the number of roots of a real polynomial in a given interval.

PolynomialMod.m

PolynomialMod.m extends to primes larger than 216 the built-in polynomial functions Factor, FactorList, and PolynomialTGCD.

ReIm.m

The package named ReIm.m defines simplification rules for built-in functions such as Re[ ] and Im[ ].  Routines in this package provide a mechanism for declaring variables real.

SymbolicSum.m

SymbolicSum.m provides a mechanism for evaluating symbolic sums of the type

 Sum[ a[k], {k, min, max}], 
 
 where a[k+1]/a[k] is a rational function.

Trigonometry.m

The package named Trigonometry.m provides routines for performing trigonometric simplifications.

Extending Mathematica's Calculus Functionality

DiracDelta.m

DiracDelta.m defines the function UnitStep (which may be used to  represent piecewise continuous functions) and its generalized derivative DiracDelta (which may be used to represent ideal distributions in problems in physics and engineering).

DSolve.m

DSolve.m extends the capabilities of Mathematica's built-in DSolve function.

EllipticIntegrate.m

EllipticIntegrate.m extends the capabilities of the built-in Integrate function to handle elliptic integrals and their analogs written in algebraic, trigonometric or hyperbolic form.

FourierTransform.m

FourierTransform.m can be used to compute the analytic Fourier transform and Fourier series of functions.

LaplaceTransform

LaplaceTransform.m implements the Laplace transform.

Limit.m

Limit.m allows you to find limits of expressions that contain a wide class of elementary and special functions.

Pade.m

Pade.m computes Pade approximations and economized rational approximations.

PDSolve1.m

PDSolve1.m enables the DSolve function to handle first-order PDEs.

VariationalMethods

VariationalMethods.m provides functions for computing first variational derivatives, Euler equations, and first integrals.

VectorAnalysis.m

VectorAnalysis.m provides routines for performing standard vector differential operations in orthogonal coordinate systems.  It also provides functions for generating coordinate transformations.

Extending Mathematica's Graphics Functionality

Animation.m

Animation.m provides tools for generating sequences of graphical images and displaying them on a variety of computer platforms.

ArgColors.m

ArgColors.m allows you to specify the color or gray level of graphics elements using the argument of a complex number.

Arrow.m

Arrow.m implements a new graphics primitive to generate arrows that can maintain their aspect ratio.

Colors.m

Colors.m gives color directives using the cyan-magenta-yellow, NTSC video form, and hue-lightness-saturation systems.

ComplexMap.m

ComplexMap.m includes functions for plotting the image of coordinate lines in the complex plane.

ContourPlot3D.m

ContourPlot3D.m includes functions for making three-dimensional contour plots.

FilledPlot.m

The package named FilledPlot.m provides a mechanism for generating plots with fills between curves of functions.

Graphics.m

Graphics.m includes definitions for graphic functions not built into Mathematica such as log plot, bar chart and pie chart functions.

Graphics3D.m

The package named Graphics3D.m includes routines for creating graphs, such as scattor plots and bar charts, in three dimensions.

ImplicitPlot.m

ImplicitPlot.m provides a mechanism for creating sketches of figures defined by equations (such as circles and ellipses).

Legend.m

The package named Legend.m can be used to draw a legend box on a graphic.  Many options are available for customizing legend characteristics such as placement, size, and orientation.

MultipleListPlot.m

MultipleListPlot.m enables you to plot several lists on the same set of axes, each with a different style of plotting symbol.

ParametricPlot3D.m

ParametricPlot3D.m allows you to specify the size of the polynomial grid used in ParametricPlot3D.

PlotField.m

Plotfield.m can be used to generate plots of vector fields in a plane, including gradient and Hamiltonian vector fields.

PlotField3D.m

The package named PlotField3D.m includes routines for plotting vector fields in three dimensional space.

Polyhedra.m

Polyhedra.m contains the graphics primitives necessary for rendering Platonic solids and nonconvex polyhedra that have faces and vertices all of the same type.

Shapes.m

Shapes.m provides functions for generating and manipulating graphs of geometric objects such as cylinders, cones, and spheres.

Spline.m

Spline.m takes the functions from the SplineFit.m package and adapts them to a graphics primitive.

SurfaceOfRevolution.m

The package named SurfaceOfRevolution.m can be used to plot the surface of revolution of a two dimensional curve.

ThreeScript.m

ThreeScript.m supplies utilities for writing Mathematica objects into 3-Script files.

Extending Mathematica's Linear Algebra Functionality

Cholesky.m

Cholesky.m provides a function for computing the Cholesky decompostion of a symmetric, positive, definite matrix.

CrossProduct.m

CrossProduct.m includes a function for computing vector cross products and contains identities for vector cross products and dot products.

GaussianElimination.m

GaussianElimination.m provides functions for solving a linear system using Gaussian elimination and back substitution.

MatrixManipulation.m

MatrixManipulation.m features matrix manipulation routines for creating matrices from block elements and extracting subblocks from a matrix.

Orthogonalization.m

Orthogonalization.m includes functions for generating an orthonormal set from a given list of real vectors, normalizing a vector, and giving the orthogonal projection of one vector onto another vector.

Tridiagonal.m

Tridiagonal.m provides a function for solving matrix equations with tridiagonal matrices.

Menu Items (Macintosh Version) ... 50

File Menu

The File menu in the Macintosh Front End provides commands for creating, saving, retrieving,  and printing Notebooks.  Following are brief descriptions of each of these commands.

Creating New Notebooks

To create a new Notebook, choose New from the File menu.  An empty, untitled Notebook will appear on the screen.  If you begin to type, without specifying a cell style, Mathematica will automatically create an Input cell to hold the information you enter.

Opening Existing Notebooks

To retrieve an existing Notebook, choose Open from the File menu.  From the dialog box that is presented, select the drive, folder, and filename of the Notebook you wish to open.  You can have multiple Notebook windows open concurrently and you can copy or move information from one Notebook to another.

The File Open command can also be used to retrieve files saved in ASCII, PICT, PICS and EPSF formats.  The information contained in the file being retrieved will be translated into a  Mathematica Notebook comprised of one or more cells, with the style of each cell being  determined by the format of the incoming file.

Closing Notebooks

To close the current Notebook, choose Close from the File menu.  Mathematica will give you an opportunity to save the current Notebook if it has not yet been saved.

Saving Notebooks

To save a new Notebook, chooseSave from the File menu.  A dialog box will prompt you to specify a name for the Notebook as well as the destination drive and folder where the Notebook should be saved.  The File Save command can also be used to replace an existing Notebook with the revised edition that is currently in memory.  To save the revised edition without replacing the original version, choose Save As from the File menu.  The Save As command can be used to save the current Notebook under a new name or in a new location.

Printing Notebooks

To print one or more copies of all or part of the current Notebook, select Print from the File menu.  The Notebook will print on the printer you have specified in the Chooser desk accessory found in the Apple menu.  To define headers and footers and to specify margin settings, orientation mode, and other page setup and printing options, select Printing Settings from the File menu.

Ending a Mathematica Session

To end a Mathematica session, select Quit from the File menu.  Mathematica will give you an opportunity to save the current Notebook if it has not yet been saved.

Edit Menu

The Edit menu contains commands for 1) moving, copying, and deleting material in the Notebook, 2) identifying incorrectly nested formulas, and 3) adjusting global defaults and preferences settings.  The following sub-subsections describe how to use each of these commands.

Moving Information

To delete material from a Notebook and transfer it to the Clipboard so that it can later be inserted elsewhere in the Notebook, select the material (text, graphics, cells, etc.) to be deleted and choose Cut from the Edit menu.  Once the material has been transferred to the Clipboard it can be inserted elsewhere in the Notebook by using the Paste command from the Edit menu.

Duplicating Information

To transfer material from the Notebook to the Clipboard without deleting it from the Notebook, select the material and choose Copy from the Edit menu.  Once the material has been copied to the Clipboard it can be inserted elsewhere in the Notebook by using the Paste command from the Edit menu.  Note that to copy the structure of a cell as well as its content to the Clipboard, the cell's bracket must be selected prior to issuing the Copy command.

Inserting Information

To place a copy of the material that has been cut or copied to the Clipboard into the Notebook, position the insertion point at the location where the material should be inserted and select Paste from the Edit menu.  Note that material can either be inserted into an existing unformatted cell (by positioning the text (vertical I-bar) insertion point) or into a new cell (by positioning the cell (horizontal I-bar) insertion point).  Also note that graphics can only be inserted at cell insertion points (and not text insertion points).

Deleting Information

To erase material from the Notebook without placing it on the Clipboard, select the material and choose Clear from the Edit menu.

Entering Nested Mathematica Formulas

The Nesting commands available in the Edit menu can be used to enter correctly nested Mathematica formulas and to identify those that are incorrectly nested.

To check the structure of Mathematica input, position the insertion point within the expression and choose Balance from the Nesting submenu.  If the expression has unbalanced parantheses, or parantheses, brackets, or braces that are incorrectly mixed, Mathematica will beep and position the text insertion point at the location of the error.

To enclose selected text within parentheses, brackets, or braces, choose Parenthesize, Bracketize, or List Bracketize respectively from the Nesting submenu.

To remove parentheses, brackets, or braces from selected text, choose Unparenthesize from the Nesting submenu.

To  aid in documenting the nesting structure of an expression, use the Indent Left and Indent Right commands in the Nesting submenu.  These commands shift selected text one tab width to the left or right respectively.

Setting Defaults and Preferences

The Preferences submenu lists commands for adjusting global defaults and preferences settings.

To modify the settings used for on-screen display of Notebooks (for example to toggle between displaying and not displaying a dialog box for all errors), select Display from the Preferences submenu.

To control how graphs are displayed and printed, select Graphics from the Preferences submenu.  

To control what occurs while Mathematica is computing a result, choose Action from the Preferences submenu.  For example, use this menu to have Mathematica display a clock timing after each evaluation or to request that Mathematica beep when a kernel message is generated.

To specify the location of the Defaults Notebook file and Help file, select File Locations from the Preferences submenu.  These files contain styles that are copied to each new Notebook and Help messages for the Front End.

Cell Menu

The Cell menu includes commands that enable you to divide, merge, group, and ungroup cells.  The Cell menu also includes commands that let you concurrently open or close all subgroups in a Notebook.

Dividing Cells

The Divide Cell command can be used to divide a cell into two or three cells.  To divide a cell so that everything before the text insertion point is included in the first cell and everything after the insertion point is in the second cell, position the insertion point where you want the split to occur and choose Divide Cell from the Cell menu.

Alternatively, to split one cell into three cells (where the first cell contains all material preceding the selected text, the second cell contains only the selected text and the third cell contains all material appearing after the selected text), highlight the text that should be placed in the second cell and choose Divide Cell from the Cell menu.

Merging Cells

To combine two or more cells into one cell, highlight the brackets of the cells to be combined and choose Merge Cells from the Cell menu.

Grouping and Ungrouping Cells

Mathematica automatically groups cells depending upon their styles.  The Automatic Grouping feature can be turned off by choosing Automatic Grouping from the Cell menu.  Once this feature has been turned off, you can change cell grouping manually by using commands in the Cell menu.  To group a range of cells manually, highlight the brackets of the contiguous cells you wish to group and select Group Cells from the Cell menu.  The selected cells will be enclosed in a grouping bracket.  Note that there is no limit to the number grouping levels possible in a Notebook.  To undo a cell group, highlight the grouping bracket for the group to be undone and choose Ungroup Cells from the Cell menu.

Opening and Closing Multilevel Cell Groups

To open all cells in multiple closed cell groups (identified by solid triangles at the bottom of the grouping brackets), select the closed group brackets and choose Open All Subgroups from the Cell menu.  All levels of the selected groups will open.  Similarly, to close all levels of selected groups, choose Close All Subgroups from the Cell menu. Since a closed group will display the first cell in the group, closing groups is useful for collapsing notebooks into outline form.  Note that a single group can be opened or closed by alternately double-clicking on  its grouping bracket.

Graph Menu

The Graph menu includes commands for converting graphics in a Notebook from one format to another including PICT, Bitmap PICT, and PostScript.  Note that the converted form of the graphic will replace the original form in the Notebook.

Converting to PICT, Bitmap PICT and PostScript

Graphics can be converted into different formats depending upon the level of visual quality desired and on the amount of disk space available.  PICT and Bitmap PICT formats are more compact than PostScript, but do not provide the same level of resolution when printed or resized.  Graphics saved in PostScript format can also be edited.   If you will never need to print or resize a graphic, converting the graphic to Bitmap PICT can result in appreciable disk storage savings. To convert a graphic to PICT, Bitmap PICT, or PostScript format, highlight the cell bracket surrounding the graphic and select either Convert to PICT, Convert to Bitmap PICT, or Convert to PostScript from the Graph menu.

Find Menu

The Find menu includes commands that can be used to locate and optionally replace text according to criteria you specify.

Searching for Text

Use the Find command in the Find menu to locate text strings or cell characteristics (including attributes, keywords, and style).  The search will begin at the position where the text insertion point is located.  You can ask Mathematica to stop the search after the first match or to search the entire document for all matches.  If you request that all matches be found, the result of the search will include only entire cells rather than individual text ranges. You can also find the next occurence of the search string by choosing Find Again from the Find menu.

Replacing Text

Three commands in the Find menu provide a mechanism for replacing text with text you specify in the Replace with field of the dialog box for the Find command.  Select the Replace command to overwrite the selected text range that is the result of the last Find request.  Choose Replace and Find Again to not only replace the selected text, but to also find the next occurrence of the string.   Finally, use Replace All to replace all occurences of the search text from the current selection to the end of the file.  Note that if the Wrap around option is on in the Find dialog box, Mathematica will "wrap around" from the end of the document to the beginning of the Notebook and replace matches that occur above, as well as below, the current selection.

Action Menu

Simplifying the Creation of Input

The Prepare Input submenu of the Action menu includes commands which help to minimize the time required to create input and minimize the possibility of making typographical errors.  There are also commands for rotating graphs and recording sounds.

Use the Copy Input from Above  command to copy the immediately preceding input to the location currently marked by the text or cell insertion point.  Once the input has been copied, it can be edited and submitted to the Kernel.  The Copy Output from Above command works similarly except that it copies the immediately preceding output.  These commands serve as an aid in creating new input that varies only slightly from existing input or output. 

Use the Complete Selection command to have Mathematica complete the name of a partially entered built-in or user-defined command, function, or variable.  If there is only one match that completes the currently selected text range, then Mathematica will replace the selection with the match.  If there are several names that begin with the selected text, Mathematica will display a menu of possible matches, and you can choose the appropriate match by highlighting it and pressing Shift-Return.  Note that the keyboard equivalent for the Complete Selection command is Command-k.

If you would like Mathematica to create a template which includes the syntax and commonly used arguments of the currently highlighted function name, choose Make Template from the Prepare Input submenu.  Once Mathematica has created the template, you can individually select arguments and replace them with their appropriate values.

The 3D ViewPoint Selector command provides a dialog box that can be used to select the Cartesian viewpoint coordinates for 3-dimensional graphs.  Once the coordinates have been specified in the dialog box, they can be pasted (by clicking on the Paste button) at the location marked by the text insertion point in the current input line.

The Color Selector command provides a mechanism for choosing colors of graphical objects without having to figure out the RGBColor settings.  The Color Selector command features a dialog box that can be used to select a color and then paste the RGBColor command into the input line currently marked by the text insertion point.

Creating and Controlling Kernel Connections

To create, configure, launch, abort, interrupt, or quit a kernel connection, choose Kernels and Tasks from the Action menu.

Evaluating a Notebook

To select and evaluate all active cells in the current Notebook, choose Evaluate Notebook from the Action menu.  This command is especially useful for recalculating a final result that depends on output generating by computing all preceding input cells.

Evaluating Initialization Cells

In Mathematica, cells can be created that contain definitions of Mathematica functions.  Subsequent cells may contain expressions that use these definitions to produce output.  Often it is desirable to declare the cells that contain the definitions as initialization cells and to configure Mathematica so that the initialization cells are automatically evaluated whenever a Notebook is opened.  If, however, automatic evaluation has been suppressed, you can still have Mathematica  evaluate initialization cells by choosing Evaluate Initialization from the Action menu.

Interrupting Calculations

To completely abort a calculation, select Interrupt Calculation from the Action menu and click the Abort button.  Alternatively, choose Abort Calculation from the Action menu.  Note that the Interrupt Calculation command can also be used to momentarily stop the current computation so that you can check the state of the Kernel or send other evaluations to the Kernel before resuming the original computation.

Style Menu

Applying Cell Styles

The Cell Style submenu of the Style menu provides a complete list of available cell styles.  To apply a style, either select the style prior to typing information into a new cell, or after selecting the cell bracket of an existing cell.  Alternatively, keyboard equivalent commands can be used to apply the most frequently used styles

Assigning Attributes to Cells

The Attributes submenu of the Style menu lists cell attributes that can be applied to cells.  Each of these attribute commands acts as a toggle switch (if a check appears beside the command, then the attribute has been applied to the currently selected cell).  Note that cell attributes can be applied to entire cells only. 

To apply an attribute to a cell, highlight the bracket of the cell that you want to apply the attribute to (or place a text insertion point within the cell) and select the attribute from the Attribute submenu.

Following is a list of available cell attributes and a brief description of their use:

1) Formatted versus Unformatted Cells:  The formatted attribute is usually applied to cells containing Mathematica output.  Formatted cells can not be edited.  Cells containing text and Mathematica input are typically unformatted. 

2) Active versus Inactive Cells:  Active cells are cells that can be evaluated by the Kernel.  Cells that are inactive are ignored by the Kernel.

3) Initialization Cells:  Initialization cells are cells that can be evaluated automatically as soon as a Notebook is opened.

4) Locked Cells:  Locked cells are cells that can not be deleted or modified.

5) Closed Cells:  A closed cell is a cell that has been collapsed so that the content of the cell is no longer visible.  Note that a closed cell can only be opened by selecting the Closed command from the Attributes submenu.

6) Fixed Height Cells:  Fixed height cells are cells whose heighth can be manually adjusted.  Assigning this attribute to a cell is useful if you wish to decrease the size of a large cell.

7) Scroll Horizontally:  This attribute is useful if a cell contains information that is too wide to fit on the screen (for example a wide graphic cell or a long formula that has been entered on one line).

8) Box around Cell:  The Box around Cell attribute can be used to add emphasis to a particular cell in the Notebook (such as a Title cell or a cell containing a major result).

Assigning Fonts

The Font submenu of the Style menu lists all fonts installed in the System file stored in your System folder.  Fonts may be  applied to text ranges or to entire cells.  Note that text included in Kernel output must be formatted with a monospaced font, such as Courier, to be displayed correctly.

Assigning Typefaces

The Face submenu of the Style menu lists nine typefaces (Plain, Bold, Italic, Underline, Outline, Shadow, Superscript, Subscript, and Overstrike) that can be applied to some or all of the text in a cell depending upon whether a text range or cell bracket is highlighted.  Note that selecting the Plain typeface turns all other typefaces off.  Also note that multiple typefaces can be applied to the same piece of text.

Assigning Type Sizes

The Size submenu of the Style menu lists type sizes that can be applied to selected text.  The sizes appearing in the outline typeface are those that will look best on your screen.  The Size submenu also includes commands (Larger and Smaller) for changing the size of selected text one point at a time and for specifying a size not listed in the menu (Custom Size).

Applying Color to Text

The Text Color submenu of the Style menu lists colors that can be applied to selected text ranges or to all text in cells whose brackets are currently highlighted.  In addition, the Text Color submenu lists a series of Special commands that can be used to assign colors from the Macintosh color wheel to selected text.  There is also a Cell Bracket command that can be used to assign a color from the Macintosh color wheel to all cell brackets in the current Notebook.

Applying Color to the Background of Cells

The Background Color submenu of the Style menu lists the same commands that are found in the Text Color submenu.  A color chosen from this submenu is applied to the background of the cell whose bracket is currently selected.  If the Cell Bracket command is used to select a color from the Macintosh color wheel, the color chosen is applied to the bracket and background of the selected cell.  

The Background Color submenu also features a Gray Box command that can be used to draw a box around a cell and to color the background of the cell to various shades of gray.

Controlling Page Breaks

The Page Breaks submenu of the Style menu provides commands for forcing or suppressing a page break above or below the selected cell.  Use the Break above Cell and Break below Cell commands to force a page break above or below the selected cell.  Use the No Break above Cell and No Break below Cell commands to suppress page breaks around the selected cell.

There are also commands in this submenu for preventing page breaks within a cell or cell group (to the extent that the cell or cell group can fit on one printed page).  Note that the Show Page Breaks command in the Printing Settings submenu of the File menu is useful for displaying page breaks on the screen.

Controlling Cell Margins

The Style menu includes a Show Ruler command that can be used to display a ruler across the top of the Notebook window.  The ruler features two triangular markers that can be used to control the left and right margins of the selected cell.  Margin settings can be changed by dragging the markers along the ruler.

Editing Cell Styles

Predefined cell styles can be modified and entirely new styles can be created by using the Edit Styles command in the Style menu.  Once a style is changed, the modifications will automatically be applied to cells in the Notebook which exhibit that style.  Note that attributes that have been applied locally (by using the Attributes command in the Style menu) are not overridden by cell style settings.  

To modify an existing style, 1) access the Styles dialog box by selecting the Edit Styles command from the Style menu, 2) highlight the cell bracket corresponding to the style you wish to edit, 3)  use the Attributes command in the Style menu to modify the attributes settings, and 4) close the dialog box to apply the changes to the cells that have been assigned that style.  Note that style changes are saved when you save the Notebook and that style sheets associated with one Notebook are not tied to (do not affect) other Notebooks.

Restoring Styles to their Original Settings

To restore cell styles that have been modified via the Styles dialog box, select the All Default Styles command from the Style menu.  This command will restore all styles to their original settings and will automatically apply the changes to the appropriate cells in the Notebook.

Window Menu

The Window menu provides commands for organizing your open Mathematica windows on the screen.  In addition, a listing of titles of open windows appears at the bottom of the menu.   You can use this listing to select the title of the window you wish to make current.

Stacking Windows

Use the Stack Windows command in theWindows menu to make all open windows the same size and to overlap them on the screen such that the window title bars remain visible.   In this arrangement, you can bring a window to the front of the stack by clicking on  its title bar.  Note that the size of the windows will be determined by the size of the monitor screen being used.

Tiling Windows

Two commands provide a means of arranging all open windows into side-by-side rectangles of equal size.  Use the Tile Windows Tall command to choose a tall and narrow shape for the tiled windows and the Tile Windows Wide command to choose a short and wide shape.

Help Menu

The Help menu includes commands for listing Mathematica functions and keyboard shortcuts for Mathematica commands.  This menu also provides access to an on-line Mathematica tutorial.

Using Mathematica Functions and Packages

The Open Function Browser command lists, by category, the names of built-in functions and standard packages.  You can use this command to view the description, syntax, and options of a built-in function, to evaluate a function, or to paste a function into a cell.  You can also use this command to view a description of a standard package, load a package, and access functions in a loaded package.

To obtain information (syntax, options, description) about a function name you have selected in your Notebook, choose Find in Function Browser from the Help menu.

Troubleshooting Problems

To view an explanation of why Mathematica beeped at you, select Why the Beep? from the Help menu.

Getting Started with Mathematica

To view an introduction to some of the basic features of Mathematica, choose Getting Started from the Help menu.

Getting Help on Menu Commands

To view a description of a menu command, select Help Pointer from the Help menu and then select the command of interest.  To view a summary of keyboard shortcuts for Mathematica commands, select Shortcuts from the Help menu.

Magnification Menu

The Magnification menu, located at the bottom of the Notebook window, is useful for enlarging or reducing the magnification of the Notebook's contents while keeping the window the same size.  The pop-up menu lists preset magnification values and an Other command that can be used to specify a magnification that is not listed.  In addition, the pop-up includes a Fit command that is useful for previewing the page layout that will be used when the Notebook is printed.

Menu Items (Windows Version) ... 60

File Menu

The File menu in the Windows Front End provides commands for creating, saving, retrieving, and printing Notebooks.  Following are brief descriptions of each of these commands.

Creating New Notebooks

To create a new Notebook, choose New from the File menu.  An empty, untitled Notebook will appear on the screen.  If you begin to type, without specifying a cell style, Mathematica will automatically create an Input cell to hold the information you enter.

Opening Existing Notebooks

To retrieve an existing Notebook, choose Open/Import from the File menu.  From the dialog box that is presented, select the drive, directory, and filename of the Notebook you wish to open.  You can have multiple Notebook windows open concurrently and you can copy or move information from one Notebook to another.

The File Open/Import command can also be used to retrieve files saved in other file formats including ASCII, Bitmap, and Metafile formats.  The information contained in the file being retrieved will be translated into a  Mathematica Notebook comprised of one cell, with the style of the cell being determined by the format of the incoming file.

Closing Notebooks

To close the current Notebook, choose Close from the File menu.  Mathematica will give you an opportunity to save the current Notebook if it has not yet been saved.

Saving Notebooks

To save a new Notebook, choose Save from the File menu.  A dialog box will prompt you to specify a name for the Notebook as well as the destination drive and directory where the Notebook should be saved.  The File Save command can also be used to replace an existing Notebook with the revised edition that is currently in memory.  To save the revised edition without replacing the original version, choose Save As/Export from the File menu.  The Save As/Export command can be used to save the current Notebook under a new name or in a new location.

Printing Notebooks

To print one or more copies of all or part of the current Notebook, select Print from the File menu.  To specify the printer to which your Notebook is sent, as well as the paper size and orientation mode to be used, click Setup from the Print dialog box.  To define headers and footers and to specify margin settings and other printing options, select Printing Options from the Options menu.

Ending a Mathematica Session

To end a Mathematica session, select Exit from the File menu.  Mathematica will give you an opportunity to save the current Notebook if it has not yet been saved.

Edit Menu

The Edit menu contains commands for moving, copying, searching for, and deleting material in the Notebook.  The following sub-subsections describe how to use each of these commands.

Moving Information

To delete material from a Notebook and transfer it to the Clipboard so that it can later optionally be inserted elsewhere in the Notebook, select the material (text, graphics, or cells) to be deleted and choose Cut from the Edit menu.  Once the material has been transferred to the Clipboard it can be inserted elsewhere in the Notebook by using the Paste command from the Edit menu.

Duplicating Information

To transfer material from the Notebook to the Clipboard without deleting it from the Notebook, select the material and choose Copy from the Edit menu.  Once the material has been copied to the Clipboard it can be inserted elsewhere in the Notebook by using the Paste command from the Edit menu.

Inserting Information

To place a copy of the material that has been cut or copied to the Clipboard into the Notebook, position the insertion point at the location where the material should be inserted and select Paste from the Edit menu.  Note that material can either be inserted into an existing cell or into a new cell (by positioning the cell (horizontal I-bar) insertion point).  Also note that graphics can only be pasted between cells and not into existing cells.

Searching for Text

The Find command in the Edit menu enables you to search the current Notebook for the text you specify.  You can specify the direction of the search and whether or not to match the case of the characters being searched for.

The Find and Replace command in the Edit menu lets you search the current Notebook for text you specify and then, optionally, replace the found text with text you specify.

Deleting Information

To erase material from the Notebook without placing it on the Clipboard, select the material and choose Clear from the Edit menu.  You can also delete pieces of text within a cell by selecting the text and pressing the Del key.

Cell Menu

The Cell menu includes commands that enable you to divide, merge, group and ungroup cells, and concurrently open or close all subgroups in a Notebook.  The Cell menu also includes commands that let you assign attributes to cells and control where page breaks should occur.

Dividing Cells

The Divide Cell command can be used to divide a cell into two or three cells.  To divide a cell so that everything before the text insertion point is included in the first cell and everything after the insertion point is in the second cell, position the insertion point where you want the split to occur and choose Divide Cell from the Cell menu.

Alternatively, to split one cell into three cells (where the first cell contains all material preceding the selected text, the second cell contains only the selected text and the third cell contains all material appearing after the selected text), highlight the text that should be placed in the second cell and choose Divide Cell from the Cell menu.

Merging Cells

To combine two or more cells into one cell, highlight the brackets of the cells to be combined and choose Merge Cells from the Cell menu.

Grouping and Ungrouping Cells

To group a range of cells, highlight the brackets of the contiguous cells you wish to group and select Group Cells from the Cell menu.  The selected cells will be enclosed in a grouping bracket.  Note that there is no limit to the number grouping levels possible in a Notebook.  To undo a cell group, highlight the grouping bracket for the group to be undone and choose Ungroup Cells from the Cell menu.

Opening and Closing Multilevel Cell Groups

To open all cells in multiple closed cell groups (identified by solid triangles at the bottom of the grouping brackets), select the closed group brackets and choose Open All Subgroups from the Cell menu.  All levels of the selected groups will open.  Similarly, to close all levels of selected groups, choose Close All Subgroups from the Cell menu. Since a closed group will display the first cell in the group, closing groups is useful for collapsing notebooks into outline form.  Note that a single group can be opened or closed by alternately double-clicking on its grouping bracket, or by choosing Open/Close Group from the Cell menu.

Assigning Attributes to Cells

The Cell menu contains four commands for assigning attributes to cells.  Each of these attribute commands acts as a toggle switch (if a check appears beside the command, then the attribute has been applied to the currently selected cell).  Note that cell attributes can be applied to entire cells only. 

To apply an attribute to a cell, highlight the bracket of the cell that you want to apply the attribute to (or place a text insertion point within the cell) and select the appropriate command from the Cell menu.  Following is a brief description of the available attributes:

1) The formatted attribute is usually applied to cells containing Mathematica output.  Formatted cells can not be edited.  Cells containing text and Mathematica input are typically unformatted.  To toggle between formatted and unformatted form, choose the Formatted command from the Cell menu.

2) Active cells are cells that can be evaluated by the Kernel.  Cells that are inactive are ignored by the Kernel.  To toggle between active and inactive status, choose Inactive from the Cell menu.

3) Initialization cells are cells that can be evaluated automatically as soon as a Notebook is opened.  To mark a selected cell as an initialization cell, select Initialization from the Cell menu.

4) Locked cells are cells that can not be deleted or modified.  To toggle between locked and unlocked status, select Locked from the Cell menu.

Controlling Page Breaks

The Page Breaks command of the Cell menu provides a mechanism for forcing or suppressing a page break above the selected cell.  Use the Force Page Break Above Cell and Prevent Page Break Above Cell commands of the Page Breaks sub-menu to respectively force or suppress a page break above the selected cell.  Use the Show Page Breaks command to display page breaks on the screen.

Graph Menu

The Graph menu includes commands for converting a Mathematica  PostScript graphic to a Bitmap or to a Mathematica Input form.  Note that the converted form of the graphic will replace the original form in the Notebook.

Converting to Bitmap or Mathematica Input Form

Graphics can be converted into different formats depending upon the level of visual quality desired and on the amount of disk space available.  Bitmap formats are more compact than PostScript, but do not provide the same level of resolution when printed or resized.  Graphics saved in PostScript format can also be edited.   If you will never need to print or resize a graphic, converting the graphic to Bitmap can result in appreciable disk storage savings. To convert a graphic to Bitmap format, highlight the cell bracket surrounding the graphic and select Image Conversions from the Graph menu.  Choose the Convert to Bitmap image conversion.  Note that a Bitmap graphic can not be subsequently converted to PostScript.

Mathematica graphics can also be converted into a form that can be treated as Mathematica input.  To transform a graphic into Mathematica input, highlight the cell bracket surrounding the graphic and select Image Conversions from the Graph menu.  Choose the Convert to Input Form command.  Note that representing the graphic in this form requires much more memory than the graphic itself.

Action Menu

The Action menu includes commands for preparing input for the Kernel, for evaluating Mathematica input, and for stopping the current calculation.

Simplifying the Creation of Input

The Prepare Input submenu of the Action menu includes commands which help to minimize the time required to create input and minimize the possibility of making typographical errors.  There is also a command for rotating graphs.

Use the Copy Input from Above  command to copy the immediately preceding input to the location currently marked by the text or cell insertion point.  Once the input has been copied, it can be edited and submitted to the Kernel.  The Copy Output from Above command works similarly except that it copies the immediately preceding output.  These commands serve as an aid in creating new input that varies only slightly from existing input or output. 

Use the Complete Selection command to have Mathematica complete the name of a partially entered built-in or user-defined command, function, or variable.  If there is only one match that completes the currently selected text range, then Mathematica will replace the selection with the match.  If there are several names that begin with the selected text, Mathematica will display a menu of possible matches, and you can choose the appropriate match by clicking it.  Note that the keyboard equivalent for the Complete Selection command is Ctrl+K.

The 3D ViewPoint Selector command provides a dialog box that can be used to select the Cartesian viewpoint coordinates for 3-dimensional graphs.  Once the coordinates have been specified in the dialog box, they can be pasted (by clicking on the Paste button) at the location marked by the text insertion point in the current input line.

The Color Selector command provides a mechanism for choosing colors of graphical objects without having to figure out the RGBColor settings.  The Color Selector command features a dialog box that can be used to select a color and then paste the RGBColor command into the input line currently marked by the text insertion point.

Evaluating a Notebook

To select and evaluate all cells in the current Notebook, choose Evaluate Notebook from the Action menu.  This command is especially useful for recalculating a final result that depends on output generating by computing all preceding input cells.

Evaluating Initialization Cells

In Mathematica, cells can be created that contain definitions of Mathematica functions.  Subsequent cells may contain expressions that use these definitions to produce output.  Often it is desirable to declare the cells that contain the definitions as initialization cells and to configure Mathematica so that the initialization cells are automatically evaluated whenever a Notebook is opened.  If, however, automatic evaluation has been suppressed, you can still have Mathematica  evaluate initialization cells by choosing Evaluate Initialization from the Action menu.

Interrupting Calculations

To completely abort a calculation, select Interrupt from the Action menu and click the Abort button. Note that the Interrupt command can also be used to step through the current computation so that you can check the state of the Kernel or send other evaluations to the Kernel before resuming the original computation.

Style Menu

Applying Cell Styles

The Cell Style submenu of the Style menu provides a complete list of available cell styles.  To apply a style to one or more cells, select the cell and choose the appropriate style from the Cell Style submenu or enter the keyboard equivalent command.  Alternatively, a style can be applied to a selected cell by choosing the style from the drop down menu featured in the Toolbar.

Editing Cell Styles

Predefined cell styles can be modified and entirely new styles can be created by using the Edit Notebook Styles command in the Style menu.  Once a style is changed, the modifications will automatically be applied to cells in the Notebook which exhibit that style.

To modify an existing style, 1) access the Styles for Notebook dialog box by selecting the Edit Notebook Styles command from the Style menu, 2) click the name of the style you wish to redefine, 3) alter style settings using the Font and Format dialog boxes, and 4) close the dialog box to apply the changes to the cells that have been assigned that style.  Note that style changes are saved when you save the Notebook and that style sheets associated with one Notebook are not tied to (do not affect) other Notebooks.

Assigning Fonts

When the Font command is chosen from the Style menu, a dialog box will be displayed that lists all fonts installed on your computer.  To apply a font to selected text, click on the name of the font you wish to apply and select OK.  Note that text included in Kernel output must be formatted with a monospaced font, such as Courier, to be displayed correctly.

Assigning Typefaces

To assign a typeface to selected text, choose the Font command from the Style menu.  A dialog box will be displayed that includes a drop box listing four typefaces (Regular, Italic, Bold and Bold Italic).  Typefaces can be applied to some or all of the text in a cell depending upon whether a text range or cell bracket is highlighted.  Note that selecting the Regular typeface turns all other typefaces off.  Also note that multiple typefaces can be applied to the same piece of text.

Assigning Type Sizes

The change the type size used in displaying and printing the selected text, choose the Font command from the Style menu.   A dialog box will be displayed that includes a drop box listing available type sizes.

Applying Color to Text

To change the color of the selected text, choose the Font command from the Style menu and select the desired color from the included drop box.

Applying Color to the Background of Cells

To apply color to the background of one or more selected cells, choose the Format command from the Style menu.  A dialog box will be displayed that includes a Cell Background option.  This option can be used to apply a predefined color, or to define and apply a custom color to a cell's background.

Assigning Display Attributes

To enclose a cell within a box, choose the Fomat command from the Style menu and select the Box Around Cell option.  Similarly, to enable the horizontal movement of a selected cell's contents when the horizontal scroll box is dragged along the bottom of a window, select Format from the Style menu and turn on the Scroll Horizontally option.

Options Menu

Controlling Cell Margins

To change cell margin definitions, use the Ruler Bars command in the Options menu to toggle the display of the ruler and margin markers across the top of the Notebook window.  The margin markers that can be used to control the left and right margins of the selected cell.  Margin settings can be changed by dragging the markers along the ruler.

Setting Defaults and Preferences

To control how and when graphs are rendered,  select Graphics from the Options menu.  

To control when and how input cells are evaluated, choose Action from the Options menu.  For example, use this command to have Mathematica display a clock timing after each evaluation.

To specify the Kernel that will be launched automatically with the first computation, and to allocate additional memory to the Kernel, select Kernel from the Options menu.

Windows Menu

The Window menu provides commands for organizing your open Mathematica windows on the screen.  In addition, a listing of titles of open windows appears at the bottom of the menu.   You can use this listing to activate a particular window.

Stacking Windows

Use the Cascade Windows command in theWindows menu to make all open windows the same size and to overlap them on the screen such that the window title bars remain visible.   In this arrangement, you can bring a window to the front of the stack by clicking on its title bar.

Tiling Windows

To place two or more open windows one above the other in horizontal rectangles of equal size, choose Tile Windows Wide from the Window menu.  To place position the windows side-by-side in vertical rectangles of equal size, choose Tile Windows Tall.

Transferring Notebooks Between the Macintosh and Windows Versions of Mathematica ... 69

Converting Macintosh Mathematica Notebooks into Windows Mathematica Notebooks

The following procedure can be used to convert a Macintosh Mathematica Notebook into a Windows Mathematica Notebook:

1) Launch Apple File Exchange, an application supplied with the Macintosh system software for use on Macintosh computers equipped with a SuperDrive (a high-density 3.5-inch floppy diskette drive that can read disks from computers that use the DOS operating system.)  Apple File Exchange can be used to convert documents between Macintosh and DOS-format.

2) Place a blank high-density disk in the Macintosh computer's SuperDrive.  In the dialog box that appears, select the MS-DOS format, and click the Initialize button to format the disk as a DOS disk.

3) Optionally, specify a name for the disk.  Note that the name supplied must follow DOS file naming conventions (that is, the name can from one to eight characters in length, and can be followed by an optional one to three character extension).

4) Select Text Translation from the Mac to MS-DOS menu.  Turn off the Text Translation option to convert carriage returns to carriage return-line feeds.  In addition, set the Tab Character option to Neither.  

5) Select the Macintosh Notebook or Notebooks you wish to convert and click the Translate button.  Note that a Macintosh filename may be shortened to conform to DOS filenaming conventions.

6) Choose Quit from the File menu.

Converting Windows Mathematica Notebooks into Macintosh Mathematica Notebooks

To convert a Windows Mathematica Notebook into a Macintosh Mathematica Notebook, use the procedure described below:

1) Launch Apple File Exchange.

2) Place the DOS disk that contains the Windows Mathematica Notebook in the Macintosh computer's SuperDrive.

3) Select Text Translation from the MS-DOS to Mac menu.  Turn on the Text Translation option to convert carriage returns-line feeds to carriage returns.  In addition, set the Tab Character option to Neither. 

4) Select the Windows Notebook or Notebooks you wish to convert and click the Translate button.

5) Choose Quit from the File menu.

Additional Tips

Appearing below are additional tips to keep in mind when converting a Mathematica Notebook for use on a Macintosh or Windows system:

1) When preparing a Macintosh Mathematica Notebook for use on a Windows system, select all cells in the Notebook and choose Uniform Style from the Style menu.  This command restores all of a cell's default style attributes and will eliminate font variation within cells.

2) Provide a name for the Notebook that conforms to the filenaming conventions used by the destination computer system.  Windows Notebooks should be given a filename that is less than or equal to eight characters in length and ends in the .ma file extension.

3) Cells in a Notebook may be assigned different fonts on different computer systems.  To minimize this possibility, use fonts that that are common across Notebook front ends such as Times, Helvetica, or Courier.

4) Do not convert graphics to Bitmap form since Bitmap graphics are not compatible across platforms.  Instead, keep graphics in PostScript form.

5) Special characters, such as Greek symbols, typically have to be translated by hand.

References ... 71

Material appearing in this book has been adapted from the references listed below.

Blachman, Nancy. Mathematica:  A Practical Approach. New Jersey:  Prentice-Hall, Inc.,          1992.

Crooke, Philip, & Ratcliffe, John. A Guidebook to Calculus with Mathematica.  California:     Wadsworth Publishing Company, 1991.
 
Wolfram, Stephen. Mathematica A System for Doing Mathematics by Computer, Second Edition, Addison-Wesley 
 
 Wolfram Research. User's Guide for the Macintosh (Rev. ed.), 1991.
 
 Wolfram Research.  User's Guide for Microsoft Windows, 1992.
 
 "Q&A-How can I transfer Notebooks from the Macintosh to Windows and vice versa?"  MathUser pp 6-7, Fall/Winter 1992.

Acknowledgement ... 71

I wish to thank Dr. Philip Crooke, Professor of Mathematics at Vanderbilt University, who developed the outline used in this Notebook and provided guidance during its development.