Matrix Algebra

We review here some of the basic definitions and elementary algebraic operations on matrices.

There are many applications as well as much interesting theory revolving around these concepts, which we encourage you to explore after reviewing this tutorial.

A matrix is simply a retangular array of numbers. For example,

A = /






\
a11
a12
a1n
a21
a22
a2n
:
:
···
:
am1
am2
amn
\
 |
 |
 |
 |
 |
 |
/
is an m×n matrix (m rows, n columns), where the entry in the ith row and jth column is aij. We often write A = [aij].

Some Terminology

For an n ×n square matrix A, the elements a11,a22,,ann form the main diagonal of the matrix.  A square matrix is called lower triangular if all the entries above the main diagonal are zero, upper triangular if all the entries below the main diagonal are zero.  The sum
n

k = 1
akk of the elements on the main diagonal of A is called the trace of A.

The matrix AT = [aji] formed by interchanging the rows and columns of A is called the transpose of A. If AT = A, the matrix A is symmetric.

We can consider a matrix of complex numbers. If C = [cij] is a matrix of complex numbers the matrix C* obtained by taking CT and then taking the complex conjugate of each entry  is called the adjoint matrix (or the conjugate transpose) of C.

Example

Let B = /


\
6
9
-4
-6
\
 |
 |
/
. The trace of B is 6 + -6 = 0.

The transpose of B is BT = /


\
6
-4
9
-6
\
 |
 |
/
.

Addition and Subtraction of Matrices

To add or subtract two matrices of the same size, simply add or subtract corresponding entries. That is, if B = [bij] and C = [cij],

B + C = [bij + cij]  and   B-C = [bij - cij]

Example

For B = /


\
6
9
-4
-6
\
 |
 |
/
and C = /


\
1
2
-1
0
\
 |
 |
/
,

B + C = /


\
6 +1
9+2
-4+(-1)
-6+0
\
 |
 |
/
= /


\
7
11
-5
-6
\
 |
 |
/

B-C = /


\
6 -1
9-2
-4-(-1)
-6-0
\
 |
 |
/
= /


\
5
7
-3
-6
\
 |
 |
/

The m×n zero matrix, 0, for which every entry is 0, has the property that for any m×n matrix A,

A+0 = A

Scalar Multiplication

To multiply a matrix A by a number c (a ``scalar''), multiply each entry of A by c. That is,

cA = [caij].

Example

Using the matrix B = /


\
6
9
-4
-6
\
 |
 |
/
from the previous example,
3B = 3 /


\
6
9
-4
-6
\
 |
 |
/
= /


\
18
27
-12
-18
\
 |
 |
/
.

Matrix Multiplication

Let X be an m×n matrix and Y be an n×p matrix. Then the product XY (or X×Y) is the m×p matrix whose (i,j)th entry is given by

n
Σ
k = 1 
xikykj

Notes

  • The product XY is only defined if the number of columns of X is the same as the number of rows of Y.
  • (X×Y)T = YT×XT.
  • (X×Y)×Z = X×(Y×Z). 
  • XY and YX  may not both be defined. If they both do exist, they are not necessarily equal and might not even be of the same size.

Example

For the matrices B = /


\
6
9
-4
-6
\
 |
 |
/
and C = /


\
1
2
-1
0
\
 |
 |
/
,
BC = /


\
6
9
-4
-6
\
 |
 |
/
/


\
1
2
-1
0
\
 |
 |
/
= /


\
(6)(1)+(9)(-1)
(6)(2)+(9)(0)
(-4)(1)+(-6)(-1)
(-4)(2) + (-6)(0)
\
 |
 |
/
= /


\
-3
12
2
-8
\
 |
 |
/
while
CB = /


\
1
2
-1
0
\
 |
 |
/
/


\
6
9
-4
-6
\
 |
 |
/
= /


\
(1)(6) + (2)(-4)
(1)(9) + (2)(-6)
(-1)(6) + (0)(-4)
(-1)(9) + (0)(-6)
\
 |
 |
/
= /


\
-2
-3
-6
-9
\
 |
 |
/

The n×n matrix having all main diagonal entries equal to 1 and all other entries equal to 0 is called the identity matrix I. For example, the 3×3 identity matrix is

/



\
1
0
0
0
1
0
0
0
1
\
 |
 |
 |
/

The n ×n identity matrix has the property that if A is any n ×n matrix,

AI = IA = A.

Inverse of a Matrix

Start with an n ×n matrix X. Suppose the n ×n matrix Y has the property that

XY = YX = I.
Then Y is called the inverse of X and is denoted X-1.

Notes

  • Only square matrices X can have inverses. If X is not square, then for any Y the product XY will not be the same size matrix as the product YX (if we're lucky enough even to have both products exist!).
  • Not every square matrix has an inverse. If an inverse exists, it is unique.
  • If a matrix has an inverse, the matrix is said to be invertible.

The inverse of a 2 ×2 matrix is simple to calculate:

If   A = /


\
a
b
c
d
\
 |
 |
/
, then A-1 = 1
ad-bc
/


\
d
-b
-c
a
\
 |
 |
/
.

Example

The inverse of C = /


\
1
2
-1
0
\
 |
 |
/
is
C-1 = 1
(1)(0)-(2)(-1)
/


\
0
-2
1
1
\
 |
 |
/
= 1
2
/


\
0
-2
1
1
\
 |
 |
/
= /


\
0
-1
1/2
1/2
\
 |
 |
/

Note that CC-1 = /


\
1
2
-1
0
\
 |
 |
/
/


\
0
-1
1/2
1/2
\
 |
 |
/
= /


\
1
0
0
1
\
 |
 |
/

       and C-1C = /


\
0
-1
1/2
1/2
\
 |
 |
/
/


\
1
2
-1
0
\
 |
 |
/
= /


\
1
0
0
1
\
 |
 |
/

Matrix B = /


\
6
9
-4
-6
\
 |
 |
/
does not have an inverse.

Determinant of a Matrix

How did we know that B = /


\
6
9
-4
-6
\
 |
 |
/
does not have an inverse?

The determinant of A, detA, is a number with the property that A is invertible if and only if detA ≠ 0.

For a 2 ×2 matrix A = /


\
a
b
c
d
\
 |
 |
/
, detA = ad -bc.

Example

For B = /


\
6
9
-4
-6
\
 |
 |
/
, detB = (6)(-6)- (9)(-4) = -36+36 = 0, so B is not invertible.
That is, B does not have an inverse.

For a 3 ×3 (or larger) matrix A, things are a little more complicated:

Denote by Mij(A) the determinant of the matrix formed by deleting row i and column j from A.
Define cij(A) = (-1)i+jMij(A) to be the (i,j) cofactor of A.
Then we can compute detA by the Laplace Expansion along any row or column of A:

Along row i:
det
A = ai1ci1(A) + ai2ci2(A) + + aincin(A)
Along column j:
det
A = a1jc1j(A) + a2jC2j(A)+ + anjcnj(A)

Example

Let A = /




\
1
-1
3
1
0
-1
2
1
6
\
 |
 |
 |
 |
/
.

Along the first row,

detA
=
(1) [ (0)(6) - (-1)(1) ] - (-1)[ (1)(6)-(-1)(2) ] + 3 [ (1)(1)-(0)(2) ]
=
(1)(1) + (1)(8)+(3)(1)
=
12.

Computing detA along the second column instead,

detA
=
-(-1) [ (1)(6) - (-1)(2) ] - ( 0)[ (1)(6)-(3)(2) ] - 1 [ (1)(-1)-(3)(1) ]
=
(1)(8)+(0)(0)-(1)(-4)
=
12  as expected.

It can be proven that  det(AT) = det(A)  and that  det(A×B) = det(A)·det(B).


Vedi qui per il calcoli con R.


Some computation techniques are discussed in Solving Systems of Equations.


Key Concepts [index]

Let A = [aij]  and   B = [bij] .

  • Transpose AT of A:
    AT = [aji]

  • Trace of A:
    n
    Σ
    k = 1 
    akk  (for an n×n matrix A)

  • Identity Matrix I:

    the n ×n matrix with 1's on the main digonal and 0's elsewhere.

  • A+B and A-B:
    A+B = [aij+ bij]
    A-B = [aij -bij]

  • Scalar Multiplication:
    cA = [caij]

  • Matrix Product AB:

    (i,j)th entry is n

    k = 1
    aikbkj

    (for an n×n matrix A and an n ×p matrix B)

  • Inverse A-1 of A:

    A-1 satisties AA-1 = A-1A = I.

    If A = /


    \
    a
    b
    c
    d
    \
     |
     |
    /
    ,

    then A-1 = 1
    ad-bc
    /


    \
    d
    -b
    -c
    a
    \
     |
     |
    /

  • Determinant detA:

    If A = /


    \
    a
    b
    c
    d
    \
     |
     |
    /
    ,
    detA = ad-bc.

    In general,

    along row i:

    detA = ai1ci1(A) + ai2ci2(A) ++ aincin(A)

    along column j:

    detA = a1jc1j(A) + a2jC2j(A)+ + anjcnj(A)