Courses / Computer Science I
Algebra

Matrices and Matrix Operations

Computer Science I 238 words Free to read

Matrices and Basic Operations

A matrix is a rectangular array of numbers arranged in rows and columns. An m×nm \times n matrix has mm rows and nn columns. They compactly represent linear systems, transformations, and data tables.

OperationRuleShape Requirement
AdditionAdd entry by entrySame shape (m×nm \times n)
Scalar MultiplicationMultiply every entry by a scalarAny shape

The identity matrix II has ones on the diagonal and zeros elsewhere, acting like the number 1 so that AI=AAI = A. A square matrix may have an inverse A1A^{-1} where AA1=IAA^{-1} = I, though not all matrices are invertible.

Matrix Multiplication & Transformations

The product ABAB is defined only when the number of columns of AA equals the number of rows of BB. An m×nm \times n times an n×pn \times p matrix yields an m×pm \times p result. Entry (i,j)(i, j) is the dot product of row ii of AA and column jj of BB.

Matrix multiplication is not commutative: in general ABBAAB \neq BA, though it is associative A(BC)=(AB)CA(BC) = (AB)C. This odd rule matters because a matrix represents a linear transformation, and multiplying matrices composes those transformations in sequence.

Common pitfall: Never multiply matrices entry-by-entry. Always use the dot product of a row and a column, and verify that shapes match.
Two grouping paths for the same three matrices, meeting at one answer

Practise this lesson

The explanation above is free to read. The graded practice for this lesson lives in the Tryals app.

9practice questions
2interactive scenes

Algebra