Engineering Mathematics

Trace of Matrix Product — GATE CS 2022

Question

Consider the following two statements with respect to the matrices \(A_{m\times n}\), \(B_{n\times m}\), \(C_{n\times n}\) and \(D_{n\times n}\).

\[ \text{Statement 1:}\qquad \operatorname{tr}(AB)=\operatorname{tr}(BA) \] \[ \text{Statement 2:}\qquad \operatorname{tr}(CD)=\operatorname{tr}(DC) \]

Where \(\operatorname{tr}(\cdot)\) represents the trace of a matrix.

Which one of the following holds?

A. Statement 1 is correct and Statement 2 is wrong

B. Statement 1 is wrong and Statement 2 is correct

C. Both Statement 1 and Statement 2 are correct

D. Both Statement 1 and Statement 2 are wrong

Given

  • \(A\) is an \(m\times n\) matrix.
  • \(B\) is an \(n\times m\) matrix.
  • \(C\) is an \(n\times n\) matrix.
  • \(D\) is an \(n\times n\) matrix.

Concept Used

The trace of a square matrix is the sum of its diagonal elements.

\[ \boxed{ \operatorname{tr}(A) = \sum_{i=1}^{n} a_{ii} } \]

The important property used in this question is:

\[ \boxed{ \operatorname{tr}(AB) = \operatorname{tr}(BA) } \]

Notice that \(AB\) and \(BA\) do not necessarily have the same dimensions. What matters is that both products are defined and are square matrices so that their traces exist.

Solution

Step 1: Check the dimensions of \(AB\) and \(BA\)

We are given

\[ A_{m\times n} \] \[ B_{n\times m} \]

Therefore,

\[ AB = (m\times n)(n\times m) \] \[ \boxed{AB=m\times m} \]

Similarly,

\[ BA = (n\times m)(m\times n) \] \[ \boxed{BA=n\times n} \]

Thus both \(AB\) and \(BA\) are square matrices. Therefore, their traces are well-defined.

Step 2: Prove Statement 1

Let

\[ A=[a_{ij}]_{m\times n} \] \[ B=[b_{ij}]_{n\times m} \]

The \(i,i\)-th element of \(AB\) is

\[ (AB)_{ii} = \sum_{j=1}^{n}a_{ij}b_{ji} \]

By definition of trace,

\[ \operatorname{tr}(AB) = \sum_{i=1}^{m}(AB)_{ii} \]

Substitute the expression for \((AB)_{ii}\):

\[ \operatorname{tr}(AB) = \sum_{i=1}^{m} \sum_{j=1}^{n} a_{ij}b_{ji} \]

Since the summations are finite, we can change their order:

\[ = \sum_{j=1}^{n} \sum_{i=1}^{m} a_{ij}b_{ji} \]

Since multiplication of scalars is commutative,

\[ a_{ij}b_{ji} = b_{ji}a_{ij} \]

Hence,

\[ \operatorname{tr}(AB) = \sum_{j=1}^{n} \sum_{i=1}^{m} b_{ji}a_{ij} \]

But the \(j,j\)-th diagonal element of \(BA\) is

\[ (BA)_{jj} = \sum_{i=1}^{m} b_{ji}a_{ij} \]

Therefore,

\[ \operatorname{tr}(AB) = \sum_{j=1}^{n}(BA)_{jj} \] \[ \boxed{ \operatorname{tr}(AB) = \operatorname{tr}(BA) } \]

Therefore, Statement 1 is TRUE.

Step 3: Check Statement 2

We are given

\[ C_{n\times n}, \qquad D_{n\times n} \]

Therefore,

\[ CD=(n\times n)(n\times n) \] \[ \boxed{CD=n\times n} \]

and

\[ DC=(n\times n)(n\times n) \] \[ \boxed{DC=n\times n} \]

Both products are square matrices. Therefore the trace property can be directly applied:

\[ \boxed{ \operatorname{tr}(CD) = \operatorname{tr}(DC) } \]

Hence, Statement 2 is TRUE.

Step 4: Evaluate the options

We have established:

\[ \boxed{ \text{Statement 1 = TRUE} } \] \[ \boxed{ \text{Statement 2 = TRUE} } \]

Therefore, both statements are correct.

Final Answer

\[ \boxed{\text{Option C}} \]

Both Statement 1 and Statement 2 are correct.

Formulas & Concepts to Remember

1. Trace of a square matrix

\[ \boxed{ \operatorname{tr}(A) = \sum_{i=1}^{n}a_{ii} } \]

2. Trace of product

\[ \boxed{ \operatorname{tr}(AB) = \operatorname{tr}(BA) } \]

3. Cyclic property of trace

For compatible matrices, trace can be cyclically permuted:

\[ \boxed{ \operatorname{tr}(ABC) = \operatorname{tr}(BCA) = \operatorname{tr}(CAB) } \]

However, do not confuse this with arbitrary rearrangement. In general,

\[ \operatorname{tr}(ABC) \neq \operatorname{tr}(ACB) \]

GATE Tip

The biggest trap in this question is thinking that \(AB\) and \(BA\) must be the same matrix.

They generally are not equal:

\[ \boxed{AB\neq BA\quad\text{in general}} \]

But their traces satisfy:

\[ \boxed{ \operatorname{tr}(AB) = \operatorname{tr}(BA) } \]

For this question, the fastest approach is simply:

  1. Check that \(AB\) and \(BA\) are square.
  2. Apply \(\operatorname{tr}(AB)=\operatorname{tr}(BA)\).
  3. Do the same for \(CD\) and \(DC\).
  4. Select Option C.

Original GATE Question

Original question image for reference: