Diagonalize Matrix Calculator
Welcome to the diagonalize matrix calculator, where we'll take you on a mathematical journey to the land of matrix diagonalization. We'll go through the topic of how to diagonalize a matrix using its eigenvalues and eigenvectors together. This process is extremely useful in advanced array calculations since it's so much easier to deal with a diagonal matrix rather than a full one.
But is it a simple algorithm? Is every array a diagonalizable matrix? Sit back, grab your morning/afternoon coffee, and let's find out, shall we?
What is a matrix?
Do you remember the good old days of primary school mathematics? You counted how many oranges Mr. Smith had if he bought eight and ate two, and they told you that these were called integer numbers, and math seemed simple enough.
Then Mr. Smith opened up a little shop and sold his own fruit – $1.20 per pound for apples and $0.90 per pound for bananas, including taxes.They told you that these new values were called rational numbers, and you spent a few months getting the hang of them, multiplying and adding them together. Still, it wasn't too bad.
But they had to go further, didn't they? As long as geometry consisted of shapes such as squares or rectangles, the calculations were pretty simple and straightforward. But once they introduced triangles, especially right triangles, and the Pythagorean theorem, some weird values appeared, which were called roots, and, apparently, they can't be described in the form of a good old fraction. And don't even get us started on the that spoiled all the circle calculations.
All these numbers were called real numbers because they appear naturally in the real world. Well, fair enough, but it's so much easier to look at an approximation of the cubic root of three, , than the flimsy sign.
And you know what? The big-headed mathematicians didn't stop there and decided that it's quite a shame that -1
doesn't have a square root, so why not imagine that it does and call it i
. Funnily enough, they actually named it the imaginary number and called this whole new extension complex numbers. But, to give credit where credit is due, complex numbers are extremely useful in all kinds of sciences, including physics and statistics.
So, now that we have all these fancy numbers, what good can we do with them? That's right – take a boatload of them, write them in a table, and treat them as one thing.
A matrix is an array of elements (usually numbers) that has a set number of rows and columns. An example of a matrix would be:
Moreover, we say that a matrix has cells, or boxes, into which we write the elements of our array. For example, matrix A
above has the value in the cell that is in the second row and the second column. The starting point here are 1-cell matrices, which are, for all intents and purposes, the same thing as real numbers.
As you can see, matrices came to be when a scientist decided that he needs to write a few numbers concisely and operate with the whole lot as a single object. As such, they naturally appear when dealing with:
- Systems of equations, especially when calculating Cramer's rule and the (reduced) row echelon form;
- Vectors and vector spaces;
- 3-dimensional geometry (e.g., the dot product and the cross product);
- Linear transformations (translation and rotation); and
- Graph theory and discrete mathematics.
We can look at matrices as an extension of the numbers as we know them (real or complex). As such, it would make sense to define some basic operations on them, like, for example, addition and subtraction. And indeed, it can be easily done, but these new objects have a much more complex structure, and, to each array, we can find several important values. For example we can calculate the matrix's rank.
However, we've gathered here today to look at something quite different: matrix diagonalization. We will need some tricks to define it, but how about we start with what exactly this diagonal matrix is and why they're easier to deal with.
Diagonal matrix: definition and properties
We call a square array of numbers a diagonal matrix if it is of the form:
where , , ..., are some numbers. In other words, a diagonal matrix is an array whose non-zero entries only appear on the main diagonal.
Now let's list a few useful properties of diagonal matrices to convince you that they are fairly easy objects.
-
The sum and product of diagonal matrices is again a diagonal matrix. In other words, if and are diagonal matrices, then , , are also diagonal. What's the last symbol? The Hadamard product: learn how to calculate it with our Hadamard product calculator!
-
Diagonal matrices are transpose-invariant. This means that if is a diagonal matrix, then the calculated transposed matrix is the same object: .
-
The k-th power of a diagonal matrix is a diagonal matrix with the same entries individually raised to the k-th power. This one might be easier to understand symbolically. Recall the array above with the 's on the diagonal. Then:
Hopefully, you can see some advantages in learning how to diagonalize a matrix. Especially the third property above shows that if we need to take the matrix to some high power, then matrix diagonalization would make the task quite a lot easier. And why spend ages doing gruesome calculations if a simple trick can make the task so much simpler?
We now need to define eigenvalues and eigenvectors, which are the most important tools when studying matrix diagonalization, and that's exactly what the next section is all about.
Eigenvalues and eigenvectors
🙋 Checkpoint! If you need to refresh your knowledge about eigenvectors and eigenvalues, visit our eigenvalue and eigenvector calculator!
Suppose that we have a square matrix of size . If there exists some number and a non-zero vector of length for which:
then we call an eigenvalue of and its corresponding eigenvector.
The above is a formal definition, so let's now try to translate it into everyday language. You know, the kind of language that you use to talk about eigenvalues and eigenvectors on a daily basis.
Suppose that you have a square matrix that has some ugly entries and is generally difficult to look at. But maybe its beauty is on the inside? Perhaps we can use some not-so-terrible smaller objects to describe it throughly?
Eigenvalues and eigenvectors are exactly that. Once we know them, we know the initial matrix quite well and are able to simplify any further calculations (as an example, recall taking a power of a matrix described in the section above).
So, how do we get these eigen-thingies? Well, let's take a second look at the equation that describes them above. If we move the right side to the left:
and write it using the identity matrix, (the diagonal matrix with -s on the diagonal), then we'll get an equivalent matrix equation:
Here we calculated the multiplication of a matrix by a non-zero vector (a one-column matrix) that should give , or rather the zero matrix. In order for this to be true, we need to have:
Where denotes the determinant of a matrix (it's also denoted — not to be confused with the absolute value of a number).
Since we know the entries of , this equality gives us an equation with as an unknown variable called the characteristic polynomial of . Its degree is equal to the size of the array, i.e., it's a quadratic equation for matrices and a cubic equation for matrices.
As the last thing in this section, let's point out a few important things concerning eigenvalues and eigenvectors.
-
Eigenvalues don't always exist. As we've mentioned above, we have quadratic and cubic equations for and matrices, respectively. Such things don't always have a real solution (e.g., no real number satisfies the equation ). However, if we instead consider the complex numbers, then every equation will have at least one solution.
-
Eigenvalues have multiplicities. It can happen that, say, a quadratic equation has only one solution. For example, the equation is satisfied only for because . This small in the exponent is called the multiplicity of . What is more, in the field of complex numbers, the sum of multiplicities of an equation's solutions is always equal to the degree of the polynomial. For instance, a cubic equation (an equation of degree ) with complex numbers can have three solutions of multiplicity , one solution of multiplicity , and one solution of multiplicity , or one solution of multiplicity .
-
A matrix with too few eigenvalues (counted with multiplicities) is not a diagonalizable matrix. As points 1. and 2. suggest, this can only happen if we don't consider complex numbers. In particular, a matrix with no real eigenvalues is not a diagonalizable matrix (in the field of real numbers).
-
One eigenvalue can have multiple eigenvectors. For example, the identity matrix (the diagonal matrix with 's in the diagonal) has only one eigenvalue, , and it corresponds to as many (linearly independent) eigenvectors as the size of the matrix (which is equal to the multiplicity of ).
-
A matrix with too few eigenvectors is not a diagonalizable matrix. One example of when that happens is point 3. above. But there's more! As opposed to eigenvalues, a matrix's eigenvectors don't have multiplicities. It may, however, happen that, say, an eigenvalue of multiplicity has only one eigenvector, even if we take complex numbers. Such matrices are called non-diagonalizable. They are rather rare, but be sure to keep an eye out for them!
Phew, that was quite a lot of theory, wouldn't you say? We keep defining some things, their properties, and a minute after minute passes without a clear set of instructions on what we're here for: how to diagonalize a matrix. It's high time we move to that, isn't it?
How to diagonalize a matrix?
Say that you're given a square array, , of size , and you know that it's a diagonalizable matrix. We've seen in the section Diagonal matrix: definition and properties what a diagonal matrix is, so, at first glance, it may seem a bit too much like magic to transform one thing into the other. Well, we might need some help with that.
The matrix diagonalization of is given by:
where:
- is diagonal; and
- is our little helper (on the right, we have the inverse of , ).
Finding and may seem like no easy task. In fact, as mentioned in the above section, once we have the eigenvalues and eigenvectors of , we have everything.
Below we list the main points of the procedure whenever you want to find matrix diagonalization. We should warn you, however, that, in full generality, some of them are no walk in the park and can take some time to finish. Oh, how lucky we are that the diagonalize matrix calculator exists!
-
Take your square matrix of size and calculate the determinant, , i.e., the determinant of with 's subtracted from the diagonal entries.
-
Find the solutions of and figure out their multiplicities. If the sum of the multiplicities is not equal to , then is not a diagonalizable matrix. Otherwise, proceed.
-
The solutions of are the eigenvalues of . Take each eigenvalue separately and write the matrix .
-
To find the eigenvectors, define a vector of length and solve the matrix equation . (It will have infinitely many solutions that depend on finitely many parameters.)
-
There are as many eigenvectors corresponding to as there are parameters in the solution of . Each of them is given by substituting in the solution for one of the parameters and for all the other ones.
-
If an eigenvalue has fewer eigenvectors than its multiplicity, then is not a diagonalizable matrix.
In the end, if is diagonalizable, we should obtain eigenvalues , , ..., (some may be repeated according to their multiplicities) and eigenvectors , , ..., . Then:
With:
And is the matrix whose first column contains the entries of , the second has entries of , and so on.
Phew, that was a lot of symbols, fancy scientific language, and generally a lot to get our heads around. But if you've made it this far, you deserve a cold one and a nice numerical example to see the diagonalize matrix calculator in practice.
Let's not waste another second and get to it!
Example: using the diagonalize matrix calculator
It's the last algebra class of the year. All the students already feel the laziness creeping in, and even the teacher seems like she's about to doze off. Unfortunately, she still has enough energy to give the class one last test, but tells you that whoever finishes it can leave and celebrate the beginning of summer.
With a little smirk on her face, the teacher writes on the blackboard a matrix and tells you to find its 20th power. You hear a quiet murmur go up all around you and think about how long it will take to make so many matrix multiplications. Well, let's at least appreciate that it's not of size .
You suddenly remember the trick with matrix diagonalization that should help speed up the calculations. Excited in spite of yourself, you grab a piece of paper and begin your last exercise of the year.
The matrix is:
Let's first see how easy it is to find the answer with our diagonalize matrix calculator.
We have a matrix, so the first thing we need to do is tell the calculator that by choosing the correct option under "Matrix size". This will show us a symbolic example of such a matrix that tells us what notation we use for its entries. For example, the first row has elements , , and , so we look back at our array and input
, , and .
Similarly, the other two rows give
, , ,
, , .
Once we write the last value, the diagonalize matrix calculator will spit out all the information we need: the eigenvalues, the eigenvectors, and the matrices and in the decomposition .
Now let's see how we can arrive at this answer ourselves. We begin by finding the matrix's eigenvalues. To do that, we first find the characteristic polynomial of . We obtain it by calculating the determinant, , which in our case is:
That went quite well! Even though we have a polynomial of degree , we managed to describe it in a nice multiplicative form. The advantage here is that the cubic equation:
Is satisfied if and only if one of the factors is zero*, i.e., if , , or . This translates to , , or , and these are exactly the eigenvalues of .
Now we need to find the eigenvectors. For that, let's take a vector and describe the matrix equation as a system of equations for each eigenvalue .
For we have:
Which translates into the following three (coordinate) equations:
Which is:
The solutions to that system are of the form , , where is an arbitrary number. Taking we get the first eigenvector: .
If we repeat this reasoning for the other two eigenvalues, we'll obtain eigenvectors (0.5, 0, 1)
and (0, -1, 1)
for λ = 1
and λ = 2
, respectively.
Now that we have the eigenvalues , , and their eigenvectors , , , we use the first to form the diagonal matrix:
And the second to create the S
matrix:
Note how the matrices differ slightly from what the diagonalize matrix calculator gives. The difference is only a matter of reordering the eigenvalues (and hence also the eigenvectors). Both answers are equally correct.
These matrices satisfy , so by the rules of matrix multiplication and matrix inverse, we have:
Now we use some properties of a diagonal matrix and observe that:
So now we just need to figure out what is and multiply it from one side by and from the other side by .
Hmm, why don't we again turn to Omni Calculator with that? They're sure to have some tools that can help us. And once that is done, we're off to the beach so that we can get that dream tan. Oh, did we forget about getting that beach body again? No matter; next year will be the year.
A | = |
|