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.
Diagonalization — writing A=PDP−1 with D diagonal.
P — the matrix whose columns are n independent eigenvectors of A; invertible because they are independent.
D — the diagonal matrix of eigenvalues, in the same order as the columns of P.
Diagonalizable — a matrix that has n 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 matrices — A and P−1AP; they share eigenvalues, trace and determinant. Diagonalization is similarity to a diagonal matrix.
Eigenvector basis — the columns of P; in this basis the map is a pure scaling.
Spectral decomposition — the symmetric case A=QDQT, where Q is orthogonal, so the inverse is the transpose.
Power formula — Ak=PDkP−1, with Dk obtained by powering the diagonal entries.
Getting Started with the Visualizer
Choose a matrix and a power, then watch it factor into PDP−1.
• Use the Preset pills for eight matrices: a classic 2×2, a symmetric one, a Markov chain, the Fibonacci matrix, a 3×3 with distinct eigenvalues, a repeated eigenvalue that still diagonalizes, a defective matrix, and a rotation • Use the Size stepper for 2×2 or 3×3, and the k stepper to choose which power Ak 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 P and D, inverting P, 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−λI for each eigenvalue, shown as columns above their eigenvalues; if there are fewer than n, the run stops with a defective verdict • Assemble — P from the eigenvectors, D from the eigenvalues, in matching order • Invert — P−1 by row reducing [P∣I], with the determinant of P noted • Factor — A=P⋅D⋅P−1 multiplied out and compared with A • Verify — P−1AP=D, the same identity from the other side • Power — Ak=PDkP−1 for the chosen k, with Dk obtained by powering the diagonal • Done — the factorization with a note on symmetry and on how Ak behaves as k grows
Complex eigenvalues stop the run after the first scene, since no real P 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 5 and 2 with their eigenvectors (1,1) and (1,−2) as columns, each above its eigenvalue.
Two eigenvectors for a 2×2 matrix, independent since they are not parallel: A is diagonalizable.
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−λ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 D follows it.
Assembling P and D
The frozen picture below shows P and D 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=PD, which is nothing more than the two eigenvector equations written as one matrix identity.
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=PD column by column is the whole proof. The j-th column of AP is Avj, and the j-th column of PD is λjvj, since multiplying on the right by a diagonal matrix scales columns. The two agree exactly because each vj is an eigenvector.
D is where all the information about the transformation sits. P is just a change of coordinates; the same A with differently scaled eigenvectors has a different P but the same D.
Inverting P
To move from AP=PD to A=PDP−1 requires P−1, which exists because the columns of P are independent. The frozen picture below shows the default preset's P and its inverse, with thirds in every entry because detP=−3.
The tool row reduces [P∣I]; for a 2×2 the formula does the same in one line.
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. P is chosen with integer columns for readability, so P−1 carries detP in its denominators, and the products PDP−1 clear them again.
For a symmetric matrix the inverse is free: with the eigenvectors normalized to unit length, P is orthogonal and P−1=PT. The symmetric preset demonstrates this, and it is the reason the spectral decomposition is written QDQT rather than QDQ−1.
The Factorization
With all three pieces in hand, A=PDP−1. The frozen picture below shows the default preset's factorization in full, A on the left and the three factors on the right.
The caption multiplies them out and recovers A exactly, which is the check that the eigenvectors and the inverse are right.
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. P−1x gives the coordinates of x in the eigenvector basis; D multiplies each coordinate by its eigenvalue; P turns the result back into standard coordinates. Nothing else happens. That is what it means for A to be a scaling in disguise.
The tool also checks the identity from the other side, P−1AP=D: conjugating A by P leaves a diagonal matrix, and every off-diagonal zero in that product is a confirmation that the corresponding column of P 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=PD3P−1: D3 is just 125 and 8 on the diagonal, and two multiplications produce A3.
Change the k stepper to see any other power; the eigenvalues make the growth rate visible before the product is even computed.
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=(PDP−1)(PDP−1)⋯(PDP−1), and every interior P−1P cancels, leaving PDkP−1. Powering a diagonal matrix is powering its entries, so the cost is constant in k, while direct multiplication costs k−1 products.
More important than the saving is what the formula says. The entries of Ak are combinations of λik, so the largest ∣λi∣ takes over as k grows: Ak grows along its eigenvector when that modulus exceeds 1, settles when it equals 1, and vanishes when it is below 1. The same formula with k replaced by a function gives eA, A and every other function of a matrix.
A Markov Chain Settling Down
The Markov preset has eigenvalues 1 and 0.4. The frozen picture below shows its eighth power: 0.48 is nearly zero, so D8 has essentially one non-zero entry and A8 is nearly the steady-state matrix, with both columns close to (5/6,1/6).
Raise the k stepper in the tool to watch the convergence.
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 1 always exists, its eigenvector is the stationary distribution, and every other eigenvalue has modulus at most 1. As k grows the powers λik of the others die out and Ak converges to a rank-one matrix whose columns are the steady state. The second-largest modulus, here 0.4, is the convergence rate.
The Fibonacci preset shows the opposite behaviour. Its dominant eigenvalue is φ≈1.618, so the entries of Ak, which are Fibonacci numbers, grow like φk; the diagonalization written out is Binet's formula.
When It Fails
The defective preset is the shear (1011). Its only eigenvalue is 1, twice, but A−I has a single free column and a single eigenvector, (1,0). The frozen picture below shows the run stopping there.
One eigenvector cannot fill a 2×2 matrix P, so there is no diagonal form.
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 x-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, (1011) itself, a diagonal of eigenvalues with a 1 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=PDP−1 holds over C and not over 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 P are colour-coded, one colour per eigenvector, and the eigenvalue row above them uses the same order • The diagonal of D is blue and its zeros are grey, to stress that only the diagonal carries information • P−1 is secondary throughout; it usually carries fractions with detP in the denominator • In the factor and power scenes the left-hand matrix, A or Ak, 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×2 classic — eigenvalues 5 and 2 with eigenvectors (1,1) and (1,−2); detP=−3, so P−1 has thirds • Symmetric — eigenvalues 3 and 1 with perpendicular eigenvectors; normalizing the columns of P gives an orthogonal Q and A=QDQT • Markov chain — eigenvalues 1 and 0.4; raise k and watch Ak settle toward the steady state, whose columns are multiples of the eigenvector for 1 • Fibonacci — (1110) with eigenvalues φ and −1/φ; Ak contains Fibonacci numbers, and the diagonalization is Binet's formula • 3×3 distinct — eigenvalues 11, 2, 1; the same matrix as the eigenvalue tool's default • Repeated but fine — λ=1 twice with a plane of eigenvectors; repeated eigenvalues do not by themselves prevent diagonalization • Defective — the shear, with λ=1 twice but a single eigenvector; the run stops • Rotation — complex eigenvalues ±i; no real diagonalization
Shuffle builds A as PDP−1 with an integer unimodular P, so the eigenvalues are small integers and the run always completes.
What Diagonalization Is
Suppose A has n linearly independent eigenvectors v1,…,vn with eigenvalues λ1,…,λn. Put the eigenvectors as the columns of P and the eigenvalues down the diagonal of D. Then
AP=A(v1⋯vn)=(λ1v1⋯λnvn)=PD
column by column, because each column of AP is Avj=λjvj. Since the columns of P are independent, P is invertible, and
A=PDP−1,D=P−1AP
Read right to left, A becomes three simple moves: P−1 expresses a vector in eigenvector coordinates, D scales each coordinate by its eigenvalue, and P converts back. In the eigenvector basis the transformation is a pure scaling; that is what "diagonal" means geometrically.
The condition is exactly n 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 P exists. Complex eigenvalues of a real matrix give a complex P and D, which is a diagonalization over C but not over R.
The payoff is functions of A. Because Ak=PDkP−1 and Dk is just the diagonal entries raised to k, every power costs two multiplications, and the same trick defines eA, A, and any polynomial in A. For the theory, see the diagonalization theory page and the eigenvalues overview.
Key Properties
Facts that follow from A=PDP−1.
• Powers: Ak=PDkP−1; negative k works too when no eigenvalue is zero • Polynomials and functions: f(A)=Pf(D)P−1 with f applied entry by entry to the diagonal • Invariants: detA=∏λi and trA=∑λi, read straight off D • Distinct eigenvalues always give a diagonalizable matrix • Symmetric matrices are always diagonalizable, with an orthogonal P: A=QDQT • Non-uniqueness: scaling or reordering the columns of P, with the same reordering of D, gives another valid factorization • Similarity: A and D are similar, so they share rank, eigenvalues, characteristic polynomial and minimal polynomial • Long-run behaviour: Ak is dominated by the eigenvalue of largest modulus; it grows if that modulus exceeds 1, settles if it equals 1, and dies out if it is below 1 • 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: Ak converges to the steady state because the eigenvalue 1 survives while the others decay; the rate is the second-largest modulus • Systems of differential equations: x˙=Ax decouples into n scalar equations in the eigenvector basis, with solutions eλit • Matrix exponentials: eAt=PeDtP−1, the workhorse of linear dynamics and control • Quadratic forms: for symmetric A, xTAx becomes a sum of λiyi2 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 k are entries of Ak for the adjacency matrix
Worked Example
Take the default preset,
A=(4213)
Eigenvalues.det(A−λI)=λ2−7λ+10=(λ−5)(λ−2), so λ=5,2. Check: they sum to the trace 7 and multiply to the determinant 10.
Eigenvectors. For λ=5, A−5I=(−121−2) gives x1=x2: v1=(1,1). For λ=2, A−2I=(2211) gives x2=−2x1: v2=(1,−2).
Assemble.P=(111−2), D=(5002).
Invert.detP=−3, so P−1=−31(−2−1−11)=(2/31/31/3−1/3).
Check.PD=(552−4), and PDP−1=(10/3+2/310/3−4/35/3−2/35/3+4/3)=(4213)=A.
A cube.D3=(125008), so A3=PD3P−1=(1251258−16)(2/31/31/3−1/3)=(86783947).
Direct multiplication agrees: A2=(1814711) and A3=A2A=(86783947). Note that 86+47=133=125+8: the trace of A3 is the sum of the cubed eigenvalues.
Common Mistakes
A few mistakes recur.
• Mismatched order — column j of P must be the eigenvector for entry j of D; reorder one and you must reorder the other • Writing P−1DP — the eigenvectors go in P and A=PDP−1; the reversed form is what you get if P holds the eigenvectors of AT, not of A • Transposing instead of inverting — P−1=PT only when P is orthogonal, which requires orthonormal eigenvectors, guaranteed only for symmetric A 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 A entry by entry — Ak is a matrix power; only Dk can be computed entry by entry, and that is the point of the factorization • Forgetting the check — P−1AP must come out diagonal; any off-diagonal entry means a column of P is wrong
Jordan form — what replaces D when the matrix is defective.
Singular value decomposition — the factorization that works for every matrix, square or not, using two orthogonal bases instead of one eigenvector basis.
Markov chains and recurrences — where powers of a fixed matrix, and hence diagonalization, do the work.