Chapter 1:  Systems of Linear Equations

MA 237

Richard Hitt

Introduction

Mathematica has several built-in commands to help with linear algebra.  First we need to know how to input a matrix.  This is done by describing the matrix as a list of lists.

m  =  {{a, b, c}, {d, e, g}}

You can view the matrix in a rectangular array as follows.

MatrixForm[m]

Row vectors and column vectors can be entered as appropriate matrices.

v1 = {{1, 2, 3}}

v1 // MatrixForm

v2 = {{1}, {2}, {3}}

v2 // MatrixForm

Another way to describe a column vector is as the transpose of a row vector.  This might be easier to input.

v3 = Transpose[{{1, 2, 3}}]

MatrixForm[v3]

Mathematica understands that v2 and v3 are the same.

v2 == v3

Mathematica understands multiplication of a matrix by a vector using the following syntax.

v = Transpose[{{x, y, z}}]
m . v // MatrixForm

Scalar multiplication can also be easily accomplished using the * or a blank space.  But be careful using the space because you can't always easily tell that its there.  So 3 c and 3c are interpreted differently in Mathematica -- the latter being the name of a new variable.

3*m // MatrixForm

Test 1

For a few examples, here are some of the Test 1 problems worked out in Mathematica.

Problem 1

m1 = {{2, -3, 2, 2}, {2, -2, 1, 4}}

m1 // MatrixForm

RowReduce[m1] // MatrixForm

Problem 2

m2 = {
{2, -1, 2, 6, 2, 
          2}, 
{2, -1, 1, 4, 1, 
          4}, 
{2, -1, 2, 5, 1, 
          1}, 
{2, -1, 1, 5, 2, 
          5}
}

m2 // MatrixForm

RowReduce[m2] // MatrixForm

a = Take[m2, {1, 4}, {1, 5}]

NullSpace[a]

a . NullSpace[a][[1]]

Problem 4

m4 = {{-1, 0, 0, 1, -20}, {0, 0, 1, -1, 10}, {0, 1, -1, 
          0, 25}, {1, -1, 0, 0, -15}}

m4 // MatrixForm

RowReduce[m4] // MatrixForm