QR Decomposition Calculator
Welcome to Omni's QR decomposition calculator! Here you can determine the QR decompositions of square and rectangular matrices. Not sure what the QR decomposition (or QR factorization) is?
Scroll down!
We will give you the definition of the QR decomposition for square matrices and tell you how it extends to rectangular matrices with more rows than columns. Moreover, we discuss the main application of the QR factorization, that is, how it can facilitate solving systems of linear equations.
What is the QR decomposition?
Decomposition (or factorization) of a matrix is the process of representing this matrix as a product of two or more matrices that have various special properties. The idea is that various matrix operations become simpler thanks to the special properties of constituent matrices. There are lots of different types of matrix decompositions; among the most popular types there is the QR decomposition, which is the topic of this page, as well as the LU decomposition, Cholesky decomposition, and the singular value decomposition (SVD).
In the QR decomposition, we factor a real square matrix A
of size n x n
into the product of two matrices:
A = QR
where,
Q
is ann x n
orthogonal matrix (i.e., a matrix whose columns form an orthonormal basis for Rⁿ; in other words, these columns are orthogonal vectors of unit length); andR
is ann x n
upper triangular matrix (i.e., all the elements below the diagonal are zero).
The QR decomposition can be extended to rectangular matrices of size m x n
, where m ≥ n
.
In such a case, we have A = QR
where Q
is of size m x n
and its n
columns are orthogonal vectors of unit length, and R
is an upper triangular matrix of size n x n
.
💡
You may benefit from the following list of equivalent conditions for Q being an orthogonal matrix:
where 
Uniqueness of the QR factorization

If
A
is invertible and we require the diagonal entries ofR
to be positive, then the QR decomposition is unique. IfA
is a square singular matrix (i.e., noninvertible), thenR
is singular too, which means it has some zeros on the diagonal. In such a case, the QR decomposition is not unique. 
Likewise, if
A
is anm x n
(withm ≥ n
) rectangular matrix of full rank (that is, its columns form a set of linearly independent vectors) and we require the diagonal entries ofR
to be positive, then the QR decomposition is unique. IfA
is not a fullrank matrix, then the QR decomposition is not unique.
How to find the QR decomposition?
There are several methods for performing the QR decomposition of a given matrix A
. The simplest one, which we want to explain here, is via the GramSchmidt orthogonalization.
First, we take the columns of A
and subject them to the process of GramSchmidt orthogonalization. This results in a collection of orthonormal vectors: e_{1}, e_{2}, ..., e_{n}
. Form a matrix with these vectors as columns and call this matrix Q
:
Well done  you have just found the orthogonal matrix Q from the QR factorization! It remains to find the uppertriangular matrix R. This we can do with the help of the following formula:
By ⟨v, w⟩
we denote the standard inner (dot) product of vectors v
and w
.
Equivalently, you can determine R
by leftmultiplying the original matrix A
by the transpose of our newlyfound matrix Q
as follows:
💡 The price we have to pay for the simplicity of this method is numerical instability (that is, it is prone to numerical errors). If you need a method that is numerically stable, check out the method of Householder reflection (a.k.a. Householder transformation). 
How to use this QR decomposition calculator?
As we have seen above, it may be hard to perform the QR decomposition of a given matrix. That's why we've created this QR decomposition calculator! 😀 To use it to factorize a matrix, follow these steps:

Enter the size of the matrix for which you need to determine the QR decomposition: the number of rows and columns.
Remember that for the QR decomposition the number of rows needs to be greater than or equal to the number of columns.

Enter the coefficients of your matrix into the respective fields of our QR decomposition calculator.

Omni's QR decomposition calculator will display the factorization of your matrix.

You can increase the precision of calculations with which this QR decomposition calculator operates. Click the
advanced mode
button and adjust theprecision
field according to your needs. By default, our QR decomposition calculator displays 3 significant figures.
Applications of the QR decomposition
The QR decomposition has multiple applications. The one we want to discuss here is solving systems of linear equations. Another important field where QR decomposition is often used is in calculating the eigenvalues and eigenvectors of a matrix. This method is known as the QR algorithm or QR iteration.
As you most likely well know, there are several methods of solving systems of linear equations, among them
Now we'll see how the QR factorization procedure can facilitate the task of solving a system of linear equations. Suppose we have to solve the system:
where,
a_{11}, a_{12}, ..., a_{mn}
are the coefficients of the system;b_{1}, b_{2}, ..., b_{m}
are the constant terms; andx_{1}, x_{2}, ..., x_{n}
are the unknowns.
Our system can be rewritten as:
Ax = b
,
where,
So now we have to determine the vector x
given the matrix A
and the vector b
.
Assume that m ≥ n
and that we have the QR decomposition of A
, i.e., we know the orthogonal matrix Q
and the uppertriangular matrix R
such that A = QR
. This means we have to solve the equation:
QRx = b
Let's multiply both sides of the above equation by Qᵀ
:
QᵀQRx = Qᵀb
Why have we done that, you may (and should) ask? Now it is more complicated than before, isn't it? At first sight, yes, but recall what we learned about orthogonal matrices back in the first section: they satisfy the property that QᵀQ = Id
. In consequence, the lefthand side simplifies as follows:
QᵀQRx = Rx
and the whole equation now looks like:
Rx = Qᵀb
Since there is a triangular matrix on the lefthand side, this equation is straightforward to solve. An example best shows it, so in the next section, we solve a system of linear equations via the QR factorization.
Example of QR decomposition application
Say we have to solve the following system of linear equations:
w + 3v + 6z = 3
w + 2v + 2z = 1
w + 3v + 8z = 5
w + 2v + 4z = 1
And we want to solve
Ax = b
with
A  = 

b  = 

x  = 

Using our QR decomposition calculator, we find that A = QR
, where
Q  = 

R  = 

Using the transformation described in the previous section, we arrive at the system:
Rx = Qᵀb
We quickly compute Rx
as
Rx  = 

and to find Qᵀb
, we first write down the transpose of Q
:
Qᵀ  = 

and then
Qᵀb  = 

Therefore, we have to solve

Now you can see the power of triangular matrices! Thanks to the fact that R
is uppertriangular, the last equation has an elementary form:
2z = 2
We can easily solve for z
, getting:
z = 1
The penultimate equation is now also simple to solve as it involves only v
and z
(and we already know the value of z
!):
v + 4z = 4
Hence, we get
v = 4  4z
v = 4  4 = 0
There remains only one equation:
2w + 5v + 10z = 4
and, given that z = 1
and v = 0
, we easily obtain
2w = 4  10z
2w = 4  10 = 6
w = 3
That's it! We have solved a system of linear equations with the help of QR decomposition! 🥳
A =  ⌈  a₁  a₂  ⌉ 
⌊  b₁  b₂  ⌋ 