September 8, 2015

A first Mathematica notebook for Math 221 Linear Algebra
This is for #1 from the In-Class work at the end of class last Thursday.

I think using the Palatte is the easiest way to enter a matrix. 
I entered the matrix below by using the menu option
	Palettes - Basic Math Assistant - Calculator - Advanced
I selected the 2x2 matrix and then used Row+ and Col+ to make it 3x3
After entering the matrix, you need to press SHIFT-RETURN for Mathematica to execute the line

A = (({{2, 5, -14}, {1, 1, -1}, {1, -2, 11}}))

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

RowReduce[A]

We can make this look a little prettier by displaying it as a matrix rather than as a list of the rows.
The %2 refers to the output on line 2

%2 // MatrixForm

You can also access WolframAlpha by entering the equal sign = at the beginning of your input.
You then just need to press return.

Let’s see what this tells us geometrically. 

First, we’ll pick out the columns of A as vectors.

u=A[[All,1]]
v=A[[All,2]]
b=A[[All,3]]

Let’s plot u, v, and w. 
(Don’t worry about learning this Mathematica syntax)

vecu =Graphics3D[{Red, Thickness[0.01],Arrow[{ {0,0,0},u}]}];
vecv = Graphics3D[{Blue, Thickness[0.01], Arrow[{ {0,0,0},v}]}];
vecb= Graphics3D[{Cyan, Thickness[0.01], Arrow[{ {0,0,0},b}]}];
Show[{vecu,vecv, vecb}]

Now let’s verify that w = 3u - 4v

threevecu =Graphics3D[{Red, Thickness[0.01],Arrow[{ {0,0,0},3*u}]}];
negfourvecv = Graphics3D[{Blue, Thickness[0.01], Arrow[{ 3*u,3*u-4*v}]}];
vecb= Graphics3D[{Cyan, Thickness[0.01], Arrow[{ {0,0,0},b}]}];
Show[{threevecu,negfourvecv, vecb}]

Let’s see what happens with the lines corresponding to the rows of the matrix

Plot[{1/5(-14-2x), -1-x, -1/2(11-x)}, {x,-5,5}]

Now let’s do the same for #2.

B= (({{2, 5, 13}, {1, 1, 8}, {1, -2, -42}}))

RowReduce[B] //MatrixForm

The right column of the augmented matrix has a pivot, so the system is inconsistent. 

Let’s look at this geometrically. 

u and v are still defined from above

b=B[[All, 3]]

vecb= Graphics3D[{Cyan, Thickness[0.01], Arrow[{ {0,0,0},b}]}];
Show[{vecu,vecv, vecb}]

Now let’s plot the lines corresponding to the rows.

Plot[{1/5(13-2x), 8-x, -1/2(-42-x)}, {x,-30,15}]