Worked examples — QR decomposition
4.5.36 · D3· Maths › Linear Algebra (Full) › QR decomposition
Scenario matrix
Examples kaam karne se pehle, chalte hain har alag cheez list karte hain jo ek QR problem tumpe throw kar sakti hai. Har row ek case class hai; last column uss example ka naam hai jo use cover karta hai.
| # | Case class | Kya special hai | Covered by |
|---|---|---|---|
| 1 | Clean tall matrix, positive diagonal | textbook path, kuch bhi weird nahi | Ex. 1 |
| 2 | Negative sign appear karta hai | "backwards" point karta hai → sign convention on | Ex. 2 |
| 3 | Already orthogonal | limiting case: , | Ex. 3 |
| 4 | Already upper-triangular | limiting case: , ek diagonal-sign matrix recover karte hain | Ex. 4 |
| 5 | Degenerate: dependent columns | → QR breaks, aur kyun | Ex. 5 |
| 6 | Nearly dependent columns | limiting behaviour: , instability | Ex. 6 |
| 7 | Wide matrix (, rows se zyada columns) | forced dependence → breakdown | Ex. 7 |
| 8 | Least squares word problem | real data, over-determined system | Ex. 8 |
| 9 | Exam twist: ke liye ka diagonal use karo | se ek hidden quantity padhna | Ex. 9 |
Ab hum inhe order mein walk karenge. Gram-Schmidt process ke steps yaad rakho — har example wahi process hai, bas alag inputs ke saath.
Geometry ka ek-figure reminder
Har example physically same move karta hai: pehla arrow rakho, phir agli arrow ka shadow phenk do taaki sirf perpendicular part bache.

Example 1 — Case 1: clean tall matrix
- Pehli axis. , . Toh aur . Yeh step kyun? Pehli clean direction bas pehla column hai, length 1 tak shrunk karo — koi earlier direction nahi hai jiske perpendicular rehna ho.
- Shadow coefficient. . Yeh step kyun? measure karta hai ka kitna hissa already ke along point karta hai — woh part jo hume remove karna hai.
- Shadow hatao. . Yeh step kyun? Jo bachta hai woh ka woh piece hai jo ke perpendicular hai — ek bilkul naya direction.
- Doosri axis. , aur . Yeh step kyun? Normalize karo taaki ki length 1 ho; ab orthonormal hai.
Verify: ✓ (perpendicular), har ki length 1 hai, aur . Saare diagonal entries positive hain → yeh the unique QR hai.
Example 2 — Case 2: backwards-pointing first column (sign convention)
- Pehli axis. , toh (length hamesha hoti hai — minus signs square hoke khatam ho gaye). . Yeh step kyun? Ek norm negative nahi ho sakta; sign direction mein rehta hai, mein nahi. Isliye QR fix karta hai : sign mein force ho jaata hai.
- Shadow coefficient. . Yeh step kyun? negative ho sakta hai — matlab sirf yeh hai ki ke against lean karta hai. Off-diagonal signs unconstrained hain.
- Shadow hatao. . Yeh step kyun? Shadow subtract karo taaki ka sirf woh part bache jo ke perpendicular hai; yahan shadow ka khud negative sign hai, toh subtract karne se add back hota hai — wahi rule jaise hamesha, bas signed coefficient ke saath.
- Doosri axis. . . Yeh step kyun? Perpendicular leftover ko length 1 tak normalize karo taaki orthonormal ho; diagonal entry phir se ek positive length hai.
Verify: diagonal ✓. ✓ (compute: , cross term ). ✓. Data ki negativity puri tarah mein gayi, ke diagonal mein kabhi nahi.
Example 3 — Case 3: already-orthogonal matrix (limiting case)
- Pehli axis. , toh , . Yeh step kyun? Column 1 already length 1 hai — normalize karne se kuch nahi badlega.
- Shadow coefficient. . Yeh step kyun? Zero shadow matlab already ke perpendicular hai — subtract karne ke liye kuch nahi.
- Doosri axis. , , . Yeh step kyun? Zero shadow remove karne ke baad, leftover hi hai, aur woh already unit length hai, toh with — Gram–Schmidt confirm karta hai frame already clean tha.
Verify: ✓. Yeh parent note mein predicted "QR kuch nahi karta" limit hai: orthogonal ke liye, har aur har off-diagonal .
Example 4 — Case 4: already upper-triangular matrix
- Pehli axis. , . Yeh step kyun? Column 1 exactly pehle coordinate axis ke along hai, toh uski clean direction hai aur length hai .
- Shadow coefficient. . Yeh step kyun? measure karta hai ke along kitna pahunchta hai — horizontal part jo hume strip off karna hai.
- Shadow hatao. , , . Yeh step kyun? Horizontal shadow subtract karne se sirf vertical part bachta hai, jo normalize hokar second axis banta hai — yeh dikhata hai columns already coordinate axes ke along point kar rahe the.
Verify: ✓. Key insight: ek already-upper-triangular matrix positive diagonal ke saath apna khud ka hota hai aur . (Agar diagonal mein negative entry hoti, toh us column ka sign mein move ho jaata, exactly Example 2 ki tarah — toh diagonal pe hota, nahi.)
Example 5 — Case 5: DEGENERATE, dependent columns (QR breaks)
- Pehli axis. , . Yeh step kyun? Wahi pehla move jaise hamesha — pehle column ko normalize karo pehli clean direction ke liye; abhi kuch galat nahi hai.
- Shadow coefficient. . Yeh step kyun? Measure karo ka kitna ke along hai; yahan bada coefficient pehla hint hai ki almost entirely ke along point karta hai.
- Shadow hatao — collapse. . Yeh kyun important hai: pura shadow tha — woh exactly ke along lie karta hai. Shadow remove karne ke baad, kuch nahi bacha. , toh .
- The break. undefined hai — division by zero.
Verify: , toh columns dependent hain (rank 1). Parent note mein QR theorem ne linearly independent columns assume kiya tha precisely taaki har ho. Yahan woh assumption fail hoti hai, , aur positive diagonal ke saath thin QR simply exist nahi karta. (Rank-revealing QR with column pivoting yeh handle karta hai, lekin plain algorithm ruk jaata hai.)
Example 6 — Case 6: nearly dependent columns (limiting behaviour)
- Pehli axis. , . Yeh step kyun? Pehla column already ek unit vector hai, toh woh apni clean direction khud hai.
- Shadow coefficient. . Yeh step kyun? ka along- part measure karo; ka almost sab kuch yahi shadow hai.
- Shadow hatao. , toh . Yeh step kyun? Shadow strip karo; tiny leftover hi woh cheez hai jo column 2 ko column 1 se alag karti hai.
- Limit lo. Jab , . Yeh step kyun? Bachne wala perpendicular part kuch nahi ban jaata — columns ek line mein merge ho rahe hain, Example 5 ke collapse ki tarah.
Verify: ✓ (dekho Example 9 — ke diagonal ka product determinant hai). ke liye, : size ka koi bhi rounding error ise daba dega, toh garbage ban jaata hai. Yahi reason hai classical Gram–Schmidt dependence ke paas unstable hai, aur isliye practitioners Householder reflections ya modified Gram–Schmidt switch karte hain.
Example 7 — Case 7: WIDE matrix (rows se zyada columns)
- Pehli axis. , . Yeh step kyun? Column 1 normalize karo pehli clean direction ke liye — abhi kaafi room hai.
- Doosri axis. , toh , , . Yeh step kyun? Column 2 already ke perpendicular hai; ab pura plane span karta hai — room full hai.
- Teesri axis — collapse. ke liye: , . Phir . Yeh kyun important hai: already poore ko span kar chuka hai, toh puri tarah pehle ke directions se bana hai. Har shadow hatane ke baad kuch nahi bachta: , .
- The break. undefined hai. Yeh step kyun? Do directions se perpendicular teesra direction nahi bana sakte jo already plane fill kar chuke hain — geometry forbid karta hai.
Verify: ek matrix ke columns teen vectors hain mein, toh woh hamesha linearly dependent hain (tum dimensions mein independent vectors nahi rakh sakte). Isliye QR theorem mein required hai; ek wide matrix () ka kabhi thin QR nahi ho sakta positive diagonal ke saath — dimension overflow karne wala pehla column deta hai.
Example 8 — Case 8: least-squares word problem
Over-determined system set up karo ek column of ones ( ke liye) aur ek column of ( ke liye) ke saath:
- ka QR. , . . . , . Yeh step kyun? QR messy least-squares ko ek triangular solve mein badal deta hai; dekho Least squares and normal equations.
- form karo. . . Yeh step kyun? ka minimizer satisfy karta hai (parent note) — hai expressed in the clean frame.
- Back-substitute . Row 2: . Row 1: . Yeh step kyun? Triangular systems bottom-up solve hote hain bina matrix inversion ke — exact aur numerically stable, yahi QR use karne ka poora point hai.
Verify (units + sanity): intercept sales at (observed ke kareeb), slope sale per hour. Predictions vs data — residuals ka sum hai, jaisa least squares demand karta hai (fit data ke centroid se guzarta hai: ✓). Slope , forecast option se match.
Example 9 — Case 9: exam twist, se padho
- ka QR. , , . Yeh step kyun? Column 1 normalize karo pehli diagonal entry ke liye — hume sirf yahi values chahiye, yeh diagonal norms.
- Shadow + second axis. ; ; . Yeh step kyun? ka shadow strip karo perpendicular leftover paane ke liye, jiski length doosri diagonal entry hai.
- Diagonal multiply karo. . Yeh step kyun? Triangular matrix ke liye determinant diagonal ka product hota hai — off-diagonal entries kabhi contribute nahi karti.
- Orthogonality use karo. . Yeh step kyun? Ek orthogonal volume preserve karta hai, toh ; ki saari "stretch" ke diagonal mein rehti hai.
Verify: direct expansion , toh ✓. Ek general rule jo exam mein quote kar sakte ho: . (Yahi trick Eigenvalues and the QR algorithm mein kaam aati hai aur mirror karti hai LU decomposition ka us triangular factor se padhna.)
Active recall
Recall Konse cases mein valid QR nahi tha, aur kyun?
Case 5 (Example 5): dependent columns banate hain. Case 7 (Example 7): ek wide matrix () dependence force karta hai, toh column se milta hai. Dono hit karte hain, undefined. Positive-diagonal QR ko aur independent columns chahiye.
kabhi negative kyun nahi ho sakta?
Jab do columns merge hote hain toh kya limit approach karta hai?
Ek wide matrix () ka thin QR kyun nahi ho sakta?
QR se kaise milta hai?
Already-orthogonal ka QR?
Already upper-triangular with positive diagonal ka QR?
Example 8 mein fitted line kya hai?
Connections
- QR decomposition — woh parent note jise yeh page drill karta hai.
- Gram-Schmidt process — har example iska ek run hai.
- Orthonormal bases and projections — shadow ek projection hai.
- Least squares and normal equations — Example 8 ka engine.
- Householder reflections — Case 6 ke liye stable fix.
- Eigenvalues and the QR algorithm — idea use karta hai.
- LU decomposition — sibling factorization jo ek triangle se bhi padhti hai.