2  Module-1: Linear Systems, Properties, and its Solution

Syllabus: System of linear equations - Solution by Gauss elimination - Row Echelon form and Rank of a matrix - Fundamental theorem for linear systems of homogeneous and nonhomogeneous (statement only) - Homogeneous linear system - Non-homogeneous linear system

3 Introduction

Welcome! We’re about to begin a journey into one of the most useful and beautiful subjects in mathematics. But we’re not going to start with abstract definitions. We’re going to start with a concrete problem that you’ve seen before, but we’ll look at it in a new way. The entire field of linear algebra grew from the simple need to solve systems of linear equations.

Let’s consider a simple system:

\[ \begin{align*} 2x - y &= 1 \\ x + y &= 5 \end{align*} \]

How do we think about this? There are two fundamental viewpoints, and seeing them both is the key to understanding linear algebra.

3.1 The Row Picture: Intersecting Lines

The first way, and the one you’re probably most familiar with, is the Row Picture. Each equation represents a line on the \(xy\)-plane. The solution to the system is the single point where these two lines intersect.

Let’s use Python to see this. We’re not just finding the answer; we’re visualizing the problem.

Code
import numpy as np
import matplotlib.pyplot as plt

# Define the matrix A and vector b for the system Ax = b
A = np.array([
    [2, -1],
    [1,  1]
])
b = np.array([1, 5])  # Corrected

# Solve Ax = b
solution = np.linalg.solve(A, b)
x_sol, y_sol = solution  # unpack for plotting

# For plotting the lines
x_vals = np.linspace(0, 4, 100)
# From 2x - y = 1  => y = 2x - 1
y1_vals = 2 * x_vals - 1
# From x + y = 5   => y = -x + 5
y2_vals = -x_vals + 5

# --- Matplotlib Plotting ---
plt.figure(figsize=(8, 6))
ax = plt.gca()

# Plot the two lines
ax.plot(x_vals, y1_vals, label='$2x - y = 1$')
ax.plot(x_vals, y2_vals, label='$x + y = 5$')

# Plot the solution point
ax.plot(x_sol, y_sol, 'ro', markersize=10, label=f'Solution ({x_sol:.0f}, {y_sol:.0f})')

# Titles and labels
ax.set_title("The Row Picture")
ax.set_xlabel("x-axis")
ax.set_ylabel("y-axis")

# Grid, legend, limits
ax.grid(True)
ax.legend()
ax.set_xlim(0, 4)
ax.set_ylim(0, 6)

# Show plot
plt.show()
Figure 3.1: The Row Picture (Matplotlib): The solution \((2, 3)\) is the intersection of two lines.

The plot clearly shows that the two lines meet at the point \((2, 3)\). That’s our solution. For a \(3 \times 3\) system, the row picture would be three planes intersecting at a single point. For anything larger, we can’t draw it, but the idea is the same! This is why we need a more systematic approach.

3.2 The Column Picture: Combining Vectors

Now for the second way, which is completely different and incredibly powerful. This is the Column Picture. We rewrite the system in a vector form:

\[ x \begin{bmatrix} 2 \\ 1 \end{bmatrix} + y \begin{bmatrix} -1 \\ 1 \end{bmatrix} = \begin{bmatrix} 1 \\ 5 \end{bmatrix} \]

The question now becomes: how much of the first “column vector” \(\begin{bmatrix} 2 \\ 1\end{bmatrix}\) do we need to add to how much of the second “column vector” \(\begin{bmatrix} -1 \\ 1\end{bmatrix}\) to get the target vector \(\begin{bmatrix} 1 \\ 5\end{bmatrix}\)?

We are trying to find the correct linear combination of the column vectors.

Let’s see what this looks like. We need to find the numbers \(x\) and \(y\) that let us “reach” the target vector \(b\). From the row picture, we already know the answer is \(x=2\) and \(y=3\). Let’s verify this with the vectors.

Code
import numpy as np
import matplotlib.pyplot as plt

# Define the vectors
v1 = np.array([2, 1])
v2 = np.array([-1, 1])
b = np.array([1, 5])

# The solution coefficients
x, y = 2, 3

# Prepare the figure
plt.figure(figsize=(6, 6))
ax = plt.gca()

# Draw base vectors from origin
ax.quiver(0, 0, v1[0], v1[1], angles='xy', scale_units='xy', scale=1,
          label='v1 = [2, 1]')
ax.quiver(0, 0, v2[0], v2[1], angles='xy', scale_units='xy', scale=1,
          label='v2 = [-1, 1]')

# Draw scaled v1 (2 * v1) from origin
scaled_v1 = x * v1
ax.quiver(0, 0, scaled_v1[0], scaled_v1[1], angles='xy', scale_units='xy', scale=1,
          alpha=0.7, label='2 * v1')

# Draw scaled v2 (3 * v2) starting from the tip of 2*v1
scaled_v2 = y * v2
ax.quiver(scaled_v1[0], scaled_v1[1], scaled_v2[0], scaled_v2[1], angles='xy',
          scale_units='xy', scale=1, alpha=0.7, label='3 * v2 (from tip of 2*v1)')

# Draw the target vector b from origin
ax.quiver(0, 0, b[0], b[1], angles='xy', scale_units='xy', scale=1, color='red',
          label='b = [1, 5]')

# Cosmetic adjustments
ax.set_xlim(-2, 6)
ax.set_ylim(-2, 7)
ax.set_xlabel("x-component")
ax.set_ylabel("y-component")
ax.set_aspect('equal', adjustable='box')  # preserve vector directions/lengths
ax.grid(True)
ax.legend(loc='upper left')
plt.title("The Column Picture")
plt.show()
Figure 3.2: The Column Picture: 2v1 + 3v2 = b, with v1=[2,1], v2=[-1,1], b=[1,5].

This picture shows that if you walk along the blue vector twice, and then walk along the green vector three times, you land exactly on the red target vector. We have found the right combination!

3.3 The Algorithm: Gauss Elimination

Drawing pictures is great for intuition, but it’s not a practical way to solve a \(10 \times 10\) system. We need a rock-solid algorithm. That algorithm is Gauss Elimination. The goal is simple: turn a complicated system into a simple one that is easy to solve.

We do this by creating an Augmented Matrix. It’s just a way to hold all the numbers of our system without writing the variables over and over.

For the system: \[ \begin{align*} x + 2y + z &= 2 \\ 3x + 8y + z &= 12 \\ 4y + z &= 2 \end{align*} \]

The augmented matrix is: \[ \left[ \begin{array}{ccc|c} 1 & 2 & 1 & 2 \\ 3 & 8 & 1 & 12 \\ 0 & 4 & 1 & 2 \end{array} \right] \]

3.3.0.1 The Rules of the Game

There are only three operations we are allowed to do. These operations don’t change the final solution: 1. Swap two rows. 2. Multiply a row by a non-zero constant. 3. Add a multiple of one row to another row. (\(R_i \leftarrow R_i + cR_j\))

Our goal is to use these rules to create zeros below the main diagonal. This turns the matrix into Row Echelon Form.

3.3.1 A Full Example: Solving a 3x3 System

Let’s solve the system above using Python’s symbolic math library, SymPy. This is great for teaching because it can show us the exact steps and avoid messy decimals.

Code
import sympy as sp

# Create augmented matrix
M = sp.Matrix([
  [1, 2, 1,  2],
  [3, 8, 1, 12],
  [0, 4, 1,  2]
])

print("Original Matrix:")
sp.pprint(M)

# Step 1
M[1, :] = M[1, :] - 3 * M[0, :]
print("\nAfter first elimination step (R_2 <- R_2 - 3*R_1):")
sp.pprint(M)

# Step 2
M[2, :] = M[2, :] - 2 * M[1, :]
print("\nAfter second elimination step (R_3 <- R_3 - 2*R_2):")
sp.pprint(M)
Original Matrix:
⎡1  2  1  2 ⎤
⎢           ⎥
⎢3  8  1  12⎥
⎢           ⎥
⎣0  4  1  2 ⎦

After first elimination step (R_2 <- R_2 - 3*R_1):
⎡1  2  1   2⎤
⎢           ⎥
⎢0  2  -2  6⎥
⎢           ⎥
⎣0  4  1   2⎦

After second elimination step (R_3 <- R_3 - 2*R_2):
⎡1  2  1    2 ⎤
⎢             ⎥
⎢0  2  -2   6 ⎥
⎢             ⎥
⎣0  0  5   -10⎦

Look at that final matrix! We have an upper-triangular form. This is Row Echelon Form. The first non-zero entries in each row are called pivots. Here our pivots are 1, 2, and 5.

The system has now become: \[ \begin{align*} x + 2y + z &= 2 \\ 2y - 2z &= 6 \\ 5z &= -10 \end{align*} \]

This is easy to solve by back substitution. From the last row: \(5z = -10 \implies z = -2\). Substitute into the second row: \(2y - 2(-2) = 6 \implies 2y + 4 = 6 \implies y = 1\). Substitute both into the first row: \(x + 2(1) + (-2) = 2 \implies x = 2\).

So the solution is \((x, y, z) = (2, 1, -2)\).

Of course, we can have a computer do this all at once. The rref() method will take it all the way to Reduced Row Echelon Form, where the pivots are 1 and there are zeros above them as well.

Code
M_original = sp.Matrix([
  [1, 2, 1,  2],
  [3, 8, 1, 12],
  [0, 4, 1,  2]
])

M_rref, pivots = M_original.rref()
print("Reduced Row Echelon Form (RREF):")
sp.pprint(M_rref)
print("\nPivot columns are:", pivots)
Reduced Row Echelon Form (RREF):
⎡1  0  0  2 ⎤
⎢           ⎥
⎢0  1  0  1 ⎥
⎢           ⎥
⎣0  0  1  -2⎦

Pivot columns are: (0, 1, 2)

The RREF form directly tells us the solution: \(1x = 2\), \(1y = 1\), \(1z = -2\).

In this method the unknowns are eliminated successively and the system is reduced to an upper triangular system from which the unknowns can be found by back substitution.

Problem 1: Using Gauss elimination method, solve the system \[\begin{align*} 4x-6y &=-11\\ -3x+8y &=10 \end{align*}\]

Solution: The given system is \(AX=b\) where \(A=\begin{bmatrix} 4 &-6\\ -3 &8 \end{bmatrix}\), \(X=\begin{bmatrix} x\\ y \end{bmatrix}\), \(b=\begin{bmatrix} -11\\ 10 \end{bmatrix}\) \[\begin{align*} [A|b]&=\begin{bmatrix} 4 &-6 &\bigm| &-11\\ -3 &8 &\bigm| &10 \end{bmatrix}\\ &\sim \begin{bmatrix} 4 &-6 &\bigm| &-11\\ 0 &\frac{7}{2} &\bigm| &\frac{7}{4} \end{bmatrix}\begin{array}{c} R_2\rightarrow R_2+\dfrac{3}{4}R_1 \end{array} \end{align*}\] The system is reduced to \[\begin{bmatrix} 4 &-6\\ 0 &\frac{7}{2} \end{bmatrix}\begin{bmatrix} x\\ y \end{bmatrix}=\begin{bmatrix} -11\\ \frac{7}{4} \end{bmatrix}\] \[\begin{align*} 4x-6y &=-11......(1)\\ \frac{7}{2}y &=\frac{7}{4}.....(2) \end{align*}\]

\((2)\rightarrow y=\frac{1}{2}\) and substituting in (1) we get \(x=-2\). \(\therefore\) the solution is \[x=-2,y=\frac{1}{2}\]

Problem 2: Using Gauss elimination method, find the solution of \[\begin{align*} x-y &=-3\\ -2x+2y &=6 \end{align*}\]

Solution: The given system is \(AX=B\) where \(A=\begin{bmatrix} 1 &-1\\ -2 &2 \end{bmatrix}\), \(X=\begin{bmatrix} x\\ y \end{bmatrix}\), \(b=\begin{bmatrix} -3\\ 6 \end{bmatrix}\) \[\begin{align*} [A|b]&=\begin{bmatrix} 1 &-1 &\bigm| &-3\\ -2 &2 &\bigm| &6 \end{bmatrix}\\ &\sim \begin{bmatrix} 1 &-1 &\bigm| &-3\\ 0 &0 &\bigm| &0 \end{bmatrix}\begin{array}{c} R_2\rightarrow R_2+2R_1 \end{array} \end{align*}\] The system is reduced to \[\begin{bmatrix} 1 &-1\\ 0 &0 \end{bmatrix}\begin{bmatrix} x\\ y \end{bmatrix}=\begin{bmatrix} -3\\ 0 \end{bmatrix}\] \[\begin{align*} x-y &=-3.....(1)\\ 0 &=0.....(2) \end{align*}\]

In (1) put \(y=t\) then \(x=-3+t\). \(\therefore\) the solution is \[x=t-3,y=t\]

Problem 3: Using Gauss elimination method, find the solution of

\[\begin{align*} -x-y &=1\\ -3x-3y &=2 \end{align*}\]

Solution: The given system is \(AX=b\) where \(A=\begin{bmatrix} -1 &-1\\ -3 &-3 \end{bmatrix}\), \(X=\begin{bmatrix} x\\ y \end{bmatrix}\), \(b=\begin{bmatrix} 1\\ 2 \end{bmatrix}\) \[\begin{align*} [A|b]&=\begin{bmatrix} -1 &-1 &\bigm| &1\\ -3 &-3 &\bigm| &2 \end{bmatrix}\\ &\sim \begin{bmatrix} -1 &-1 &\bigm| &1\\ 0 &0 &\bigm| &-1 \end{bmatrix}\begin{array}{c} R_2\rightarrow R_2-3R_1 \end{array} \end{align*}\] The system is reduced to \[\begin{bmatrix} -1 &-1\\ 0 &0 \end{bmatrix}\begin{bmatrix} x\\ y \end{bmatrix}=\begin{bmatrix} 1\\ -1 \end{bmatrix}\] \[\begin{align*} -x-y &=1.....(1)\\ 0 &=-1.....(2) \end{align*}\] The false statement \(0=-1\) shows that the system has no solution.

Problem 4: Solve the linear system \[\begin{align*} x_1-x_2+x_3 &=0\\ -x_1+x_2-x_3 &=0\\ 10x_2+25x_3 &= 90\\ 20x_1+10x_2 &= 80 \end{align*}\]

Solution: The given system is \(AX=B\) where \(A=\begin{bmatrix} 1 &-1 &1\\ -1 &1 &-1\\ 0 &10 &25\\ 20 &10 &0 \end{bmatrix}\), \(X=\begin{bmatrix} x_1\\ x_2\\ x_3 \end{bmatrix}\), \(b=\begin{bmatrix} 0\\ 0\\ 90\\ 80 \end{bmatrix}\) \[\begin{align*} [A|b]&=\begin{bmatrix} 1 &-1 &1 &\bigm| &0\\ -1 &1 &-1 &\bigm| &0\\ 0 &10 &25 &\bigm| &90\\ 20 &10 &0 &\bigm| &80 \end{bmatrix}\\ &\sim \begin{bmatrix} 1 &-1 &1 &\bigm| &0\\ 0 &0 &0 &\bigm| &0\\ 0 &10 &25 &\bigm| &90\\ 0 &30 &-20 &\bigm| &80 \end{bmatrix}\begin{array}{c} R_2\rightarrow R_2+R_1\\ R_4\rightarrow R_4-20R_1 \end{array}\\ &\sim \begin{bmatrix} 1 &-1 &1 &\bigm| &0\\ 0 &30 &-20 &\bigm| &80\\ 0 &10 &25 &\bigm| &90\\ 0 &0 &0 &\bigm| &0 \end{bmatrix}\begin{array}{c} R_2\leftrightarrow R_4 \end{array}\\ &\sim \begin{bmatrix} 1 &-1 &1 &\bigm| &0\\ 0 &10 &25 &\bigm| &90\\ 0 &30 &-20 &\bigm| &80\\ 0 &0 &0 &\bigm| &0 \end{bmatrix}\begin{array}{c} R_2\leftrightarrow R_3 \end{array}\\ &\sim \begin{bmatrix} 1 &-1 &1 &\bigm| &0\\ 0 &10 &25 &\bigm| &90\\ 0 &0 &-95 &\bigm| &-190\\ 0 &0 &0 &\bigm| &0 \end{bmatrix}\begin{array}{c} R_3\rightarrow R_3-3R_2 \end{array}\\ \end{align*}\] The system is reduced to \[\begin{bmatrix} 1 &-1 &1\\ 0 &10 &25\\ 0 &0 &-95\\ 0 &0 &0 \end{bmatrix}\begin{bmatrix} x_1\\ x_2\\ x_3 \end{bmatrix}=\begin{bmatrix} 0\\ 90\\ -190\\ 0 \end{bmatrix}\] \[\begin{align*} x_1-x_2+x_3 &=0.....(1)\\ 10x_2+25x_3 &=90.....(2)\\ -95x_3 &=-190........(3)\\ 0 &=0............(4) \end{align*}\] \((3)\rightarrow x_3=2\) and substituting in (2), we get \(x_2=4\)

Substituting the value of \(x_2\) and \(x_3\) in (1), we get \(x_1=2\). \(\therefore\) the solution is \(x_1=2, x_2=4, x_3=2\).

Problem 5: Using Gauss elimination method, find the solution of the system of equation \[\begin{align*} 2x+z &=3\\ x-y-z&=1\\ 3x-y &= 4 \end{align*}\]

Solution: The given system is \(AX=b\) where \(A=\begin{bmatrix} 2 &0 &1\\ 1 &-1 &-1\\ 3 &-1 &0 \end{bmatrix}\), \(X=\begin{bmatrix} x\\ y\\ z \end{bmatrix}\), \(b=\begin{bmatrix} 3\\ 1\\ 4 \end{bmatrix}\) \[\begin{align*} [A|b]&=\begin{bmatrix} 2 &0 &1 &\bigm| &3\\ 1 &-1 &-1 &\bigm| &1\\ 3 &-1 &0 &\bigm| &4 \end{bmatrix}\\ &\sim \begin{bmatrix} 1 &-1 &-1 &\bigm| &1\\ 2 &0 &1 &\bigm| &3\\ 3 &-1 &0 &\bigm| &4 \end{bmatrix}\begin{array}{c} R_1\leftrightarrow R_2 \end{array}\\ &\sim \begin{bmatrix} 1 &-1 &-1 &\bigm| &1\\ 0 &2 &3 &\bigm| &1\\ 0 &2 &3 &\bigm| &1 \end{bmatrix}\begin{array}{c} R_2\rightarrow R_2-2R_1\\ R_3\rightarrow R_3-3R_1 \end{array}\\ &\sim \begin{bmatrix} 1 &-1 &-1 &\bigm| &1\\ 0 &2 &3 &\bigm| &1\\ 0 &0 &0 &\bigm| &0 \end{bmatrix}\begin{array}{c} R_3\rightarrow R_3-R_2 \end{array} \end{align*}\] The system is reduced to \[\begin{bmatrix} 1 &-1 &-1\\ 0 &2 &3\\ 0 &0 &0 \end{bmatrix}\begin{bmatrix} x\\ y\\ z \end{bmatrix}=\begin{bmatrix} 1\\ 1\\ 0 \end{bmatrix}\] \[\begin{align*} x-y-z &=1.....(1)\\ 2y+3z &=1.....(2)\\ 0 &=0........(3) \end{align*}\] Put \(z=t\), then \((2)\rightarrow 2y=1-3t\Rightarrow y=\frac{1}{2}-\frac{3}{2}t\)\ \((1)\rightarrow x=\frac{3}{2}-\frac{1}{2}t\). \(\therefore\) the solution is \(x=\frac{3}{2}-\frac{1}{2}t, y=\frac{1}{2}-\frac{3}{2}t, z=t\).

Problem 6: Solve the linear system \[\begin{align*} 3x_1+2x_2+x_3 &=3\\ 2x_1+x_2+x_3 &=0\\ 6x_1+2x_2+4x_3 &= 6 \end{align*}\]

Solution: $The given system is \(AX=b\) where \(A=\begin{bmatrix} 3 &2 &1\\ 2 &1 &1\\ 6 &2 &4 \end{bmatrix}\), \(X=\begin{bmatrix} x_1\\ x_2\\ x_3 \end{bmatrix}\), \(b=\begin{bmatrix} 3\\ 0\\ 6 \end{bmatrix}\) \[\begin{align*} [A|b]&=\begin{bmatrix} 3 &2 &1 &\bigm| &3\\ 2 &1 &1 &\bigm| &0\\ 6 &2 &4 &\bigm| &6 \end{bmatrix}\\ &\sim \begin{bmatrix} 3 &2 &1 &\bigm| &3\\ 0 &-\frac{1}{3} &\frac{1}{3} &\bigm| &-2\\ 0 &-2 &2 &\bigm| &0 \end{bmatrix}\begin{array}{c} R_2\rightarrow R_2-\frac{2}{3}R_1\\ R_3\rightarrow R_3-2R_1 \end{array}\\ &\sim \begin{bmatrix} 3 &2 &1 &\bigm| &3\\ 0 &-\frac{1}{3} &\frac{1}{3} &\bigm| &-2\\ 0 &0 &0 &\bigm| &12 \end{bmatrix}\begin{array}{c} R_3\rightarrow R_3-6R_2 \end{array} \end{align*}\] The system is reduced to \[\begin{bmatrix} 3 &2 &1\\ 0 &-\frac{1}{3} &\frac{1}{3}\\ 0 &0 &0 \end{bmatrix}\begin{bmatrix} x_1\\ x_2\\ x_3 \end{bmatrix}=\begin{bmatrix} 3\\ -2\\ 12 \end{bmatrix}\] \[\begin{align*} 3x_1+2x_2+x_3 &=3.....(1)\\ -\frac{1}{3}x_2+\frac{1}{3}x_3 &=9-2.....(2)\\ 0 &=12........(3) \end{align*}\]

The false statement \(0=12\) shows that the system has no solution.

Problem 7: Using Gauss elimination method, find the solution of the system of equation \[\begin{align*} x+2y+z &=3\\ 2x+3y+2z&=5\\ 3x-5y+5z &= 2\\ 3x+9y-z &=4 \end{align*}\]

Solution: The given system is \(AX=B\) where \(A=\begin{bmatrix} 1 &2 &1\\ 2 &3 &2\\ 3 &-5 &5\\ 3 &9 &-1 \end{bmatrix}\), \(X=\begin{bmatrix} x\\ y\\ z \end{bmatrix}\), \(b=\begin{bmatrix} 3\\ 5\\ 2\\ 4 \end{bmatrix}\) \[\begin{align*} [A|b]&=\begin{bmatrix} 1 &2 &1 &\bigm| &3\\ 2 &3 &2 &\bigm| &5\\ 3 &-5 &5 &\bigm| &2\\ 3 &9 &-1 &\bigm| &4 \end{bmatrix}\\ &\sim \begin{bmatrix} 1 &2 &1 &\bigm| &3\\ 0 &-1 &0 &\bigm| &-1\\ 0 &-11 &2 &\bigm| &-7\\ 0 &3 &-4 &\bigm| &-5 \end{bmatrix}\begin{array}{c} R_2\rightarrow R_2-2R_1\\ R_3\rightarrow R_3-3R_1\\ R_4\rightarrow R_4-3R_1 \end{array}\\ &\sim \begin{bmatrix} 1 &2 &1 &\bigm| &3\\ 0 &-1 &0 &\bigm| &-1\\ 0 &0 &2 &\bigm| &4\\ 0 &0 &-4 &\bigm| &-8 \end{bmatrix}\begin{array}{c} R_3\rightarrow R_3-11R_2\\ R_4\rightarrow R_4+3R_2 \end{array}\\ &\sim \begin{bmatrix} 1 &2 &1 &\bigm| &3\\ 0 &-1 &0 &\bigm| &-1\\ 0 &0 &2 &\bigm| &4\\ 0 &0 &0 &\bigm| &0 \end{bmatrix}\begin{array}{c} R_4\rightarrow R4+2R_3 \end{array} \end{align*}\] The system is reduced to \[\begin{bmatrix} 1 &2 &1\\ 0 &-1 &0\\ 0 &0 &2\\ 0 &0 &0 \end{bmatrix}\begin{bmatrix} x\\ y\\ z \end{bmatrix}=\begin{bmatrix} 3\\ -1\\ 4\\ 0 \end{bmatrix}\] \[\begin{align*} x+2y+z &=3.....(1)\\ -y+0z &=-1.....(2)\\ 2z &=4 .........(3)\\ 0 &=0........(4) \end{align*}\] \((3)\rightarrow z=2\) and substituting in (2), we get \(y=1\)\ Also substituting \(y\) and \(z\) in (1), we get \(x=-1\). \(\therefore\) the solution is \(x=-1, y=1, z=2\).

3.3.2 Row Echelon Form

At the end of the Gauss elimination the form of the coefficient matrix, the augmented matrix and the system itself are called row echelon form. In it, rows of zeros, if present, are the last rows and the number of zeros before the leading nonzero element in each row is greater than the corresponding number of zeros of the preceeding rows.

3.4 Solve the following using Gauss Elimination method.

3.4.1 Question 1

Solve the system: \[ \begin{cases} 2x + y - z = 8 \\ -3x - y + 2z = -11 \\ -2x + y + 2z = -3 \end{cases} \]

Solution:

Start with the augmented matrix: \[ \begin{bmatrix} 2 & 1 & -1 & 8 \\ -3 & -1 & 2 & -11 \\ -2 & 1 & 2 & -3 \end{bmatrix} \]

Apply \(R_2 \rightarrow R_2 + \frac{3}{2}R_1\) and \(R_3 \rightarrow R_3 + R_1\):

\[ \begin{bmatrix} 2 & 1 & -1 & 8 \\ 0 & 0.5 & 0.5 & 1 \\ 0 & 2 & 1 & 5 \end{bmatrix} \]

Next, \(R_3 \rightarrow R_3 - 4R_2\):

\[ \begin{bmatrix} 2 & 1 & -1 & 8 \\ 0 & 0.5 & 0.5 & 1 \\ 0 & 0 & -1 & 1 \end{bmatrix} \]

From the last row: \(z = -1\). Substituting back: - From \(R_2\): \(0.5y + 0.5(-1) = 1 \implies y = 3\) - From \(R_1\): \(2x + 3 - (-1) = 8 \implies x = 2\)

Final solution: \(\boxed{x=2, y=3, z=-1}\).


3.4.2 Question 2

Solve: \[ \begin{cases} x + 2y + 3z = 14 \\ 2x + y + z = 10 \\ 3x + 4y + 7z = 30 \end{cases} \]

Solution:

Augmented matrix: \[ \begin{bmatrix} 1 & 2 & 3 & 14 \\ 2 & 1 & 1 & 10 \\ 3 & 4 & 7 & 30 \end{bmatrix} \]

\(R_2 \rightarrow R_2 - 2R_1\), \(R_3 \rightarrow R_3 - 3R_1\):

\[ \begin{bmatrix} 1 & 2 & 3 & 14 \\ 0 & -3 & -5 & -18 \\ 0 & -2 & -2 & -12 \end{bmatrix} \]

\(R_3 \rightarrow R_3 - \frac{2}{3}R_2\):

\[ \begin{bmatrix} 1 & 2 & 3 & 14 \\ 0 & -3 & -5 & -18 \\ 0 & 0 & \frac{4}{3} & 0 \end{bmatrix} \]

From \(R_3\): \(z = 0\).
From \(R_2\): \(-3y - 5(0) = -18 \implies y = 6\).
From \(R_1\): \(x + 2(6) + 3(0) = 14 \implies x = 2\).

Solution: \(\boxed{x=2, y=6, z=0}\).


3.4.3 Question 3

Solve: \[ \begin{cases} x - y + z = 4 \\ 2x + y - z = 2 \\ 3x + y + z = 10 \end{cases} \]

Solution:

Augmented matrix: \[ \begin{bmatrix} 1 & -1 & 1 & 4 \\ 2 & 1 & -1 & 2 \\ 3 & 1 & 1 & 10 \end{bmatrix} \]

\(R_2 \rightarrow R_2 - 2R_1\), \(R_3 \rightarrow R_3 - 3R_1\):

\[ \begin{bmatrix} 1 & -1 & 1 & 4 \\ 0 & 3 & -3 & -6 \\ 0 & 4 & -2 & -2 \end{bmatrix} \]

\(R_3 \rightarrow R_3 - \frac{4}{3}R_2\):

\[ \begin{bmatrix} 1 & -1 & 1 & 4 \\ 0 & 3 & -3 & -6 \\ 0 & 0 & 2 & 6 \end{bmatrix} \]

From \(R_3\): \(z = 3\).
From \(R_2\): \(3y - 3(3) = -6 \implies y = 1\).
From \(R_1\): \(x - 1 + 3 = 4 \implies x = 2\).

Solution: \(\boxed{x=2, y=1, z=3}\).


3.4.4 Question 4

Solve: \[ \begin{cases} x + y + z = 6 \\ 2x + 3y + 5z = 4 \\ 4x + 0y + 5z = 2 \end{cases} \]

Solution:

Augmented matrix: \[ \begin{bmatrix} 1 & 1 & 1 & 6 \\ 2 & 3 & 5 & 4 \\ 4 & 0 & 5 & 2 \end{bmatrix} \]

\(R_2 \rightarrow R_2 - 2R_1\), \(R_3 \rightarrow R_3 - 4R_1\):

\[ \begin{bmatrix} 1 & 1 & 1 & 6 \\ 0 & 1 & 3 & -8 \\ 0 & -4 & 1 & -22 \end{bmatrix} \]

\(R_3 \rightarrow R_3 + 4R_2\):

\[ \begin{bmatrix} 1 & 1 & 1 & 6 \\ 0 & 1 & 3 & -8 \\ 0 & 0 & 13 & -54 \end{bmatrix} \]

From \(R_3\): \(z = -54/13\).
From \(R_2\): \(y + 3(-54/13) = -8 \implies y = -8 + 162/13 = -104/13 + 162/13 = 58/13\).
From \(R_1\): \(x + 58/13 - 54/13 = 6 \implies x = 6 - 4/13 = 74/13\).

Solution: \(\boxed{x=\frac{74}{13},\ y=\frac{58}{13},\ z=-\frac{54}{13}}\).


3.4.5 Question 5

Solve: \[ \begin{cases} 2x + 4y - 2z = 2 \\ 4x + 9y - 3z = 8 \\ -2x - 3y + 7z = 10 \end{cases} \]

Solution:

Augmented matrix: \[ \begin{bmatrix} 2 & 4 & -2 & 2 \\ 4 & 9 & -3 & 8 \\ -2 & -3 & 7 & 10 \end{bmatrix} \]

\(R_2 \rightarrow R_2 - 2R_1\), \(R_3 \rightarrow R_3 + R_1\):

\[ \begin{bmatrix} 2 & 4 & -2 & 2 \\ 0 & 1 & 1 & 4 \\ 0 & 1 & 5 & 12 \end{bmatrix} \]

\(R_3 \rightarrow R_3 - R_2\):

\[ \begin{bmatrix} 2 & 4 & -2 & 2 \\ 0 & 1 & 1 & 4 \\ 0 & 0 & 4 & 8 \end{bmatrix} \]

From \(R_3\): \(z = 2\).
From \(R_2\): \(y + 2 = 4 \implies y = 2\).
From \(R_1\): \(2x + 8 - 4 = 2 \implies x = -1\).

Solution: \(\boxed{x=-1, y=2, z=2}\).

3.5 Tutorial questions

3.5.1 Problem 1: Circuit Analysis (Electronics Core)

Scenario:

You are given a simple DC circuit with three loops. Using Kirchhoff’s Voltage Law (KVL), which states that the sum of voltages around any closed loop must be zero, we can set up a system of equations to find the unknown loop currents \(i_1, i_2,\) and \(i_3\).

Figure 3.3: Circuit
  • Loop 1: The 30V source minus the voltage drops across the 4Ω and 2Ω resistors gives the equation: \(30 - 4i_1 - 2(i_1 - i_2) = 0\)

  • Loop 2: The voltage drops across the 2Ω, 1Ω, and 3Ω resistors give: \(-2(i_2 - i_1) - 1i_2 - 3(i_2 - i_3) = 0\)

  • Loop 3: The voltage drops across the 3Ω and 5Ω resistors give: \(-3(i_3 - i_2) - 5i_3 = 0\)

Find the values of the three loop currents: \(i_1, i_2,\) and \(i_3\).

Solution:

Mathematical Setup

First, simplify the equations and align the variables:

  1. \(30 - 6i_1 + 2i_2 = 0 \implies 6i_1 - 2i_2 + 0i_3 = 30\)

  2. \(2i_1 - 6i_2 + 3i_3 = 0\)

  3. \(3i_2 - 8i_3 = 0 \implies 0i_1 + 3i_2 - 8i_3 = 0\)

This gives us the system \(Ax=b\).

Step 1: Write the Augmented Matrix \[ \left[ \begin{array}{ccc|c} 6 & -2 & 0 & 30 \\ 2 & -6 & 3 & 0 \\ 0 & 3 & -8 & 0 \end{array} \right] \]

Step 2: Perform Gauss Elimination

Let’s simplify Row 1 first by dividing by 2: \(R_1 \leftarrow R_1 / 2\). \[ \left[ \begin{array}{ccc|c} 3 & -1 & 0 & 15 \\ 2 & -6 & 3 & 0 \\ 0 & 3 & -8 & 0 \end{array} \right] \] Now, create a zero in the first column of Row 2. The operation is \(R_2 \leftarrow R_2 - \frac{2}{3}R_1\). (To make it easier, let’s do \(R_2 \leftarrow 3R_2 - 2R_1\)). \[ 3 \times [2, -6, 3, 0] \rightarrow [6, -18, 9, 0] \] \[ 2 \times [3, -1, 0, 15] \rightarrow [6, -2, 0, 30] \] \[ \text{New } R_2 = [0, -16, 9, -30] \] Our matrix is now: \[ \left[ \begin{array}{ccc|c} 3 & -1 & 0 & 15 \\ 0 & -16 & 9 & -30 \\ 0 & 3 & -8 & 0 \end{array} \right] \] Finally, let’s eliminate the first element in Row 3. Oh, wait, it’s already zero! So we move to the next pivot. We need to create a zero in the second column of Row 3. The operation is \(R_3 \leftarrow R_3 + \frac{3}{16}R_2\) (or \(R_3 \leftarrow 16R_3 + 3R_2\)). \[ 16 \times [0, 3, -8, 0] \rightarrow [0, 48, -128, 0] \] \[ 3 \times [0, -16, 9, -30] \rightarrow [0, -48, 27, -90] \] \[ \text{New } R_3 = [0, 0, -101, -90] \] Our final Row Echelon Form is: \[ \left[ \begin{array}{ccc|c} 3 & -1 & 0 & 15 \\ 0 & -16 & 9 & -30 \\ 0 & 0 & -101 & -90 \end{array} \right] \]

Step 3: Back Substitution

  • From \(R_3\): \(-101i_3 = -90 \implies i_3 = 90/101 \approx 0.891\) A.

  • From \(R_2\): \(-16i_2 + 9i_3 = -30 \implies -16i_2 + 9(90/101) = -30 \implies i_2 \approx 2.375\) A.

  • From \(R_1\): \(3i_1 - i_2 = 15 \implies 3i_1 - 2.375 = 15 \implies i_1 \approx 5.792\) A.

Python Verification

Code
import numpy as np

# Coefficient matrix A (from KVL equations)
A = np.array([
    [6, -2, 0],
    [2, -6, 3],
    [0, 3, -8]
])

# Constants vector b (from voltage sources)
b = np.array([30, 0, 0])   # <-- adjust according to your circuit

# Solve the system Ax = b
currents = np.linalg.solve(A, b)

print("The solution currents are:")
print(f"i1 = {currents[0]:.3f} Amps")
print(f"i2 = {currents[1]:.3f} Amps")
print(f"i3 = {currents[2]:.3f} Amps")
The solution currents are:
i1 = 5.792 Amps
i2 = 2.376 Amps
i3 = 0.891 Amps

3.5.2 Problem 2: Polynomial Curve Fitting (Computer Graphics)

Scenario: You are a game developer designing a smooth path for a character. You want a parabola of the form \(y = ax^2 + bx + c\) to pass through three specific points: \(P_1(-1, 10)\), \(P_2(1, 4)\), and \(P_3(2, 7)\). Find the coefficients \(a, b,\) and \(c\) that define this unique parabola.

Solution

Step 1: Mathematical Setup

Each point must satisfy the equation \(y = ax^2 + bx + c\). Plugging in the coordinates gives us three linear equations for the unknowns \(a, b, c\).

  • For \(P_1(-1, 10)\): \(a(-1)^2 + b(-1) + c = 10 \implies a - b + c = 10\)
  • For \(P_2(1, 4)\): \(a(1)^2 + b(1) + c = 4 \implies a + b + c = 4\)
  • For \(P_3(2, 7)\): \(a(2)^2 + b(2) + c = 7 \implies 4a + 2b + c = 7\)

Step 2: Gauss Elimination

  • Matrix: \(\left[ \begin{array}{ccc|c} 1 & -1 & 1 & 10 \\ 1 & 1 & 1 & 4 \\ 4 & 2 & 1 & 7 \end{array} \right]\)
  • \(R_2 \leftarrow R_2 - R_1\) and \(R_3 \leftarrow R_3 - 4R_1\): \(\left[ \begin{array}{ccc|c} 1 & -1 & 1 & 10 \\ 0 & 2 & 0 & -6 \\ 0 & 6 & -3 & -33 \end{array} \right]\)
  • \(R_3 \leftarrow R_3 - 3R_2\): \(\left[ \begin{array}{ccc|c} 1 & -1 & 1 & 10 \\ 0 & 2 & 0 & -6 \\ 0 & 0 & -3 & -15 \end{array} \right]\)

Step 3: Back Substitution:

  • \(-3c = -15 \implies c = 5\)

  • \(2b = -6 \implies b = -3\)

  • \(a - b + c = 10 \implies a - (-3) + 5 = 10 \implies a = 2\)

  • The parabola is \(y = 2x^2 - 3x + 5\).

Python Verification

Code
import numpy as np
import matplotlib.pyplot as plt

# Matrix for system (x^2, x, 1) at points x = -1, 1, 2
A = np.array([
    [(-1)**2, -1, 1],   # point (-1, 10)
    [(1)**2,  1, 1],    # point (1, 4)
    [(2)**2,  2, 1]     # point (2, 7)
])

# Corresponding y-values
b = np.array([10, 4, 7])

# Solve for coefficients a, b, c
coeffs = np.linalg.solve(A, b)
a, b_c, c = coeffs

print(f"The coefficients are a={a:.1f}, b={b_c:.1f}, c={c:.1f}")
print(f"The parabola is y = {a:.1f}x² + {b_c:.1f}x + {c:.1f}")

# Plotting
x_vals = np.linspace(-2, 3, 200)
y_vals = a * x_vals**2 + b_c * x_vals + c

plt.plot(x_vals, y_vals, label='Fitted Parabola')
plt.plot([-1, 1, 2], [10, 4, 7], 'ro', label='Data Points')
plt.legend()
plt.grid(True)
plt.show()
The coefficients are a=2.0, b=-3.0, c=5.0
The parabola is y = 2.0x² + -3.0x + 5.0


3.5.3 Problem 3: Network Traffic Flow (Computer Science)

Scenario: The figure below shows the traffic flow (in cars per hour) over a network of one-way streets. The total flow into any intersection must equal the total flow out of that intersection. This conservation principle gives us a system of linear equations.

Figure 3.4: Network diagram

Consider a simpler 3-node network. * Node 1: \(500 = x_1 + x_2\) * Node 2: \(x_1 + x_3 = 300\) * Node 3: \(x_2 = x_3 + 200\)

Find the traffic flows \(x_1, x_2,\) and \(x_3\).

Solution:

Step 1: Mathematical Setup

Rearrange the equations: 1. \(x_1 + x_2 + 0x_3 = 500\) 2. \(x_1 + 0x_2 + x_3 = 300\) 3. \(0x_1 + x_2 - x_3 = 200\)

Step 2: Gauss Elimination

  • The matrix form of the system can be written as: \(\left[ \begin{array}{ccc|c} 1 & 1 & 0 & 500 \\ 1 & 0 & 1 & 300 \\ 0 & 1 & -1 & 200 \end{array} \right]\)\ Using elementory transformations;

  • \(R_2 \leftarrow R_2 - R_1\): \(\left[ \begin{array}{ccc|c} 1 & 1 & 0 & 500 \\ 0 & -1 & 1 & -200 \\ 0 & 1 & -1 & 200 \end{array} \right]\)

  • \(R_3 \leftarrow R_3 + R_2\): \(\left[ \begin{array}{ccc|c} 1 & 1 & 0 & 500 \\ 0 & -1 & 1 & -200 \\ 0 & 0 & 0 & 0 \end{array} \right]\)

  • It represents a system with two equations in three variables. So the system has infinitely many solutions!

Step 3: Back substitution

From the equations; \[ \begin{cases} x_1 + x_2 = 500 \\ x_2 - x_3 = 200 \end{cases} \]

Let \(x_3 = t\) (free parameter). Then:

\[ x_2 = 200 + t, \quad x_1 = 500 - x_2 = 300 - t. \]

Thus the solution set is:

\[ (x_1, x_2, x_3) = (300 - t,\; 200 + t,\; t), \qquad t \in \mathbb{R}. \]


Non-Negative Constraints

If the variables represent flows, they must satisfy \(x_i \geq 0\):

\[ \begin{align*} x_1 &= 300 - t \geq 0 \quad \Rightarrow \quad t \leq 300\\ x_2 &= 200 + t \geq 0 \quad \Rightarrow \quad t \geq -200\\ x_3 = t \geq 0 \end{align*} \] Hence the valid range is: \[ 0 \leq t \leq 300 \]


Example Solution

For \(t = 50\), we get one solution as given below:

\[ (x_1, x_2, x_3) = (250, 250, 50). \]

Python code for verification

Code
import numpy as np

# Coefficient matrix from the equations:
# x1 + x2      = 500
# x1     + x3  = 300
#      x2 - x3 = 200
A = np.array([
    [1, 1, 0],
    [1, 0, 1],
    [0, 1, -1]
])
b = np.array([500, 300, 200])

# Since this system is dependent, use least-squares solution
flows, residuals, rank, s = np.linalg.lstsq(A, b, rcond=None)

x1, x2, x3 = flows

print("General traffic flow solution (with free variable t):")
print(f"x1 = {x1:.1f} + t")
print(f"x2 = {x2:.1f} - t")
print(f"x3 = {x3:.1f} + t")
General traffic flow solution (with free variable t):
x1 = 266.7 + t
x2 = 233.3 - t
x3 = 33.3 + t

3.6 Application Challenge: Gauss Elimination for Multiple Linear Regression

Objective

This challenge demonstrates how the Gauss elimination method from Linear Algebra can be applied to solve a multiple linear regression problem.
We use the Diabetes dataset available in sklearn and compare our solution with the library function LinearRegression.

Dataset:

Use the Diabetes dataset from sklearn.datasets. Let the response be the target vector \(y\). Use the first three features as predictors. Include an intercept term.

Step 1: Formulation of the regression problem

For multiple linear regression, we model the response variable \(y\) as

\[ y \approx X \beta \]

where

  • \(X\) is the design matrix (with columns for features and an intercept),
  • \(\beta\) is the vector of regression coefficients,
  • \(y\) is the target vector.

The least squares solution is obtained from the normal equations:

\[ (X^T X) \beta = X^T y \]


Step 2: Load the dataset and prepare \(X\) and \(y\)

Code
import numpy as np
from sklearn.datasets import load_diabetes

# Load the diabetes dataset
X, y = load_diabetes(return_X_y=True)

# Select the first 3 features for simplicity
X = X[:, :3]

# Add a column of ones for the intercept
X = np.c_[np.ones(X.shape[0]), X]

# Normal equations
A = X.T @ X
b = X.T @ y

print("Matrix A (X^T X):\n", A)
print("\nVector b (X^T y):\n", b)
Matrix A (X^T X):
 [[ 4.42000000e+02 -1.66533454e-16  2.60902411e-15 -1.00239261e-13]
 [-1.66533454e-16  1.00000000e+00  1.73737101e-01  1.85084666e-01]
 [ 2.60902411e-15  1.73737101e-01  1.00000000e+00  8.81613990e-02]
 [-1.00239261e-13  1.85084666e-01  8.81613990e-02  1.00000000e+00]]

Vector b (X^T y):
 [67243.           304.18307453    69.71535568   949.43526038]

Step 3: Solve using Gauss elimination

Code
def gauss_elimination(A, b):
    A = A.astype(float).copy()
    b = b.astype(float).copy()
    n = len(b)
    
    # Forward elimination
    for i in range(n):
        # Normalize the pivot row
        pivot = A[i, i]
        A[i] = A[i] / pivot
        b[i] = b[i] / pivot
        
        # Eliminate below
        for j in range(i+1, n):
            factor = A[j, i]
            A[j] = A[j] - factor * A[i]
            b[j] = b[j] - factor * b[i]
    
    # Back substitution
    x = np.zeros(n)
    for i in range(n-1, -1, -1):
        x[i] = b[i] - np.dot(A[i, i+1:], x[i+1:])
    
    return x

beta_gauss = gauss_elimination(A, b)
print("Regression coefficients (Gauss elimination):\n", beta_gauss)
Regression coefficients (Gauss elimination):
 [152.13348416 138.9039107  -36.13526678 926.91201212]

Step 4: Compare with sklearn LinearRegression

Code
from sklearn.linear_model import LinearRegression

reg = LinearRegression().fit(X, y)

# Collect sklearn coefficients (intercept + first 3 features)
beta_sklearn = np.r_[reg.intercept_, reg.coef_[1:4]]

print("Regression coefficients (sklearn):\n", beta_sklearn)
Regression coefficients (sklearn):
 [152.13348416 138.9039107  -36.13526678 926.91201212]

Conclusions:

  • Gauss elimination successfully solved the regression problem by computing the coefficients from the normal equations.

  • The result matches the coefficients obtained from sklearn.LinearRegression().

  • This demonstrates how a classical linear algebra algorithm underlies a modern machine learning method.

3.7 Rank and The Fundamental Theorem

The number of pivots in a matrix is a fundamentally important number. It is called the Rank of the matrix.

Definition: Rank The rank of a matrix \(A\) is the number of pivots in its row echelon form.

In our example, the rank is 3. The rank cannot be larger than the number of rows or columns.

This brings us to the Fundamental Theorem for Linear Systems. This theorem tells us everything about the existence and uniqueness of solutions.

The Fundamental Theorem for Linear Systems (Statement Only)

  1. Existence: A system \(Ax = b\) has a solution if and only if the rank of the coefficient matrix \(A\) is equal to the rank of the augmented matrix \([A | b]\). (In other words, the elimination process doesn’t lead to an impossible equation like \(0 = 5\)).

  2. Uniqueness:

    • If a solution exists and the \(\text{rank} = \text{number of variables}\), the solution is unique.
    • If a solution exists and the \(\text{rank} < \text{number of variables}\), there are infinitely many solutions. The difference \((\text{number of variables} - \text{rank})\) tells you the number of “free variables” you can choose.

3.8 Problems on Rank of a Matrix

3.8.1 Problem 1

Find the rank of \(A = \begin{bmatrix} 1 & 2 & 3 \\ 2 & 4 & 6 \\ 3 & 6 & 9 \end{bmatrix}.\)

Solution:
Applying row operations: \[ R_2 \to R_2 - 2R_1, \quad R_3 \to R_3 - 3R_1 \] \[ \Rightarrow \begin{bmatrix} 1 & 2 & 3 \\ 0 & 0 & 0 \\ 0 & 0 & 0 \end{bmatrix} \] Only one non-zero row remains.
Rank = 1.


3.8.2 Problem 2

Find the rank of \(B = \begin{bmatrix} 2 & 4 & 1 \\ 0 & 5 & 2 \\ 0 & 0 & 3 \end{bmatrix}.\)

Solution:
The matrix is in upper triangular form. All diagonal entries are non-zero.
Rank = 3.


3.8.3 Problem 3

Find the rank of \(C = \begin{bmatrix} 1 & 1 & 1 \\ 1 & 2 & 3 \\ 1 & 3 & 6 \end{bmatrix}.\)

Solution:
Applying \(R_2 \to R_2 - R_1\) and \(R_3 \to R_3 - R_1\): \[ \Rightarrow \begin{bmatrix} 1 & 1 & 1 \\ 0 & 1 & 2 \\ 0 & 2 & 5 \end{bmatrix} \] Now \(R_3 \to R_3 - 2R_2\): \[ \Rightarrow \begin{bmatrix} 1 & 1 & 1 \\ 0 & 1 & 2 \\ 0 & 0 & 1 \end{bmatrix} \] All rows are non-zero.
Rank = 3.


3.8.4 Problem 4

Find the rank of \(D = \begin{bmatrix} 1 & 2 & 3 & 4 \\ 2 & 4 & 6 & 8 \\ 1 & 3 & 4 & 7 \end{bmatrix}.\)

Solution:

\(R_2 \to R_2 - 2R_1\), \(R_3 \to R_3 - R_1\): \[ \Rightarrow \begin{bmatrix} 1 & 2 & 3 & 4 \\ 0 & 0 & 0 & 0 \\ 0 & 1 & 1 & 3 \end{bmatrix} \] Swap \(R_2\) and \(R_3\): \[ \Rightarrow \begin{bmatrix} 1 & 2 & 3 & 4 \\ 0 & 1 & 1 & 3 \\ 0 & 0 & 0 & 0 \end{bmatrix} \] Two non-zero rows.
Rank = 2.


3.8.5 Problem 5

Find the rank of \(A = \begin{bmatrix} 0 & 2 & 4 \\ 1 & 3 & 5 \\ 2 & 4 & 6 \end{bmatrix}.\)

Solution:
Swap \(R_1\) and \(R_2\): \[ \Rightarrow \begin{bmatrix} 1 & 3 & 5 \\ 0 & 2 & 4 \\ 2 & 4 & 6 \end{bmatrix} \] \(R_3 \to R_3 - 2R_1\): \[ \Rightarrow \begin{bmatrix} 1 & 3 & 5 \\ 0 & 2 & 4 \\ 0 & -2 & -4 \end{bmatrix} \] \(R_3 \to R_3 + R_2\): \[ \Rightarrow \begin{bmatrix} 1 & 3 & 5 \\ 0 & 2 & 4 \\ 0 & 0 & 0 \end{bmatrix} \] Two non-zero rows.
Rank = 2.

3.9 Application problems

3.9.1 Problem 1

In a digital communication system, three transmitted signals are received at three different antennas. The received signal strengths (in arbitrary units) are represented by the matrix, \[ A = \begin{bmatrix} 2 & 3 & 1 \\ 4 & 6 & 2 \\ 1 & 1.5 & 0.5 \end{bmatrix} \]

Determine the rank of \(A\) and comment on whether the received signals are linearly independent.

Solution:
By performing Gaussian elimination: \[ R_2 \to R_2 - 2R_1,\quad R_3 \to R_3 - 0.5R_1 \] We get:

\[ \begin{bmatrix} 2 & 3 & 1 \\ 0 & 0 & 0 \\ 0 & 0 & 0 \end{bmatrix} \]

The rank is $1$. This implies that all received signals are linearly dependent — effectively carrying the same information.


3.9.2 Problem 2

In a computer vision system, the transformation matrix mapping 3D world points to 2D image points is given by:

\[ B = \begin{bmatrix} 1 & 0 & 2 \\ 0 & 1 & 3 \\ 2 & 1 & 7 \end{bmatrix} \]

Find the rank of \(B\) and state whether the transformation is invertible.

Solution:
Perform:

\[ R_3 \to R_3 - 2R_1 \]

\[ \begin{bmatrix} 1 & 0 & 2 \\ 0 & 1 & 3 \\ 0 & 1 & 3 \end{bmatrix} \]

Now:

\[ R_3 \to R_3 - R_2 \]

\[ \begin{bmatrix} 1 & 0 & 2 \\ 0 & 1 & 3 \\ 0 & 0 & 0 \end{bmatrix} \]

Rank = \(2\). The transformation is not invertible because it is not full rank.


3.9.3 Problem 3

In a microprocessor system, the current equations for three loops are given by:

\[ \begin{cases} 2I_1 + I_2 + I_3 = 5 \\ 4I_1 + 2I_2 + 2I_3 = 10 \\ 3I_1 + 1.5I_2 + 1.5I_3 = 7.5 \end{cases} \]

Form the coefficient matrix and determine its rank. Comment on the uniqueness of the solution.

Solution:
Coefficient matrix:

\[ C = \begin{bmatrix} 2 & 1 & 1 \\ 4 & 2 & 2 \\ 3 & 1.5 & 1.5 \end{bmatrix} \]

Using Gaussian elimination, all rows become proportional to the first row, giving rank = \(1\).
Since the rank is less than the number of variables, the system has infinitely many solutions.


3.9.4 Problem 4

In a data transmission system, the coding matrix is:

\[ D = \begin{bmatrix} 1 & 2 & 3 & 4 \\ 2 & 4 & 6 & 8 \\ 1 & 3 & 4 & 7 \end{bmatrix} \]

Find the rank and explain its implication on error detection capability.

Solution:
Perform:

\[ R_2 \to R_2 - 2R_1 \]

\[ \begin{bmatrix} 1 & 2 & 3 & 4 \\ 0 & 0 & 0 & 0 \\ 1 & 3 & 4 & 7 \end{bmatrix} \]

\[ R_3 \to R_3 - R_1 \]

\[ \begin{bmatrix} 1 & 2 & 3 & 4 \\ 0 & 0 & 0 & 0 \\ 0 & 1 & 1 & 3 \end{bmatrix} \]

This has two non-zero rows → rank = \(2\).
A rank less than the number of columns implies reduced ability to detect and correct transmission errors.


3.9.5 Problem 5

An image compression algorithm stores pixel blocks as linear combinations of a set of basis images. The matrix of basis images is:

\[ E = \begin{bmatrix} 1 & 0 & 1 \\ 0 & 1 & 1 \\ 1 & 1 & 2 \end{bmatrix} \]

Find the rank of \(E\) and comment on whether the basis set is minimal.

Solution:
Perform: \[ R_3 \to R_3 - R_1 \]

\[ \begin{bmatrix} 1 & 0 & 1 \\ 0 & 1 & 1 \\ 0 & 1 & 1 \end{bmatrix} \]

\[ R_3 \to R_3 - R_2 \]

\[ \begin{bmatrix} 1 & 0 & 1 \\ 0 & 1 & 1 \\ 0 & 0 & 0 \end{bmatrix} \]

Rank = \(2\). This means the third basis image is not independent; a smaller basis can be used for compression.

3.10 Homogeneous and Non-Homogeneous Systems

There are two main flavors of systems we need to discuss.

3.10.1 Homogeneous System: \(Ax = 0\)

This is a system where the right-hand side is all zeros. For example: \(x + 2y + z = 0\).

  • These systems always have at least one solution: the trivial solution \(x=0, y=0, z=0\).
  • The interesting question is whether they have non-trivial solutions.
  • From the Fundamental Theorem, we will have infinitely many (non-trivial) solutions if \(\text{rank} < \text{number of variables}\). The solutions form a space called the nullspace.

Let’s find the nullspace of a different matrix, one that has a non-trivial nullspace.

Code
import sympy as sp

# Matrix with non-trivial nullspace
B = sp.Matrix([
  [1, 2, 3],
  [4, 5, 6],
  [7, 8, 9]
])

nullspace_vectors = B.nullspace()
print(f"The rank of matrix B is {B.rank()}. It has {B.shape[1]} columns.")
print("The nullspace is spanned by:")
sp.pprint(nullspace_vectors)
The rank of matrix B is 2. It has 3 columns.
The nullspace is spanned by:
⎡⎡1 ⎤⎤
⎢⎢  ⎥⎥
⎢⎢-2⎥⎥
⎢⎢  ⎥⎥
⎣⎣1 ⎦⎦

For matrix \(B\), the rank (2) is less than the number of variables (3), so there is one free variable and the nullspace is a line through the origin. Any multiple of the vector \([1, -2, 1]^T\) is a solution to \(Bx=0\).

3.10.2 Non-Homogeneous System: \(Ax = b\)

This is the general case where \(b\) is not all zeros. The complete solution has a beautiful structure.

Structure of the Complete Solution The complete solution to \(Ax = b\) is given by: \[ x_{\text{complete}} = x_{\text{particular}} + x_{\text{homogeneous}} \]

Where: * \(x_{\text{particular}}\) is one particular solution to \(Ax = b\). * \(x_{\text{homogeneous}}\) is all the solutions to the associated homogeneous system \(Ax = 0\).

This is an amazing and deep result! It says that the set of all solutions to \(Ax = b\) is just a shifted version of the nullspace. The nullspace goes through the origin, and we just shift the whole thing by one particular solution vector.

3.11 Tutorial questions: Applications of Fundamental Theorem in Linear Algebra

Objectives and expected outcomes:

  • This tutorial focuses on application-level problems based on the Fundamental Theorem of Linear Algebra (FTLA).

    • Students are expected to formulate, solve, and interpret systems of linear equations in applied contexts.

    • Apply rank and FTLA to determine solvability and uniqueness of engineering systems.

    • Connect mathematical theory with applications in signal processing, circuit analysis, and graphics.

    • Justify consistency, uniqueness, or multiplicity of solutions through stepwise reasoning.


3.11.1 Signal Processing – Solvability of Filter Design Equations

A digital filter is to be designed such that its output satisfies the linear system

\[ Ax = b, \quad A = \begin{bmatrix} 1 & 0 & -1 \\ 0 & 1 & -1 \\ 1 & 1 & -2 \end{bmatrix}, \quad b = \begin{bmatrix} 2 \\ 1 \\ 3 \end{bmatrix}. \]

Discuss the consistency of the system design and the filter design flexibility using the FTLA.

Solution:

  1. Check rank of \(A\): \[ A \sim \begin{bmatrix} 1 & 0 & -1 \\ 0 & 1 & -1 \\ 0 & 0 & 0 \end{bmatrix} \quad \Rightarrow \quad \text{rank}(A)=2. \]

  2. Augmented matrix rank: \[ K \sim \begin{bmatrix} 1 & 0 & -1 & | & 2 \\ 0 & 1 & -1 & | & 1 \\ 0 & 0 & 0 & | & 0 \end{bmatrix}. \] Rank \((A)=\)Rank \(K=2\).
    System is consistent.

  3. Number of solutions:
    Since \(\text{rank}(A)=2 < n=3\), the system has infinitely many solutions.

  4. Solve reduced system:
    \[ x_1 - x_3 = 2, \quad x_2 - x_3 = 1. \] General solution: \[ x = \begin{bmatrix} 2 \\ 1 \\ 0 \end{bmatrix} + x_3 \begin{bmatrix} 1 \\ 1 \\ 1 \end{bmatrix}, \quad x_3 \in \mathbb{R}. \]

Apply-level justification: Students apply rank conditions to check consistency, then compute and interpret the infinite solution set as filter design flexibility.


3.11.2 Circuit Analysis – Nodal Equations

A circuit yields the nodal equations:

\[ \begin{bmatrix} 2 & -1 & -1 \\ -1 & 2 & -1 \\ -1 & -1 & 2 \end{bmatrix} \begin{bmatrix} V_1 \\ V_2 \\ V_3 \end{bmatrix} = \begin{bmatrix} 0 \\ 0 \\ 0 \end{bmatrix}. \]

Examine the consistency of the system and find the voltage across the circuit.

Solution

  1. Form augmented matrix: The augmented matrix, \(K\) is given by:

\[ K=\left[\begin{array}{ccc|c} 2 & -1 & -1 & 0\\ -1 & 2 & -1 & 0\\ -1 & -1 & 2 & 0 \end{array}\right]. \]

  1. Eliminate first column entries below the pivot (2 in row 1):
  • \(R_2 \to 2R_2 + R_1\)
  • \(R_3 \to 2R_3 + R_1\)

This gives: \[ K\sim \left[\begin{array}{ccc|c} 2 & -1 & -1 & 0\\ 0 & 3 & -3 & 0\\ 0 & -3 & 3 & 0 \end{array}\right]. \]

  1. Eliminate second column entry below pivot (3 in row 2):
  • \(R_3 \to R_3 + R_2\).

This gives: \[ K\sim \left[\begin{array}{ccc|c} 2 & -1 & -1 & 0\\ 0 & 3 & -3 & 0\\ 0 & 0 & 0 & 0 \end{array}\right]. \]

  1. Interpret the reduced system: \[ \begin{cases} 2V_1 - V_2 - V_3 = 0 \\ 3V_2 - 3V_3 = 0 \end{cases} \]

Simplify the equations: \[ \begin{cases} 2V_1 = V_2 + V_3 \\ V_2 = V_3 \end{cases} \]

  1. Parametric solution:
    Let \(V_3 = t\). Then \(V_2 = t\), and \(2V_1 = 2t \Rightarrow V_1 = t\).

So, \[ \begin{bmatrix}V_1\\V_2\\V_3\end{bmatrix} = t \begin{bmatrix}1\\1\\1\end{bmatrix}, \quad t \in \mathbb{R}. \]

Apply-level justification: Students apply elimination (without normalizing pivots) to show that the solution space is one-dimensional, matching the physics of nodal equations.


3.11.3 Computer Graphics – Transformation Equations

In a 2D graphics engine, the system for affine transformation parameters is:

\[ \begin{bmatrix} 1 & 0 & 0 & 0 \\ 0 & 1 & 0 & 0 \\ 1 & 1 & 1 & 0 \\ 0 & 0 & 1 & 1 \end{bmatrix} \begin{bmatrix} a \\ b \\ c \\ d \end{bmatrix} = \begin{bmatrix} 2 \\ 3 \\ 7 \\ 5 \end{bmatrix}. \]

Examine the stability of the transformation and find a representation of the parameters if possible.

Solution:

1. Form the augmented matrix \([A\mid b]\): \[ \left[\begin{array}{cccc|c} 1 & 0 & 0 & 0 & 2\\[4pt] 0 & 1 & 0 & 0 & 3\\[4pt] 1 & 1 & 1 & 0 & 7\\[4pt] 0 & 0 & 1 & 1 & 5 \end{array}\right]. \]

2. Use the obvious pivots in rows 1 and 2 to eliminate corresponding entries below/above (they already isolate \(a\) and \(b\)):
- Row 1 already gives \(a = 2\).
- Row 2 already gives \(b = 3\).

We can still perform systematic elimination to show consistency:

3. Eliminate \(a\) and \(b\) from row 3 using rows 1 and 2: - Replace \(R_3 \to R_3 - R_1 - R_2\): \[ R_3 = [1,1,1,0\,|\,7] - [1,0,0,0\,|\,2] - [0,1,0,0\,|\,3] = [0,0,1,0\,|\,2]. \]

After this operation the augmented matrix becomes: \[ \left[\begin{array}{cccc|c} 1 & 0 & 0 & 0 & 2\\[4pt] 0 & 1 & 0 & 0 & 3\\[4pt] 0 & 0 & 1 & 0 & 2\\[4pt] 0 & 0 & 1 & 1 & 5 \end{array}\right]. \]

4. Use the pivot in row 3 (now isolates \(c\)) to eliminate \(c\) from row 4:
- Replace \(R_4 \to R_4 - R_3\): \[ R_4 = [0,0,1,1\,|\,5] - [0,0,1,0\,|\,2] = [0,0,0,1\,|\,3]. \]

Now the matrix is: \[ \left[\begin{array}{cccc|c} 1 & 0 & 0 & 0 & 2\\[4pt] 0 & 1 & 0 & 0 & 3\\[4pt] 0 & 0 & 1 & 0 & 2\\[4pt] 0 & 0 & 0 & 1 & 3 \end{array}\right]. \]

5. Read off the solution from the (upper-triangular/diagonalized) augmented matrix:

\[ \begin{aligned} a &= 2,\\ b &= 3,\\ c &= 2,\\ d &= 3. \end{aligned} \]

So the unique solution is \[ (a,b,c,d) = (2,\,3,\,2,\,3). \]

6. Verify uniqueness and consistency:

  • The elimination produced a diagonal (full pivot in each column), showing ((A)=4) and hence a unique solution.
  • All rows were consistent (no contradictory zero = nonzero row), so the system is consistent.

Apply-level justification: Students carry out elimination steps to solve a real-engineering parameter identification problem, verifying full-rank condition and interpreting the unique parameter set for a stable affine transformation in graphics.


3.12 Module I Summary

  • We can view a linear system in two ways: the Row Picture (intersecting hyperplanes) and the Column Picture (linear combination of vectors).
  • Gauss Elimination is the core algorithm for solving any system. It reduces the system to Row Echelon Form.
  • The rank of a matrix is the number of pivots, and it’s the most important number about that matrix.
  • The Fundamental Theorem tells us when solutions exist and if they are unique, all based on the rank.
  • The complete solution to \(Ax = b\) is a combination of one particular solution and all solutions to \(Ax = 0\) (the nullspace).

This module has set the stage. We have the main problem (\(Ax=b\)) and the main algorithm (elimination). In the next modules, we will build a much deeper understanding of the matrix \(A\) itself.