Blog
2020-02-06
This is the third post in a series of posts about matrix methods.
Yet again, we want to solve , where is a (known) matrix, is a (known) vector, and is an unknown vector.
In the previous post in this series, we used Gaussian elimination to invert a matrix.
You may, however, have been taught an alternative method for calculating the inverse of a matrix. This method has four steps:
- Find the determinants of smaller blocks of the matrix to find the "matrix of minors".
- Multiply some of the entries by -1 to get the "matrix of cofactors".
- Transpose the matrix.
- Divide by the determinant of the matrix you started with.
An example
As an example, we will find the inverse of the following matrix.
The result of the four steps above is the calculation
Calculating the determinants gives
which simplifies to
How many operations
This method can be used to find the inverse of a matrix of any size. Using this method on an matrix will require:
- Finding the determinant of
different matrices. - Multiplying
of these matrices by -1. - Calculating the determinant of a
matrix. - Dividing
numbers by this determinant.
If is the number of operations needed to find the determinant of an matrix, the total number of operations for this method is
How many operations to find a determinant
If you work through the usual method of calculating the determinant by calculating determinants of smaller blocks the combining them, you
can work out that the number of operations needed to calculate a determinant in this way is . For large values of , this is significantly larger than any power of .
There are other methods of calculating determinants: the fastest of these
is . For large , this is significantly smaller than .
How many operations
Even if the quick method for calculating determinants is used, the number of operations required to invert a matrix will be of the order of
In fact, this method could only be faster than Gaussian elimination if you discovered a method of finding a determinant faster than . This seems highly unlikely
to be possible, as an matrix has entries and we should expect to operate on each of these at least once.
So, for large matrices, Gaussian elimination looks like it will always be faster, so you can safely forget this four-step method.
Previous post in series
This is the third post in a series of posts about matrix methods.
(Click on one of these icons to react to this blog post)
You might also enjoy...
Comments
Comments in green were written by me. Comments in blue were not written by me.
Add a Comment
2020-01-24
This is the second post in a series of posts about matrix methods.
We want to solve , where is a (known) matrix, is a (known) vector, and is an unknown vector.
This matrix system can be thought of as a way of representing simultaneous equations. For example, the following matrix problem and system of simultaneous equations are equivalent.
The simultaneous equations here would usually be solved by adding or subtracting the equations together. In this example, subtracting the first equation from the second gives .
From there, it is not hard to find that .
One approach to solving is to find the inverse matrix , and use . In this post, we use Gaussian elimination—a method
that closely resembles the simultaneous equation method—to find .
Gaussian elimination
As an example, we will use Gaussian elimination to find the inverse of the matrix
First, write the matrix with an identity matrix next to it.
Our aim is then to use row operations to change the matrix on the left of the vertical line into the identity matrix, as
the matrix on the right will then be the inverse. We are allowed to use two row operations: we can multiply a row by a scalar; or we can add a multiple of a row to another row.
These operations closely resemble the steps used to solve simultaneous equations.
We will get the matrix to the left of the vertical line to be the identity in a systematic manner: our first aim is to get the first column to read 1, 0, 0.
We already have the 1; to get the 0s, add 2 times the first row to both the second and third rows.
Our next aim is to get the second column to read 0, 1, 0. To get the 1, we multiply the second row by -1.
To get the 0s, we add 2 times the second row to both the first and third rows.
Our final aim is to get the third column to read 0, 0, 1. To get the 1, we multiply the third row by -½.
To get the 0s, we add 8 and 6 times the third row to the first and second rows (respectively).
We have the identity on the left of the vertical bar, so we can conclude that
How many operations
This method can be used on matrices of any size. We can imagine doing this with an matrix and look at how many operations
the method will require, as this will give us an idea of how long this method would take for very large matrices.
Here, we count each use of , , and as a (floating point) operation (often called a flop).
Let's think about what needs to be done to get the th column of the matrix equal to 0, ..., 0, 1, 0, ..., 0.
First, we need to divide everything in the th row by the value in the th row and th column. The first entries in the column will already be 0s though, so there is no need to divide
these. This leaves entries that need to be divided, so this step takes , or operations.
Next, for each other row (let's call this the th row), we add or subtract a multiple of the th row from the th row. (Again the first entries can be ignored as they are 0.)
Multiplying the th row takes operations, then adding/subtracting takes another operations.
This needs to be done for rows, so takes a total of operations.
After these two steps, we have finished with the th column, in a total of operations.
We have to do this for each from 1 to , so the total number of operations to complete Gaussian elimination is
This simplifies to
or
The highest power of is , so we say that this algorithm is an order algorithm, often written .
We focus on the highest power of as if is very large, will be by far the largest number in the expression, so gives us an idea of how fast/slow this algorithm will be for large
matrices.
Previous post in series
This is the second post in a series of posts about matrix methods.
Next post in series
(Click on one of these icons to react to this blog post)
You might also enjoy...
Comments
Comments in green were written by me. Comments in blue were not written by me.
Add a Comment
2020-01-23
This is the first post in a series of posts about matrix methods.
When you first learn about matrices, you learn that in order to multiply two matrices, you use this strange-looking method involving the rows of the left matrix and the columns of this right.
It doesn't immediately seem clear why this should be the way to multiply matrices. In this blog post, we look at why this is the definition of matrix multiplication.
Simultaneous equations
Matrices can be thought of as representing a system of simultaneous equations. For example, solving the matrix problem
is equivalent to solving the following simultaneous equations.
Two matrices
Now, let and be two 3×3 matrices, let by a vector with three elements, and let .
We consider the equation
In order to understand what this equation means, we let and think about solving the two simuntaneous matrix equations,
We can write the entries of , , , and as
We can then write out the simultaneous equations that and represent:
Substituting the equations on the right into those on the left gives:
Gathering the terms containing , and leads to:
We can write this as a matrix:
This equation is equivalent to , so the matrix above is equal to . But this matrix is what you get if follow the
row-and-column matrix multiplication method, and so we can see why this definition makes sense.
This is the first post in a series of posts about matrix methods.
Next post in series
(Click on one of these icons to react to this blog post)
You might also enjoy...
Comments
Comments in green were written by me. Comments in blue were not written by me.
Add a Comment