WHY does such a simple sum matter? Because it turns out to equal the sum of the eigenvalues and it behaves beautifully under products (cyclic property). In ML it appears everywhere: the trace of a covariance matrix is total variance, tr(A⊤A) is the squared Frobenius norm, and traces let us rewrite ugly quadratic forms into differentiable expressions.
Start with two matrices where A is m×n and B is n×m (so both AB and BA are square):
tr(AB)=∑i=1m(AB)ii=∑i=1m∑j=1nAijBjiWhy this step? Definition of trace, then definition of matrix product (AB)ii=∑jAijBji.
Now swap the order of summation (finite sums, always legal) and relabel:
=∑j=1n∑i=1mBjiAij=∑j=1n(BA)jj=tr(BA)Why this step?∑iBjiAij=(BA)jj by the product definition. So
The characteristic polynomial is p(λ)=det(A−λI)=∏i(λi−λ). Expanding det(A−λI), the coefficient of (−λ)n−1 is ∑iAii=tr(A). From the factored form that same coefficient is ∑iλi. Matching:
WHY invariant under similarity? If A′=P−1AP (a change of basis), then by cyclic property
tr(P−1AP)=tr(APP−1)=tr(A).
So trace depends only on the map, not the chosen coordinates. That's the deep reason it equals a sum of eigenvalues.
Let A=(0010). Forecast tr(A) and its eigenvalues.
Answer:tr(A)=0+0=0. Eigenvalues both 0, sum =0. ✓ Note: a nonzero matrix can have zero trace.
Recall Feynman: explain to a 12-year-old
Imagine a square grid of numbers. Walk from the top-left corner straight down to the bottom-right corner — that diagonal line. Add up only the numbers you step on. That total is the "trace." The cool magic trick: if you tilt your head and look at the same shape from a different angle (change coordinates), that diagonal total stays exactly the same. It's like the weight of an object: doesn't change if you turn the object around.
Trace ka matlab bahut simple hai: kisi bhi square matrix ke main diagonal (top-left se bottom-right) ke numbers ko add kar do — bas wahi trace hai, ek single number. Yaad rakho, sirf square matrices ka trace hota hai, rectangular ka nahi. Off-diagonal numbers ko ignore kar dete hain.
Ab isme khaas baat kya hai? Trace ka number coordinates badalne par nahi badalta. Matlab agar aap basis rotate kar do (similarity transform P−1AP), trace same rehta hai. Iska deep reason yeh hai ki trace actually eigenvalues ka sum ke barabar hai — aur eigenvalues to map ki apni property hain, aapke likhe numbers ki nahi. Isliye trace ko "invariant" kehte hain, jaise kisi cheez ka weight ghumane se nahi badalta.
Sabse useful trick hai cyclic property: tr(AB)=tr(BA), aur teen matrices ho to ABC→BCA→CAB — cycle (loop) ghuma sakte ho, lekin randomly reorder nahi. Ek dum common galti: log sochte hain ABC aur ACB same honge — nahi! Sirf cyclic rotation allowed hai.
ML me trace har jagah aata hai: covariance matrix ka trace = total variance (PCA ka base yahi hai), aur tr(A⊤A)=∥A∥F2 yaani Frobenius norm squared. Ek aur pyaari cheez: do vectors ka outer product xy⊤ ka trace bas inner product y⊤x ban jaata hai — isse loss functions ke derivatives nikalne me bahut aasaani hoti hai. Toh trace ko halke me mat lo, chhota dikhta hai par power-packed hai.