Numerical Method · Unit 4 · 8 hrs
Solving System of Linear Equations
Exam-focused notes for Solving System of Linear Equations (Numerical Method, CSC212): what the TU syllabus asks and how it has actually been tested, with 12 solved past questions from this unit.
Solving System of Linear Equations in short
A system of linear equations $A\mathbf{x}=\mathbf{b}$ underlies almost every numerical technique, from curve fitting to differential equations. This chapter develops direct methods that solve such a system in a fixed number of steps (Gaussian elimination, Gauss-Jordan, LU and Cholesky factorization) and iterative methods that refine an initial guess until it converges (Jacobi, Gauss-Seidel, the power method for eigenvalues).
What this unit covers
- Review of the existence of solutions and properties of matrices
- Gaussian elimination method
- pivoting
- Gauss-Jordan method
- Inverse of matrix using Gauss-Jordan method
- Matrix factorization and Solving System of Linear Equations by using Dolittle and Cholesky's algorithm
- Iterative Solutions of System of Linear Equations
- Jacobi Iteration Method
- Gauss-Seidal Method
- Eigen values and eigen vectors problems
- Solving eigen value problems using power method
Jacobi Iteration Method
2081 · 10 marks
What are the limitations of direct methods for solving a system of linear equations? How does Gauss Seidel method differ from Jacobi iteration? Solve the following system of linear equations using Jacobi iteration method:
$$ \begin{aligned} 2x - 7y - 10z &= -17 \ 5x + y + 3z &= 14 \ x + 10y + 9z &= 7 \end{aligned} $$
[10]
Show solved answerHide answer
Limitations of Direct Methods, Gauss-Seidel vs Jacobi, and Jacobi Iteration
Part 1: Limitations of Direct Methods
Direct methods (Gauss Elimination, LU Decomposition, Cramer's Rule) obtain the solution in a finite number of steps, but have limitations:
- High computational cost: Gauss Elimination needs about $O(n^3)$ operations; expensive for large $n$.
- Round-off error accumulation: Fixed long sequences of operations let rounding errors propagate.
- Large memory needs: Full matrix storage is required.
- Poor for sparse systems: Fill-in destroys sparsity, wasting memory and time.
- Pivoting problems: Zero or small pivots cause failure or instability without pivoting.
- Hard to parallelize: Inherently sequential.
Part 2: Gauss-Seidel vs Jacobi
| Feature | Jacobi | Gauss-Seidel |
|---|---|---|
| Values used | Only previous iteration values | Most recent updated values immediately |
| Storage | Needs old and new arrays | Single array (in-place) |
| Convergence | Slower | Faster (≈ twice) |
| Parallelism | Easy | Harder |
Formulas: $$x_i^{(k+1)} = \frac{1}{a_{ii}}\Big(b_i - \sum_{j\neq i} a_{ij}x_j^{(k)}\Big)\quad\text{(Jacobi)}$$ $$x_i^{(k+1)} = \frac{1}{a_{ii}}\Big(b_i - \sum_{j<i} a_{ij}x_j^{(k+1)} - \sum_{j>i} a_{ij}x_j^{(k)}\Big)\quad\text{(Gauss-Seidel)}$$
Part 3: Jacobi Iteration Solution
Given System
$$2x - 7y - 10z = -17 \quad (1)$$ $$5x + y + 3z = 14 \quad (2)$$ $$x + 10y + 9z = 7 \quad (3)$$
Step 1: Rearrange for Diagonal Dominance
Swap to place dominant coefficients on the diagonal: $$5x + y + 3z = 14 \quad (1')$$ $$x + 10y + 9z = 7 \quad (2')$$ $$2x - 7y - 10z = -17 \quad (3')$$
Check:
- Row 1: $|5|=5 > 1+3=4$ ✓
- Row 2: $|10|=10 = 1+9=10$ (borderline, acceptable)
- Row 3: $|-10|=10 > 2+7=9$ ✓
Step 2: Iteration Formulas
$$x^{(k+1)} = \tfrac{1}{5}\big(14 - y^{(k)} - 3z^{(k)}\big)$$ $$y^{(k+1)} = \tfrac{1}{10}\big(7 - x^{(k)} - 9z^{(k)}\big)$$ $$z^{(k+1)} = \tfrac{1}{10}\big(17 + 2x^{(k)} - 7y^{(k)}\big)$$
Step 3: Iterations (start $x^{(0)}=y^{(0)}=z^{(0)}=0$)
Iteration 1: $$x^{(1)} = \tfrac{1}{5}(14) = 2.8$$ $$y^{(1)} = \tfrac{1}{10}(7) = 0.7$$ $$z^{(1)} = \tfrac{1}{10}(17) = 1.7$$
Iteration 2: $$x^{(2)} = \tfrac{1}{5}(14 - 0.7 - 3(1.7)) = \tfrac{1}{5}(14 - 0.7 - 5.1) = \tfrac{8.2}{5} = 1.64$$ $$y^{(2)} = \tfrac{1}{10}(7 - 2.8 - 9(1.7)) = \tfrac{1}{10}(7 - 2.8 - 15.3) = \tfrac{-11.1}{10} = -1.11$$ $$z^{(2)} = \tfrac{1}{10}(17 + 2(2.8) - 7(0.7)) = \tfrac{1}{10}(17 + 5.6 - 4.9) = \tfrac{17.7}{10} = 1.77$$
Iteration 3: $$x^{(3)} = \tfrac{1}{5}(14 - (-1.11) - 3(1.77)) = \tfrac{1}{5}(14 + 1.11 - 5.31) = \tfrac{9.8}{5} = 1.96$$ $$y^{(3)} = \tfrac{1}{10}(7 - 1.64 - 9(1.77)) = \tfrac{1}{10}(7 - 1.64 - 15.93) = \tfrac{-10.57}{10} = -1.057$$ $$z^{(3)} = \tfrac{1}{10}(17 + 2(1.64) - 7(-1.11)) = \tfrac{1}{10}(17 + 3.28 + 7.77) = \tfrac{28.05}{10} = 2.805$$
Iteration 4: $$x^{(4)} = \tfrac{1}{5}(14 + 1.057 - 3(2.805)) = \tfrac{1}{5}(14 + 1.057 - 8.415) = \tfrac{6.642}{5} = 1.3284$$ $$y^{(4)} = \tfrac{1}{10}(7 - 1.96 - 9(2.805)) = \tfrac{1}{10}(7 - 1.96 - 25.245) = \tfrac{-20.205}{10} = -2.0205$$ $$z^{(4)} = \tfrac{1}{10}(17 + 2(1.96) - 7(-1.057)) = \tfrac{1}{10}(17 + 3.92 + 7.399) = \tfrac{28.319}{10} = 2.8319$$
Iteration 5: $$x^{(5)} = \tfrac{1}{5}(14 + 2.0205 - 3(2.8319)) = \tfrac{1}{5}(14 + 2.0205 - 8.4957) = \tfrac{7.5248}{5} = 1.505$$ $$y^{(5)} = \tfrac{1}{10}(7 - 1.3284 - 9(2.8319)) = \tfrac{1}{10}(7 - 1.3284 - 25.4871) = \tfrac{-19.8155}{10} = -1.9816$$ $$z^{(5)} = \tfrac{1}{10}(17 + 2(1.3284) - 7(-2.0205)) = \tfrac{1}{10}(17 + 2.6568 + 14.1435) = \tfrac{33.8003}{10} = 3.380$$
Observation on Convergence
The iterates are oscillating and not settling quickly:
| k | x | y | z |
|---|---|---|---|
| 1 | 2.80 | 0.70 | 1.70 |
| 2 | 1.64 | -1.11 | 1.77 |
| 3 | 1.96 | -1.057 | 2.805 |
| 4 | 1.328 | -2.021 | 2.832 |
| 5 | 1.505 | -1.982 | 3.380 |
The values are drifting rather than converging tightly. This is because Row 2 is only borderline dominant ($|10| = |1| + |9|$), so strict diagonal dominance is not satisfied, and Jacobi converges very slowly (borderline behavior).
Exact Solution (for reference)
Solving the system directly gives: $$x = 1,\quad y = -2,\quad z = 3$$
The Jacobi iterates ($x\to$ near 1.5, $y\to$ near $-2$, $z\to$ near 3) are drifting toward the neighborhood of this solution but require many more iterations owing to the borderline dominance.
Final result (converged / exact): $x = 1,\ y = -2,\ z = 3$.
Gauss-Jordan method
2081 · 5 marks
Solve the following system of linear equations using Gauss-Jordan elimination method:
$$ \begin{aligned} x + 2y - 3z &= 4 \ 2x + 4y - 6z &= 8 \ x - 2y + 5z &= 4 \end{aligned} $$
[5]
Show solved answerHide answer
Gauss-Jordan Elimination Method
Given Data
System of equations: $$x + 2y - 3z = 4 \quad \cdots (1)$$ $$2x + 4y - 6z = 8 \quad \cdots (2)$$ $$x - 2y + 5z = 4 \quad \cdots (3)$$
Step 1: Augmented Matrix
$$[A|b] = \begin{bmatrix} 1 & 2 & -3 & | & 4 \ 2 & 4 & -6 & | & 8 \ 1 & -2 & 5 & | & 4 \end{bmatrix}$$
Step 2: Eliminate column 1 below pivot
$R_2 \to R_2 - 2R_1$: $[0,\ 0,\ 0,\ |\ 0]$
$R_3 \to R_3 - R_1$: $[0,\ -4,\ 8,\ |\ 0]$
$$\begin{bmatrix} 1 & 2 & -3 & | & 4 \ 0 & 0 & 0 & | & 0 \ 0 & -4 & 8 & | & 0 \end{bmatrix}$$
Step 3: Swap $R_2 \leftrightarrow R_3$
$$\begin{bmatrix} 1 & 2 & -3 & | & 4 \ 0 & -4 & 8 & | & 0 \ 0 & 0 & 0 & | & 0 \end{bmatrix}$$
Step 4: Normalize Row 2 ($R_2 \to R_2 / (-4)$)
$$\begin{bmatrix} 1 & 2 & -3 & | & 4 \ 0 & 1 & -2 & | & 0 \ 0 & 0 & 0 & | & 0 \end{bmatrix}$$
Step 5: Eliminate column 2 above pivot ($R_1 \to R_1 - 2R_2$)
$R_1: [1,\ 0,\ 1,\ |\ 4]$
$$\begin{bmatrix} 1 & 0 & 1 & | & 4 \ 0 & 1 & -2 & | & 0 \ 0 & 0 & 0 & | & 0 \end{bmatrix}$$
Step 6: Interpretation
Row 3 gives $0 = 0$, which is consistent. Rank of coefficient matrix $= 2 <$ number of unknowns $= 3$, so there are infinitely many solutions.
Let $z = t$ (free parameter, $t \in \mathbb{R}$).
From Row 2: $y - 2t = 0 \implies y = 2t$
From Row 1: $x + t = 4 \implies x = 4 - t$
Verification with equation (3): $x - 2y + 5z = (4-t) - 2(2t) + 5t = 4 - t - 4t + 5t = 4$ ✓
Final Answer
$$x = 4 - t, \quad y = 2t, \quad z = t, \quad t \in \mathbb{R}$$
The system has infinitely many solutions since equation (2) $= 2 \times$ equation (1), reducing to two independent equations in three unknowns.
2080 · 10 marks
How Gauss Jordan method differs from Gauss Elimination method? Solve the following system of equations using Gauss Jordan method. How can we use Gauss Jordan method to find the inverse of a matrix? Discuss.
$$ \begin{aligned} 2x - y + 4z &= 15 \ 2x + 3y - 2z &= 4 \ 3x + 2y - 4z &= -4 \end{aligned} $$
[10]
2078 · 5 marks
Solve the following set of linear equations using the Gauss-Jordan method.
$$x_2 + 2x_3 + 3x_4 = 9$$ $$7x_1 + 6x_2 + 5x_3 + 4x_4 = 33$$ $$8x_1 + 9x_2 + x_4 = 27$$ $$2x_1 + 5x_2 + 4x_3 + 3x_4 = 23$$
[5]
Matrix factorization and Solving System of Linear Equations by using Dolittle and Cholesky's algorithm
2080 · 5 marks
Factorise the following matrix using Cholesky method. $$\begin{bmatrix} 2 & 1 & 1 \ 3 & 2 & 3 \ 1 & 4 & 9 \end{bmatrix}$$ [5]
2077 · 5 marks
Discuss the Doolittle LU decomposition method for matrix factorization. [5]
pivoting
2079 · 10 marks
What is pivoting? Why is it necessary? Write an algorithm and program to solve the set of n linear equations using Gaussian elimination method.[10]
2077 · 10 marks
Why partial pivoting is used with Naive Gauss Elimination method? Solve the following system of equations using Gauss Elimination method with partial pivoting? How Gauss Jordan method differs from Gauss elimination method? $2x + 2y - z = 6$, $4x + 2y + 3z = 4$, $x + y + z = 0$ [10]
Gauss-Seidal Method
2079 · 5 marks
Solve the following set of equations using Gauss Siedal method.
$$ \begin{aligned} x + 2y + 3z &= 4 \ 6x + 4y + 5z &= 16 \ 5x + 2y + 3z &= 12 \end{aligned} $$
[5]
Show solved answerHide answer
Gauss-Seidel Method
Given
The system of equations: $$x + 2y + 3z = 4 \quad \text{...(1)}$$ $$6x + 4y + 5z = 16 \quad \text{...(2)}$$ $$5x + 2y + 3z = 12 \quad \text{...(3)}$$
Initial guess (standard assumption): $x^{(0)} = y^{(0)} = z^{(0)} = 0$.
Solution
Analysis of Diagonal Dominance
For Gauss-Seidel to converge reliably, we should try to arrange the largest coefficients on the diagonal. Examine:
- Coefficient of $x$: largest in (2) and (3), both equal to 6 and 5.
- Coefficient of $y$: largest is 4 (in eq 2).
- Coefficient of $z$: largest is 5 (in eq 2).
The largest coefficients cluster in equation (2), so a clean diagonally dominant arrangement is not possible. This is a poorly conditioned system for Gauss-Seidel. However, following the standard exam approach (partial pivoting), we rearrange to place the largest coefficient in each row on the diagonal.
Rearranged system:
$$6x + 4y + 5z = 16 \Rightarrow x = \frac{16 - 4y - 5z}{6}$$ $$5x + 2y + 3z = 12 \Rightarrow y = \frac{12 - 5x - 3z}{2}$$ $$x + 2y + 3z = 4 \Rightarrow z = \frac{4 - x - 2y}{3}$$
Iteration 1 (from $x=y=z=0$)
$$x = \frac{16 - 0 - 0}{6} = 2.6667$$ $$y = \frac{12 - 5(2.6667) - 0}{2} = \frac{12 - 13.3333}{2} = -0.6667$$ $$z = \frac{4 - 2.6667 - 2(-0.6667)}{3} = \frac{4 - 2.6667 + 1.3333}{3} = \frac{2.6667}{3} = 0.8889$$
Iteration 2
$$x = \frac{16 - 4(-0.6667) - 5(0.8889)}{6} = \frac{16 + 2.6667 - 4.4444}{6} = \frac{14.2222}{6} = 2.3704$$ $$y = \frac{12 - 5(2.3704) - 3(0.8889)}{2} = \frac{12 - 11.8519 - 2.6667}{2} = \frac{-2.5185}{2} = -1.2593$$ $$z = \frac{4 - 2.3704 - 2(-1.2593)}{3} = \frac{4 - 2.3704 + 2.5185}{3} = \frac{4.1481}{3} = 1.3827$$
Iteration 3
$$x = \frac{16 - 4(-1.2593) - 5(1.3827)}{6} = \frac{16 + 5.0370 - 6.9136}{6} = \frac{14.1235}{6} = 2.3539$$ $$y = \frac{12 - 5(2.3539) - 3(1.3827)}{2} = \frac{12 - 11.7696 - 4.1481}{2} = \frac{-3.9177}{2} = -1.9588$$ $$z = \frac{4 - 2.3539 - 2(-1.9588)}{3} = \frac{4 - 2.3539 + 3.9177}{3} = \frac{5.5638}{3} = 1.8546$$
Iteration 4 (check on convergence)
$$x = \frac{16 - 4(-1.9588) - 5(1.8546)}{6} = \frac{16 + 7.8353 - 9.2730}{6} = \frac{14.5623}{6} = 2.4270$$ $$y = \frac{12 - 5(2.4270) - 3(1.8546)}{2} = \frac{12 - 12.1352 - 5.5638}{2} = \frac{-5.6990}{2} = -2.8495$$ $$z = \frac{4 - 2.4270 - 2(-2.8495)}{3} = \frac{4 - 2.4270 + 5.6990}{3} = \frac{7.2720}{3} = 2.4240$$
Summary Table
| Iteration | $x$ | $y$ | $z$ |
|---|---|---|---|
| 0 | 0 | 0 | 0 |
| 1 | 2.6667 | -0.6667 | 0.8889 |
| 2 | 2.3704 | -1.2593 | 1.3827 |
| 3 | 2.3539 | -1.9588 | 1.8546 |
| 4 | 2.4270 | -2.8495 | 2.4240 |
Important Observation on Convergence
The iterates are diverging, not converging. The values of $y$ move $-0.67 \to -1.26 \to -1.96 \to -2.85$ and $z$ moves $0.89 \to 1.38 \to 1.85 \to 2.42$; the gaps are growing, not shrinking. This confirms the earlier note that the system is not diagonally dominant and no rearrangement makes it so, so Gauss-Seidel does not converge here.
Exact solution (by direct elimination, subtracting (1) from (3): $4x = 8 \Rightarrow x = 2$; then $2y + 3z = 2$ and $4y + 5z = 4$, giving $y = -1,\ z = ...$). Solving:
- From $4x=8$: $x = 2$.
- $2y + 3z = 4 - 2 = 2$.
- $4y + 5z = 16 - 12 = 4$.
- Multiply first by 2: $4y + 6z = 4$; subtract: $z = 0$, then $2y = 2 \Rightarrow y = 1$.
So the true solution is $x = 2,\ y = 1,\ z = 0$. The Gauss-Seidel iterates ($x\approx 2.4,\ y\approx -2.8,\ z\approx 2.4$) are moving away from this, confirming divergence.
Final Result
The iterations up to iteration 3 and 4 are as tabulated. The method does not converge here: the iterates move away from the exact solution $x=2,\ y=1,\ z=0$, so any claim that it settles near $x=2,\ y=-2,\ z=2$ would be wrong.
2075 · 5 marks
Solve the following set of equations using Gauss Seidel method.
$$ \begin{aligned} x + 2y + 3z &= 4 \ 6x - 4y + 5z &= 10 \ 5x + 2y + 2z &= 25 \end{aligned} $$
[5]
Make Unit 4 stick
Practice CSC212 with flashcards & quizzes