Matrix diagonalization is the process of reducing a square matrix into its diagonal form using a similarity transformation. This process is useful because diagonal matrices are easier to work with, especially when raising them to integer powers.
Not all matrices are diagonalizable. A matrix is diagonalizable if it has no defective eigenvalues, meaning each eigenvalue’s geometric multiplicity is equal to its algebraic multiplicity.

Matrix Diagonalization
Matrix Similarity Transformation
Let A and B be two matrices of order n. Matrix B is considered similar to A if there exists an invertible matrix P such that:
B = P-1 A P
This transformation is known as Matrix Similarity Transformation. Similar matrices have the same rank, trace, determinant, and eigenvalues. Additionally, the eigenvalues of similar matrices maintain their algebraic and geometric multiplicities.
Diagonalization of a Matrix
Diagonalization of a matrix refers to the process of transforming any matrix A into its diagonal form D. According to the similarity transformation, if A is diagonalizable, then:
[Tex]D=P^{-1} A P [/Tex]
where D is a diagonal matrix and P is a modal matrix.
A modal matrix is an n × n matrix consisting of the eigenvectors of A. It is essential in the process of diagonalization and similarity transformation.
In simpler words, it is the process of taking a square matrix and converting it into a special type of matrix called a diagonal matrix.
Steps to Diagonalize a Matrix
Step 1: Initialize the diagonal matrix D as:
[Tex]D=\left[\begin{array}{ccc} \lambda_{1} & 0 & 0 \\ 0 & \lambda_{2} & 0 \\ 0 & 0 & \lambda_{3} \end{array}\right] [/Tex]
where λ1, λ2, λ3 -> eigen values
Step 2: Find the eigen values using the equation given below.
[Tex]\operatorname{det}(A-\lambda I)=0 [/Tex]
where, A -> given 3×3 square matrix.
I -> identity matrix of size 3×3.
λ -> eigen value.
Step 3: Compute the corresponding eigen vectors using the equation given below.
At λ=i
[Tex][A – \lambda I] X_i = 0[/Tex]
where, λi -> eigen value.
Xi -> corresponding eigen vector.
Step 4: Create the modal matrix P.
[Tex]P=\left[X_{0} X_{1} . . X_{n}\right] [/Tex]
Here, all the eigenvectors till Xi have filled column-wise in matrix P.
Step 5: Find P-1 and then use the equation given below to find diagonal matrix D.
[Tex]D=P^{-1} A P [/Tex]
Example Problem
Problem Statement: Assume a 3×3 square matrix A having the following values:
[Tex]A=\left[\begin{array}{ccc} 1 & 0 & -1 \\ 1 & 2 & 1 \\ 2 & 2 & 3 \end{array}\right] [/Tex]
Find the diagonal matrix D of A using the diagonalization of the matrix. [ D = P-1AP ]
Solution:
Step 1: Initializing D as:
[Tex]D=\left[\begin{array}{ccc} \lambda_{1} & 0 & 0 \\ 0 & \lambda_{2} & 0 \\ 0 & 0 & \lambda_{3} \end{array}\right] [/Tex]
Step 2: Find the eigen values. (or possible values of λ)
[Tex]\operatorname{det}(A-\lambda I)=0 [/Tex]
[Tex]\begin{array}{l} \Longrightarrow \operatorname{det}(A-\lambda I)=\operatorname{det}\left(\left[\begin{array}{ccc} 1-\lambda & 0 & -1 \\ 1 & 2-\lambda & 1 \\ 2 & 2 & 3-\lambda \end{array}\right]\right)=0 \\ \Longrightarrow\left(\lambda^{3}-6 \lambda^{2}+11 \lambda-6\right)=0 & \\ \Longrightarrow(\lambda-1)(\lambda-2)(\lambda-3)=0 \end{array} [/Tex]
[Tex]⟹\lambda=1,2,3 [/Tex]
Step 3: Find the eigen vectors X1, X2, X3 corresponding to the eigen values λ = 1,2,3.
At λ=1
[Tex](A – (1) I) X_{1}=0[/Tex]
[Tex]\Longrightarrow \begin{bmatrix} 1-1 & 0 & -1 \\ 1 & 2-1 & 1 \\ 2 & 2 & 3-1 \end{bmatrix} \begin{bmatrix} x_{1} \\ x_{2} \\ x_{3} \end{bmatrix} = \begin{bmatrix} 0 \\ 0 \\ 0 \end{bmatrix} [/Tex]
[Tex]\Longrightarrow \begin{bmatrix} 0 & 0 & -1 \\ 1 & 1 & 1 \\ 2 & 2 & 2 \end{bmatrix} \begin{bmatrix} x_{1} \\ x_{2} \\ x_{3} \end{bmatrix} = \begin{bmatrix} 0 \\ 0 \\ 0 \end{bmatrix} [/Tex]
On solving, we get the following equations:
[Tex]x_{3}=0(x_{1}) [/Tex]
[Tex] x_{1}+x_{2}=0 \Longrightarrow x_{2}=-x_{1} [/Tex]
[Tex]\therefore X_{1}= \begin{bmatrix} x_{1} \\ -x_{1} \\ 0(x_{1}) \end{bmatrix} [/Tex]
[Tex]\Longrightarrow X_{1}= \begin{bmatrix} 1 \\ -1 \\ 0 \end{bmatrix} [/Tex]
Similarly, for λ=2:
[Tex]X_{2}= \begin{bmatrix} -2 \\ 1 \\ 2 \end{bmatrix}[/Tex]
And for λ=3 :
[Tex]X_{3}= \begin{bmatrix} 1 \\ -1 \\ -2 \end{bmatrix} [/Tex]
Step 5: Creation of modal matrix P. (here, X1, X2, X3 are column vectors)
[Tex]P=\left[X_{1} X_{2} X_{3}\right]=\left[\begin{array}{ccc} 1 & -2 & 1 \\ -1 & 1 & -1 \\ 0 & 2 & -2 \end{array}\right] [/Tex]
Step 6: Finding P-1 and then putting values in diagonalization of a matrix equation [D= P-1 AP]
We do Step 6 to find out which eigenvalue will replace λ1, λ2, and λ3 in the initial diagonal matrix created in Step 1.
[Tex]\begin{array}{l} \begin{array}{l} \quad P=\left[\begin{array}{ccc} 1 & -2 & 1 \\ -1 & 1 & -1 \\ 0 & 2 & -2 \end{array}\right] \\\\ \operatorname{det}(P)=[0+(4)+(-2)] \\ =2 \end{array}\\\\ \text { Since } \operatorname{det}(P) \neq 0 \Longrightarrow \text { Matrix } P \text { is invertible. } \end{array} [/Tex]
We know that [Tex]P^{-1}=\frac{\operatorname{adj}(P)}{\operatorname{det}(P)} [/Tex]
On solving, we get [Tex]P^{-1}=\frac{1}{2}\left[\begin{array}{ccc} 0 & -2 & 1 \\ -2 & -2 & 0 \\ -2 & -2 & -1 \end{array}\right] [/Tex]
Putting in the Diagonalization of Matrix equation, we get
[Tex]\begin{array}{l} \quad D=P^{-1} A P \\\\ D=\frac{1}{2}\left[\begin{array}{ccc} 0 & -2 & 1 \\ -2 & -2 & 0 \\ -2 & -2 & -1 \end{array}\right]\left[\begin{array}{ccc} 1 & 0 & -1 \\ 1 & 2 & 1 \\ 2 & 2 & 3 \end{array}\right]\left[\begin{array}{ccc} 1 & -2 & 1 \\ -1 & 1 & -1 \\ 0 & 2 & -2 \end{array}\right] \\\\ D=\left[\begin{array}{lll} 1 & 0 & 0 \\ 0 & 2 & 0 \\ 0 & 0 & 3 \end{array}\right] \end{array} [/Tex]
MATLAB Implementation for Diagonalization of a Square Matrix
Matlab
% MATLAB Implementation for
% Diagonalization of a Square Matrix:
clear all
clc
disp("MATLAB Implementation for Diagonalization
of a Square Matrix | GeeksforGeeks")
A = input("Enter a matrix A : ");
[P , D] = eig(A);
D1 = inv(P)*(A)*(P);
disp("Diagonal form 'D' of Input Matrix 'A' is:")
disp(D1)
Output:
For the Matrix: [Tex]A = \begin{bmatrix} 1 & 3\\ 3 & 9\\ \end{bmatrix} [/Tex]

For the Matrix: [Tex]A = \begin{bmatrix} 1 & 0 & -1 \\ 1 & 2 & 1 \\ 2 & 2& 3\\ \end{bmatrix}[/Tex]

The Diagonalization is Not Unique
If a matrix A is diagonalizable, there is no unique way to diagonalize it.
- The order of eigenvalues in the diagonal matrix D can be changed.
- A column in P can be replaced with a scalar multiple of itself, as it remains an eigenvector for the same eigenvalue.
- If an eigenvalue is repeated, different bases for its eigenspace can be chosen.
Example
in the previous example, we could have defined:
[Tex]D = \begin{bmatrix} \lambda_2 & 0 & 0 \\ 0 & \lambda_1 & 0 \\ 0 & 0 & \lambda_3 \end{bmatrix} = \begin{bmatrix} 3 & 0 & 0 \\ 0 & 2 & 0 \\ 0 & 0 & 1 \end{bmatrix}[/Tex]
and
[Tex]P = \begin{bmatrix} x_2 & x_1 & x_3 \end{bmatrix} = \begin{bmatrix} 1 & 0 & -1 \\ 1 & 2 & 1 \\ 2 & 2 & 3 \end{bmatrix}[/Tex]
Another possibility would have been to choose:
[Tex]x_2 = \begin{bmatrix} -1 \\ -1 \\ -2 \end{bmatrix}[/Tex]
and
[Tex]P = \begin{bmatrix} x_2 & x_1 & x_3 \end{bmatrix} = \begin{bmatrix} -1 & 0 & -1 \\ -1 & 2 & 1 \\ -2 & 2 & 3 \end{bmatrix}[/Tex]
This shows that diagonalization is not unique since we can change eigenvectors by scalar multiples or reorder them while maintaining the same eigenvalues.
Inverse Matrix
Once a matrix has been diagonalized, computing its inverse (if it exists) becomes straightforward.
In fact, we have:
[Tex]A^{-1} = (PDP^{-1})^{-1} =P D^{-1} P^{-1}[/Tex]
where:
[Tex]D^{-1} = \text{diag} \left(\frac{1}{\lambda_1}, \frac{1}{\lambda_2}, \dots, \frac{1}{\lambda_n} \right)[/Tex]
provided none of the eigenvalues λ are zero.
Practice Problems on Matrix Diagonalization
Problem 1: Check if a Matrix is Diagonalizable
Given the matrix: [Tex]A = \begin{bmatrix} 4 & 1 \\ 6 & -1 \end{bmatrix}[/Tex]
Find the eigenvalues and eigenvectors. Determine if A is diagonalizable.
Problem 2: Compute the Diagonal Form
For the matrix: [Tex]A = \begin{bmatrix} 2 & 0 & 0 \\ 1 & 3 & 1 \\ 0 & 0 & 3 \end{bmatrix}[/Tex]
Find the diagonal matrix D and the matrix P such that A= P D P−1.
Problem 3: Find the Inverse Using Diagonalization
Given the matrix: [Tex]A = \begin{bmatrix} 1 & 2 \\ 4 & 3 \end{bmatrix}[/Tex]
Diagonalize A, and use it to compute A−1, if it exists.
Problem 4: Repeated Eigenvalues Case
Consider the matrix: [Tex]A = \begin{bmatrix} 6 & -2 \\ 2 & 2 \end{bmatrix}[/Tex]
Check if it is diagonalizable, given that it has a repeated eigenvalue.
Problem 5: Diagonalizing a 3×3 Matrix
For the matrix: [Tex]A = \begin{bmatrix} 7 & -4 & 4 \\ -4 & 8 & -4 \\ 4 & -4 & 7 \end{bmatrix}[/Tex]
Find the eigenvalues and eigenvectors. Determine P and D for diagonalization.
Similar Reads
Engineering Mathematics Tutorials
Engineering mathematics is a vital component of the engineering discipline, offering the analytical tools and techniques necessary for solving complex problems across various fields. Whether you're designing a bridge, optimizing a manufacturing process, or developing algorithms for computer systems,
3 min read
Matrix and Determinants
Matrices
Matrices are key concepts in mathematics, widely used in solving equations and problems in fields like physics and computer science. A matrix is simply a grid of numbers, and a determinant is a value calculated from a square matrix. Example: [Tex]\begin{bmatrix} 6 & 9 \\ 5 & -4 \\ \end{bmatr
3 min read
Different Operations on Matrices
For an introduction to matrices, you can refer to the following article: Matrix Introduction In this article, we will discuss the following operations on matrices and their properties: Matrices AdditionMatrices SubtractionMatrices MultiplicationMatrices Addition: The addition of two matrices A m*n a
11 min read
Representation of Relation in Graphs and Matrices
Understanding how to represent relations in graphs and matrices is fundamental in engineering mathematics. These representations are not only crucial for theoretical understanding but also have significant practical applications in various fields of engineering, computer science, and data analysis.
8 min read
Determinant of Matrix with Solved Examples
The determinant of a matrix is a scalar value that can be calculated for a square matrix (a matrix with the same number of rows and columns). It serves as a scaling factor that is used for the transformation of a matrix. It provides important information about the matrix, such as whether the matrix
15+ min read
Properties of Determinants
Properties of Determinants are the properties that are required to solve various problems in Matrices. There are various properties of the determinant that are based on the elements, rows, and columns of the determinant. These properties help us to easily find the value of the determinant. Suppose w
10 min read
Row Echelon Form
Row Echelon Form (REF) of a matrix simplifies solving systems of linear equations, understanding linear transformations, and working with matrix equations. A matrix is in Row Echelon form if it has the following properties: Zero Rows at the Bottom: If there are any rows that are completely filled wi
4 min read
Eigenvalues and Eigenvectors
Eigenvectors are the directions that remain unchanged during a transformation, even if they get longer or shorter. Eigenvalues are the numbers that indicate how much something stretches or shrinks during that transformation. These ideas are important in many areas of math and engineering, including
15+ min read
System of Linear Equations
In mathematics, a system of linear equations consists of two or more linear equations that share the same variables. These systems often arise in real-world applications, such as engineering, physics, economics, and more, where relationships between variables need to be analyzed. Understanding how t
8 min read
Matrix Diagonalization
Matrix diagonalization is the process of reducing a square matrix into its diagonal form using a similarity transformation. This process is useful because diagonal matrices are easier to work with, especially when raising them to integer powers. Not all matrices are diagonalizable. A matrix is diago
8 min read
LU Decomposition
LU decomposition or factorization of a matrix is the factorization of a given square matrix into two triangular matrices, one upper triangular matrix and one lower triangular matrix, such that the product of these two matrices gives the original matrix. It was introduced by Alan Turing in 1948, who
8 min read
Finding Inverse of a Square Matrix using Cayley Hamilton Theorem in MATLAB
Matrix is the set of numbers arranged in rows & columns in order to form a Rectangular array. Here, those numbers are called the entries or elements of that matrix. A Rectangular array of (m*n) numbers in the form of 'm' horizontal lines (rows) & 'n' vertical lines (called columns), is calle
4 min read
Sequence and Series
Binomial Theorem
Binomial theorem is a fundamental principle in algebra that describes the algebraic expansion of powers of a binomial. According to this theorem, the expression (a + b)n where a and b are any numbers and n is a non-negative integer. It can be expanded into the sum of terms involving powers of a and
15+ min read
Sequences and Series
A sequence is an ordered list of numbers following a specific rule. Each number in a sequence is called a "term." The order in which terms are arranged is crucial, as each term has a specific position, often denoted as anâ, where n indicates the position in the sequence. For example: 2, 5, 8, 11, 14
7 min read
Finding nth term of any Polynomial Sequence
Given a few terms of a sequence, we are often asked to find the expression for the nth term of this sequence. While there is a multitude of ways to do this, In this article, we discuss an algorithmic approach which will give the correct answer for any polynomial expression. Note that this method fai
4 min read
Mathematics | Sequence, Series and Summations
Sequences, series, and summations are fundamental concepts of mathematical analysis and it has practical applications in science, engineering, and finance. Table of Content What is Sequence?Theorems on SequencesProperties of SequencesWhat is Series?Properties of SeriesTheorems on SeriesSummation Def
8 min read
Calculus
Limits in Calculus
Limits are used in calculus to define differential, continuity, and integrals, and they are defined as the approaching value of the function with the input approaching to ascertain value. Let's say we have a function f(x) = x2. In the graph given below, notice that as xâ¢0, f(x) also tends to become
11 min read
Indeterminate Forms
Assume a function [Tex]F(x)=\frac{f(x)}{g(x)}[/Tex] which is undefined at x=a but it may approach a limit as x approaches a. The process of determining such a limit is known as evaluation of indeterminate forms. The L' Hospital Rule helps in the evaluation of indeterminate forms. According to this r
3 min read
Limits, Continuity and Differentiability
Limits, Continuity, and Differentiation are fundamental concepts in calculus. They are essential for analyzing and understanding function behavior and are crucial for solving real-world problems in physics, engineering, and economics. Table of Content LimitsKey Characteristics of LimitsExample of Li
10 min read
Cauchy's Mean Value Theorem
Cauchy's Mean Value theorem provides a relation between the change of two functions over a fixed interval with their derivative. It is a special case of Lagrange Mean Value Theorem. Cauchy's Mean Value theorem is also called the Extended Mean Value Theorem or the Second Mean Value Theorem. According
7 min read
Lagrange's Mean Value Theorem
Lagrange's Mean Value Theorem (LMVT) is a fundamental result in differential calculus, providing a formalized way to understand the behavior of differentiable functions. This theorem generalizes Rolle's Theorem and has significant applications in various fields of engineering, physics, and applied m
9 min read
Rolle's Mean Value Theorem
Rolle's theorem one of the core theorem of calculus states that, for a differentiable function that attains equal values at two distinct points then it must have at least one fixed point somewhere between them where the first derivative of the function is zero. Rolle's Theorem and the Mean Value The
8 min read
Taylor Series
A Taylor series represents a function as an infinite sum of terms, calculated from the values of its derivatives at a single point. Taylor series is a powerful mathematical tool used to approximate complex functions with an infinite sum of terms derived from the function's derivatives at a single po
8 min read
Maclaurin series
Prerequisite - Taylor theorem and Taylor series We know that formula for expansion of Taylor series is written as: [Tex]f(x)=f(a)+\sum_{n=1}^{\infty}\frac{f^n(a)}{n!}(x-a)^n[/Tex] Now if we put a=0 in this formula we will get the formula for expansion of Maclaurin series. T hus Maclaurin series expa
2 min read
Euler's Formula
Euler's formula holds a prominent place in the field of mathematics. It aids in establishing the essential link between trigonometric functions and complex exponential functions. It is a crucial formula used for solving complicated exponential functions. It is also known as Euler's identity. It has
5 min read
Chain Rule: Theorem, Formula and Solved Examples
Chain Rule is a way to find the derivative of composite functions. It is one of the basic rules used in mathematics for solving differential problems. It helps us to find the derivative of composite functions such as (3x2 + 1)4, (sin 4x), e3x, (ln x)2, and others. Only the derivatives of composite f
9 min read
Inverse functions and composition of functions
Inverse Functions - In mathematics a function, a, is said to be an inverse of another, b, if given the output of b a returns the input value given to b. Additionally, this must hold true for every element in the domain co-domain(range) of b. In other words, assuming x and y are constants, if b(x) =
3 min read
Definite Integral | Definition, Formula & How to Calculate
A definite integral is an integral that calculates a fixed value for the area under a curve between two specified limits. The resulting value represents the sum of all infinitesimal quantities within these boundaries. i.e. if we integrate any function within a fixed interval it is called a Definite
9 min read
Mathematics | Indefinite Integrals
Antiderivative - Definition :A function ∅(x) is called the antiderivative (or an integral) of a function f(x) of ∅(x)' = f(x). Example : x4/4 is an antiderivative of x3 because (x4/4)' = x3. In general, if ∅(x) is antiderivative of a function f(x) and C is a constant.Then, {∅
4 min read
Application of Derivative - Maxima and Minima
Derivatives have many applications, like finding rate of change, approximation, maxima/minima and tangent. In this section, we focus on their use in finding maxima and minima. Note: If f(x) is a continuous function, then for every continuous function on a closed interval has a maximum and a minimum
6 min read
Summation Formula
In mathematics, the summation is the basic addition of a sequence of any numbers, called addends or summands; the result is their sum or total. In Mathematics numbers, functions, vectors, matrices, polynomials, and, in general, elements of any mathematical object can be associated with an operation
6 min read
Statistics and Numerical Methods
Mean, Variance and Standard Deviation
Mean, Variance and Standard Deviation are fundamental concepts in statistics and engineering mathematics, essential for analyzing and interpreting data. These measures provide insights into data's central tendency, dispersion, and spread, which are crucial for making informed decisions in various en
10 min read
Mathematics - Law of Total Probability
Probability theory is the branch of mathematics concerned with the analysis of random events. It provides a framework for quantifying uncertainty, predicting outcomes, and understanding random phenomena. In probability theory, an event is any outcome or set of outcomes from a random experiment, and
13 min read
Probability Distribution - Function, Formula, Table
A probability distribution describes how the probabilities of different outcomes are assigned to the possible values of a random variable. It provides a way of modeling the likelihood of each outcome in a random experiment. While a frequency distribution shows how often outcomes occur in a sample or
15+ min read
Bayes' Theorem
Bayes' Theorem is a mathematical formula that helps determine the conditional probability of an event based on prior knowledge and new evidence. It adjusts probabilities when new information comes in and helps make better decisions in uncertain situations. Bayes' Theorem helps us update probabilitie
12 min read
Conditional Probability
Conditional probability defines the probability of an event occurring based on a given condition or prior knowledge of another event. Conditional probability is the likelihood of an event occurring, given that another event has already occurred. In probability this is denoted as A given B, expressed
11 min read
Probability Distribution
Mathematics | Probability Distributions Set 1 (Uniform Distribution)
Prerequisite - Random Variable In probability theory and statistics, a probability distribution is a mathematical function that can be thought of as providing the probabilities of occurrence of different possible outcomes in an experiment. For instance, if the random variable X is used to denote the
4 min read
Mathematics | Probability Distributions Set 2 (Exponential Distribution)
The previous article covered the basics of Probability Distributions and talked about the Uniform Probability Distribution. This article covers the Exponential Probability Distribution which is also a Continuous distribution just like Uniform Distribution. Introduction - Suppose we are posed with th
5 min read
Mathematics | Probability Distributions Set 3 (Normal Distribution)
The previous two articles introduced two Continuous Distributions: Uniform and Exponential. This article covers the Normal Probability Distribution, also a Continuous distribution, which is by far the most widely used model for continuous measurement. Introduction - Whenever a random experiment is r
5 min read
Mathematics | Probability Distributions Set 4 (Binomial Distribution)
The previous articles talked about some of the Continuous Probability Distributions. This article covers one of the distributions which are not continuous but discrete, namely the Binomial Distribution. Introduction - To understand the Binomial distribution, we must first understand what a Bernoulli
5 min read
Mathematics | Probability Distributions Set 5 (Poisson Distribution)
The previous article covered the Binomial Distribution. This article talks about another Discrete Probability Distribution, the Poisson Distribution. Introduction -Suppose an event can occur several times within a given unit of time. When the total number of occurrences of the event is unknown, we c
4 min read
Covariance and Correlation
Covariance and correlation are the two key concepts in Statistics that help us analyze the relationship between two variables. Covariance measures how two variables change together, indicating whether they move in the same or opposite directions. In this article, we will learn about the differences
5 min read
Engineering Math Practice Problems