4.5.41 · HinglishLinear Algebra (Full)

Least squares — normal equations, QR approach

1,490 words7 min readRead in English

4.5.41 · Maths › Linear Algebra (Full)


Least-squares problem KYA hai?

Squared length KYU? Yeh har jagah differentiable (smooth) hota hai, jabki zero par ek kink rakhta hai. Square ko minimise karna length ko minimise karne ke barabar hai (same minimiser), aur algebra linear rehta hai.


Normal Equations KAISE derive karte hain (scratch se)

Hum ka minimum chahte hain. Do independent derivations — jo bhi samajh aaye woh lo.

Derivation 1 — Geometry (projection / orthogonality)

Set column space hai, jo ek subspace hai. Ek subspace mein ke sabse karib wala point orthogonal projection hota hai. Toh residual ke har column ke perpendicular hona chahiye:

Yeh step kyun? Agar residual ka koi component ke andar hota, toh hum ko us direction mein thoda move karke aur karib aa sakte — toh true minimum par residual ka zero component column space mein hota hai, yaani woh sabhi columns se orthogonal hai.

Sabhi columns ko stack karne par milta hai, isliye

Derivation 2 — Calculus

Expand karo: Gradient ko zero set karo (using symmetric ke liye, aur ): Maximum nahi, minimum kyun? Hessian positive semidefinite hai (kyunki ), toh critical point ek minimum hai.


QR approach KAISE kaam karta hai (aur yeh better kyun hai)

Normal equations hi use kyun nahi karte? banane se condition number square ho jaata hai (), jo rounding errors ko amplify karta hai. QR, banane se bilkul bachta hai.

Derivation. ko normal equations mein substitute karo: Kyunki invertible hai (full rank), cancel karo:

Yeh step kyun? triangular hai, toh back-substitution se solve karo — fast aur numerically stable. kabhi appear hi nahi karta.

Figure — Least squares — normal equations, QR approach

Worked Examples


Common Mistakes (Steel-manned)


Recall Feynman: 12-saal ke bacche ko explain karo

Socho tum darts phenk rahe ho jo ek seedhi line par lagne chahiye, lekin tumhara haath hilta hai toh woh bikhar jaate hain. Tum ek line sab ke through nahi khich sakte. Toh tum woh line khinchte ho jो total miss-distance (upar-neeche mapa hua) ko jitna ho sake utna chota kare. "Miss" arrows line se seedhe door point karne chahiye — agar koi line ke saath lean karta, toh tum line slide kar ke better kar sakte. Least squares woh sabse fair line dhundta hai. QR sirf arithmetic karne ka ek saaf tarika hai jo tumhare calculator ki rounding errors ko nahi udaata.


Active Recall

Least squares kya minimise karta hai?
Squared residual norm .
Normal equations batao.
.
Geometrically, residual Col(A) se orthogonal kyun hona chahiye?
Warna uska ek component column space ke andar hoga; ko us direction mein move karne se distance kam hoti, jo minimality ke against hai.
kab invertible hota hai?
Tab hi jab ka full column rank ho (independent columns).
Col(A) par projection matrix kya hai?
, with , .
mein Q aur R ki kya properties hain?
ke orthonormal columns hain (); upper triangular aur invertible hai.
QR, least squares ko kaun si equation mein reduce karta hai?
, back-substitution se solve hota hai.
Normal equations se QR numerically better kyun hai?
banane se condition number square ho jaata hai (); QR isse avoid karta hai, stable rehta hai.
Norm ki jagah squared norm kyun use karte hain?
Yeh har jagah smooth/differentiable hai aur same minimiser deta hai, equations ko linear rakhta hai.

Connections

  • Orthogonal Projection — least squares is projection onto Col(A).
  • QR Factorization — solve ke peeche stable engine.
  • Gram-Schmidt Process banane ka ek tarika.
  • Column Space and Rank — full rank ⇔ unique solution.
  • Pseudoinverse (Moore-Penrose) — jab rank deficient ho tab generalise karta hai.
  • Condition Number — kyun square karna nuksan karta hai.
  • Linear Regression — in equations ka statistics application.

Concept Map

minimise residual norm

defines

solved via

solved via

residual orthogonal to Col A

set gradient to zero

Hessian 2 A^T A is PSD

if full column rank

gives

closest point to b

better conditioned via

Tall system Ax=b, no exact solution

Least-squares solution x-hat

Residual r = b - Ax-hat

Geometry derivation

Calculus derivation

Normal equations A^T A x = A^T b

Guarantees a minimum

x-hat = A^T A inverse times A^T b

Projection A x-hat onto Col A

QR approach