Visual Tools
Calculators
Tables
Mathematical Keyboard
Converters
Other Tools


Matrix Diagonalization


Find the eigenvectors, assemble P and D, invert P, and use A = P D P⁻¹ to compute a power of A.

Preset?A square matrix is diagonalizable when it has n linearly independent eigenvectors. Put them as the columns of P and the matching eigenvalues down the diagonal of D; then A P = P D, so A = P D P⁻¹. In the eigenvector basis A is just a scaling, and A^k = P D^k P⁻¹ costs only powering the diagonal. A matrix fails to diagonalize when a repeated eigenvalue has too few eigenvectors (defective) or when the eigenvalues are complex.
Size and power
A2× 2Ak, k =3
Entries of A
A2×2
4
1
2
3
Step 1 / 9

Step explanations

1Diagonalize a 2×2 matrix
The goal is A = P D P⁻¹ with D diagonal: the columns of P are eigenvectors of A and the diagonal of D holds their eigenvalues, in the same order. It works exactly when A has 2 independent eigenvectors. Plan: find the eigenvalues, find an eigenvector for each, assemble P and D, invert P, check the product — then use the factorization to compute A3 the easy way.
Eigenvectors into P, eigenvalues into D, and A becomes a scaling in disguise. Learn more about the eigenvector matrix · what it is








Key Terms

Diagonalization — writing A=PDP1A = PDP^{-1} with DD diagonal.

PP — the matrix whose columns are nn independent eigenvectors of AA; invertible because they are independent.

DD — the diagonal matrix of eigenvalues, in the same order as the columns of PP.

Diagonalizable — a matrix that has nn independent eigenvectors; equivalently, one whose geometric multiplicities all equal the algebraic ones.

Defective — a matrix with too few eigenvectors; it has no diagonal form, only a Jordan form.

Similar matricesAA and P1APP^{-1}AP; they share eigenvalues, trace and determinant. Diagonalization is similarity to a diagonal matrix.

Eigenvector basis — the columns of PP; in this basis the map is a pure scaling.

Spectral decomposition — the symmetric case A=QDQTA = QDQ^T, where QQ is orthogonal, so the inverse is the transpose.

Power formulaAk=PDkP1A^k = PD^kP^{-1}, with DkD^k obtained by powering the diagonal entries.

Getting Started with the Visualizer

Choose a matrix and a power, then watch it factor into PDP1PDP^{-1}.

• Use the Preset pills for eight matrices: a classic 2×22 \times 2, a symmetric one, a Markov chain, the Fibonacci matrix, a 3×33 \times 3 with distinct eigenvalues, a repeated eigenvalue that still diagonalizes, a defective matrix, and a rotation
• Use the Size stepper for 2×22 \times 2 or 3×33 \times 3, and the k stepper to choose which power AkA^k the last scene computes
• Edit any entry directly, or press Shuffle for a random matrix with small integer eigenvalues
• Hover the ? icon for a reminder of what diagonalization is and when it works
• Press play or step manually; the step log on the right keeps every stage

The eigenvalues and eigenvectors are reported, not derived, since the eigenvalue visualizer shows that derivation. This tool picks up where it stops: assembling PP and DD, inverting PP, checking the product, and using the factorization for a power. Defective and complex cases stop early with an explanation.

The Scenes in Order

The visualizer follows the textbook procedure exactly.

Eigenvalues — the characteristic polynomial and its roots, with the trace as a check
Eigenvectors — one per free column of AλIA - \lambda I for each eigenvalue, shown as columns above their eigenvalues; if there are fewer than nn, the run stops with a defective verdict
AssemblePP from the eigenvectors, DD from the eigenvalues, in matching order
InvertP1P^{-1} by row reducing [PI][P \mid I], with the determinant of PP noted
FactorA=PDP1A = P \cdot D \cdot P^{-1} multiplied out and compared with AA
VerifyP1AP=DP^{-1} A P = D, the same identity from the other side
PowerAk=PDkP1A^k = P D^k P^{-1} for the chosen kk, with DkD^k obtained by powering the diagonal
Done — the factorization with a note on symmetry and on how AkA^k behaves as kk grows

Complex eigenvalues stop the run after the first scene, since no real PP exists.

The Eigenvector Matrix

The first thing the tool checks is whether there are enough eigenvectors. The frozen picture below shows the default preset's eigenvalues 55 and 22 with their eigenvectors (1,1)(1, 1) and (1,2)(1, -2) as columns, each above its eigenvalue.

Two eigenvectors for a 2×22 \times 2 matrix, independent since they are not parallel: AA is diagonalizable.
A2×24123λ for each column52eigenvectors2×2111−2
Eigenvectors, frozen

The default preset: eigenvalues 5 and 2, eigenvectors (1, 1) and (1, −2) as the columns on the right, each above its eigenvalue. Two independent eigenvectors for a 2×2 matrix - diagonalizable.

Independence is automatic when the eigenvalues are distinct, and that is the common case. The count only becomes a question for repeated eigenvalues, where it is decided by how many free columns AλIA - \lambda I has: as many as the multiplicity means a full set, fewer means defective.

The order of the columns is a free choice. The tool sorts eigenvalues in decreasing order, so the dominant one comes first, but any order works as long as DD follows it.

Assembling P and D

The frozen picture below shows PP and DD for the default preset side by side: the eigenvectors as columns, the eigenvalues down the diagonal in the same order, zeros elsewhere.

Together they encode the equation AP=PDAP = PD, which is nothing more than the two eigenvector equations written as one matrix identity.
P2×2111−2D2×25002
P and D, frozen

P with the eigenvectors as columns, D with the eigenvalues down the diagonal in the same order. Together they say A P = P D, one eigenvector equation per column.

Reading AP=PDAP = PD column by column is the whole proof. The jj-th column of APAP is AvjA\mathbf{v}_j, and the jj-th column of PDPD is λjvj\lambda_j\mathbf{v}_j, since multiplying on the right by a diagonal matrix scales columns. The two agree exactly because each vj\mathbf{v}_j is an eigenvector.

DD is where all the information about the transformation sits. PP is just a change of coordinates; the same AA with differently scaled eigenvectors has a different PP but the same DD.

Inverting P

To move from AP=PDAP = PD to A=PDP1A = PDP^{-1} requires P1P^{-1}, which exists because the columns of PP are independent. The frozen picture below shows the default preset's PP and its inverse, with thirds in every entry because detP=3\det P = -3.

The tool row reduces [PI][P \mid I]; for a 2×22 \times 2 the formula does the same in one line.
P2×2111−2P⁻¹2×22/31/31/3−1/3
P⁻¹, frozen

det P = −3, so the inverse has thirds everywhere: P⁻¹ = [2/3, 1/3; 1/3, −1/3]. Found by row reducing [P | I], or by the 2×2 formula.

The fractions are typical, not a sign of trouble. PP is chosen with integer columns for readability, so P1P^{-1} carries detP\det P in its denominators, and the products PDP1PDP^{-1} clear them again.

For a symmetric matrix the inverse is free: with the eigenvectors normalized to unit length, PP is orthogonal and P1=PTP^{-1} = P^T. The symmetric preset demonstrates this, and it is the reason the spectral decomposition is written QDQTQDQ^T rather than QDQ1QDQ^{-1}.

The Factorization

With all three pieces in hand, A=PDP1A = PDP^{-1}. The frozen picture below shows the default preset's factorization in full, AA on the left and the three factors on the right.

The caption multiplies them out and recovers AA exactly, which is the check that the eigenvectors and the inverse are right.
A2×24123=P2×2111−2·D2×25002·P⁻¹2×22/31/31/3−1/3
A = P D P⁻¹, frozen

The full factorization. Multiplying the three factors on the right reproduces A exactly, which checks both the eigenvectors and the inverse.

The factorization is best read right to left as three moves applied to a vector. P1xP^{-1}\mathbf{x} gives the coordinates of x\mathbf{x} in the eigenvector basis; DD multiplies each coordinate by its eigenvalue; PP turns the result back into standard coordinates. Nothing else happens. That is what it means for AA to be a scaling in disguise.

The tool also checks the identity from the other side, P1AP=DP^{-1}AP = D: conjugating AA by PP leaves a diagonal matrix, and every off-diagonal zero in that product is a confirmation that the corresponding column of PP is a genuine eigenvector.

Powers Through the Diagonal

The reason to diagonalize is what it does to powers. The frozen picture below shows the default preset's A3=PD3P1A^3 = PD^3P^{-1}: D3D^3 is just 125125 and 88 on the diagonal, and two multiplications produce A3A^3.

Change the kk stepper to see any other power; the eigenvalues make the growth rate visible before the product is even computed.
2×286397847=P2×2111−2·2×2125008·P⁻¹2×22/31/31/3−1/3
A³ = P D³ P⁻¹, frozen

D³ is just 125 and 8 on the diagonal. Two multiplications give A³ = [86, 39; 78, 47], the same as A·A·A - and its trace 133 = 125 + 8.

The algebra is one line: Ak=(PDP1)(PDP1)(PDP1)A^k = (PDP^{-1})(PDP^{-1})\cdots(PDP^{-1}), and every interior P1PP^{-1}P cancels, leaving PDkP1PD^kP^{-1}. Powering a diagonal matrix is powering its entries, so the cost is constant in kk, while direct multiplication costs k1k - 1 products.

More important than the saving is what the formula says. The entries of AkA^k are combinations of λik\lambda_i^k, so the largest λi|\lambda_i| takes over as kk grows: AkA^k grows along its eigenvector when that modulus exceeds 11, settles when it equals 11, and vanishes when it is below 11. The same formula with kk replaced by a function gives eAe^{A}, A\sqrt{A} and every other function of a matrix.

A Markov Chain Settling Down

The Markov preset has eigenvalues 11 and 0.40.4. The frozen picture below shows its eighth power: 0.480.4^8 is nearly zero, so D8D^8 has essentially one non-zero entry and A8A^8 is nearly the steady-state matrix, with both columns close to (5/6,1/6)(5/6, 1/6).

Raise the kk stepper in the tool to watch the convergence.
A⁸2×20.8330.8330.1670.167=P2×2511−1·D⁸2×21000.001·P⁻¹2×21/61/61/6−5/6
Markov chain, eighth power, frozen

Eigenvalues 1 and 0.4; 0.4⁸ ≈ 0.00066, so D⁸ is nearly diag(1, 0) and A⁸ is nearly the steady-state matrix with both columns close to (5/6, 1/6).

This is the general picture for stochastic matrices. The eigenvalue 11 always exists, its eigenvector is the stationary distribution, and every other eigenvalue has modulus at most 11. As kk grows the powers λik\lambda_i^k of the others die out and AkA^k converges to a rank-one matrix whose columns are the steady state. The second-largest modulus, here 0.40.4, is the convergence rate.

The Fibonacci preset shows the opposite behaviour. Its dominant eigenvalue is φ1.618\varphi \approx 1.618, so the entries of AkA^k, which are Fibonacci numbers, grow like φk\varphi^k; the diagonalization written out is Binet's formula.

When It Fails

The defective preset is the shear (1101)\begin{pmatrix} 1 & 1 \\ 0 & 1 \end{pmatrix}. Its only eigenvalue is 11, twice, but AIA - I has a single free column and a single eigenvector, (1,0)(1, 0). The frozen picture below shows the run stopping there.

One eigenvector cannot fill a 2×22 \times 2 matrix PP, so there is no diagonal form.
A2×21101λ for each column1eigenvectors2×110
Defective, frozen

The shear: λ = 1 twice but only the single eigenvector (1, 0). One column cannot fill P, so the run stops - no diagonal form exists.

Geometrically the shear moves every vector off the xx-axis sideways, so no second direction is preserved. No change of basis can turn that into a scaling. The nearest replacement is the Jordan form, (1101)\begin{pmatrix} 1 & 1 \\ 0 & 1 \end{pmatrix} itself, a diagonal of eigenvalues with a 11 above it recording the missing eigenvector.

The other way to fail is complex eigenvalues, shown by the rotation preset. There the eigenvectors exist but are complex, so A=PDP1A = PDP^{-1} holds over C\mathbb{C} and not over R\mathbb{R}; in the real plane the matrix is a rotation-scaling and stays that way.

Reading the Scene Player

Each scene shows the matrices for one step with the arithmetic in the caption.

• The columns of PP are colour-coded, one colour per eigenvector, and the eigenvalue row above them uses the same order
• The diagonal of DD is blue and its zeros are grey, to stress that only the diagonal carries information
P1P^{-1} is secondary throughout; it usually carries fractions with detP\det P in the denominator
• In the factor and power scenes the left-hand matrix, AA or AkA^k, is the target being reproduced
• In the verify scene the diagonal of the product is the target: the off-diagonal zeros are the check
• Eigenvectors are scaled to small integers whenever possible; the Fibonacci preset shows decimals because its eigenvalues are irrational

Choosing a Matrix

The eight presets each make a different point.

2×22 \times 2 classic — eigenvalues 55 and 22 with eigenvectors (1,1)(1, 1) and (1,2)(1, -2); detP=3\det P = -3, so P1P^{-1} has thirds
Symmetric — eigenvalues 33 and 11 with perpendicular eigenvectors; normalizing the columns of PP gives an orthogonal QQ and A=QDQTA = QDQ^T
Markov chain — eigenvalues 11 and 0.40.4; raise kk and watch AkA^k settle toward the steady state, whose columns are multiples of the eigenvector for 11
Fibonacci(1110)\begin{pmatrix} 1 & 1 \\ 1 & 0 \end{pmatrix} with eigenvalues φ\varphi and 1/φ-1/\varphi; AkA^k contains Fibonacci numbers, and the diagonalization is Binet's formula
3×33 \times 3 distinct — eigenvalues 1111, 22, 11; the same matrix as the eigenvalue tool's default
Repeated but fineλ=1\lambda = 1 twice with a plane of eigenvectors; repeated eigenvalues do not by themselves prevent diagonalization
Defective — the shear, with λ=1\lambda = 1 twice but a single eigenvector; the run stops
Rotation — complex eigenvalues ±i\pm i; no real diagonalization

Shuffle builds AA as PDP1PDP^{-1} with an integer unimodular PP, so the eigenvalues are small integers and the run always completes.

What Diagonalization Is

Suppose AA has nn linearly independent eigenvectors v1,,vn\mathbf{v}_1, \ldots, \mathbf{v}_n with eigenvalues λ1,,λn\lambda_1, \ldots, \lambda_n. Put the eigenvectors as the columns of PP and the eigenvalues down the diagonal of DD. Then

AP=A(v1vn)=(λ1v1λnvn)=PDAP = A\begin{pmatrix} \mathbf{v}_1 & \cdots & \mathbf{v}_n \end{pmatrix} = \begin{pmatrix} \lambda_1\mathbf{v}_1 & \cdots & \lambda_n\mathbf{v}_n \end{pmatrix} = PD


column by column, because each column of APAP is Avj=λjvjA\mathbf{v}_j = \lambda_j\mathbf{v}_j. Since the columns of PP are independent, PP is invertible, and

A=PDP1,D=P1APA = PDP^{-1}, \qquad D = P^{-1}AP


Read right to left, AA becomes three simple moves: P1P^{-1} expresses a vector in eigenvector coordinates, DD scales each coordinate by its eigenvalue, and PP converts back. In the eigenvector basis the transformation is a pure scaling; that is what "diagonal" means geometrically.

The condition is exactly nn independent eigenvectors. Distinct eigenvalues guarantee it. A repeated eigenvalue is fine as long as its eigenspace is as large as its multiplicity; when it is smaller the matrix is defective and no PP exists. Complex eigenvalues of a real matrix give a complex PP and DD, which is a diagonalization over C\mathbb{C} but not over R\mathbb{R}.

The payoff is functions of AA. Because Ak=PDkP1A^k = PD^kP^{-1} and DkD^k is just the diagonal entries raised to kk, every power costs two multiplications, and the same trick defines eAe^{A}, A\sqrt{A}, and any polynomial in AA. For the theory, see the diagonalization theory page and the eigenvalues overview.

Key Properties

Facts that follow from A=PDP1A = PDP^{-1}.

Powers: Ak=PDkP1A^k = PD^kP^{-1}; negative kk works too when no eigenvalue is zero
Polynomials and functions: f(A)=Pf(D)P1f(A) = Pf(D)P^{-1} with ff applied entry by entry to the diagonal
Invariants: detA=λi\det A = \prod \lambda_i and trA=λi\operatorname{tr} A = \sum \lambda_i, read straight off DD
Distinct eigenvalues always give a diagonalizable matrix
Symmetric matrices are always diagonalizable, with an orthogonal PP: A=QDQTA = QDQ^T
Non-uniqueness: scaling or reordering the columns of PP, with the same reordering of DD, gives another valid factorization
Similarity: AA and DD are similar, so they share rank, eigenvalues, characteristic polynomial and minimal polynomial
Long-run behaviour: AkA^k is dominated by the eigenvalue of largest modulus; it grows if that modulus exceeds 11, settles if it equals 11, and dies out if it is below 11
Defective matrices have no diagonal form; the Jordan form is the nearest replacement

Why It Matters

Diagonalization is how eigenvalues get used.

Recurrences: the Fibonacci matrix diagonalized is Binet's closed formula, and the same works for any linear recurrence
Markov chains: AkA^k converges to the steady state because the eigenvalue 11 survives while the others decay; the rate is the second-largest modulus
Systems of differential equations: x˙=Ax\dot{\mathbf{x}} = A\mathbf{x} decouples into nn scalar equations in the eigenvector basis, with solutions eλite^{\lambda_i t}
Matrix exponentials: eAt=PeDtP1e^{At} = Pe^{Dt}P^{-1}, the workhorse of linear dynamics and control
Quadratic forms: for symmetric AA, xTAx\mathbf{x}^TA\mathbf{x} becomes a sum of λiyi2\lambda_i y_i^2 in the eigenvector coordinates, which classifies conics and tests definiteness
Principal component analysis: diagonalizing a covariance matrix rotates the data onto its axes of greatest variance
Graph algorithms: counts of walks of length kk are entries of AkA^k for the adjacency matrix

Worked Example

Take the default preset,

A=(4123)A = \begin{pmatrix} 4 & 1 \\ 2 & 3 \end{pmatrix}


Eigenvalues. det(AλI)=λ27λ+10=(λ5)(λ2)\det(A - \lambda I) = \lambda^2 - 7\lambda + 10 = (\lambda - 5)(\lambda - 2), so λ=5,2\lambda = 5, 2. Check: they sum to the trace 77 and multiply to the determinant 1010.

Eigenvectors. For λ=5\lambda = 5, A5I=(1122)A - 5I = \begin{pmatrix} -1 & 1 \\ 2 & -2 \end{pmatrix} gives x1=x2x_1 = x_2: v1=(1,1)\mathbf{v}_1 = (1, 1). For λ=2\lambda = 2, A2I=(2121)A - 2I = \begin{pmatrix} 2 & 1 \\ 2 & 1 \end{pmatrix} gives x2=2x1x_2 = -2x_1: v2=(1,2)\mathbf{v}_2 = (1, -2).

Assemble. P=(1112)P = \begin{pmatrix} 1 & 1 \\ 1 & -2 \end{pmatrix}, D=(5002)D = \begin{pmatrix} 5 & 0 \\ 0 & 2 \end{pmatrix}.

Invert. detP=3\det P = -3, so P1=13(2111)=(2/31/31/31/3)P^{-1} = \frac{1}{-3}\begin{pmatrix} -2 & -1 \\ -1 & 1 \end{pmatrix} = \begin{pmatrix} 2/3 & 1/3 \\ 1/3 & -1/3 \end{pmatrix}.

Check. PD=(5254)PD = \begin{pmatrix} 5 & 2 \\ 5 & -4 \end{pmatrix}, and PDP1=(10/3+2/35/32/310/34/35/3+4/3)=(4123)=APDP^{-1} = \begin{pmatrix} 10/3 + 2/3 & 5/3 - 2/3 \\ 10/3 - 4/3 & 5/3 + 4/3 \end{pmatrix} = \begin{pmatrix} 4 & 1 \\ 2 & 3 \end{pmatrix} = A.

A cube. D3=(125008)D^3 = \begin{pmatrix} 125 & 0 \\ 0 & 8 \end{pmatrix}, so A3=PD3P1=(125812516)(2/31/31/31/3)=(86397847)A^3 = PD^3P^{-1} = \begin{pmatrix} 125 & 8 \\ 125 & -16 \end{pmatrix}\begin{pmatrix} 2/3 & 1/3 \\ 1/3 & -1/3 \end{pmatrix} = \begin{pmatrix} 86 & 39 \\ 78 & 47 \end{pmatrix}.

Direct multiplication agrees: A2=(1871411)A^2 = \begin{pmatrix} 18 & 7 \\ 14 & 11 \end{pmatrix} and A3=A2A=(86397847)A^3 = A^2A = \begin{pmatrix} 86 & 39 \\ 78 & 47 \end{pmatrix}. Note that 86+47=133=125+886 + 47 = 133 = 125 + 8: the trace of A3A^3 is the sum of the cubed eigenvalues.

Common Mistakes

A few mistakes recur.

Mismatched order — column jj of PP must be the eigenvector for entry jj of DD; reorder one and you must reorder the other
Writing P1DPP^{-1}DP — the eigenvectors go in PP and A=PDP1A = PDP^{-1}; the reversed form is what you get if PP holds the eigenvectors of ATA^T, not of AA
Transposing instead of invertingP1=PTP^{-1} = P^T only when PP is orthogonal, which requires orthonormal eigenvectors, guaranteed only for symmetric AA and only after normalizing
Reading a repeated root as defective — a repeated eigenvalue is only a problem if its eigenspace is too small; the repeated preset diagonalizes fine
Assuming every matrix diagonalizes — shears and other defective matrices do not, and real rotations do not over the reals
Powering AA entry by entryAkA^k is a matrix power; only DkD^k can be computed entry by entry, and that is the point of the factorization
Forgetting the checkP1APP^{-1}AP must come out diagonal; any off-diagonal entry means a column of PP is wrong