## Matrix Equations

Matrices can be used to compactly write and work with systems of multiple linear equations.

### Learning Objectives

Identify how matrices can represent a system of equations

### Key Takeaways

#### Key Points

- If [latex]A[/latex] is an [latex]m \times n[/latex] matrix, and [latex]x[/latex] designates a column vector (i.e. [latex]n \times 1[/latex] matrix) of [latex]n[/latex] variables [latex]x_1, x_2,…, x_n[/latex], and [latex]b[/latex] is an [latex]m \times 1[/latex] column vector, then the matrix equation is: [latex]Ax=b[/latex].

#### Key Terms

**matrix**: A rectangular arrangement of numbers or terms having various uses such as transforming coordinates in geometry, solving systems of linear equations in linear algebra and representing graphs in graph theory.

Matrices can be used to compactly write and work with systems of equations. As we have learned in previous sections, matrices can be manipulated in any way that a normal equation can be. This is very helpful when we start to work with systems of equations. It is helpful to understand how to organize matrices to solve these systems.

### Writing a System of Equations with Matrices

It is possible to solve this system using the elimination or substitution method, but it is also possible to do it with a matrix operation. Before we start setting up the matrices, it is important to do the following:

- Make sure that all of the equations are written in a similar manner, meaning the variables need to all be in the same order.
- Make sure that one side of the equation is only variables and their coefficients, and the other side is just constants.

Solving a system of linear equations using the inverse of a matrix requires the definition of two new matrices: [latex]X[/latex] is the matrix representing the variables of the system, and [latex]B[/latex] is the matrix representing the constants. Using matrix multiplication, we may define a system of equations with the same number of equations as variables as:

[latex]\displaystyle A\cdot X=B[/latex]

To solve a system of linear equations using an inverse matrix, let [latex]A[/latex] be the coefficient matrix, let [latex]X[/latex] be the variable matrix, and let [latex]B[/latex] be the constant matrix.

Given the system:

[latex]\displaystyle \begin{align} x+8y&=7 \\ 2x-8y&=-3 \end{align}[/latex]

The coefficient matrix is:

[latex]A=\begin{bmatrix} 1 & 8\\ 2 & -8 \end{bmatrix}[/latex]

The variable matrix is:

[latex]\displaystyle X=\begin{bmatrix} x\\ y \end{bmatrix}[/latex]

The constant matrix is:

[latex]\displaystyle B=\begin{bmatrix} 7\\ -3 \end{bmatrix}[/latex]

Thus, to solve a system [latex]AX=B[/latex], for [latex]X[/latex], multiply both sides by the inverse of [latex]A[/latex] and we shall obtain the solution:

[latex]\displaystyle X=(A^{-1})B[/latex]

Provided the inverse [latex]\left( A^{-1} \right)[/latex] exists, this formula will solve the system.

If the coefficient matrix is not invertible, the system could be inconsistent and have no solution, or be dependent and have infinitely many solutions.

## Matrices and Row Operations

Two matrices are row equivalent if one can be changed to the other by a sequence of elementary row operations.

### Learning Objectives

Explain how to use row operations and why they produce equivalent matrices

### Key Takeaways

#### Key Points

- An elementary row operation is any one of the following moves: row switching (swap two rows of a matrix ), row multiplication (multiply a row of a matrix by a non-zero constant ), or row addition (add to one row of a matrix to some multiple of another row).
- If the rows of the matrix represent a system of linear equations, then the row space consists of all linear equations that can be deduced algebraically from those in the system.

#### Key Terms

**row space**: The set of all possible linear combinations of its row vectors.**row equivalent**: In linear algebra, when one matrix can be changed to the other by a sequence of elementary row operations.

### Elementary Row Operations (ERO)

In linear algebra, two matrices are row equivalent if one can be changed to the other by a sequence of elementary row operations. Alternatively, two [latex]m \times n[/latex]matrices are row equivalent if and only if they have the same row space. The *row space* of a matrix is the set of all possible linear combinations of its row vectors. If the rows of the matrix represent a system of linear equations, then the row space consists of all linear equations that can be deduced algebraically from those in the system. Two matrices of the same size are row equivalent if and only if the corresponding homogeneous systems have the same set of solutions, or equivalently the matrices have the same null space. Because elementary row operations are reversible, row equivalence is an equivalence relation. It is commonly denoted by a tilde (~).

An elementary row operation is any one of the following three moves:

- Row switching (swap): Swap two rows of a matrix.
- Row multiplication (scale): Multiply a row of a matrix by a nonzero constant.
- Row addition (pivot): Add to one row of a matrix some multiple of another row.

### Produce Equivalent Matrices Using Elementary Row Operations

Since the matrix is essentially the coefficients and constants of a linear system, the three row operations preserve the matrix. For example, swapping two rows simply means switching their position within the matrix. Also, when solving a system of linear equations by the elimination method, row multiplication would be the same as multiplying the whole equation by a number to obtain additive inverses so that a variable cancels. Finally, row addition is also the same as the elimination method, when one chooses to add or subtract the like terms of the equations to obtain the variable. Therefore, row operations preserve the matrix and can be used as an alternative method to solve a system of equations.

### Example 1: Show that these two matrices are row equivalent:

[latex]\displaystyle A=\begin{pmatrix} 1 & -1 & 0 \\ 2 & 1 & 1 \end{pmatrix}\quad B=\begin{pmatrix} 3 & 0 & 1 \\ 0 & 3 & 1 \end{pmatrix}[/latex]

Start with [latex]A[/latex], add the second row to the first:

[latex]\displaystyle A=\begin{pmatrix} 3 & 0 & 1 \\ 2 & 1 & 1 \end{pmatrix}[/latex]

Then, multiply the second row by 3 and then subtract the first row from the second:

[latex]\displaystyle A=\begin{pmatrix} 3 & 0 & 1 \\ 3 & 3 & 2 \end{pmatrix}[/latex]

Finally, subtract the first row from the second:

[latex]\displaystyle A=\begin{pmatrix} 3 & 0 & 1 \\ 0 & 3 & 1 \end{pmatrix}[/latex]

You can see that [latex]A=B[/latex], which we achieved through a series of elementary row operations.

### Row Reduction: Solving a System of Linear Equations

In row reduction, the linear system:

[latex]\displaystyle x+3y-2z=5 \\ 3x+5y+6z=7 \\ 2x+4y+3z=8[/latex]

Is represented as an augmented matrix:

[latex]\displaystyle A=\begin{pmatrix} 1 & 3 & -2 & 5 \\ 3 & 5 & 6 & 7 \\ 2 & 4 & 3 & 8 \end{pmatrix}[/latex]

This matrix is then modified using elementary row operations until it reaches reduced row echelon form.

Because these operations are reversible, the augmented matrix produced always represents a linear system that is equivalent to the original.

There are several specific algorithms to row-reduce an augmented matrix, the simplest of which are Gaussian elimination and Gauss-Jordan elimination. This computation can be done by hand (using the three types of ERO) or on the calculator under the matrix function ‘rref’ (reduced row echelon form).

The final matrix is in reduced row echelon form, and represents the system [latex]x=-15[/latex], [latex]y=8[/latex][latex]z=2[/latex].

[latex]\displaystyle A=\begin{pmatrix} 1 & 0 & 0 & -15 \\ 0 & 1 & 0 & 8 \\ 0 & 0 & 1 & 2 \end{pmatrix}[/latex]

## Simplifying Matrices With Row Operations

Using elementary operations, Gaussian elimination reduces matrices to row echelon form.

### Learning Objectives

Use elementary row operations to put a matrix in simplified form

### Key Takeaways

#### Key Points

- Since elementary row operations preserve the row space of the matrix, the row space of the row echelon form is the same as that of the original matrix.
- There are three types of elementary row operations: swap the positions of two rows, multiply a row by a nonzero scalar, and add to one row a scalar multiple of another.
- In practice, one does not usually deal with the systems in terms of equations but instead makes use of the augmented matrix (which is also suitable for computer manipulations).

#### Key Terms

**augmented matrix**: A matrix obtained by appending the columns of two given matrices, usually for the purpose of performing the same elementary row operations on each of the given matrices.

By means of a finite sequence of elementary row operations, called Gaussian elimination, any matrix can be transformed to a row echelon form. This transformation is necessary for solving a system of linear equations.

Before getting into more detail, there are a couple of key terms that should be mentioned:

*Augmented matrix*: an augmented matrix is a matrix obtained by appending the columns of two given matrices, usually for the purpose of performing the same elementary row operations on each of the given matrices.*Upper triangle form*: A square matrix is called upper triangular if all the entries below the main diagonal are zero. A triangular matrix is one that is either lower triangular or upper triangular. A matrix that is both upper and lower triangular is a diagonal matrix.*Elementary row operations*: Swap rows, add rows or multiply rows.

### Gaussian Elimination

- Write the augmented matrix for the linear equations.
- Use elementary row operations on the augmented matrix [latex][A|b][/latex] to transform [latex]A[/latex] to upper triangle form. If a zero is on the diagonal, switch the rows until a nonzero is in its place.
- Use back substitution to find the solution.

### Example 1: Solve the system by Gaussian Elimination:

[latex]\displaystyle 2x+y-z=8\\ -3x-y+2z=-11\\ -2x+y+2z=-3[/latex]

Write the augmented matrix:

[latex]\left[\begin{array}{rrr|r} 2 & 1 & -1 & 8 \\ -3 & -1 & 2 & -11 \\ -2 & 1 & 2 & -3 \end{array} \right] [/latex]

Use elementary row operations to reduce the matrix to reduced row echelon form:

[latex]\left[\begin{array}{rrr|r} 1 & 0 & 0 & 2 \\ 0 & 1 & 0 & 3 \\ 0 & 0 & 1 & -1 \end{array} \right] [/latex]

Using elementary row operations to obtain reduced row echelon form (‘rref’ in the calculator) the solution to the system is revealed in the last column: [latex]x=2, y=3, z=-1[/latex].