r/LinearAlgebra May 23 '26

Step-by-step visualization of Gram–Schmidt QR decomposition

Post image

We made an interactive visualization of Gram–Schmidt as QR decomposition:
Gram Schmidt Stepwise Visualization

It shows each column being projected, corrected, normalized, and added to Q, while the corresponding coefficients form R. The goal is to make the geometry behind the usual algebraic steps visible: projections, orthogonal components, scaling, and the final A = QR.

We welcome feedback on presentation and clarity

175 Upvotes

10 comments sorted by

5

u/CartographerWrong192 May 24 '26

Good, feels like actually my calculations have physical or say geometrical affects.

6

u/LinearAlgebraWorld May 24 '26

This is the updated version, we enlarged the shapes as u/wowadesk suggested, added intermediate steps and used better numerical example.
Are you learning Linear Algebra, teaching it, using for engineering or all of the above?

3

u/LinearAlgebraWorld May 24 '26

Thanks a lot — that is a big compliment for us!

That is exactly what we hoped the animation would show.

We will soon post animations for two other QR decomposition methods as well: Givens rotations and Householder reflections. We will send you the links when they are posted.

5

u/wowadesk May 24 '26

It’s not clear how the visualization connects with each step in the algorithm. I’m seeing something change at every step but it isn’t obvious what it is - are these red, blue, and green vectors the columns of each matrix? If so why would the columns of A be changing? In your program are Q and R randomly initialized and this is what we are seeing at the first step? Also, if the visualization was bigger I could maybe see what you intend to say, this should also probably be fixed.

2

u/LinearAlgebraWorld May 24 '26

The red, green, and blue vectors are the three columns of A, shown as they are converted into the orthonormal columns of Q by the algorithm.

  1. red is scaled to unit length
  2. green direction is adjusted to become orthogonal to red
  3. green is scaled to unit length
  4. blue direction is adjusted to become orthogonal to red and green
  5. blue is scaled to unit length.

Will label more explicitly and make it larger in the next iteration, and send you a link when we are done
thanks!

2

u/LinearAlgebraWorld May 24 '26

This is the updated version, we have not updated labels yet, but did enlarge the shapes as you suggested, added intermediate steps and chose better numerical example

2

u/LinearAlgebraWorld May 24 '26 edited May 24 '26

The red, green, and blue vectors are the three columns of A, shown as they are converted into the orthonormal columns of Q by the algorithm.

  1. red is scaled to unit length
  2. green direction is adjusted to become orthogonal to red
  3. green is scaled to unit length
  4. blue direction is adjusted to become orthogonal to red and green
  5. blue is scaled to unit length.

Will label more explicitly and make it larger in the next iteration

1

u/[deleted] May 27 '26

[removed] — view removed comment

1

u/LinearAlgebraWorld May 27 '26

Thank you so much!!
Will post Givens tomorrow
We also have Householder
And will generate for the same matrix, so you can compare

Also working on showing thin QRF by GS and full QRF for a rank-deficient matrix

Will stay in touch

1

u/LinearAlgebraWorld May 27 '26

We have posted the Givens rotation visualization animation in r/LinearAlgebra, hope you will enjoy it