Matrices and linear algebra

Last week we did vector
operations with *lists*. This week we
introduce you to matrices, their representation using lists and to
some of the matrix operations which Mathematica is able to do.
The reading material for this week is sections 1.2.1-1.2.6 (same as
last week) and 1.83, 1.84 of A practical
introduction to Mathematica .

Let us first see how to represent matrices in Mathematica as
a *list*. Type ``m={{a,b},{c,d}}''.
Now ``type MatrixForm[m]''.
Note that all of the *Mathematica operations* must be
applied to the *list* form of the matrix (not the matrix form).
You can see that you get the matrix *m* with its elements *a*,*b*,*c*,*d* in the
usual form. You can think of this matrix as consisting of two row vectors
(a,b) and (c,d). Type ``m[[1]]'' and check you get the first row
vector (a,b). Now type ``m[[1,1]]''; this will give you the 1st element
of the first vector, namely *a* (notice that ``m[[1]][[1]]'' also
does the same thing). Likewise, to access the element *d*,
type ``m[[2,2]]''. As you have done with vectors, you can perform algebraic
operations on matrices. You can multiply a matrix with a vector.
To see this, type ``r=x,y''.
In order to take a dot product of the matrix *m*
with this vector *r*, Type ``m.r'' (or Dot[a,r]).
Now type ``Dimensions[m]''. The output (2,2) verifies
that the matrix *m* is a matrix.

At times, you need to get
the *transpose* of a matrix, which is obtained by exchanging its
off-diagonal
elements (in this case the elements *c* and *d*). Type ``t=Transpose[m]''.
Now type ``MatrixForm[t]''. You see that the matrix has diagonal elements
the same but the elements *c* and *d* got interchanged with respect to
the original matrix *m*. Often we require the *determinant*
of a matrix, which
is a scalar quantity constructed from the elements. Type ``Det[m]'' which
will give you the *determinant* of the matrix *m*. Now type ``Det[t]''
and verify that the *determinant* is the same for the transposed matrix.
A *diagonal matrix* has all off-diagonal elements set to zero.
Type ``DiagonalMatrix[{e,f}]''.
Now type ``MatrixForm[DiagonalMatrix[{e,f}]]''
(you can type this by taking the cursor to the end of the output and pushing
the return key. Mathematica will immediately give you a replica of the output
which you can use as partial input for further operations.
This is a convenient way of avoiding the usual cut and paste).

The ``Inverse'' of a matrix is the one which
when multiplied by the original matrix
produces a unit diagonal matrix (unit matrix, as it is often called).
Type ``mi=Inverse[m]''. Now take the product ``h=m.mi'' and check that
h is indeed a unit matrix ( you may have to perform ``Simplify'' on h).
In general any
matrix has n eigenvalues and n eigenvectors.
Type ``Eigenvalues[m]'' followed by ``Eigenvectors[m]'' to see what
they are for the matrix m.

**Assignment 3. - Hand in by Thursday Feb. 3rd**

**Problem 1**. The
matrix , ** A**, is constructed from
the following rows: (5,3) and (2,1).

(i) Write it in matrix form.

(ii) Find its determinant.

(iii) Find its transpose.

(iv) Find its inverse,

(v) Check is a unit matrix.

(vi) Find its eigenvalues and eigenvectors.

**Problem 2**.

(i) Find the solution to the following set of equations:

2*x* - *y* + 2*z* = 2

-*x* + 5*y* + *z* = 1

2*x* + *y* + 6*z* = 1

(Hint: Write it as a matrix equation Ax=b, which
has solution *x*=*A*^{-1}*b*).

Check that you have the solution by evaluating *Ax*-*b*.

(ii) Try to find the solution to the following set of equations:

1*x* + 2*y* - *z* = 2

1.3*x* - 3.2 *y* + 1.3*z* = 1

-2.1*x* - 4.2 *y* + 2.1 *z* = 1

Explain why this set of equations does not have a unique solution.