# 12.3: Matrix Inverse, Rank and Determinant

• • Carey Smith
• Oxnard College
$$\newcommand{\vecs}{\overset { \rightharpoonup} {\mathbf{#1}} }$$ $$\newcommand{\vecd}{\overset{-\!-\!\rightharpoonup}{\vphantom{a}\smash {#1}}}$$$$\newcommand{\id}{\mathrm{id}}$$ $$\newcommand{\Span}{\mathrm{span}}$$ $$\newcommand{\kernel}{\mathrm{null}\,}$$ $$\newcommand{\range}{\mathrm{range}\,}$$ $$\newcommand{\RealPart}{\mathrm{Re}}$$ $$\newcommand{\ImaginaryPart}{\mathrm{Im}}$$ $$\newcommand{\Argument}{\mathrm{Arg}}$$ $$\newcommand{\norm}{\| #1 \|}$$ $$\newcommand{\inner}{\langle #1, #2 \rangle}$$ $$\newcommand{\Span}{\mathrm{span}}$$ $$\newcommand{\id}{\mathrm{id}}$$ $$\newcommand{\Span}{\mathrm{span}}$$ $$\newcommand{\kernel}{\mathrm{null}\,}$$ $$\newcommand{\range}{\mathrm{range}\,}$$ $$\newcommand{\RealPart}{\mathrm{Re}}$$ $$\newcommand{\ImaginaryPart}{\mathrm{Im}}$$ $$\newcommand{\Argument}{\mathrm{Arg}}$$ $$\newcommand{\norm}{\| #1 \|}$$ $$\newcommand{\inner}{\langle #1, #2 \rangle}$$ $$\newcommand{\Span}{\mathrm{span}}$$$$\newcommand{\AA}{\unicode[.8,0]{x212B}}$$

By Carey Smith

Consider this square matrix:

B = [1 2 3;      4 5 6;      7 8 0]

The inverse of B, IB, is a matrix such that B*IB = the identity matrix and IB*B = the identity matrix.

Not every square matrix has an inverse. For example these 3x3 matrices do not have inverses:

C = [1 0 0;

     0 0 0;

    0 0 0]

D = [1 0 0;

     0 2 3;

     1 2 3]

A matrix which does not have an inverse is called a "singular" matrix.

The rank of a matrix is the number of independent rows.
When the rank of a square matrix = the number of rows, it has "full rank" and is non-singular, so it has an inverse.

The rank of a matrix can be computed with the MATLAB function rank():

B_rank = rank(B) % = 3. Since B has 3 rows and columns and its rank is 3, B has full rank and is non-singular.

C_rank = rank(C) % = 1. C does not have full rank.

D_rank = rank(D) % = 2. D does not have full rank.

Another characteristic of a square matrix is its determinant.
When the determinant is not 0, it has full rank. It doesn't matter whether the determinant is positive or negative. When the determinant is not 0, the matrix is nonsingular and can be inverted. The calculation of the inverse divides by the matrix determinant, which is why it can't be zero.

The determinant of a matrix can be computed with the MATLAB function det():

B_det = det(B) = 27 => B is nonsingular and can be inverted.

C_det = det(B) = 0 => C is singular and cannot be inverted.

D_det = det(B) = 0 => C is singular and cannot be inverted.

The inverse of a square matrix can be computed with the MATLAB function inv():

W = inv(B)

% -1.7778  0.8889 -0.1111 %  1.5556 -0.7778  0.2222 % -0.1111  0.2222 -0.1111

Test the inverse: IB1 = B*W % 1 0 0 % 0 1 0 % 0 0 1

This is the 3x3 identity matrix

Although matrix multiplication is not commutative in general, multiplying a matrix by its inverse is commutative. The same result occurs when the order of the matrix and its inverse is reversed.
IB2 = W*B computes the same result.

##### Example $$\PageIndex{1}$$ Inverse of 3x3 Pacal matrix

C = pascal(3)

Compute the rank and determinant of C.

If it is non-singular, compute its inverse, C_inv/

Then test that C_inv*C is the identity matrix.

###### Solution

det_C = det(C) % 1 Non-Singular C_rank = rank(C) % 3 Non-Singular C_inv = inv(C) C_inv*C

.

##### Example $$\PageIndex{2}$$ Singular matrices

Compute the rank and determinant of these singular matrices:

%% Singular Matrix #1 % 2nd row is a multiple of the 1st row, % so it is not independent S1 = [ 1 2 3 2 4 6 7 8 9]

S2 = [ 1 2 3 4 5 6 5 7 9]

S3 = [ 1 0 0 1 0 0 0 0 0]

##### Exercise $$\PageIndex{1}$$ Operations on a "Hilbert" Matrix

By Troy Siemers

Consider the 5 x 5 \Hilbert matrix"
H5 = [1 1/2 1/3 1/4 1/5;
1/2 1/3 1/4 1/5 1/6;
1/3 1/4 1/5 1/6 1/7;
1/4 1/5 1/6 1/7 1/8;
1/5 1/6 1/7 1/8 1/9];

a. Find the determinant of H5.
b. Find the inverse of H5.
b. Find the transpose of H5.
c. Using the commands in the text, find the dimensions of H5, the column sums of H5, and the row sums of H5.
d. Use the max function to determine the value of the maximum entry of H5.
e. Find the eigenvalues and eigenvectors of H5.
f. Find the matrices H5^2, H5.^ 2, and H5./H5 and explain your answers.
g. By referencing H5, create a matrix that consists of the 2nd and 3rd rows of H5 (Do not simply retype the entries).