Tutorials › Linear Algebra › Multiplication Of Diagonal Matrices

Matrix Operations and Algebra · Tutorial 75 of 1000

Multiplication Of Diagonal Matrices

Use diagonal entries to compute scalar multiples and products, and justify why the results remain diagonal.

Beginner 10 min read

What You'll Learn

  • Identify a diagonal matrix from its entries and write it using diagonal notation.
  • Compute scalar multiples of diagonal matrices entry by entry.
  • Prove the formula for multiplying two diagonal matrices of the same order.
  • Explain why diagonal matrices of the same order commute.
  • Determine exactly when the product of two diagonal matrices is the zero matrix.
  • Check diagonal-matrix calculations by multiplying rows and columns.

Recognizing a Diagonal Matrix

A diagonal matrix has a simple pattern: entries away from the main diagonal are zero, while the entries on the main diagonal may be any real numbers. This pattern makes multiplication particularly direct. Instead of mixing entries from different rows and columns, the product of two diagonal matrices pairs entries in the same diagonal position.

Throughout, matrices have real entries. A diagonal matrix is square, so write its order as \(n\times n\). We use \(\operatorname{diag}(d_1,\dots,d_n)\) to denote the matrix whose diagonal entries are \(d_1,\dots,d_n\) and whose other entries are all zero. The values \(d_i\) are allowed to be zero.

Definition: A matrix \(\mathbf{D}=(d_{ij})\in\mathbb{R}^{n\times n}\) is diagonal if \(d_{ij}=0\) whenever \(i\ne j\). Equivalently, it has the form \(\mathbf{D}=\operatorname{diag}(d_1,\dots,d_n)\), where \(d_i=d_{ii}\) for \(1\le i\le n\).

The two descriptions are equivalent because the diagonal entries specify every entry that is not required to be zero. For \(n=1\), there are no off-diagonal positions, so every \(1\times1\) matrix is diagonal. A diagonal matrix need not have nonzero diagonal entries; for example, \(\operatorname{diag}(2,0,-1)\) is diagonal.

Scalar Multiples: Scale Each Diagonal Entry

For a real scalar \(c\), the scalar multiple \(c\mathbf{D}\) is obtained by multiplying every entry of \(\mathbf{D}\) by \(c\). Since every off-diagonal entry of \(\mathbf{D}\) is zero, scaling those entries leaves them zero. Only the diagonal entries need to be calculated.

Theorem: If \(\mathbf{D}=\operatorname{diag}(d_1,\dots,d_n)\in\mathbb{R}^{n\times n}\) and \(c\in\mathbb{R}\), then \(c\mathbf{D}=\operatorname{diag}(cd_1,\dots,cd_n)\).

Proof. By the definition of scalar multiplication, the entry in position \((i,j)\) of \(c\mathbf{D}\) is \(c d_{ij}\). If \(i\ne j\), then \(d_{ij}=0\), so \(c d_{ij}=0\). If \(i=j\), that entry is \(c d_{ii}=c d_i\). Thus the off-diagonal entries remain zero and the \(i\)th diagonal entry becomes \(c d_i\), as stated. \(\square\)

Worked Example: Scaling a Diagonal Matrix

Compute \(-4\mathbf{D}\) for \(\mathbf{D}=\begin{bmatrix}3&0\\0&-2\end{bmatrix}\), and verify the entries.

Multiply every entry by \(-4\):

$$ -4\mathbf{D} = \begin{bmatrix} (-4)(3)&(-4)(0)\\ (-4)(0)&(-4)(-2) \end{bmatrix} = \begin{bmatrix} -12&0\\ 0&8 \end{bmatrix}. $$

Check: the two diagonal entries are \(-12\) and \(8\), which are \((-4)(3)\) and \((-4)(-2)\), respectively. Both off-diagonal entries are \((-4)(0)=0\), so the result is diagonal and agrees with the formula.

The scalar \(c=0\) is included in the theorem: \(0\mathbf{D}\) is the zero matrix. If \(c\ne0\), each diagonal entry is scaled by the same nonzero number; an entry that was zero remains zero. These conclusions follow directly from the entry formula and do not require any condition on the diagonal entries of \(\mathbf{D}\).

Products: Pair Entries in the Same Position

Two diagonal matrices can be multiplied when they have the same order. Indeed, if \(\mathbf{D}\) is \(n\times n\) and \(\mathbf{E}\) is \(m\times m\), their product is defined only when the number of columns of \(\mathbf{D}\) equals the number of rows of \(\mathbf{E}\), which requires \(n=m\). Let \(\mathbf{D}=\operatorname{diag}(d_1,\dots,d_n)\) and \(\mathbf{E}=\operatorname{diag}(e_1,\dots,e_n)\). The entry formula for matrix multiplication gives \((\mathbf{D}\mathbf{E})_{ij}=\sum_{k=1}^{n}d_{ik}e_{kj}\). In this sum, the diagonal pattern forces all terms to vanish unless \(i=j=k\).

Theorem: If \(\mathbf{D}=\operatorname{diag}(d_1,\dots,d_n)\) and \(\mathbf{E}=\operatorname{diag}(e_1,\dots,e_n)\) are diagonal matrices of the same order, then \(\mathbf{D}\mathbf{E}=\operatorname{diag}(d_1e_1,\dots,d_ne_n)\). In particular, their product is diagonal.

Proof. Fix any row index \(i\) and column index \(j\). The entry formula gives \((\mathbf{D}\mathbf{E})_{ij}=\sum_{k=1}^{n}d_{ik}e_{kj}\). Since \(\mathbf{D}\) is diagonal, \(d_{ik}=0\) unless \(k=i\); therefore the only possible nonzero term is \(d_{ii}e_{ij}\). Since \(\mathbf{E}\) is diagonal, \(e_{ij}=0\) unless \(i=j\). Thus \((\mathbf{D}\mathbf{E})_{ij}=0\) when \(i\ne j\). When \(i=j\), the surviving term is \(d_{ii}e_{ii}=d_i e_i\). Every off-diagonal entry is zero and every diagonal entry is \(d_i e_i\), proving the formula. \(\square\)

Worked Example: Multiplying Two 3×3 Diagonal Matrices

Compute the product of \(\mathbf{D}=\operatorname{diag}(2,-1,3)\) and \(\mathbf{E}=\operatorname{diag}(4,5,0)\). Then check the result using rows and columns.

The diagonal entries pair in order: \(2\cdot4=8\), \((-1)\cdot5=-5\), and \(3\cdot0=0\). Therefore, the product formula gives

$$ \mathbf{D}\mathbf{E} = \begin{bmatrix}2&0&0\\0&-1&0\\0&0&3\end{bmatrix} \begin{bmatrix}4&0&0\\0&5&0\\0&0&0\end{bmatrix} = \begin{bmatrix}8&0&0\\0&-5&0\\0&0&0\end{bmatrix}. $$

Check: the first row of \(\mathbf{D}\) is \((2,0,0)\), so its dot products with the three columns of \(\mathbf{E}\) are \(2(4)+0(0)+0(0)=8\), \(2(0)+0(5)+0(0)=0\), and \(2(0)+0(0)+0(0)=0\). The second row \((0,-1,0)\) gives \(0\), \(-5\), and \(0\); the third row \((0,0,3)\) gives \(0\), \(0\), and \(0\). These nine entries reproduce the displayed product.

The formula also shows that the factors commute. This is a special property of diagonal matrices: it does not mean that arbitrary matrices commute.

Theorem: Any two diagonal matrices of the same order commute: \(\mathbf{D}\mathbf{E}=\mathbf{E}\mathbf{D}\).

Proof. By the product formula, the \(i\)th diagonal entry of \(\mathbf{D}\mathbf{E}\) is \(d_i e_i\), and the \(i\)th diagonal entry of \(\mathbf{E}\mathbf{D}\) is \(e_i d_i\). Real numbers commute under multiplication, so \(d_i e_i=e_i d_i\) for each \(i\). Both products have zero off-diagonal entries. Hence their corresponding entries agree everywhere, and \(\mathbf{D}\mathbf{E}=\mathbf{E}\mathbf{D}\). \(\square\)

When Is the Product the Zero Matrix?

The product formula gives an entry-by-entry test: the product is the zero matrix exactly when every paired diagonal product is zero. This does not require either factor to be the zero matrix; different positions can have zero entries in different factors.

Characterization: For diagonal matrices \(\mathbf{D}=\operatorname{diag}(d_1,\dots,d_n)\) and \(\mathbf{E}=\operatorname{diag}(e_1,\dots,e_n)\) of the same order, \(\mathbf{D}\mathbf{E}=\mathbf{O}\) if and only if \(d_i e_i=0\) for every \(i\).

Proof. The product formula says \(\mathbf{D}\mathbf{E}=\operatorname{diag}(d_1e_1,\dots,d_ne_n)\). A diagonal matrix equals the zero matrix exactly when each of its diagonal entries is zero. Therefore, \(\mathbf{D}\mathbf{E}=\mathbf{O}\) exactly when \(d_i e_i=0\) for every \(i\). \(\square\)

Worked Example: A Zero Product of Nonzero Diagonal Matrices

Let \(\mathbf{A}=\operatorname{diag}(2,0,-3)\) and \(\mathbf{B}=\operatorname{diag}(0,5,0)\). Compute both product orders and check them directly.

Pairing entries gives \(2\cdot0=0\), \(0\cdot5=0\), and \((-3)\cdot0=0\). Hence

$$ \mathbf{A}\mathbf{B} = \begin{bmatrix}2&0&0\\0&0&0\\0&0&-3\end{bmatrix} \begin{bmatrix}0&0&0\\0&5&0\\0&0&0\end{bmatrix} = \begin{bmatrix}0&0&0\\0&0&0\\0&0&0\end{bmatrix}. $$

Reversing the factors pairs the entries \(0\cdot2=0\), \(5\cdot0=0\), and \(0\cdot(-3)=0\), so \(\mathbf{B}\mathbf{A}=\mathbf{O}\) as well. Check: in \(\mathbf{A}\mathbf{B}\), each row of \(\mathbf{A}\) has its only possible nonzero entry in a position where the corresponding column of \(\mathbf{B}\) has a zero in that position. Every row-column dot product is therefore zero. Both factors are nonzero, since \(\mathbf{A}\) has diagonal entries \(2,-3\) that are nonzero and \(\mathbf{B}\) has diagonal entry \(5\) that is nonzero.

How the Diagonal Entries Act on a Vector

The same entry pattern explains the effect of a diagonal matrix on a column vector. If \(\mathbf{x}=(x_1,\dots,x_n)^{\top}\), then the \(i\)th entry of \(\mathbf{D}\mathbf{x}\) is \(\sum_{j=1}^{n}d_{ij}x_j=d_i x_i\), because \(d_{ij}=0\) for \(j\ne i\). Thus \(\mathbf{D}\) scales each coordinate separately:

$$ \operatorname{diag}(d_1,\dots,d_n) \begin{bmatrix}x_1\\ \vdots\\ x_n\end{bmatrix} = \begin{bmatrix}d_1x_1\\ \vdots\\ d_nx_n\end{bmatrix}. $$

This coordinate-by-coordinate view matches the product rule: applying \(\mathbf{E}\) first scales coordinate \(i\) by \(e_i\), and then applying \(\mathbf{D}\) scales that coordinate by \(d_i\), giving \(d_i e_i\). It also highlights the limits of the rule. The product formula here applies when both factors are diagonal and of the same order; it does not say that an arbitrary matrix can be multiplied by pairing its diagonal entries.

Common Mistake: Adding Instead of Multiplying

A frequent error is to add corresponding diagonal entries when calculating a matrix product. For example, for \(\mathbf{D}=\operatorname{diag}(2,-1)\) and \(\mathbf{E}=\operatorname{diag}(3,4)\), writing \(\mathbf{D}\mathbf{E}=\operatorname{diag}(5,3)\) incorrectly adds \(2+3\) and \(-1+4\). Matrix multiplication uses products of entries, not sums of matching entries. The correct calculation is

$$ \mathbf{D}\mathbf{E} = \begin{bmatrix}2&0\\0&-1\end{bmatrix} \begin{bmatrix}3&0\\0&4\end{bmatrix} = \begin{bmatrix}2(3)+0(0)&2(0)+0(4)\\ 0(3)+(-1)(0)&0(0)+(-1)(4)\end{bmatrix} = \begin{bmatrix}6&0\\0&-4\end{bmatrix}. $$

Check: the first row times the first and second columns gives \(6\) and \(0\); the second row times those columns gives \(0\) and \(-4\). The result agrees with the diagonal product rule. Adding matching entries belongs to matrix addition, not matrix multiplication.

Check Your Understanding

Use the entry formulas to justify each answer, and check any product by the row-column rule.

  1. Write a general \(3\times3\) diagonal matrix using \(\operatorname{diag}\) notation and state which entries must be zero.
  2. Compute \(5\operatorname{diag}(-2,0,3)\).
  3. Compute \(\operatorname{diag}(1,-4,2)\operatorname{diag}(3,0,-5)\).
  4. Explain why two diagonal matrices of the same order commute.
  5. Give diagonal matrices that are both nonzero but whose product is the zero matrix, and verify the product.

Test yourself: Linear Algebra final exam practice

Ready to check what you know? Work a full-length practice final, then open the complete worked solutions.

Want all 1,114 practice problems?

This tutorial covers one topic. Calc Pass covers the full Calculus AB & BC curriculum (the core of Calculus I and II): full review, every practice question, and step-by-step solutions to each one.

QR code to download the Calc Pass app

Get the Calc Pass App

Scan to download and practice on the go, with instant scoring.

Calc Pass Volume 1: 1,114 Practice Questions book cover

Vol. 1: 1,114 Questions

The complete practice question bank, organized by AB & BC topic.

View on Amazon
Calc Pass Volume 2: Solutions Manual book cover

Vol. 2: Solutions Manual

Fully worked solutions to every question in Volume 1.

View on Amazon