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,
1.44, than the flimsy
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 and .
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
2 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 with 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 associate several important values, such as their 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
xₙ 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
Bare diagonal matrices, then
A + Band
A * Bare also diagonal.
Diagonal matrices are transpose-invariant. This means that if
Ais a diagonal matrix, then it's transposition is the same object:
Aᵀ = A.
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
Aabove with the
xᵢ'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 whatis all about.
Eigenvalues and eigenvectors
Suppose that we have a square matrix
A of size
n × n. If there exists some number
λ and a non-zero vector
v of length
n for which
A * v = λ · v,
then we call
λ an eigenvalue of
v 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).
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
A * v - λ · v = 0
and write it using the identity matrix,
I (the diagonal matrix with
1-s on the diagonal), then we'll get an equivalent matrix equation
(A - λ·I) * v = 0.
Here we have a multiplication of a matrix
A - λ·I by a non-zero vector (a one-column matrix) that should give
0, or rather the zero matrix. In order for this to be true, we need to have
det(A - λ·I) = 0,
Since we know the entries of
A, this equality gives us an equation with
λ as an unknown variable called the characteristic polynomial of
A. Its degree is equal to the size of the array, i.e., it's a quadratic equation for 2×2 matrices and a cubic equation for 3×3 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 2×2 and 3×3 matrices, respectively. Such things don't always have a real solution (e.g., no real number satisfies the equation
x² + 1 = 0). 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
x² + 2x + 1 = 0is satisfied only for
x = -1because
x² + 2x + 1 = (x + 1)². This small
2in the exponent is called the multiplicity of
x = -1. 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
3) with complex numbers can have three solutions of multiplicity
1, one solution of multiplicity
2, and one solution of multiplicity
1, 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
1's in the diagonal) has only one eigenvalue,
λ = 1, and it corresponds to as many (linearly independent) eigenvectors as the size of the matrix (which is equal to the multiplicity of
λ = 1).
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
2has 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,
A, of size
n × n, and you know that it's a diagonalizable matrix. We've seen in the section 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
A is given by
A = S * D * S⁻¹,
Dis diagonal; and
Sis our little helper (on the right, we have the inverse of
D may seem like no easy task. In fact, as mentioned in , once we have the eigenvalues and eigenvectors of
A, 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
n × nand calculate the determinant,
det(A - λ·I), i.e., the determinant of
λ's subtracted from the diagonal entries.
Find the solutions of
det(A - λ·I) = 0and figure out their multiplicities. If the sum of the multiplicities is not equal to
Ais not a diagonalizable matrix. Otherwise, proceed.
The solutions of
det(A - λ·I) = 0are the eigenvalues of
A. Take each eigenvalue
λseparately and write the matrix
A - λ·I.
To find the eigenvectors, define a vector
v = (x₁, x₂,..., xₙ)of length
nand solve the matrix equation
(A - λ·I) * v = 0. (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
(A - λ·I) * v = 0. Each of them is given by substituting in the solution
1for one of the parameters, and
0for all the other ones.
If an eigenvalue has fewer eigenvectors than its multiplicity, then
Ais not a diagonalizable matrix.
In the end, if
A is diagonalizable, we should obtain eigenvalues
λₙ (some may be repeated according to their multiplicities) and eigenvectors
A = S * D * S⁻¹
S is the matrix whose first column contains the entries of
v₁, the second has entries of
v₂, 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 3×3 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 4×4.
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 3×3 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
a₃, so we look back at our array and input
a₁ = 1,
a₂ = 0, and
a₃ = 0.
Similarly, the other two rows give
b₁ = 2,
b₂ = 1,
b₃ = -1,
c₁ = 0,
c₂ = -1,
c₃ = 1.
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
D in the decomposition
A = S * D * S⁻¹.
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
A. We obtain it by calculating the determinant,
det(A - λ·I), which in our case is
= (1 - λ)³ + 0 + 0 - (1 - λ)·(-1)·(-1) =
= (1 - λ)³ - (1 - λ) =
= (1 - λ)·[(1 - λ)² - 1] =
= (1 - λ)·(1 - 2λ + λ² - 1) =
= (1 - λ)·(λ² - 2λ) =
= λ·(1 - λ)·(λ - 2).
That went quite well! Even though we have a polynomial of degree
3, we managed to describe it in a nice multiplicative form. The advantage here is that the cubic equation
λ·(1 - λ)·(λ - 2) = 0
is satisfied if and only if one of the factors is zero, i.e., if
λ = 0,
1 - λ = 0, or
λ - 2 = 0. This translates to
λ = 0,
λ = 1, or
λ = 2, and these are exactly the eigenvalues of
Now we need to find the eigenvectors. For that, let's take a vector
v = (x, y, z) and describe the matrix equation
(A - λ·I) * v = 0 as a system of equations for each eigenvalue
λ = 0 we have
|A - λ·I||=||A||=||
(A - λ·I) * v = 0 into the following three (coordinate) equations:
1·x + 0·y + 0·z = 0
2·x + 1·y + (-1)·z = 0
0·x + (-1)·y + 1·z = 0,
x = 0
2x + y - z = 0
-y + z = 0.
The solutions to that system are of the form
x = 0,
y = t,
z = t where
t is an arbitrary number. Taking
t = 1 we get the first eigenvector:
v = (0, 1, 1).
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
λ₁ = 0,
λ₂ = 1,
λ₃ = 2 and their eigenvectors
v₁ = (0, 1, 1),
v₂ = (0.5, 0, 1),
v₃ = (0, -1, 1), we use the first to form the diagonal matrix:
and the second to create the
S = [v₁, v₂, v₃] =
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
A = S * D * S⁻¹, so by the rules of matrix multiplication and matrix inverse, we have
A²⁰ = (S * D * S⁻¹)²⁰ = S * D²⁰ * S⁻¹.
Now we use some properties of a diagonal matrix and observe that
So now we just need to figure out what
2²⁰ is and multiply it from one side by
S 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.