Search⌘ K
AI Features

Solution Preserving Operations

Explore how solution preserving operations such as row swaps, scaling, and row sums can transform a system of linear equations into an equivalent system. Learn to perform these operations on augmented matrices and understand why they keep the system’s solutions unchanged, facilitating easier solving methods.

Earlier, while defining linear systems, we discussed the different possibilities of the solution of a linear system. In this chapter, we’ll describe how we can achieve those possibilities. Let’s start by learning the foundations before moving on to a systematic approach.

Augmented matrix

We’ve already learned two different representations of a system of linear equations. We started with a set of linear equations, that is,

a11x1+a12x2+...+a1nxn=y1a_{11}x_1 + a_{12}x_2+...+ a_{1n}x_n = y_1

a21x1+a22x2+...+a2nxn=y2a_{21}x_1 + a_{22}x_2+...+ a_{2n}x_n = y_2

\vdots

am1x1+am2x2+...+amnxn=yma_{m1}x_1 + a_{m2}x_2+...+ a_{mn}x_n = y_m

Later, we defined the matrix representation, Ax=bA\bold{x} = \bold{b}, where AA is the coefficient matrix, x\bold{x} contains all the unknowns, and b\bold{b} is on the right-hand side of the equations.

[a11a12a1na21a22a2nam1am2amn][x1x2xn]=[y1y2ym]\begin{bmatrix} a_{11} & a_{12} & \cdots & a_{1n} \\ a_{21} & a_{22} & \cdots & a_{2n} \\ \vdots & \vdots & \ddots & \vdots \\ a_{m1} & a_{m2} & \cdots & a_{mn} \end{bmatrix} \begin{bmatrix} x_1\\ x_2\\ \vdots\\ x_n \end{bmatrix} = \begin{bmatrix} y_1\\ y_2\\ \vdots\\ y_m \end{bmatrix}

Let’s look at yet another representation of the system of linear equations called the augmented matrix. It’s simply a combination of our system’s coefficient matrix, AA, and the right-hand-side vector, b\bold b, separated by a vertical line (the vertical line can be omitted if the context is clear).

(a11a12a1ny1a21a22a2ny2am1am2amnym)\left(\begin{array}{cccc|c} a_{11} & a_{12} & \cdots & a_{1n} & y_1\\ a_{21} & a_{22} & \cdots & a_{2n} & y_2\\ \vdots & \vdots & \vdots & \vdots & \vdots \\ a_{m1} & a_{m2} & \cdots & a_{mn} & y_m \end{array}\right)

Each row in the augmented matrix represents an equation from the system of linear equations. In the augmented matrix, the variables aren’t included explicitly. However, each column on the left side of the vertical separating line represents the constraints on the corresponding variable in the equation, as depicted in the figure below.

Example

To understand the concept above more clearly, have a side-by-side look at three representations of a system of linear equations below:

Elementary row operations

Elementary row operations are simple operations that allow us to transform a system of linear equations into an equivalent linear systemEquivalentSystem, which may be easier to solve.

There are three elementary operations:

  • Row swap
  • Row scaling
  • Row sum

We’ll learn how these operations are performed on an augmented matrix representation of a system and why they preserve its linearity and solution.

Row swap

A row swap is simply the swapping of ithi^{th} row (ri\bold{r_i}) with the jthj^{th} row (rj\bold{r_j}) of an augmented matrix. This can be represented mathematically as follows:

rirj\bold{r_i} \leftrightarrow \bold{r_j}

Swapping rows in the augmented matrix corresponds to swapping the respective equations in the linear system, which doesn’t alter the solution. As an example, look at the following:

In Python, this can be achieved by fancy indexing as follows:

C++
import numpy as np
mat = np.array([[2, 3, -4, 7],
[1, 6, -5, 1],
[-2, 1, 10, -4]])
print(mat)
print("Swap row 1 with row 2")
mat[[1, 2]] = mat[[2, 1]]
print(mat)

Row scaling

Row scaling multiplies both sides of the equation by the same nonzero number.

ri=αriwhereα0\bold{r_i} = \alpha \bold{r_i} \qquad \text where \enspace \alpha \neq 0

The operation equally scales the constants on both sides of an equation by a nonzero value. The points satisfying the equation remain the same. The solution and linearity of the system remain preserved.

The Python implementation of the operation is as follows:

C++
import numpy as np
mat = np.array([[2, 3, -4, 7],
[1, 6, -5, 1],
[-2, 1, 10, -4]])
print(mat)
print("Scale row 3 by 2")
mat[2]=2*mat[2]
print(mat)

Row sum

Row sum is the process of adding a scalar multiple of one equation to another.

ri=ri+αrj\bold{r_i} = \bold{r_i} + \alpha \bold{r_j}

Note: α=0\alpha=0 in row sum eliminates the effect of the operation because we’re simply adding zeros to a row.

Because the solution of the system is the common solution of the two equations used in this operation, the operation won’t affect the solution or linearity.

In Python, we can do this as follows:

C++
import numpy as np
mat = np.array([[2, 3, -4, 7],
[1, 6, -5, 1],
[-2, 1, 10, -4]])
print(mat)
print("Add 2 times row 1 to row 2")
mat[1] += 2*mat[0]
print(mat)