# Preface

This tutorial was made solely for the purpose of education and it was designed for students taking Applied Math 0330. It is primarily for students who have very little experience or have never used *Mathematica* and programming before and would like to learn more of the basics for this computer algebra system.
As a friendly reminder, don't forget to clear variables in use and/or the kernel. The *Mathematica* commands in this tutorial are all written in **bold black font**,
while *Mathematica* output is in normal font.

Finally, you can copy and paste all commands into your *Mathematica* notebook, change the parameters, and run them because the tutorial is under the terms of the GNU General Public License
(GPL). You, as the user, are free to use the scripts for your needs to learn the *Mathematica* program, and have
the right to distribute this tutorial and refer to this tutorial as long as
this tutorial is accredited appropriately. The tutorial accompanies the
textbook *Applied Differential Equations.
The Primary Course* by Vladimir Dobrushkin, CRC Press, 2015; http://www.crcpress.com/product/isbn/9781439851043

Return to computing page for the second course APMA0340

Return to Mathematica tutorial for the first course APMA0330

Return to Mathematica tutorial for the second course APMA0340

Return to the main page for the course APMA0330

Return to the main page for the course APMA0340

## Glossary

# Case Sensitivity

In fact, every predefined symbol in *Mathematica* begins with a capital letter. One advantage of
this is that you can define your own symbols beginning with
lowercase letters, knowing that you will not conflict with any
of *Mathematica*'s names. *Mathematica* is case sensitive for both variables that can be defined and for commands. The variable a (lower case) is different from A (upper case). You will know if the command that you enter is correct because the color of the command will change to black. The irrational constant Pi (=3.141926...) can be entered either as **Pi** or, to see Greek letter, as **\[Pi]** (this is how *Mathematica* displays Greek letters).

One of the key aspects of using *Mathematica* is knowing how to enter a command. Once you have typed the command, hold shift down and then hit enter. Hitting shift and enter simultaneously allows you to enter the command, but just hitting enter has no effect.

Subscripts can be very helpful when differentiating between variables. To create a subscript first navigate to your Basic Math Assistant palette. If it is not already up navigate to Palettes in your toolbar and it will be your first choice. On the toolbar scroll down until you see typesetting. Select If you wish to add a subscript to a variable that has already been typed, simply highlight the variable before you select . If you wish to add a superscript, select . If you wish to add both a subscript and a superscript select . If you wish to avoid the toolbar you can just as easily type in your subscripts and superscripts using the format shown below

Superscript[x,a]

Subscript[Superscript[x,a],3]

Consider the following calculation:

*Mathematica*knows that the tangent of \( \pi /3 \) is exactly a square root of 3; it does not return an estimate like 1.73205, as a handheld calculator might.

Now compare the previous example with this:

The only difference between the two examples is that the integer
3 in the first was replaced by the floating point number
3.0 in the second. This difference was enough to cause
*Mathematica*
to return a floating point (approximate) result in the
second example.

Here is an important rule: An expression involving only exact (symbolic) quantities will be evaluated exactly
(symbolically), while an expression involving one or more floating point numbers will be evaluated approximately using
floating point arithmetic.

There are two more points that I would like to emphasize. First of all, one will often wish to perform a
calculation in several steps.
*Mathematica* makes it possible to refer to previous results in a couple of ways. The "**%**"
character always represents the last output. To refer to an earlier output (not just the most recent), use
the "**Out**" keyword, followed by the index of the output. For
example, Out[1] always refers to the first output of your
*Mathematica* session:

**N**operator:

Any built-in command/function in *Mathematica* has a literal/string
equivalent. This is most easily seen with the help of the built-in
function FullForm, which shows the internal representation of any
object/expression, in the way it is really "seen" by the kernel. For
instance:

**TreeForm**command:

In[4]:= a[[1,2]]

Rewrite Rules: A typical rule looks like a -> b where in general < a > and < b > are some *Mathematica* expressions.
The rule just says: whenever < a > is encountered, replace it by < b >.
A pattern is essentially any expression with some part of it replaced by "blank" (Blank[]), which is a placeholder for any expression - that is, instead of that part there can be anything (this is somewhat oversimplified). The literal equivalent for Blank[] is the single underscore ("_") symbol. For instance, f[x_] means f[anything].

**Example: **
In this example, we first start with the **Clear** command to remove previous value f.
Realistically you will only be using the command as **ClearAll** is more often used in more advanced computations than will be covered in this tutorial.

In[7]:= f[x_]= x^2 - Sin[x]

In[8]:= f[Sqrt[3]], f[Oliver]

**DownValues**command. With its help we see:

f[x_ ?OddQ] := x^3;

f[x_] := Tan[Pi*x]

*Mathematica*is case-sensitive, so names like AA and Aa are considered different. There are several special symbols that should not be used in symbol names, such as @,#,$,%,^,&,*,!,~,`. What may be surprising for C programmers is that the underscore <_> should not be used either - it has a different purpose in

*Mathematica*.

If you are in doubt whether your symbol is legitimate, you can always
use the `Head[Unevaluated[yoursymbol]]`

command to check its head: if it
is, you are in business. The reasons why you need
`Unevaluated`

are a bit involved to discuss now, but basically it
guarantees that the Head function tests the head of your original
symbol rather than what it may evaluate to.

Return to Mathematica page

Return to the main page (APMA0330)

Return to the Part 1 (Plotting)

Return to the Part 2 (First Order ODEs)

Return to the Part 3 (Numerical Methods)

Return to the Part 4 (Second and Higher Order ODEs)

Return to the Part 5 (Series and Recurrences)

Return to the Part 6 (Laplace Transform)

Return to the Part 7 (Boundary Value Problems)