Lecture 04: Introduction to systems of linear equations#
Introduction#
Basic problem: Solve a set of \(n\) linear equations for \(n\) unknown values \(x_j\), \(j = 1, \ldots, n\).
Notation:
Notes:
The values \(a_{ij}\) are known as coefficients.
The right hand side values \(b_i\) are known.
\(x_1, x_2, x_3, \ldots, x_n\) are not known.
Computing \(x_1, x_2, x_3, \ldots, x_n\) solves the problem.
Notes#
Many computational algorithms require the solution of linear equations, e.g. in fields such as
Scientific computation;
Network design and optimisation;
Graphics and visualisation;
Machine learning.
Typically these systems are very large (\(n \approx 10^9\)).
It is therefore important that this problem can be solved
accurately;
efficiently;
reliably.
General matrix-vector form#
Solve the system of equations given by
In other words, given an \(n \times n\) matrix \(A\) and an \(n\)-vector \(\vec{b}\), find the \(n\)-vector \(\vec{x}\) which satisfies \(A \vec{x} = \vec{b}\).
Application I: Temperature in a sealed room#
Suppose we wish to estimate the temperature distribution inside an object:
We can place a network of points inside the object and use the following model: the temperature at each interior point is the average of its neighbours.
This example leads to the system:
Application II: Traffic network#
Suppose we wish to monitor the flow of traffic in a city centre:
As the above example shows, it is not necessary to monitor at every single road. If we know all of the \(y\) values we can calculate the \(x\) values!
This example leads to the system:
Special types of matrices#
The general matrix \(A\) before the examples is known as a full matrix: any of its components \(a_{ij}\) might be nonzero.
Often the problem being solved leads to a matrix with a particular structure.
Some entries may be known to be zero.
If this is the case then it is often possible to use this knowledge to improve the efficiency of the algorithm (in terms of both speed and/or storage).
Example 1: Triangular matrix#
One common (and important) structure takes the form
A is a lower triangular matrix. Every entry above the leading diagonal is zero:
\[ a_{ij} = 0 \quad \text{ for } \quad j > i. \]The transpose of this matrix is an upper triangular matrix and can be treated in a very similar manner.
Example 2: Sparse matrices#
Sparse matrices are extremely common in any application which relies on some form of graph structure (see both temperature and traffic network examples).
The \(a_{ij}\) typically represents some form of “communication” between vertices \(i\) and \(j\) of the graph, so the element is only nonzero if the vertices are connected.
There is no generic pattern for these entries, though there is usually one that is specific to the problem solved.
Usually \(a_{ii} \neq 0\) - the diagonal is nonzero.
A “large” portion of the matrix is zero.
A full \(n \times n\) matrix has \(n^2\) nonzero entries.
A sparse \(n \times n\) has \(\alpha n\) nonzero entries, where \(\alpha \ll n\).
Many special techniques exist for handling sparse matrices, some of which can be used automatically within Python (
scipy.sparse
documentation)
Significance#
What is the significance of these special examples?
In the next lecture we will discuss a general numerical algorithm for the solution of linear systems of equations.
This will involve reducing the problem to one involving a triangular matrix which, as we show below, is relatively easy to solve.
In subsequent lectures, we will see that, for sparse matrix systems, alternative solution techniques are available.
Uniqueness of solutions#
For the time-being we will only consider square systems of equations: for which the number of equations is equal to the number of unknowns (\(n\), say).
In this case the following statements are equivalent:
The linear system \(A \vec{x} = \vec{b}\) has a unique solution.
There exists a matrix (let’s call it \(A^{-1}\)) such that \(A^{-1} A = I\), and we say that the matrix \(A\) is invertible.
The linear system \(A \vec{x} = \vec{b}\) is non-singular.
Further reading#
Wikipedia: Systems of linear equations (includes a nice geometric picture of what a system of linear equations means).
Maths is fun: Systems of linear equations (very basic!)
Gregory Gundersen Why shouldn’t I invert that matrix?