Introduction to Mathematica
Math 221 Linear Algebra, Fall 2021
September 9, 2021

T. Ratliff, Wheaton College
ratliff_thomas@wheatoncollege.edu

A few basics

Mathematica notebooks are composed of different types of cells. 
This is a text cell where you can enter comments and descriptions. The text cells in this notebook have a dark red font.  
Commands are contained in input cells, like the one below, where the font is black. 

Mathematica commands begin with capital letters, so I’ll often use lower case for variables to avoid any conflict
Arguments are contained in square brackets [ ]

To execute a Mathematica command, press SHIFT-ENTER

For example, to graph y=cos(x) from x=0 to 2 π, move anywhere in the following input cell and press SHIFT-ENTER

Plot[ Cos[x], {x,0,2Pi}]

Or to find the derivative of sin(8π x) *(Sqrt[cos(23(x^2))]) with respect to x

D[ Sin[8 Pi x] * Sqrt[ Cos[23 x^2]], x]

Working with matrices (Example 1 from class today)

A basic structure in Mathematica is a list enclosed in braces { }
To enter a matrix, each row is a list, and then the matrix is a list of lists.
For example, to enter the matrix  A = (({{1, -2, 1}, {3, 1, -2}, {5, -3, 0}})), we enter (remember SHIFT-Enter to execute the command!)

a ={ {1,-2,1},{3,1,-2},{5,-3,0}}

The advantage of naming the matrix is that we don’t have to retype it

RowReduce[a]

We can make this look a little prettier by displaying the output as a matrix

RowReduce[a] // MatrixForm

Example 2

Enter the augmented matrix

a = {{1,-2,1,-3},{3,1,-2,2},{5,-3,0,-4}}

I like to check that I didn’t have a typo

a //MatrixForm

Now let’s row reduce

RowReduce[a] //MatrixForm

In-class #5a

a= { {1,3,5},{-2,-6,7}}
a//MatrixForm

RowReduce[a] //MatrixForm

In-class #5b

a= { {1,3,5,-3},{-2,-6,7,9}}
a//MatrixForm

RowReduce[a] //MatrixForm

In-class #6

a = {{1,2,3,5,-7},{2,4,3,1,-4},{-1,-2,-6,-14,17}}
a//MatrixForm

RowReduce[a]//MatrixForm

Socrative Questions

If you press ‘Enter’ rather than ‘SHIFT-Enter’, Mathematica won’t execute the commands. 
This gives a way to put several commands in a single input cell and execute them all at once.

a1 = { {1,2,-3},{2,-3,4},{-1,3,2}}
a1//MatrixForm
RowReduce[a1] //MatrixForm

a2 = { {2,0,-2},{0,-1,-4},{3,6,21}}
a2//MatrixForm
RowReduce[a2]//MatrixForm