Linear Algebra

1.3 Matrices and Matrix Operations

Imron Rosyadi

Matrices and Matrix Operations

Beyond augmented matrices for linear systems, rectangular arrays of numbers are fundamental entities in their own right. In this section, we define matrices and their basic arithmetic operations.

We will cover:

  • Matrix notation and terminology.
  • Basic matrix operations: equality, addition, subtraction, scalar multiplication.
  • The crucial operation of matrix multiplication.
  • Special concepts: partitioned matrices, linear combinations, transpose, and trace.

Matrix Notation and Terminology

A matrix is a rectangular array of numbers. The numbers are called entries.

Example: Student study hours (Mon-Sun over 3 subjects) \[ \left[{\begin{array}{c c c c c c c}{2}&{3}&{2}&{4}&{1}&{4}&{2}\\ {0}&{3}&{1}&{4}&{3}&{2}&{2}\\ {4}&{1}&{3}&{1}&{0}&{0}&{2}\end{array}}\right] \]

  • Size: Described by rows x columns (e.g., \(3 \times 7\)).
  • Row Vector (Row Matrix): One row (e.g., \([2 \ 1 \ 0 \ -3]\)).
  • Column Vector (Column Matrix): One column (e.g., \(\left[\begin{smallmatrix} 1 \\ 3 \\ 3 \end{smallmatrix}\right]\)).
  • Square Matrix of order \(n\): \(n\) rows and \(n\) columns.
  • Entry Notation: \(a_{ij}\) (or \((A)_{ij}\)) denotes the entry in row \(i\) and column \(j\).
  • Main Diagonal: For a square matrix, entries \(a_{11}, a_{22}, \ldots, a_{nn}\).

\[ A = \left[ \begin{array}{cccc}a_{11} & a_{12} & \dots & a_{1n}\\ a_{21} & a_{22} & \dots & a_{2n}\\ \vdots & \vdots & & \vdots \\ a_{m1} & a_{m2} & \dots & a_{mn} \end{array} \right] \quad \text{general } m \times n \text{ matrix} \]

Matrix Equality, Addition, and Subtraction

Matrix Equality

Two matrices \(A\) and \(B\) are equal if:

  1. They have the same size.
  2. Their corresponding entries are equal (\(a_{ij} = b_{ij}\) for all \(i,j\)).

Example: \(A = \left[\begin{smallmatrix} 2 & 1 \\ 3 & x \end{smallmatrix}\right]\), \(B = \left[\begin{smallmatrix} 2 & 1 \\ 3 & 5 \end{smallmatrix}\right]\). \(A=B\) iff \(x=5\).

Matrix Addition and Subtraction

If \(A\) and \(B\) are matrices of the same size:

  • Sum \(A+B\): Obtained by adding corresponding entries. \((A+B)_{ij} = a_{ij} + b_{ij}\).
  • Difference \(A-B\): Obtained by subtracting corresponding entries. \((A-B)_{ij} = a_{ij} - b_{ij}\). Matrices of different sizes cannot be added or subtracted.

Interactive Example: Matrix Operations

Let’s demonstrate matrix addition and subtraction with Python:

Scalar Multiplication

If \(A\) is any matrix and \(c\) is any scalar (real number), then the product \(cA\) is the matrix obtained by multiplying each entry of \(A\) by \(c\). \(cA\) is called a scalar multiple of \(A\).

In matrix notation: \((cA)_{ij} = c(A)_{ij} = ca_{ij}\).

Example: For \(A = \left[\begin{smallmatrix} 2 & 3 & 4 \\ 1 & 3 & 1 \end{smallmatrix}\right]\), then \(2A = \left[\begin{smallmatrix} 4 & 6 & 8 \\ 2 & 6 & 2 \end{smallmatrix}\right]\).

It is common practice to denote \((-1)B\) by \(-B\).

Application in ECE: Scaling measurements from sensors, adjusting signal amplitudes, or weighting different components in a multi-input system.

Matrix Multiplication (Product)

This is the most complex, but most powerful, basic matrix operation.

If \(A\) is an \(m \times r\) matrix and \(B\) is an \(r \times n\) matrix, then the product \(AB\) is the \(m \times n\) matrix.

Crucial Compatibility Rule: The number of columns of the first matrix (\(A\)’s columns, \(r\)) must equal the number of rows of the second matrix (\(B\)’s rows, \(r\)).

  • If compatible (\(m \times \mathbf{r} \cdot \mathbf{r} \times n\)), the resulting product matrix has size \(m \times n\).

Row-Column Rule: To find the entry \((AB)_{ij}\) (row \(i\), column \(j\) of \(AB\)), you single out row \(i\) from \(A\) and column \(j\) from \(B\). Multiply corresponding entries from the selected row and column, and then add up the resulting products. \[ (AB)_{ij} = a_{i1}b_{1j} + a_{i2}b_{2j} + \dots + a_{ir}b_{rj} \]

Example 5: Multiplying Matrices

Find \(AB\) for: \[ A={\left[\begin{array}{l l l}{1}&{2}&{4}\\ {2}&{6}&{0}\end{array}\right]},\quad B={\left[\begin{array}{l l l l}{4}&{1}&{4}&{3}\\ {0}&{-1}&{3}&{1}\\ {2}&{7}&{5}&{2}\end{array}\right]} \] \(A\) is \(2 \times \mathbf{3}\) and \(B\) is \(\mathbf{3} \times 4\). Product \(AB\) will be \(2 \times 4\).

Let’s compute \((AB)_{23}\) (row 2, col 3): \((2 \cdot 4) + (6 \cdot 3) + (0 \cdot 5) = 8 + 18 + 0 = 26\)

Let’s compute \((AB)_{14}\) (row 1, col 4): \((1 \cdot 3) + (2 \cdot 1) + (4 \cdot 2) = 3 + 2 + 8 = 13\)

The full product: \[ A B={\left[\begin{array}{l l l l}{12}&{27}&{30}&{13}\\ {8}&{-4}&{26}&{12}\end{array}\right]} \]

Applications in ECE:

  • Transformations: Rotating, scaling, or projecting vectors in graphics and robotics.
  • Circuit Analysis: Solving network equations (e.g., \(V = IZ\)), impedance, and admittance matrices.
  • Digital Signal Processing (DSP): Filtering operations, Fourier transforms can be expressed as matrix multiplications.

Interactive Example: Matrix Multiplication

Let’s use Python to compute the full matrix product:

Matrix Multiplication by Columns and By Rows

Matrix multiplication can be viewed column by column or row by row:

If \(AB\) is defined,

  1. \(j\)-th column of \(AB\) is \(A\) times the \(j\)-th column of \(B\). \[ AB = A[\mathbf{b}_1\quad \mathbf{b}_2\quad \dots \quad \mathbf{b}_n] = [A\mathbf{b}_1\quad A\mathbf{b}_2\quad \dots \quad A\mathbf{b}_n] \]
  2. \(i\)-th row of \(AB\) is \(i\)-th row of \(A\) times \(B\). \[ AB = \left[ \begin{array}{c}\mathbf{a}_1\\ \mathbf{a}_2\\ \vdots \\ \mathbf{a}_m \end{array} \right]B = \left[ \begin{array}{c}\mathbf{a}_1B\\ \mathbf{a}_2B\\ \vdots \\ \mathbf{a}_mB \end{array} \right] \]

This is useful for computing specific rows or columns without the full product.

Matrix Products as Linear Combinations

A linear combination of matrices \(A_1, \ldots, A_r\) with scalars \(c_1, \ldots, c_r\) is \(c_1A_1 + c_2A_2 + \dots + c_rA_r\).

Theorem 1.3.1: If \(A\) is an \(m \times n\) matrix and \(\mathbf{x}\) is an \(n \times 1\) column vector, then the product \(A\mathbf{x}\) can be expressed as a linear combination of the column vectors of \(A\), in which the coefficients are the entries of \(\mathbf{x}\).

\(A\mathbf{x} = x_1(\text{col }_1 \text{ of } A) + x_2(\text{col }_2 \text{ of } A) + \dots + x_n(\text{col }_n \text{ of } A)\)

Example 8: \[ {\left[\begin{array}{l l l}{-1}&{3}&{2}\\ {1}&{2}&{-3}\\ {2}&{1}&{-2}\end{array}\right]}{\left[\begin{array}{l}{2}\\ {-1}\\ {3}\end{array}\right]}={\left[\begin{array}{l}{1}\\ {-9}\\ {-3}\end{array}\right]} \] This is equivalent to: \[ 2{\left[\begin{array}{l}{-1}\\ {1}\\ {2}\end{array}\right]} - 1{\left[\begin{array}{l}{3}\\ {2}\\ {1}\end{array}\right]} + 3{\left[\begin{array}{l}{2}\\ {-3}\\ {-2}\end{array}\right]} = {\left[\begin{array}{l}{1}\\ {-9}\\ {-3}\end{array}\right]} \]

Application in ECE: This is fundamental for understanding superposition principles in circuits, representing signals as combinations of basis functions (like Fourier series), or combining effects of multiple inputs in control systems.

Matrix Form of a Linear System

Any system of \(m\) linear equations in \(n\) unknowns can be written compactly as a single matrix equation: \[ A\mathbf{x} = \mathbf{b} \] Where:

  • \(A\) is the coefficient matrix (\(m \times n\)).
  • \(\mathbf{x}\) is the unknown vector (\(n \times 1\)).
  • \(\mathbf{b}\) is the constant vector (\(m \times 1\)).

Example: \[ \begin{array}{c}x_{1} - 2x_{2} + x_{3} = 0\\ 2x_{1} + 0x_{2} + 3x_{3} = 5\end{array} \quad \rightarrow \quad \left[ \begin{array}{r r r}{1} & -2 & 1\\ 2 & 0 & 3 \end{array} \right]\left[ \begin{array}{c}{x_{1}}\\{x_{2}}\\{x_{3}}\end{array} \right] = \left[ \begin{array}{c}{0}\\{5}\end{array} \right] \]

The augmented matrix for the system is \([A \mid \mathbf{b}]\).

Application in ECE: This compact notation simplifies the representation and analysis of large, complex systems found in circuits, control, and power systems. Rather than writing out pages of individual equations, we can deal with the entire system as one matrix equation.

Transpose of a Matrix

The transpose of an \(m \times n\) matrix \(A\), denoted by \(A^T\), is the \(n \times m\) matrix obtained by interchanging the rows and columns of \(A\).

  • The first column of \(A^T\) is the first row of \(A\), and so on.
  • The entry in row \(i\), column \(j\) of \(A^T\) is \((A^T)_{ij} = (A)_{ji}\).

Example: \[ A=\left[\begin{array}{c c c}{{1}}&{{-2}}&{{4}}\\ {{3}}&{{7}}&{{0}}\\ {{-5}}&{{8}}&{{6}}\end{array}\right] \quad \rightarrow \quad A^{T}=\left[\begin{array}{c c c}{{1}}&{{3}}&{{-5}}\\ {{-2}}&{{7}}&{{8}}\\ {{4}}&{{0}}&{{6}}\end{array}\right] \] For a square matrix, this is like “reflecting” the matrix entries about its main diagonal.

Application in ECE:

  • Signal Processing: Analyzing properties of signals and systems, e.g., in covariance matrices for noisy signals.
  • Data Science/ML: Reshaping data for algorithms, in least squares regression and principal component analysis (PCA).
  • Quantum Mechanics: Representing operators and states in quantum computing.

Transpose of a Matrix

Trace of a Matrix

If \(A\) is a square matrix, then the trace of \(A\), denoted by \(\operatorname{tr}(A)\), is defined to be the sum of the entries on the main diagonal of \(A\). The trace of \(A\) is undefined if \(A\) is not a square matrix.

Example: For \(A = \left[\begin{smallmatrix} a_{11} & a_{12} & a_{13} \\ a_{21} & a_{22} & a_{23} \\ a_{31} & a_{32} & a_{33} \end{smallmatrix}\right]\), \(\operatorname{tr}(A) = a_{11} + a_{22} + a_{33}\).

For \(B = \left[\begin{smallmatrix} -1 & 2 & 7 & 0 \\ 3 & 5 & -8 & 4 \\ 1 & 2 & 7 & -3 \\ 4 & -2 & 1 & 0 \end{smallmatrix}\right]\), \(\operatorname{tr}(B) = -1 + 5 + 7 + 0 = 11\).

Application in ECE:

  • Control Systems: Used in system analysis, e.g., in stability criteria and Lyapunov equations.
  • Quantum Mechanics: Represents observable quantities; used in density matrices.
  • Numerical Analysis: Useful properties for eigenvalue calculations.

Trace of a Matrix

Conclusion

  • Matrices are powerful data structures: Representing data and relationships in a structured way (e.g., sensor arrays, system states).
  • Core Operations:
    • Addition & Subtraction: Element-wise (same size required).
    • Scalar Multiplication: Scales all entries by a constant.
    • Matrix Multiplication: Row-column rule (inner dimensions must match)  —  represents linear transformations and data interaction.
  • Conceptual Depth: Matrix products as linear combinations (superposition, basis vectors).
  • Special Operations:
    • Transpose (\(A^T\)): Swaps rows and columns (data reorientation).
    • Trace (\(\operatorname{tr}(A)\)): Sum of main diagonal elements (for square matrices, revealing system properties).
  • Ubiquitous in ECE: These operations form the bedrock of numerical methods for solving problems in circuits, signals, control, robotics, imaging, communication, and machine learning.

Mastering these matrix operations is essential for your engineering toolkit!

Exercises

grasple_exercise_3_2_2

To compute \(c_1A + c_2B\).

Exercises

grasple_exercise_3_2_3

To compute \(c_1A + c_2B\).