Vishvanath Solutions

Insights on spirituality, wisdom, and purposeful living.

Categories

  • Blog writing
  • CSIR entrance
  • Finance
  • Global Career counselling
  • Health, life style & nature
  • Higher Mathematics
  • Higher Mathematics Hindi
  • Insurance, types, fears, concerns and coverage
  • JEE Mains
  • JEE Mathematics syllabus
  • Maths
  • Model, predict & update
  • Palmistry
  • Physics
  • Spirituality
  • Spirituality
  • Travel
  • Vaastu Shaastra
  • Vedant

Explore

  • Home
  • About
  • Contact
  • Sitemap
  • Privacy Policy
  • Admin Login
Admin Login

© 2026 Vishvanath Solutions. All rights reserved.

profmastervidyanand@gmail.com

Vishvanath Solutions
HomeBlog writingCSIR entrance FinanceGlobal Career counsellingHealth, life style & natureHigher MathematicsHigher Mathematics Hindi Insurance, types, fears, concerns and coverageJEE MainsJEE Mathematics syllabusMathsModel, predict & updatePalmistry PhysicsSpiritualitySpirituality TravelVaastu ShaastraVedant
HomeBlog writingCSIR entrance FinanceGlobal Career counsellingHealth, life style & natureHigher MathematicsHigher Mathematics Hindi Insurance, types, fears, concerns and coverageJEE MainsJEE Mathematics syllabusMathsModel, predict & updatePalmistry PhysicsSpiritualitySpirituality TravelVaastu ShaastraVedant
Higher Mathematics

Understanding QR Factorization: A Step‑by‑Step Gram‑Schmidt Example for a 3×3 Matrix

This article defines QR factorization, walks through a complete Gram‑Schmidt orthogonalisation of a 3×3 matrix to obtain Q and R, and highlights key uses such as solving linear equations, least‑squares fitting, and eigenvalue algorithms.

November 23, 2026Prof. Dr. Vidya Prasad Shukla2 views

Photo by Thomas T on Unsplash

What Is QR Factorization?

QR factorization (or QR decomposition) expresses a real or complex matrix AAA as the product of an orthogonal (or unitary) matrix QQQ and an upper‑triangular matrix RRR:

A=QRA = QRA=QR
where Q⊤Q=IQ^{\top}Q = IQ⊤Q=I (or Q∗Q=IQ^{*}Q = IQ∗Q=I) and RRR has zeros below its main diagonal. The decomposition is fundamental in numerical linear algebra because it separates the geometric information (the orthogonal basis) from the scaling and shear information (the triangular factor).

Why Use QR Factorization?

QR factorization is employed in many computational tasks:

  • Solving linear systems Ax=bAx=bAx=b efficiently by solving QRx=bQRx=bQRx=b.
  • Computing least‑squares solutions for over‑determined systems.
  • Providing a stable basis for eigenvalue algorithms such as the QR algorithm.
  • Facilitating rank‑revealing decompositions and condition‑number estimates.

Gram‑Schmidt Orthogonalisation – The Core Idea

The classical Gram‑Schmidt process takes a set of linearly independent column vectors of AAA and orthogonalises them step by step, producing the columns of QQQ. The coefficients used during orthogonalisation form the entries of RRR.

Given columns a1,a2,…,ana_1, a_2,\dots,a_na1​,a2​,…,an​ of AAA, the process computes:

u1=a1,q1=u1∥u1∥u_1 = a_1,\quad q_1 = \frac{u_1}{\|u_1\|}u1​=a1​,q1​=∥u1​∥u1​​

For k≥2k\ge2k≥2:

uk=ak−∑j=1k−1(qj⊤ak) qj,u_k = a_k - \sum_{j=1}^{k-1} (q_j^{\top}a_k)\,q_j,uk​=ak​−j=1∑k−1​(qj⊤​ak​)qj​,

qk=uk∥uk∥.q_k = \frac{u_k}{\|u_k\|}.qk​=∥uk​∥uk​​.

The inner products (qj⊤ak)(q_j^{\top}a_k)(qj⊤​ak​) become the entries rjkr_{jk}rjk​, while rkk=∥uk∥r_{kk}=\|u_k\|rkk​=∥uk​∥.

Step‑by‑Step Example: A 3×3 Matrix

Consider the matrix

A=[110101011].A = \begin{bmatrix}1 & 1 & 0\\ 1 & 0 & 1\\ 0 & 1 & 1\end{bmatrix}.A=​110​101​011​​.

We will apply Gram‑Schmidt to its columns a1,a2,a3a_1, a_2, a_3a1​,a2​,a3​.

Step 1 – First Column

u1=a1=[110],∥u1∥=12+12+02=2.u_1 = a_1 = \begin{bmatrix}1\\ 1\\ 0\end{bmatrix},\quad \|u_1\| = \sqrt{1^2+1^2+0^2}=\sqrt{2}.u1​=a1​=​110​​,∥u1​∥=12+12+02​=2​.

q1=12[110]=[12120].q_1 = \frac{1}{\sqrt{2}}\begin{bmatrix}1\\ 1\\ 0\end{bmatrix} = \begin{bmatrix}\frac{1}{\sqrt{2}}\\ \frac{1}{\sqrt{2}}\\ 0\end{bmatrix}.q1​=2​1​​110​​=​2​1​2​1​0​​.

Step 2 – Second Column

Project a2a_2a2​ onto q1q_1q1​:

r12=q1⊤a2=[12120][101]=1sqrt2.r_{12}=q_1^{\top}a_2 = \begin{bmatrix}\frac{1}{\sqrt{2}} & \frac{1}{\sqrt{2}} & 0\end{bmatrix}\begin{bmatrix}1\\ 0\\ 1\end{bmatrix}=\frac{1}{sqrt{2}}.r12​=q1⊤​a2​=[2​1​​2​1​​0​]​101​​=sqrt21​.

Subtract the projection:

u2=a2−r12q1=[101]−12[12120]=[1−12−121]=[12−121].u_2 = a_2 - r_{12}q_1 = \begin{bmatrix}1\\ 0\\ 1\end{bmatrix} - \frac{1}{\sqrt{2}}\begin{bmatrix}\frac{1}{\sqrt{2}}\\ \frac{1}{\sqrt{2}}\\ 0\end{bmatrix}=\begin{bmatrix}1-\frac{1}{2}\\ -\frac{1}{2}\\ 1\end{bmatrix}=\begin{bmatrix}\frac{1}{2}\\ -\frac{1}{2}\\ 1\end{bmatrix}.u2​=a2​−r12​q1​=​101​​−2​1​​2​1​2​1​0​​=​1−21​−21​1​​=​21​−21​1​​.

Norm of u2u_2u2​:

r22=∥u2∥=(12)2+(−12)2+12=14+14+1=1.5=32.r_{22}=\|u_2\| = \sqrt{\left(\frac12\right)^2+\left(-\frac12\right)^2+1^2}=\sqrt{\frac14+\frac14+1}=\sqrt{1.5}=\sqrt{\frac32}.r22​=∥u2​∥=(21​)2+(−21​)2+12​=41​+41​+1​=1.5​=23​​.

q2=u2r22=13/2[12−121]=[16−1626].q_2 = \frac{u_2}{r_{22}} = \frac{1}{\sqrt{3/2}}\begin{bmatrix}\frac12\\ -\frac12\\ 1\end{bmatrix}=\begin{bmatrix}\frac{1}{\sqrt{6}}\\ -\frac{1}{\sqrt{6}}\\ \frac{2}{\sqrt{6}}\end{bmatrix}.q2​=r22​u2​​=3/2​1​​21​−21​1​​=​6​1​−6​1​6​2​​​.

Step 3 – Third Column

First compute the projections onto q1q_1q1​ and q2q_2q2​:

r13=q1⊤a3=[12120][011]=12.r_{13}=q_1^{\top}a_3 = \begin{bmatrix}\frac{1}{\sqrt{2}} & \frac{1}{\sqrt{2}} & 0\end{bmatrix}\begin{bmatrix}0\\ 1\\ 1\end{bmatrix}=\frac{1}{\sqrt{2}}.r13​=q1⊤​a3​=[2​1​​2​1​​0​]​011​​=2​1​.

r23=q2⊤a3=[16−1626][011]=−1+26=16.r_{23}=q_2^{\top}a_3 = \begin{bmatrix}\frac{1}{\sqrt{6}} & -\frac{1}{\sqrt{6}} & \frac{2}{\sqrt{6}}\end{bmatrix}\begin{bmatrix}0\\ 1\\ 1\end{bmatrix}=\frac{-1+2}{\sqrt{6}}=\frac{1}{\sqrt{6}}.r23​=q2⊤​a3​=[6​1​​−6​1​​6​2​​]​011​​=6​−1+2​=6​1​.

Subtract both projections:

u3=a3−r13q1−r23q2u_3 = a_3 - r_{13}q_1 - r_{23}q_2u3​=a3​−r13​q1​−r23​q2​

=[011]−12[12120]−16[16−1626]=\begin{bmatrix}0\\ 1\\ 1\end{bmatrix} - \frac{1}{\sqrt{2}}\begin{bmatrix}\frac{1}{\sqrt{2}}\\ \frac{1}{\sqrt{2}}\\ 0\end{bmatrix} - \frac{1}{\sqrt{6}}\begin{bmatrix}\frac{1}{\sqrt{6}}\\ -\frac{1}{\sqrt{6}}\\ \frac{2}{\sqrt{6}}\end{bmatrix}=​011​​−2​1​​2​1​2​1​0​​−6​1​​6​1​−6​1​6​2​​​

=[011]−[12120]−[16−1626]=[−232323].=\begin{bmatrix}0\\ 1\\ 1\end{bmatrix} - \begin{bmatrix}\frac12\\ \frac12\\ 0\end{bmatrix} - \begin{bmatrix}\frac{1}{6}\\ -\frac{1}{6}\\ \frac{2}{6}\end{bmatrix}=\begin{bmatrix}-\frac{2}{3}\\ \frac{2}{3}\\ \frac{2}{3}\end{bmatrix}.=​011​​−​21​21​0​​−​61​−61​62​​​=​−32​32​32​​​.

Norm of u3u_3u3​:

r33=∥u3∥=(−23)2+(23)2+(23)2=49+49+49=129=43=23.r_{33}=\|u_3\| = \sqrt{\left(-\frac23\right)^2+\left(\frac23\right)^2+\left(\frac23\right)^2}=\sqrt{\frac{4}{9}+\frac{4}{9}+\frac{4}{9}}=\sqrt{\frac{12}{9}}=\sqrt{\frac{4}{3}}=\frac{2}{\sqrt{3}}.r33​=∥u3​∥=(−32​)2+(32​)2+(32​)2​=94​+94​+94​​=912​​=34​​=3​2​.

q3=u3r33=32[−232323]=[−333333].q_3 = \frac{u_3}{r_{33}} = \frac{\sqrt{3}}{2}\begin{bmatrix}-\frac23\\ \frac23\\ \frac23\end{bmatrix}=\begin{bmatrix}-\frac{\sqrt{3}}{3}\\ \frac{\sqrt{3}}{3}\\ \frac{\sqrt{3}}{3}\end{bmatrix}.q3​=r33​u3​​=23​​​−32​32​32​​​=​−33​​33​​33​​​​.

Assembling QQQ and RRR

The orthogonal matrix QQQ consists of the three qqq vectors as columns:

Q=[1216−3312−163302633].Q = \begin{bmatrix}\frac{1}{\sqrt{2}} & \frac{1}{\sqrt{6}} & -\frac{\sqrt{3}}{3}\\[4pt] \frac{1}{\sqrt{2}} & -\frac{1}{\sqrt{6}} & \frac{\sqrt{3}}{3}\\[4pt] 0 & \frac{2}{\sqrt{6}} & \frac{\sqrt{3}}{3}\end{bmatrix}.Q=​2​1​2​1​0​6​1​−6​1​6​2​​−33​​33​​33​​​​.

The upper‑triangular matrix RRR collects the coefficients rijr_{ij}rij​:

R=[21212032160023].R = \begin{bmatrix} \sqrt{2} & \frac{1}{\sqrt{2}} & \frac{1}{\sqrt{2}}\\ 0 & \sqrt{\frac32} & \frac{1}{\sqrt{6}}\\ 0 & 0 & \frac{2}{\sqrt{3}}\end{bmatrix}.R=​2​00​2​1​23​​0​2​1​6​1​3​2​​​.

One can verify that QRQRQR reproduces the original AAA (up to rounding errors) and that Q⊤Q=IQ^{\top}Q = IQ⊤Q=I.

Photo by S.Hossein Hassanpour on Unsplash

Mid‑Article Illustration

students working on matrix decomposition

The picture above shows a study group analysing a QR decomposition on a whiteboard, highlighting the collaborative nature of learning higher mathematics.

Practical Uses of QR Factorization

  • Solving Ax=bAx=bAx=b: Compute y=Q⊤by = Q^{\top}by=Q⊤b and then solve the triangular system Rx=yRx = yRx=y by back‑substitution.
  • Least‑Squares Problems: For an over‑determined system Ax≈bAx\approx bAx≈b, QR yields the minimiser x=R−1Q⊤bx = R^{-1}Q^{\top}bx=R−1Q⊤b without forming A⊤AA^{\top}AA⊤A.
  • Eigenvalue Computations: The QR algorithm repeatedly factors Ak=QkRkA_k = Q_kR_kAk​=Qk​Rk​ and sets Ak+1=RkQkA_{k+1}=R_kQ_kAk+1​=Rk​Qk​, converging to a Schur form.
  • Numerical Stability: Orthogonal transformations preserve vector norms, making QR preferable to Gaussian elimination in many contexts.

Conclusion

QR factorization, built on the Gram‑Schmidt orthogonalisation, provides a clear geometric decomposition of any full‑rank matrix into an orthogonal basis and an upper‑triangular scaling matrix. The step‑by‑step 3×3 example demonstrates how each column of QQQ is obtained and how RRR records the projection coefficients. Mastery of QR opens the door to efficient linear‑system solvers, robust least‑squares fitting, and powerful eigenvalue algorithms—tools that are indispensable in scientific computing, data analysis, and engineering design.

Frequently asked questions

What is the main difference between QR factorization and LU decomposition?▾
QR factorization uses an orthogonal matrix QQQ and an upper‑triangular matrix RRR, preserving vector norms and offering numerical stability, while LU decomposition splits a matrix into lower‑ and upper‑triangular matrices (LLL and UUU) without orthogonal components.
ShareEmailX / TwitterLinkedIn

Related articles

Higher MathematicsNov 1, 20261 min read9 views

Singular Value Decomposition and the Pseudoinverse Explained

The article introduces singular value decomposition (SVD) as a factorization of any matrix into orthogonal (or unitary) components and shows how replacing non‑zero singular values with their reciprocals produces the Moore‑Penrose pseudoinverse. A concrete 2×2 example illustrates the calculations, and several real‑world uses—such as low‑rank approximation, solving ill‑conditioned systems, latent semantic analysis, and robot kinematics—are discussed.

Read more →
Can QR factorization be applied to non‑square matrices?▾
Yes. For an m×nm\times nm×n matrix with m≥nm\ge nm≥n, QR yields an m×nm\times nm×n orthogonal matrix QQQ (with Q⊤Q=InQ^{\top}Q=I_nQ⊤Q=In​) and an n×nn\times nn×n upper‑triangular RRR. When m<nm<nm<n, a reduced QR (or thin QR) is used.
Why is the Gram‑Schmidt process considered numerically unstable?▾
In finite‑precision arithmetic, rounding errors can cause the computed qiq_iqi​ vectors to lose orthogonality. Modified Gram‑Schmidt or Householder reflections are preferred for higher stability.
How does QR factorization help in solving least‑squares problems?▾
By writing A=QRA=QRA=QR, the least‑squares solution to min⁡∥Ax−b∥\min\|Ax-b\|min∥Ax−b∥ becomes x=R−1Q⊤bx = R^{-1}Q^{\top}bx=R−1Q⊤b, avoiding the formation of A⊤AA^{\top}AA⊤A which can amplify conditioning issues.
Is QR factorization unique?▾
If all diagonal entries of RRR are taken to be positive, the QR decomposition of a full‑rank matrix is unique. Changing signs of columns of QQQ and corresponding rows of RRR yields alternative valid factorizations.
Higher MathematicsOct 25, 20261 min read53 views

Understanding Singular Value Decomposition and Its Link to the Pseudoinverse

This article introduces singular value decomposition (SVD) for any real matrix, shows how the same factors yield the Moore‑Penrose pseudoinverse, works through a rank‑deficient 2×2 example, and outlines common applications such as least‑squares solving, low‑rank approximation, and PCA.

Read more →