Systems of Linear Equations

Introduction

Consider a system of equations on variables

Alternatively represented in a more compact, matrix form such that

Theorem: Existence and Uniqueness of Solutions

Consider the augmented matrix , where we simply add as a new column of . Then, the following cases apply.

  1. Case 1: If , then there exists one solution that is unique.
  2. Case 2: If , there are infinitely many solutions.
  3. Case 3: If , then there does not exist any solution!

In this article, we discuss efficient and practical ways to solve such systems in the real world.

Solving Systems of Linear Equations

Consider the linear system , where is an matrix and is a vector of length . Given this, how do we find all vectors which satisfy the equality (known as solving the system)?

Special (Simple) Cases

In some special / simple cases, we can easily solve the system. These cases are given below.

  1. When is a diagonal matrix, we simply divide all terms in by the corresponding value on ‘s diagonal.
  2. When is an upper triangular matrix, we can solve it using back substitution.
  3. When is a lower triangular matrix, we can solve it using forward substitution.

It may even be possible to exchange rows of and to obtain one of the above forms!

Gaussian Elimination

Motivation

What do we do if one of the above special cases cannot be easily obtained?

Suppose we have an invertible matrix . Then, given our system ,

Letting , , we obtain an equivalent system ! In other words, if solves , it must also solve .

Thus, we can smartly choose to obtain a matrix that coincides with one of our special cases, to find solutions to our original system!

Transformations and Algorithm

Now that we understand the intuition, how do we actually find this matrix ?

First, we look at some useful transformations and their corresponding matrix.

  1. We can multiply each equation with a non-zero scalar . Then, is a diagonal matrix with values along the diagonal.
  2. We can add a scalar multiple of an equation to another equation . Then, is the identity matrix with in the row, column.
  3. We can interchange two equations and . Then, is the identity matrix with the row and row swapped.

    This is often known as a permutation matrix!

We can multiply each of these tranformations together to find a single matrix that collectively performs all of them!

Below, we discuss a general algorithm that applies these transformations to obtain a simpler system - Gaussian Elimination. In such an algorithm, we essentially continuously subtract a row from the rows beneath it, to obtain an upper triangular matrix.

To make the algorithm clearer, we will show using an example.

Suppose we have the following system.

We convert this to a simpler, upper triangular matrix. Note that to do this, we want 0’s below our diagonal - and we can achieve this by using each equation to cancel out equations beneath it!

  1. Take our first equation in row 1. Use it to eliminate the first term in all rows below this row. So, we perform
  2. Take our second equation in row 2. Use it to eliminate the second term in all rows below this row. So, we perform
  3. We are done! Note that we could continue this process for row 3, 4, and onwards, to obtain an upper triangular matrix.

We now have an upper triangular matrix, which we can use back substitution to solve!

Note that the computational cost of this algorithm is .

Variations of Gaussian Elimination

Note that while the above Gaussian Elimination method is effective, it is also naive. In fact, there exist some systems that the algorithm is not able to solve.

Below, we propose some variations on Gaussian Elimination that avoid these issues, particularly on the computer.

Partial Pivoting

Consider the following systems. Let be an extremely small number.

In these examples, Gaussian Elimination will fail to obtain the correct solution!

  1. In the first system, the leading coefficient in the first row is 0, preventing us from obtaining an upper triangular matrix!
  2. In the second sytem, while this coefficient is not 0, it is extremely small, which will blow up our numbers and create lots of errors!

In both examples, we may be able to fix our issues if we swap our first and second row before applying Gaussian Elimination. This is the idea of partial pivoting!

In partial pivoting, before we apply a Gaussian Elimination with row , we will check if there exists a row among rows with a larger leading coefficient. If there does, we perform a row exchange , and continue as normal.

If we swap and our leading coefficient is still 0, our solution is not unique!

Scaled Partial Pivoting

However, partial pivoting is also not without issue. Consider the following system, where is an extremely large number, say .

We apply Gaussian Elimination with partial pivoting.

Without rounding, we obtain

So we should expect to obtain !

However, on a computer, loss of precision will cause numbers such as and to round to , which will skew our answers!

Note that to calculate a result, the machine pushes everything to the same exponent (choosing the highest one). However, it only has precision to the power, so we lose the 1 after converting it (as it drops to 0).

This gives us an incorrect solution!

To address this, we can use a variant of partial pivoting called scaled partial pivoting. Here, we find the scale of each row (equation) as the largest coefficient in that row

These scales are fixed to each equation, and will not be recomputed.

And while pivoting, we determine row swaps by swapping with the row that has the highest ratio

Then we perform Gaussian Elimination, and repeat as normal.

We are essentially scaling our pivots to account for the largest element in the row!

Consider the following example.

Example: Scaled Partial Pivoting

Consider the system

  1. Start with row 1. We have ratios . Swap row 1 and 3.
  2. Continue with row 2. We have ratios . Swap row 2 and 3.

We have an upper triangular matrix!

Note that if we have a tie between our pivot values, we can break the tie by choosing any row we want!

LU Factorization

Introduction

Suppose we can factorize into a product of two matrices and , where is a lower triangular matrix, and is an upper triangular matrix. This is known as a LU Factorization (Decomposition) of .

If and are non-singular (which we can check by seeing if any of the diagonals is 0), then the following two systems are equivalent.

This can easily be solved via forward and backward substitutions, which are fairly efficient!

Practical Applications

LU Factorizations can be useful in solving a system many times under different vectors! This lets us use backwards / forwards substitution instead of Gaussian elimination, which is faster!

One useful way this can be applied is in finding matrix inverses, as when finding them, we are really just solving the system for each column of ! If we factorize beforehand, we can use substitution to save on a lot of complexity!

Such a decomposition may not even exist! The following theorem lets us know whether or not such a decomposition exists.

Theorem: Existence of Decompositions

Let be an matrix. Then, if can be transformed to using Gaussian Elimination without any pivoting, there exists a decomposition of .

The elimination may still continue after a 0 pivot, as it may still yield a decomposition (albeit with 0’s on the diagonal).

Moreover, this decomposition is equal to the inverse of the transform matrix applied to .

Common cases where this occurs is as follows:

  • is diagonally dominant
  • is symmetric and positive definite: , and

However, if we are allowed to interchange the rows of , then we can always obtain an factorization!

Theorem: Permutations and Factorizations

Given an matrix , there exists a such that

Where is the permutation matrix of , swapping its rows.

General Approach to Factorization

Finding a factorization can be a bit tricky! We discuss a general algorithm to find it below.

Let and be lower and upper triangular matrices (respectively). If , then

Note that we can simplify our summation, because we know and are triangular matrices (by assumption), so for , and for .

Now suppose we either know or . We can use what we know above to derive our factorization!

  1. We start by deriving row 1 of . Then, for , we know that

  2. Then, we derive column 1 of . Then, for , we know that

  3. Now, suppose we want to derive the next row of , or column of . Suppose we have already determined rows of and columns of from previous steps.

    Then, we can find the next rows and columns using the following summations. For the diagonals and , choose an arbitrary number for one diagonal, to find the other.

    We repeat this until we are done!

This algorithm works, provided and are not zero!

decompositions are not unique! If one exists for a matrix , may more could too! Below, we discuss some special decompositions that can be unique in some scenarios.

Special LU Factorizations

We can find some special LU factorizations of ! The following theorem guarantees uniqueness of these factorizations.

Uniqueness of LU Factorizations

If is invertible, then there exists a giving us a unique Doolittle factorization, Grout factorization, and Cholesky’s factorization.

Doolittle Factorization

If where the elements on ‘s diagonal are 1, then we have a Doolittle Factorization.

This is obtained by finding the matrix with 1’s on the diagonal, where the entries below the diagonal are the multipliers used by the Gaussian Elimination, and taking the inverse.

When finding this factorization, set when solving for the diagonal along .

Grout's Factorization

We similarly have Grout’s Factorization, if where the elements on ‘s diagonal are 1.

Cholesky’s Factorization

If with , then we have a Cholesky Factorization. By definition, , meaning that is not only symmetric, but also positive semi-definite.

Norms and Errors

Vector Spaces and Norms

A vector space is a set with two operations

Satisfying the following properties:

  1. Commutivity:
  2. Additive Identity: There such that for all .
  3. Additive Inverse: For every , there exists a such that .
  4. Multiplicative Identity: There such that for all .
  5. Distributivity: For , and ,

Given a vector space , a norm is a function satisfying:

  1. For all , .
  2. If , then .
  3. for some scalar .
  4. Triangle Inequality:

If , then the norm is given as

Example: Norms

Some examples are given below.

For example, if , then .

Theorem: Norm Comparisons

On , we have

Given any norm on , the induced matrix norm on is given as

In other words, the maximum norm of given all possible unit vectors .

Theorem: Properties of the Matrix Norm

The following properties of the matrix norm are true.

  • If , then .
  • If , then .
  • If , then .
  • For any vector , then .
  • For any scalar , then .
  • For any matrix , then .
  • Triangle Inequality:

Furthermore, for any vector ,

Note that while is an induced matrix norm, is just a vector norm!

Example: Matrix Norms

Note that our matrix norm depends on our selection of the vector norm.

  • If we use the , then will be the max of each of ‘s rows (absolute value) sums.
  • If we use , then will be the max of each of ‘s columns sums.

Errors in Systems of Equations

Propagation of Errors on

We can use norms to calculate error propagation!

Consider the system of equations , and assume is non-singular.

Let’s say we make an error, and take an approximation instead of . Then, our relative error on is given as

Given this, how does our error propagate? In other words, what is our relative error in ?

  1. First, we find that
  2. We also find

Using this, we can find the relative error on as

Where is the condition number of ! This tells us the amount in which our error will be magnified.

Note that our condition number depends on the vector norm we are using.

Theorem: Condition Numbers

Let be a singular matrix. Then, for any matrix ,

Giving us a measure of how close to being a singular matrix is! By convention, we’ll say that for singular matrices, .

Example: Condition Numbers

Assume we are using the norm. Then,

Suppose our is small. Then, our condition number will be huge, which is not good!

Propagation of Errors on

Say for the system , we now have an approximation of , . Also assume that is non-singular.

What is our error on ?

First note the following.

Additionally, note that

We use this to calculate as

We can refactor to obtain