# 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

# Mathematica Commands

Before using variables in Mathematica, it's always a good idea to quit the Kernel or to use the Clear command to make sure your variables don't have any old meanings attached to them:
Clear[f,x]

The following commands and syntax are very helpful to solving algebraic and differential equations using Mathematica.

 /. means ReplaceAll -> means Rule & means Function && means logical AND || means logical OR != means not equal # means Slot N means numerical evaluation D means differentiation Dt means evaluation of the total derivative % means is used to refer to the output of the previous command line %% means is used to refer to the output of the two previous commands

The command, Part, can be used to extract any sub-expression from a function. Part[expression,n] is the same as expression[[n]]
An example of this command is.
u={a,b,c,d,e}
Part[u,2]
gives b or
u[] gives b again.

For example, if a, b, and x are specific real numbers, then the expression Not[a<= x <=b] and the command (x<a) || (x>b) each return True when the number x is not within the interval [a,b] and False otherwise.

If you have a function of a single variable defined, say f and you wish to take the derivative of of f all you need to type is f ‘ and press shift+enter. If you wish to take a second derivative, you would type f ‘ ‘. If you have a function of more than one variable then you should use the derivative function. Suppose you have a function F=f(x,y,z), then you would type D[function, variable] . A third and final way is to use the derivative function located in the Basic Math Assistant palette and scroll down to type settings. Select the button, which best suits your needs.

When you use N for numerical evaluation, Mathematica usually provides only its truncated version up to six digits. If you wish to see all the digits in the answer that Mathematica knows, you can use the InputForm command:

N[Pi]
3.14159
InputForm[%]
3.141592653589793
There is a very important Mathematica command---Reduce.
Cosh[x]^2 - Sinh[x]^2 == TrigReduce[Cosh[x]^2 - Sinh[x]^2 ]
Cosh[x]^2 - Sinh[x]^2 == 1

Another important command is related to maximization/minimization.
Maximize[(-0.2^2/3)*(-1/x^2), {x} \[Element] Interval[{8.1, 8.5}]]
{0.000203221, {x -> 8.1}}

Suppose you want to substitute the values a = 4 and b= 5 into the expression a² +b³. This may be accomplished with the command (below->is generated by using the - and > key)

a^2 + b^3 /.{a->4, b->5} (*Shift Enter *)
Here {a->4, b->5} is called a rule that says a becomes 4 and b becomes 5. The /. means apply the rule given after /. to the result of computing whatever comes before /. .