UMM Calculus 0.
Introduction to Mathematica

Byungik Kahng and Michael O'Reilly

Abstract.  The purpose of this lesson is to provide a thorough introduction to Mathematica for beginners.  Take the cursor to an arrow bracket in the right hand side and double click it to open hidden cells.

General Setup

Off[General::spell];
Off[General::spell1];
SetOptions[Limit, Analytic -> True];

Graphics Setup

2D setup

<< Graphics`Colors`;
<< Graphics`Graphics`;
<< Graphics`ImplicitPlot`;
<< Graphics`FilledPlot`;
<< Graphics`Animation`;

    
Begin["`Private`"];
SetOptions[ParametricPlot, 
        AspectRatio -> Automatic];
SetOptions[Plot, AspectRatio -> Automatic];
SetOptions[Graphics, AspectRatio -> Automatic];

3D setup

<< RealTime3D`;
MathView = {2.5, 2.0, 1.5};

Vector Setup

2D vectors

Options[Arrow] = {HeadRatio -> 0.15, Sharpness -> 0.25, 
          ShaftRatio -> 0.25};
Arrow[from_?VectorQ, to_?VectorQ, 
          opts___] := 
Module[{vector, vectorlength, 
              unitvector, perp, headratio, arrowbase, sharpness, shaftratio, 
              ii}, 
{headratio, sharpness, 
                shaftratio} = {HeadRatio, Sharpness, 
                    ShaftRatio} /. {opts} /. 
                Options[Arrow]; 
vector = 
              to - from; 
vectorlength = (Sqrt[N])[vector . vector]; 
If[vectorlength > 0, 
              unitvector = (vector/vectorlength), 
              unitvector = {0, 
                  0}]; 
perp = {unitvector[[2]], -unitvector[[1]]}; 
arrowbase = 
              from + (1 - headratio)*
                  vector; 
Flatten[{
Polygon[{to, 
                    arrowbase + (headratio*vectorlength*Tan[sharpness]) 
                        perp, 
arrowbase + (headratio*
                            shaftratio) 
                        vector, 
arrowbase - (headratio*
                            vectorlength*Tan[sharpness]) perp, 
                    to}], 
Line[{from, 
                    arrowbase + (headratio*shaftratio) 
                        vector}]
}]
] /; 
          Length[from] == Length[to] == 2;

3D vectors

Options[Arrow3D] = {HeadRatio -> 0.15, 
          Sharpness -> (π/12)};
Arrow3D[from_?VectorQ, to_?VectorQ, opts___]:=
Module[{vector, vectorlength, unitvector, tmpvector, 
                tmplength, , perp, biperp, headratio, arrowbase, arrowvertex, 
                sharpness, ii, jj, kk},
{headratio, 
                    sharpness} = {HeadRatio, Sharpness} /. {opts} /. 
                    Options[Arrow3D];
vector = to - from;
vectorlength = (Sqrt[N])[vector . vector];
If[vectorlength > 0, 
                  unitvector = (vector/vectorlength), 
                  unitvector = {0, 0, 0}];
tmpvector = {0, 
                    unitvector[[3]], -unitvector[[2]]};
tmplength = (Sqrt[N])[unitvector[[2]]^2 + unitvector[[3]]^2];
If[tmplength > 0, 
                  perp = (tmpvector/tmplength), perp = {0, 1, 0}];
biperp = 
                  N[Det[{{ii, jj, kk}, unitvector, 
                          perp}] /. {ii -> {1, 0, 0}, 
                        jj -> {0, 1, 0}, kk -> {0, 0, 1}}];
arrowbase = 
                  from + (1 - headratio)*vector;
arrowvertex = 
                  Table[arrowbase + (headratio*vectorlength*
                            Tan[sharpness]) (Cos[(π/4) ii] perp + 
                            Sin[(π/4) ii] biperp), {ii, 0, 8, 1}];
Flatten[{
Table[
Polygon[{to, 
                          arrowvertex[[ii]], 
                          arrowvertex[[ii + 
                                1]]}], 
{ii, 1, 8, 
                        1}], 
Line[{from, 
                        to}]
}]
]/;Length[from] == Length[to] == 3;

Vector fields

<< Graphics`PlotField`;
<< Graphics`PlotField3D`;

1.  The Structure of Mathematica Notebook Files

(1.1)  How to open and save Mathematica notebook files.

1.1.1.  How to open .nb files.

Mathematica notebook files have extension name .nb.  This file, for instance, is called intro.nb.  The easiest way to open a Mathematica notebook file is simply to double click the icon of the .nb file.  If it doesn't work, you must adjust the file setting of your computer.  Another way to open a notebook file is to open Mathematica first and go to File, Open, and then find the file you want to open.

1.1.2.  How to save .nb files.

Saving .nb file is easy.  Just go to file and select Save, or Save As.  You can save the file as a web page through Save As Special, or as a pdf file through Print.

1.1.3.  .nb files and .m files.

Mathematica notebook files with initialization cells create an auxiliary file with an extension name .m.  The important file is the .nb file.  .m file is dispensable.  If you are a beginner, however, save both files unless you know what you are doing!

(1.2)  How to start programming with Mathematica.

1.2.1.  Starting a new file.

You can go to File and select New to get a fresh new file with default name Untitled-1.nb.  The same thing happens if you start Mathematica without selecting any notebook file to open.  Everything you type in the window is considered an input, and Mathematica will try to calculate it.

1.2.2.  Starting a new cell.

When you are editing a previously written Mathematica notebook file, you need to be careful about the cells.  You can start a new cell by placing the cursor between two cells (or at the very top or at the very bottom) and click the mouse button.  If successful, you will get a horizontal line to indicate the location of the new cell.  All you have to do now is to

start typing!

1.2.3.  The default style of a new cell is input.

Anything you type in a new cell is automatically considered an input, unless you designate otherwise.  Mathematica understands it as a part of a program that it must run.

3  +  23.5

1.2.4.  How to run an input cell.

You can run an input cell by hitting the enter key in the lower right corner, or pressing the shift-return.  However, you must first tell Mathematica which cell you want it to run.  You can do this either by clicking the mouse button anywhere inside the input cell or highlighting the entire cell-marker(s) in the right hand side.  The latter method is particularly useful when running several input cells sequentially.

Example 1.2.5.

Clear[f, x];
f[x_] = -9 (x^4) - 10 (x^3) + 
          20 (x^2);
\(\(Plot[f[x], {x, \(-0.3\), 1}, 
        AspectRatio -> 
          1/GoldenRatio, 
	\ \ PlotStyle -> {{Thickness[0], 
              DarkGreen}}, 
        AxesLabel -> {"x", ""}];\)\)
Print["f[x] = ",  f[x]];

Clear[f, g, x, a, b]
a  =  
      0.4;  b  =  
      0.8;
f[x_] = -9 (x^4) - 10 (x^3) + 
          20 (x^2);
g[
          x_] = ((f[b]  -  f[a])/(b - a)) (x  -  a)  +  
          f[a];
Plot[{f[x], g[x]},{x, -0.3, 1},AspectRatio -> 1/GoldenRatio,
	  PlotStyle -> {{Thickness[0], 
                DarkGreen}, {Thickness[0], Blue}},AxesLabel -> {"x", ""}];
\(Print[\*""g[x] = \!\(\(f[b]\\  - \\ f[a]\)\/\(b\\  - \\ a\)\)(x - a) + f[a] = "", \ g[x]];\)

Clear[f, g0, x, a, b]
a  =  0.4;  b  =  0.8;
f[x_] = -9 (x^4) - 10 (x^3) + 
          20 (x^2);
g0[x_] = f'[a] (x  -  a) + 
          f[a];
\(\(Plot[{f[x], g0[x]}, {x, \(-0.3\), 1}, AspectRatio -> 1/GoldenRatio, 
        PlotRange -> {\(-1\), 
            5}, 
	\ \ PlotStyle -> {{Thickness[0], 
              DarkGreen}, {Thickness[0], Red}}, 
        AxesLabel -> {"x", ""}];\)\)
\(\(Print[\*""\!\(g\_0\)[x] = f'[a](x - a) + f[a] = "", \ 
        g0[x]];\)\)

(1.3)  What to write in input cells.

The input cell is where you write Mathematica programs.  More detailed help page is given in the next section.  Here, let us list only the most basic introductory topics.

1.3.1.  Elementary Calculations.

Calling Mathematica a sophisticated calculator is an understatement.  Nonetheless, it does support all the functions of graphic calculators.  + is for addition, - is for subtraction.  Either * or space is used for multiplication, and / is used for division.  Finally, ^ is used to indicate the power.

2 + 2  -  Sqrt[2]
2*3  -  3 2  + 4/5
4^2  -  4^(1/2)

Put //N at the end of calculation to get decimals.

2 + 2  -  Sqrt[2]   // N
2*3  -  3 2  + 4/5   // N

The default decimal representation runs through 6 non-zero digits.   You can change it manually through the following command.

N[2 +  2  -  Sqrt[2]]
N[2 +  2  -  Sqrt[2],  10]
N[2 +  2  -  Sqrt[2],  15]

As you saw in the N[ ] command, the square brackets are reserved for special Mathematica commands.  Braces are reserved to represent the lists.  Only parentheses are used for algebraic expressions.

(2  +  2)*(3  -  1)

[2  +  2]*[3  -  1]

{2 ,  2}*3

(2,  2)*3

1.3.2.  Naming expressions.

From now on, Mathematica begins to function as a computer program rather than a oversized calculator.  We use = to name an expression.  Note that the semicolon as used to run a command line without producing an output.

Clear[a, b]
a =  3^5  +  2  - Sqrt[5];
b = 3^3  -  Sqrt[2/5];
a  -  3  b
a/b

Clear[...] command is used to clear the previously defined data listed in the bracket.  Most of the calculus level programs will work just fine without Clear[...] command at all, but it is generally a good idea to begin any program with Clear[...].

Here are a couple of programs that exemplify the use of Clear command.

x = 1;
Solve[x + 2 == 1, x]

Clear[x]
Solve[x + 2 == 1, x]

1.3.3.  Functions.

In Mathematica, there are pre-defined functions and there are functions defined by users.  When a user defines a function, an underscore, _ is needed after a variable.  Once the function is defined, do not use the underscore afterwards.

Clear[f, x]
f[x_] = -(x^4) - (x^3) + 2  (x^2)
Plot[f[x], {x, -0.3, 1}];

Clear[f, x]
f[x] = -(x^4) - (x^3) + 2  (x^2)
Plot[f[x], {x, -0.3, 1}];

Pre-defined functions always start with capital letters.  In fact, every pre-defined Mathematica command starts with a capital letter.  Here is a list of some commonly used pre-defined functions.

1.  Trigonometric functions and inverse trigonometric functions.

Sin[x],  Cos[x],  Tan[x],  Csc[x],  Sec[x],  
    Cot[x],  
ArcSin[x],  ArcCos[x],  ArcTan[x]

2.  Exponential and logarithmic functions.

Exp[x]=(E^x)=(e^x),    Log[x].

Warning!  Mathematica does not recognize

(e^x)  or  Ln[x].

3.  Miscellaneous functions and operators.

Sqrt[2]
Abs[-2]

Numerator[3/5]
Numerator[(x^2  +  1) / (x  -  3)]

Denominator[3/5]
Denominator[(x^2  +  1) / (x  -  3)]

1.3.4.  Brackets, braces and parentheses.

In paper, there is little difference between parentheses, braces and brackets.  In Mathematica, there is world of difference.

1.  Parentheses are used in algebraic expressions.  They indicate which operations to do before others.

(3  +  1)*2
3  +  1*2

2.  Brackets are used to indicate functions.

Both user-defined functions (f[x]) and predefined functions (Sin[x], Clear[...], Plot[...]) require brackets.

Clear[f, x];
f[x_] = ((x^2)/2) Sin[x];
Plot[f[x], {x, -3, 3}, PlotStyle -> Blue];

Brackets cannot be replaced by parentheses.

Clear[f, x];
f (x_) = ((x^2)/2) - x;
Plot[f (x), {x, -3, 3}, 
        PlotStyle -> Blue];

Don't forget the underscore when defining functions.

Clear[f, x];
f[x] = ((x^2)/2) Sin[x];
Plot[f[x], {x, -3, 3}, PlotStyle -> Blue];

3.  Braces are used to indicate lists.

Do not confuse lists with sets.  In Mathematica, {1, 2, 3} ≠ {1, 3, 2}.

Clear[l, m];
l = {1, 3, 5, 7, 9};
m = {2, 4, 6, 8, 10};
l + m
m - l
2  l - m

Double brackets are used to indicate components of lists.

(2  l - m)[[2]]
(2  l - m)[[5]]

1.3.5.  Warning!

1.  Multiplication and spacebar.

Multiplication requires either *, ×, or a spacebar.  Missing spacebar is one of the most common Mathematica mistake by beginners.

Clear[a, b]
a = 2;
b = 10;
ab
a b

Clear[f, x]
f[x_] = xCos[x^2];
Plot[f[x], {x, -Pi, Pi}];

Clear[f, x]
f[x_] = x Cos[x^2];
Plot[f[x], {x, -Pi, Pi}];

2.  Function and underscore.

You need to put an underscore when defining a function.

Clear[f, x]
f[x] = x Cos[x^2];
Plot[f[x], {x, -Pi, Pi}];

Clear[f, x]
f[x_] = x Cos[x^2];
Plot[f[x], {x, -Pi, Pi}];

3.  Function and capital letter.

Pre-defined functions always begin in capital letters.

Clear[f, x]
f[x_] = x cos[x^2];
Plot[f[x], {x, -Pi, Pi}];

Clear[f, x]
f[x_] = x Cos[x^2];
Plot[f[x], {x, -Pi, Pi}];

4.  Natural exponent is represented by capital letter E.  Mathematica does not recognize (e^x).

E  // N
Plot[E^x, {x, -1, 2}];

e   // N
Plot[e^x, {x, -1, 2}];

5.  Mathematica does not recognize Ln[x] or ln x.  Natural log is represented by Log[x].

Log[10]  // N
Plot[Log[x], {x, 0, 5}];

Ln[10]  // N
Plot[Ln[x], {x, 0, 5}];

(1.4)  How to create and format text cells.

The default style of a new cell is input.

However,  
    writing long comments in input cells is not a good idea .   Not only must one put up with ugly fonts,  
    one gets unnecessary error messages and beeps when one tries to run a whole section or a notebook.

Instead, we recommend users to create text cells, or to convert ugly looking input cells to text cells.  This can be done by selecting Format, Style and then Text.  You can do this at any time.  Either before creating a new cell, or create an input cell and then change its style to text format.  Once you get a text cell running, you can use the Format option again to change its font, size, text color, background color, alignment, etc.  In short, you can use Mathematica like a word-processor that supports mathematical symbols.  We will discuss more about this in section 3.

2.  Introduction to Mathematica Programing

In this section, we assume that the readers are capable of opening a Mathematica notebook file and starting new Mathematica program.  The first subsection, (2.1) is intended as a review.  It is identical to (1.3).

(2.1)  What to write in input cells.

The input cell is where you write Mathematica programs.  More detailed help page is given in the next section.  Here, let us list only the most basic introductory topics.

2.1.1.  Elementary Calculations.

Calling Mathematica is a sophisticated calculator is an understatement.  Nonetheless, it does support all the functions of graphic calculators.  + is for addition, - is for subtraction.  Either * or space is used for multiplication, and / is used for division.  Finally, ^ is used to indicate the power.

2 + 2  -  Sqrt[2]
2*3  -  3 2  + 4/5
4^2  -  4^(1/2)

Put //N at the end of calculation to get decimals.

2 + 2  -  Sqrt[2]   // N
2*3  -  3 2  + 4/5   // N

The default decimal representation runs through 6 non-zero digits.   You can change it manually through the following command.

N[2 +  2  -  Sqrt[2]]
N[2 +  2  -  Sqrt[2],  10]
N[2 +  2  -  Sqrt[2],  15]

As you saw in the N[ ] command, the square brackets are reserved for special Mathematica commands.  Braces are reserved to represent the lists.  Only parentheses are used for algebraic expressions.

(2  +  2)*(3  -  1)

[2  +  2]*[3  -  1]

{2 ,  2}*3

(2,  2)*3

2.1.2.  Naming expressions.

From now on, Mathematica begins to function as a computer program rather than a oversized calculator.  We use = to name an expression.  Note that the semicolon as used to run a command line without producing an output.

Clear[a, b]
a =  3^5  +  2  - Sqrt[5];
b = 3^3  -  Sqrt[2/5];
a  -  3  b
a/b

Clear[...] command is used to clear the previously defined data listed in the bracket.  Most of the calculus level programs will work just fine without Clear[...] command at all, but it is generally a good idea to begin any program with Clear[...].

Here are a couple of programs that exemplify the use of Clear command.

x = 1;
Solve[x + 2 == 1, x]

Clear[x]
Solve[x + 2 == 1, x]

2.1.3.  Functions.

In Mathematica, there are pre-defined functions and there are functions defined by users.  When a user defines a function, an underscore, _ is needed after a variable.  Once the function is defined, do not use the underscore afterwards.

Clear[f, x]
f[x_] = -(x^4) - (x^3) + 2  (x^2)
Plot[f[x], {x, -0.3, 1}];

Clear[f, x]
f[x] = -(x^4) - (x^3) + 2  (x^2)
Plot[f[x], {x, -0.3, 1}];

Pre-defined functions always start with capital letters.  In fact, every pre-defined Mathematica command starts with a capital letter.  Here is a list of some commonly used pre-defined functions.

1.  Trigonometric functions and inverse trigonometric functions.

Sin[x],  Cos[x],  Tan[x],  Csc[x],  Sec[x],  
    Cot[x],  
ArcSin[x],  ArcCos[x],  ArcTan[x]

2.  Exponential and logarithmic functions.

Exp[x]=(E^x)=(e^x),    Log[x].

Warning!  Mathematica does not recognize

(e^x)  or  Ln[x].

3.  Miscellaneous functions and operators.

Sqrt[2]
Abs[-2]

Numerator[3/5]
Numerator[(x^2  +  1) / (x  -  3)]

Denominator[3/5]
Denominator[(x^2  +  1) / (x  -  3)]

2.1.4.  Brackets, braces and parentheses.

In paper, there is little difference between parentheses, braces and brackets.  In Mathematica, there is world of difference.

1.  Parentheses are used in algebraic expressions.  They indicate which operations to do before others.

(3  +  1)*2
3  +  1*2

2.  Brackets are used to indicate functions.

Both user-defined functions (f[x]) and predefined functions (Sin[x], Clear[...], Plot[...]) require brackets.

Clear[f, x];
f[x_] = ((x^2)/2) Sin[x];
Plot[f[x], {x, -3, 3}, PlotStyle -> Blue];

Brackets cannot be replaced by parentheses.

Clear[f, x];
f (x_) = ((x^2)/2) - x;
Plot[f (x), {x, -3, 3}, 
        PlotStyle -> Blue];

Don't forget the underscore when defining functions.

Clear[f, x];
f[x] = ((x^2)/2) Sin[x];
Plot[f[x], {x, -3, 3}, PlotStyle -> Blue];

3.  Braces are used to indicate lists.

Do not confuse lists with sets.  In Mathematica, {1, 2, 3} ≠ {1, 3, 2}.

Clear[l, m];
l = {1, 3, 5, 7, 9};
m = {2, 4, 6, 8, 10};
l + m
m - l
2  l - m

Double brackets are used to indicate components of lists.

(2  l - m)[[2]]
(2  l - m)[[5]]

2.1.5.  Warning!

1.  Multiplication and spacebar.

Multiplication requires either *, ×, or a spacebar.  Missing spacebar is one of the most common Mathematica mistake by beginners.

Clear[a, b]
a = 2;
b = 10;
ab
a b

Clear[f, x]
f[x_] = xCos[x^2];
Plot[f[x], {x, -Pi, Pi}];

Clear[f, x]
f[x_] = x Cos[x^2];
Plot[f[x], {x, -Pi, Pi}];

2.  Function and underscore.

You need to put an underscore when defining a function.

Clear[f, x]
f[x] = x Cos[x^2];
Plot[f[x], {x, -Pi, Pi}];

Clear[f, x]
f[x_] = x Cos[x^2];
Plot[f[x], {x, -Pi, Pi}];

3.  Function and capital letter.

Pre-defined functions always begin in capital letters.

Clear[f, x]
f[x_] = x cos[x^2];
Plot[f[x], {x, -Pi, Pi}];

Clear[f, x]
f[x_] = x Cos[x^2];
Plot[f[x], {x, -Pi, Pi}];

4.  Natural exponent is represented by capital letter E.  Mathematica does not recognize (e^x).

E  // N
Plot[E^x, {x, -1, 2}];

e   // N
Plot[e^x, {x, -1, 2}];

5.  Mathematica does not recognize Ln[x] or ln x.  Natural log is represented by Log[x].

Log[10]  // N
Plot[Log[x], {x, 0, 5}];

Ln[10]  // N
Plot[Ln[x], {x, 0, 5}];

(2.2)  Writing with style.

Mathematica 4.x and higher support a large class of traditional mathematical symbols.  In time, students will get themselves familiar with direct commands, such as control-2 for square root, control-6 for power, control-/ for fraction, etc.  In the beginning, it is easier to utilize help windows.  Here are a number of options to improve the looks.

2.2.1.  BasicInput.

Go to File, Palettes, and select BasicInput, if the basic input window is not already open.  You can create most of the basic mathematical symbols in calculus level through this window.

(2^3) + (((4/5))^(1/3))
(∑_(k = 0)^n) (k^2)
(∫_0^(2  π))(Sqrt[2 +  
              Cos[t]]) \[DifferentialD]t
N[%]

Cos[Pi/2]
Cos[(π/2)]
N[E]
N[E]
(I^2)
(I^2)

2.2.2.  BasicTypesetting and CompleteCharacters.

Go to File, Palettes, and select BasicTypesetting, if you want more symbols.  If that is not enough for you, go to File, Palettes, CompleteCharacters.

2.2.3.  The role of semicolons.

Semicolons have two basic roles.  One obvious role is to run a calculation without yielding an output.

s = (∑_(k = 0)^n) (k^2);

s = (∑_(k = 0)^n) (k^2)

But that is not always true, as shown in the following example.

Print[(∑_(k = 0)^n) (k^2)];

The second role of semicolon is the role of a separator.  It separates one Mathematica command from next.

s = (∑_(k = 0)^n) (k^2);  
    t = (∑_(k = 0)^n) (k^3);
\(Print[\*""\!\(∑\+\(k = 0\)\%n\)\!\(k\^2\) = "", s]; \ 
    Print[\*""\!\(∑\+\(k = 0\)\%n\)\!\(k\^3\) = "", 
      t];\)

The latter aspect becomes more important in advanced programing.  In advanced programing, it will turn out better to put semicolon everywhere and use Print command to print out (on the screen) the outcome, than to omit semicolon here and there and risk hard-to-find errors.

(2.3)  Plotting with Mathematica.

2.3.1.  Basic syntax.

For most students in calculus level the Plot command (and their cousins) must be the single most important Mathematica command there is.  The basic syntax is

Plot[f[x], {x,xstart,xend}];

For instance,

Plot[x Cos[(x^2)], {x, -π, π}];

2.3.2.  Plotting two or more graphs together.

The basic syntax to plot two or more graphs together is to join the functions with braces and plot them.

Plot[{Sin[x], Cos[x]}, {x, -(π/2), 
          2  π}];

2.3.3.  Color and Thickness.

Students who wish to plot more stylish graphs can include PlotStyle->{...} option inside the Plot command and create colored plots.

Plot[x Cos[(x^2)], {x, -π, π}, 
        PlotStyle -> {Blue}];

Plot[{Sin[x], Cos[x]}, {x, -(π/2), 2  π}, 
        PlotStyle -> {Blue, Red}];

The second plot required two plot styles because it plots two graphs.

In addition to colors, we can adjust the thickness of the curves, too.

Plot[{(x^2), (Sqrt[x]), x}, {x, 0, 1.5}, 
        PlotStyle -> {{Blue, Thickness[0.02]}, {Red, 
              Thickness[0.02]}, {Purple, Thickness[0]}}];

In the above example, there are three graphs, so we need three plot styles.  We put {Blue,Thickness[0.02]} for the first function y = (x^2), we put {Red,Thickness[0.02]} for the second function y = (Sqrt[x]), and we put {Purple,Thickness[0]} for the third function y = x.

2.3.4.  Plot range.

One can restrict the range of the plot and let Mathematica display only the desired part of a graph.  Here is the last plot from 2.3.3.

Plot[{(x^2), (Sqrt[x]), x}, {x, 0, 2}, 
        PlotStyle -> {{Blue, Thickness[0.01]}, {Red, 
              Thickness[0.01]}, {Purple, Thickness[0]}}];

The above command plots the graphs f(x) = (x^2) and g(x) = (Sqrt[x]), along with the line y = x.  Since, f and g are inverses of each other, the graph of f and that of g must be symmetric across the line y = x.  But the above plot does not do sufficient justice to this fact.  That is because the plot range is not properly set.  Since the domain of g is set as [0, 2], in the above plot, it is only fair to take the same interval as the range of f.  We can do this by adjusting PlotRange option inside the Plot command.

Plot[{(x^2), (Sqrt[x]), x}, {x, 0, 2}, 
        PlotStyle -> {{Blue, Thickness[0.01]}, {Red, 
              Thickness[0.01]}, {Purple, Thickness[0]}}, 
        PlotRange -> {0, 2}];

There!

Example 2.3.5.

Plot the graph of the following functions in an appropriate domain.

f(x) = (e^x),   g(
        x) = Log[x].

Solution.

First, let us discuss some wrong methods.  Note that f = (g^(-1)), so the graphs must be symmetric to each other with respect to y = x.

Plot[{(E^x), Log[x]}, {x, -E, E}];

Does it look all right?  Apparently not.  How about this?

Plot[{(E^x), Log[x], x}, {x, -E, E}, 
        PlotRange -> {-E, E}];

Much better.  We can improve its looks through colors.

Plot[{(E^x), Log[x], x}, {x, -E, E}, 
        PlotRange -> {-E, E}, 
        PlotStyle -> {{Thickness[0.01], Blue}, {Thickness[0.01], 
              Red}, {Thickness[0], Purple}}];

In introductory level,  the above graph is considered perfect.  The only defect is the error messages, which is because our viewing window goes beyond the domain of the natural log functions.  We will discuss a method to get by this problem in the next subsection.

2.3.6.  Aspect ratio.

Here is the plot of a rational function defined by

\(TraditionalForm\`R(
          x) = \(\(-x\^4\)\  - \ 14  x\^3\  + \ 2  x\  - \ 3\)\/\(\(-x\^5\)\  - \ 2  x + \ 3\)\).

Clear[R, x];
R[
          x_] = ((-(x^4)  -  14  (x^3)  +  2  x  -  3)/(-(x^5)  -  2  x +  3));
Plot[R[x], {x, -4, 4}, 
        PlotStyle -> {{Thickness[0], Blue}}];

It is hard to see the important features of the graph because it is too tall and thin..  Here is one way to fix it.

Plot[R[x], {x, -4, 4}, PlotRange -> {-4, 4}, 
        PlotStyle -> {{Thickness[0], Red}}];

Here is another.

Plot[R[x], {x, -4, 4}, AspectRatio -> 1/GoldenRatio, 
        PlotStyle -> {{Thickness[0], DarkGreen}}];

The method we used in the first fix (red plot) is to adjust PlotRange.  The plot from the first fix is identical to the original (blue) except that the top portion (y ≥ 4) and the bottom portion (y ≤ -4) are cut off from our viewing window.  The second fix does not cut off anything.  It resizes the viewing window to a golden rectangle (height/width = 1/GoldenRatio) and stretch and compress the graph accordingly.  One can try different AspectRatio, too.

Plot[R[x], {x, -4, 4}, AspectRatio -> 1/GoldenRatio, 
        PlotStyle -> {DarkGreen}];
Plot[R[x], {x, -4, 4}, AspectRatio -> 1/3, 
        PlotStyle -> {Brown}];
Plot[R[x], {x, -4, 4}, AspectRatio -> 1, 
        PlotStyle -> {Pink}];

The default setting of this notebook is AspectRatio->Automatic.  By changing AspectRatio to something else, we lose the accuracy as exemplified by the next set of commands.

Plot[{(Sqrt[1 - (x^2)]), -(Sqrt[1 - (x^2)])}, {x, -1, 1}, 
        PlotStyle -> {Blue}];
Plot[{(Sqrt[1 - (x^2)]), -(Sqrt[1 - (x^2)])}, {x, -1, 1}, 
        AspectRatio -> 1/GoldenRatio, 
        PlotStyle -> {Red}];

This first command (default setting) plots a circle perfectly (blue).  The second command, on the other hand, squeezes the circle to a golden rectangle, and ends up plotting an ellipse (red).  It is best to leave the AspectRatio as the default setting (Automatic) unless there is something specific to gain by changing it.

Remark.

The default option for a blank Mathematica notebook is AspectRatio->1/GoldenRatio.  If you wish to plot accurate graphs in other Mathematica notebook files, you must manually include AspectRatio->Automatic in the Plot command.  The default option of UMM Calculus notebooks is initialized as AspectRatio->Automatic for instructional purpose.

(2.4)  Commands for algebra and calculus.

2.4.1.  Commands for algebraic manipulation.

Simplify and FullSimplify simplify expressions.

Clear[x]
Simplify[((((x^2) - 1) ((x^2) - 3  x + 2))/(((x^2) + 2  x + 1) ((x^2) - 4)))]

Clear[a, x, k, ratio]
a[x_, k_]  =  ((x^k)/((2  k)!));
ratio[x_, k_]  =  a[x, k + 1]/a[x, k]
Simplify[ratio[x, k]]
FullSimplify[ratio[x, k]]

Expand expands powers and products of terms.  TrigExpand is used for trigonometric functions.

Clear[x]
Expand[(x - 3) ((x^2) + 1) (((x + 4))^3)]

Clear[t]
Expand[Cos[t]^4 - Sin[t]^4]
TrigExpand[Cos[t]^4 - Sin[t]^4]
Simplify[Cos[t]^4 - Sin[t]^4]

Factor factorizes expressions.

Factor[(x^16) - 1]

Factor[Cos[t]^4 - Sin[t]^4]

Apart separates a fractional expressions as the sum of simple fractions.  Together does the opposite.

Apart[((3  x - 2)/((x^4) + 3  (x^2) - 4))]
Together[
      (1/(10 (x - 1))) + 
        (1/(2 (x + 1))) - ((3 x - 2)/(5 ((x^2) + 4)))]

Expand[Numerator[Together[(1/(10 (x - 1))) + (1/(2 (x + 1))) - ((3 x - 2)/(5 ((x^2) + 4)))]]]/Expand[Denominator[Together[(1/(10 (x - 1))) + (1/(2 (x + 1))) - ((3 x - 2)/(5 ((x^2) + 4)))]]]

2.4.2.  Commands for solving equations.

Solve and NSolve solve equations.  The former solves symbolically, and the latter, numerically.

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

NSolve[(x^2) + 3  x - 1 == 0, x]
NSolve[{(x^2) - (y^2) == 0, x y  == 2}, {x, y}]

FindRoot command is used to estimate an approximate solution from an initial guess.

Plot[{10  Sin[x], x}, {x, -4 π, 4  π}, 
        AspectRatio -> 1/GoldenRatio, 
        PlotStyle -> {{Thickness[0], Blue}, {Thickness[0], 
              Red}}];

    
NSolve[10  Sin[x] == x, x]
FindRoot[
      10  Sin[x] == x, {x, π/6}]
FindRoot[10  Sin[x] == x, {x, π}]
FindRoot[
      10  Sin[x] == x, {x, 2  π}]
FindRoot[10  Sin[x] == x, {x, 3  π}]

Example 2.4.3.

Plot the graph of the following rational function in an appropriate domain and find all of its zeros and asymptotes.

\(TraditionalForm\`R(
        x) = \(\(-x\^4\)\  - \ 14  x\^3\  + \ 2  x\  - \ 3\)\/\(\(-x\^5\)\  - \ 2  x + \ 3\)\)

Solution.

Here is the graph of the given rational function.

Clear[R, x];
R[
          x_] = ((-(x^4)  -  14  (x^3)  +  2  x  -  3)/(-(x^5)  -  2  x +  3));
\(\(Plot[R[x], {x, \(-5\), 5}, 
        AspectRatio -> 
          1/GoldenRatio, 
	\ \ PlotStyle -> {{Thickness[0], 
              Blue}}];\)\)
Print["R[x] = ",  R[x]];

Looks like there is one zero (x-intercept), one vertical asymptote, and the horizontal asymptote, y = 0.  Be careful, though, because eyes can be deceiving!  Let us find the vertical asymptotes and the zeros explicitly.

NSolve[Denominator[R[x]] == 0, x]

As expected, we have one vertical asymptote, x = 1.  None of the other roots is real.

Now, let us find the zeros.

NSolve[Numerator[R[x]] == 0, x]

What conclusion can you draw?

Example 2.4.4.

Plot the graph of the following rational function in an appropriate domain and find all of its zeros and asymptotes.

\(TraditionalForm\`R(
        x) = \(3  x\^4\  - \ x\^3\  + \ x\^2\  - \ 5\)\/\(x\^3\  - \ 4  x\  + \ 3\)\)

Solution.

Here is the graph of the given rational function.

Clear[R, x];
R[
          x_] = ((3  (x^4)  -  (x^3)  +  (x^2)  -  5)/((x^3)  -  4  x  +  1));
Plot[R[x], {x, -5, 5}, AspectRatio -> 1/GoldenRatio, 
        PlotStyle -> {{Thickness[0], 
              Blue}}];
Print["R[x] = ",  R[x]];

Looks like there are two zeros (x-intercept), three vertical asymptotes, and a slanted asymptote that we must find.  Mathematica can help us find them easily.

NSolve[Denominator[R[x]] == 0, x]

As expected, we have three vertical asymptotes.  How about zeros?

NSolve[Numerator[R[x]] == 0, x]

Thus, we found the two zeros.  Finally the slanted asymptote.

Apart[R[x]]

This tells us that the slanted asymptote is y = 3  x - 1, because the fraction part vanishes as x -> ±∞.  Consequently, we get

Clear[R, L, x];
R[
          x_] = ((3  (x^4)  -  (x^3)  +  (x^2)  -  5)/((x^3)  -  4  x  +  1));
L[x_] = 3  x - 1;
\(\(Plot[{R[x], L[x]}, {x, \(-5\), 5}, 
        AspectRatio -> 
          1/GoldenRatio, 
	\ \ PlotStyle -> {{Thickness[0], 
              Blue}, {Thickness[0], Red}}];\)\)
Print["R[x] = ",  R[x]];
Print["The slanted Asymptote is, y = ", L[x]];

(2.5)  Substitution and naming.

We went through a basic example of substitution (naming) in (2.1).  Mathematica can handle more sophisticated substitutions, too.

2.5.1.  Naming algebraic expressions and lists.

Here is an example of naming algebraic expressions.

Clear[x, y, r, θ]
x = r Cos[θ];
y = r Sin[θ];
(x^2) + (y^2)
TrigExpand[(x^2) + (y^2)]
(y/x)

Here is an example of naming lists.

Clear[i, j, k]
i = {1, 0, 0};
j = {0, 1, 0};
k = {0, 0, 1};
i + j - 2  k

2.5.2.  Naming graphics elements.

Here are the functions from Example 2.3.5.

f(x) = (e^x),   g(
        x) = Log[x].

Here is the Mathematica program from Example 2.3.5 to plot them together.

Clear[f, g, h, x];
f[x_] = (E^x);
g[x_] = Log[x];
h[x_] = x;
fghplot = 
        Plot[{f[x], g[x], h[x]}, {x, -E, E}, 
          AspectRatio -> Automatic, PlotRange -> {-E, E}, 
          PlotStyle -> {{Thickness[0.01], Blue}, {Thickness[0.01], 
                Red}, {Thickness[0], Purple}}];

Note that the plot was named, fghplot.  If you want to use the plot later you can use Show command to let Mathematica show the plot without asking it to redo the computations.

Show[fghplot];

If you are not impressed with the above gimmick example, see the following program.

Clear[f, g, h, x];
f[x_] = (E^x);
g[x_] = Log[x];
h[x_] = x;
expplot = 
        Plot[f[x], {x, -E, E}, PlotRange -> {-E, E}, 
          PlotStyle -> {{Thickness[0.01], Blue}}, 
          DisplayFunction -> Identity];
logplot = 
        Plot[g[x], {x, 0, E}, PlotRange -> {-E, E}, 
          PlotStyle -> {{Thickness[0.01], Red}}, 
          DisplayFunction -> Identity];
symplot = 
        Plot[h[x], {x, -E, E}, PlotRange -> {-E, E}, 
          PlotStyle -> {{Thickness[0], Purple}}, 
          DisplayFunction -> Identity];
Show[expplot, logplot, symplot, 
        DisplayFunction -> $DisplayFunction];

Now don't they look symmetric!  No more error messages, either!  In the above program, we named the graphs of the exponential function, the log function and of y = x, and then showed them together through Show command in the end.  Also, we changed the DisplayFunction appropriately so that unnecessary graphs are computed, but not displayed.  This method is utilized frequently, when we need to combine two more plots together.

Example 2.5.3.

Plot the following function in an appropriate domain.

f(x)=(({{({{Sin[x],,        x < 
                            0}, {0.5,,        x = 0}})}, {({{1 - 0.1  (x^2),, x > 0}})}})

Solution.

\(\(negplot = 
        Plot[Sin[x], {x, \(-2\) π, 
            0}, 
		PlotStyle -> {{Blue, Thickness[0]}}, 
          AspectRatio -> 
            1/GoldenRatio, 
DisplayFunction -> 
            Identity];\)\)
\(\(zeroplot = 
        Graphics[{Blue, PointSize[0.015], 
	
            Point[{0, 0.5}]}];\)\)
\(\(posplot = 
        Plot[1 - 0.1  x\^2, {x, 
            0, π}, 
		PlotStyle -> {{Blue, Thickness[0]}}, 
          AspectRatio -> 1/GoldenRatio, \ 
          DisplayFunction -> Identity];\)\)
Show[negplot, zeroplot, posplot, 
        DisplayFunction -> $DisplayFunction];

By the way, here is another way to define and graph a function piecewise.

Example 2.5.4.

Plot the following piecewise defined function in an appropriate domain.

f(x)={({{({{Sin[x],,        x < 
                                0}})}, {({{1 - 0.1  (x^2),, x > 0}})}})

Solution.

Clear[f, x];
f[x_] := Sin[x] /; x ≤ 0;
f[x_] := 1 - 0.1  (x^2) /; x > 0;
\(\(Plot[
        f[x], {x, \(-2\) π, π}, 
		PlotStyle -> {{Blue, 
              Thickness[0]}}, 
        AspectRatio -> 1/GoldenRatio];\)\)

There is a fundamental difference between the method used in Example 2.5.3 and that in Example 2.5.4.  Example 2.5.3 plotted y = f(x) in three separate domains and then displayed the three plots together.  Example 2.5.4, on the other hand, defined f(x) piecewise, and then plotted y = f(x) in entire (-2 π, π).  The second method is simpler, but it cannot plot (0, f(0)).

(2.6)  Advanced programing.

In this subsection, we discuss the use of Mathematica commands that do not appear very often in calculus level.  These aren't really advanced topics in the view point of computer science.

2.6.1.  Lists and tables.

Here are some examples of lists.

numbers = {2, 4, 8, 45, 3, 1, 2, 1, 2, 5, 
        78}
points = {{1, 2}, {3, -2}, {8, 0}, {3, -2}}

There are several different ways to represent a list.

StandardForm[points]
MatrixForm[points]
ColumnForm[points]
TableForm[points]

Ordering does matter in lists.  n-th entry of a list can be found by putting [[n]] behind the name of the list.

numbers[[3]]
points[[2]]

By disregarding the order, we can make a list a set.

Union[numbers]
Union[points]

One of more effective way to get a list is to use Table command.

newnumbers = Table[i, {i, 1, 10}]
newpoints = 
      Table[i + j, {i, 1, 10}, {j, 1, 10}]
MatrixForm[newpoints]

If there are too many braces, we can get rid of n pairs of them through the command Flatten[..., n].  If you don't specify the n value, all braces (save the outermost pair) will disappear.

Flatten[newpoints, 1]
Flatten[newpoints]

Another effective way to get a list is the command NestList.  It borderlines the topic of 2.6.3.  Its use is discussed in Example 2.6.4.  Finally, there is an interesting command called ListPlot that allows us to plot a list of points in a single viewing window.  A sample program that utilizes ListPlot is given in the addendum of Example 2.6.2.

Example 2.6.2.

Find all rational numbers of the form

q = (m/n),   n = 1, ⋯ , 
    20,   m = 1, ⋯ , n,

in the interval [0, 1].  How many are there?

Solution.

Here is the answer.

Clear[m, n];
allrats = 
      Union[Flatten[
          Table[(m/n), {n, 1, 20}, {m, 0, n}]]]
Print["The number of such rational numbers = ", 
        Length[allrats]];

We start from the innermost part.  For simplicity, let us take 1 ≤ n ≤ 10.

Table[(m/n), {n, 1, 10}, {m, 0, n}]

There are too many braces, so we flatten them all out by

Flatten[Table[(m/n), {n, 1, 10}, {m, 0, n}]]

Now, let us kill of the redundancy.

Union[
      Flatten[Table[(m/n), {n, 1, 10}, {m, 0, n}]]]
Length[%]

This covers all the rational numbers in [0, 1] with denominator 10 or less.  There are 33 of them.

Addendum.

The following program visualizes the graph of the following function in an interval [a, b].  It is written by Dave Roberts and Byungik Kahng.

φ[x]={({{0,, \(\(x ∉ ℚ\)\(,\)\)}, {(1/n), x = (m/n),}})   ({{ }, { m ∈ ℤ, 
                  n ∈ ℕ, gcd(m, n) = 1. }})

As you increase nn, the maximum of n, you can see the overwhelming majority of the dots are concentrated below y = ε, the blue band at the bottom of the plot.

Clear[i, j, nn, PP, RR, BB, a, 
        b, ε];
margin = 0.02; topend = 0.5; 
    dotsize = 0.002;
a = 0; b = 2;
nn = 100; ε = 0.05;
epsilonplot = 
        Graphics[{RGBColor[0.85, 1, 1], 
            Polygon[{{a, 0}, {b, 
                  0}, {b, ε}, {a, ε}}]}];
allrats = 
        Union[Flatten[
            Table[i/j, {j, 1, nn}, {i, a*j, b*j}]]];
bigrats = 
        Union[Flatten[
            Table[If[(1/
                      Denominator[i/j]) ≥ ε, 
                i/j, 1], 
{j, 1, nn}, {i, a*j, 
                b*j}]]];
alldots = 
        Table[{allrats[[i]], 1/Denominator[allrats[[i]]]}, {i, 1, 
            Length[allrats]}];
highdots = 
        Table[{bigrats[[i]], 1/Denominator[bigrats[[i]]]}, {i, 1, 
            Length[bigrats]}];
alldotsplot = 
        ListPlot[alldots, Axes -> False, Frame -> True, 
          PlotStyle -> {Black, PointSize[dotsize]}, 
          DisplayFunction -> Identity];
highdotsplot = 
        ListPlot[highdots, Axes -> False, Frame -> True, 
          PlotStyle -> {Red, PointSize[2*dotsize]}, 
          DisplayFunction -> Identity];
PhiPlot = 
        Show[epsilonplot, alldotsplot, highdotsplot, Frame -> True, 
          AspectRatio -> 1/GoldenRatio, 
          PlotRange -> {{a - margin, b + margin}, {0, topend + margin}}, 
          DisplayFunction -> $DisplayFunction];
Print["The \
number of dots above y = ", ε, " is " , 
        Length[bigrats]];
\(Print["The total number of dots is "\ , Length[allrats]];\)

2.6.3.  Recursively defined functions and sequences.

Sometimes, we need to define functions or sequences recursively.  Here is a basic example.

Clear[f, n]
f[0] = 1;
f[n_] := f[n] = f[n - 1]^2 + 1;
Table[f[n], {n, 0, 5}]

If you disregard f[n] in the third line and write f[n_]:=f[n-1]^2 + 1, the computation will take longer.

You can disregard f[n] in the third line and write f[n_]:=f[n-1]^2 + 1.

Clear[f, n]
f[0] = 1;
f[n_] := f[n - 1]^2 + 1;
Table[f[n], {n, 0, 25}];
Print["Done."];

However, this program contains duplicate computations of f[n] that slows down the computer.  We can cache the value of the functions and avoid duplicate computation by naming the values of f[n] within the definition as follows.

Clear[f, n]
f[0] = 1;
f[n_] := f[n] = f[n - 1]^2 + 1;
Table[f[n], {n, 0, 25}];
Print["Done."];

This speeds up the evaluation by storing each value of the function as it is calculated but takes up more memory.

Another effective way to get sequences through recursive formulae is to use iteration of a function.  Here is a basic example.

Clear[g, n]
n = 25;
g[x_] = (x^2) + 1;
NestList[g, 1, n];

The computation is fast, but we get the sequence only up to n (n = 5 in this example).

2.6.5.  Local substitution.

Mathematica allows you to substitute an expression for a symbol for one line, without affecting its value in other part of program.  For instance,

Clear[a, x]
a = x /. x -> 3;
x
a

As you see above, a value was assigned (permanently) as x, where x is temporarily assigned as 3.  Therefore, a value remains as 3 and it will stay as 3 until it is cleared or given another value.  x value, on the other hand, was not affected, because the value 3 was assigned to x only temporarily.  This concept will be discussed more extensively in the following examples.

Example 2.6.7.

Solve the following system of equations.

y z = λ(y + z) + μ
z x = λ(z + x) + μ
x y = λ(x + y) + μ
x + y + z = 5
x y±y z+z x=-75

Solution.

If we want only the solutions, we need nothing but Solve command.

Clear[x, y, z, λ, μ]
Solve[{y z == λ (y + z) + μ,  
        z x == λ (z + x) + μ,  
        x y == λ (x + y) + μ, 
        x + y + z - 5 == 0, x y + y  z + x z + 75 == 0}, {x, 
        y, z, λ, μ}]

Apparently, the system has 6 real roots.  Now, suppose that we wish to do something with the solutions.  One way is to type up all the roots for the next part of your program, but that way, you can't make your program interactive.  For instance, if you change the equation a little and get different set of roots, you must go back to your program and change all the solutions.

Clear[x, y, z, λ, μ]
Solve[{y z == λ (y + z) + μ, z x == λ (z + x) + μ, x y == λ (x + y) + μ,x + y + z - 5 == 0,x y - y  z + x z + 75 == 0},{x, y, z, λ, μ}]

Local substitution can solve this problem.

Clear[x, y, z, λ, μ]
roots = {x, y, z, λ, μ} /. 
        Solve[{y z == λ (y + z) + μ,  
            z x == λ (z + x) + μ,  
            x y == λ (x + y) + μ, 
            x + y + z - 5 == 0, 
            x y + y  z + x z + 75 == 0}, {x, y, 
            z, λ, μ}]

If you want to work with the first root, for instance, you can write

roots[[1]]

Or,

Print["{x, y, z, λ, μ} = ", 
        roots[[1]]];

If you need to change your equation, just go right ahead.

Clear[x, y, z, λ, μ]
roots={x, y, z, λ, μ}/.Solve[{y z == λ (y + z) + μ, z x == λ (z + x) + μ, x y == λ (x + y) + μ,x + y + z - 5 == 0,x y - y  z + x z + 75 == 0},{x, y, z, λ, μ}]
Print["{x, y, z, λ, \
μ} = ", roots[[1]]];

2.6.10. Miscellaneous commands.

Random[]

data = {{1, 2}, {2, 4}, {3, 7}, {4, 
            11}};
curvefit = Fit[data, {1, t, (t^2)}, t]

(2.7)  Help browser and palettes.

2.7.1.  Help Browser

Mathematica comes with its own manual.  Go to Help and select Help Browser, and you can get help on numerous Mathematica commands.  It takes a while when you open the help browser for the first time.

If you are real novice and need fruther help, try Tutorial, included in the Help menu.

2.7.2.  Palettes.

Mathematica 4.x or higher supports various traditional mathematical symbols.  Go to Format and then Palettes to see various palettes.  The shortest and the most commonly used palette is BasicInput.  Most mathematical symbols in calculus level are supported in BasicInput.  If more symbols are needed, consider selecting BasicTypesetting or CompleteCharacters.

AlgebraicManipulation and BasicCalculation contain large lists of commonly used Mathematica commands for algebraic and other mathematical operations.

3.  Formatting and Editing Mathematica Notebooks

Mathematica can be used as a word-processor or a presentation tool by clever formatting.  This section has nothing to do with Mathematica programing.  The first subsection is a review.  It is identical to (1.4).

(3.1)  How to create and format text cells.

The default style of a new cell is input.

However,  
    writing long comments in input cells is not a good idea .   Not only one must put up with ugly fonts,  
    one gets unnecessary error messages and beeps when he/
        she tries to run a whole section or a notebook.

Instead, we recommend users to create text cells, or to convert ugly looking input cells to text cells.  This can be done by selecting Format, Style and then Text.  You can do this at any time.  Either before creating a new cell, or create an input cell and then change its style to text format.  Once you get a text cell running, you can use the Format option again to change its font, size, text color, background color, alignment, etc.  In short, you can use Mathematica like a word-processor that supports mathematical symbols.

(3.2)  Format.

The best way to learn these features and more are actually trying.  Go to Format in the top horizontal bar and use your common sense.  You can use your mouse to select a block, and then change the format of the highlighted block.  If you wish to change the format of entire cell, select entire cell by clicking the cell bracket in the right hand side.  You can change Style (title, section, text, input, output, ...), Font, Face, Size, Text Color, Background Color, Text Alignment, etc. through Format.

This is what happens when you highlight only a text-block and set the background color.

This is what happens if you select entire cell and set the background color.

The former method is useful when you wish to  partially  change the format within a cell.

The latter is useful when you want to highlight the entire cell.  You can go further by selecting Format, Background Color, Cell Gray Box to emphasize the paragraph further.

(3.3)  Cell.

3.3.1.  Convert To.

You can convert the Mathematica's default input forms to traditional mathematical symbols (and vice versa) through Convert To.  For instance, you can change the following default input forms,

Integrate[(x-1)/(x^2+1),{x,0,1}]
Limit[Sin[x]/x,x->0]
Sum[k^2,{k,n}]

to

(∫_0^1)(( x - 1)/((x^2) + 
              1)) dx
(lim_(x -> 0)) ((sin(x))/x)
(∑_(k = 1)^n) (k^2)

Mathematica can handle such traditional forms.

(∫_0^1)(( x - 1)/((x^2) + 
              1)) \[DifferentialD]x

(lim_(x -> 0)) ((sin(x))/x)

(∑_(k = 1)^n) (k^2)

3.3.2.  Cell Grouping

Cell Grouping can be useful in many ways.  In programing, you can group a number of cells together so that they can be run sequentially.  In text editing, you can mark the beginning and the end of a section, subsection, a problem, solution, proof, etc.  The default setting is Automatic Grouping.  You must change it to Manual Grouping before actively engaging in cell grouping.  UMM Calculus notebooks are already set as manual grouping, so you need not worry about this part.

3.3.3.  Other cell options.

Animate Selected Graphics will be used often in UMM Calculus.  Align Selected Graphics is useful when making several graphics into the same non-default size.  These commands can be used only after the selection is made.  Beginners should not play with Cell Properties, unless they know what they are doing.

(3.4)  Palettes.

3.4.1.  Traditional mathematical symbols.

Mathematica 4.x or higher supports various traditional mathematical symbols.  Go to Format and then Palettes to see various palettes.  The shortest and the most commonly used palette is BasicInput.  Most mathematical symbols in calculus level are supported in BasicInput.  If more symbols are needed, consider selecting BasicTypesetting or CompleteCharacters.

3.4.2.  Mathematical operations.

AlgebraicManipulation and BasicCalculation contain large lists of commonly used Mathematica commands for algebraic and other mathematical operations.

3.4.3.  Other palettes.

For those who write books with Mathematica, AuthorTools may be useful.  CreateSlideShow may be useful for those who present with Mathematica.  InternationalCharacters supports various European languages.