Math 4452 (Peh Ng)

Examples of Matrix Operations

To enter the data for an m x n matrix, we enter them as a list, but by the rows, i.e { {row1}, {row 2},... , {row n} } :

M={ {1.0,2.0,4.0},{0,-2,9}, {0,4,8}}

To view the entered data in matrix form,  type in:

m={ {1.0,2.0,4.0},{0,-2,9}, {0,4,8}}//MatrixForm

Suppose we want to multiply two matrices. Let A be the following matrix:

A={ {9.0,2.0,3.0},{5,1,6},{2,0,0}}

Let c be the product of A and M:

c=M*A

The following command, MatrixForm[%] means that you want the matrix format of the most recent (%) matrix output.

MatrixForm[%]

Suppose we want the scalar multiplication of 1/3 and A:

(1/3)*A

MatrixForm[%]

0.5M

MatrixForm[%]

Suppose we want the sum of scalar multiples or product of M & A:

T=0.2*A + 0.8*M -A*M

MatrixForm[%]

Suppose M is a square matrix and we want M^n where n is some positive integer, the command is Power[M,n]:

MatrixPower[M,2]

MatrixForm[%]

M={ {0.5, 0.4},{-0.104, 1.1}}

Suppose M is a square matrix and we want the eigenvalues of M

Eigenvalues[M]

Suppose we know M is 2x2, we can name both eigenvalues:

{λ,μ}=Eigenvalues[M]

These are the eigenvectors of M.

Suppose M is a square matrix and we want the eigenvectors of M:

Eigenvectors[M]

Suppose we know M is 2x2, we can name two eigenvectors:

{𝓊,𝓋}=Eigenvectors[M]

The following lists the eigenvalues and eigenvectors for M; eigenvalues are listed first.

Eigensystem[M]

M={ {1.5, 1.0},{0.5, 1.0}}

Eigensystem[M]