Math & ModelingAdvancedExperiment simulation~25 min

Matrix Transformations and Linear Algebra

Every time a game rotates a character, a phone straightens a photo or a search engine ranks web pages, a computer is multiplying matrices. A matrix is a grid of numbers, but it is also a machine that moves, stretches, flips and squashes space. Multiply matrices step by step, transform shapes in 2D and 3D, watch the determinant measure area, and find the special directions a transformation leaves alone.

Explore

Matrix operations, 2D transformations, determinants (area), eigenvectors and 3D transformations.

Matrix A
Matrix B
2
—
—
—
—
—
—
—
—
—
—
—
—

How to use this simulator

  1. In Algebra, set the size of A and B, type their entries, and choose an operation. Tap any entry of the result to see its working; for A · B, the row and column that combine are highlighted. Press Start to step through every entry. Invalid sizes are explained instead of computed.
  2. In 2D, choose a shape and up to two transformations, change their parameters, switch the order, and drag the shape. Press Show that order matters, or Start to animate from the identity.
  3. In Area, drag the red and green arrow tips (the columns of the matrix) and watch the unit square’s area and orientation.
  4. In Eigen, try the presets and drag the blue test vector v. Green arrows are vectors that stay on their own line.
  5. In 3D, scale, rotate and reflect the block, and orbit the camera to look at it from any side.

Learning objectives

  • Describe matrices by their size and carry out addition, subtraction, scalar multiplication, multiplication and transposition.
  • Decide when a matrix operation is defined, and explain why AB ≠ BA in general.
  • Interpret a matrix as a linear transformation and use homogeneous coordinates for translations.
  • Interpret the determinant as an area (or volume) scale factor with a sign for orientation.
  • Find the inverse of a 2×2 matrix and explain when no inverse exists.
  • Explain eigenvalues and eigenvectors with A v = λ v, including matrices with no real eigenvectors.

What a matrix is

A matrix is a rectangular array of numbers. Its size (or dimensions) is written rows × columns: a 2×3 matrix has 2 rows and 3 columns. The entry in row i and column j is written aij. Asquare matrix has as many rows as columns, and the identity matrix I has 1s on its diagonal and 0s elsewhere: multiplying by I changes nothing.

Matrix operations

  • Addition and subtraction: only for matrices of the same size; add or subtract matching entries.
  • Scalar multiplication: k·A multiplies every entry by the number k.
  • Transpose: Aᵀ swaps rows and columns, so (Aᵀ)ij = aji and an m×n matrix becomes n×m.

Matrix multiplication

The product AB is defined only when the number of columns of A equals the number of rows of B. If A is m×n and B is n×p, then AB is m×p, and each entry is a row of A “dotted” with a column of B:

(AB)ij = ai1b1j + ai2b2j + … + ainbnj

Matrix multiplication is associative ((AB)C = A(BC)) but not commutative: AB and BA are usually different, and one can exist while the other does not.

Matrices as transformations

Multiplying a column vector by a matrix transforms it. In this lab, points are column vectors and the matrix acts on the left: p′ = M p. The columns of a 2×2 matrix show where the basis vectors î = (1, 0) and ĵ = (0, 1) land, and every other point follows: (x, y) ↦ x·î′ + y·ĵ′. Such a linear transformation keeps the origin fixed and turns straight lines into straight lines and parallel lines into parallel lines.

Transformation2×2 matrix
Scale by sₓ and s_y[sₓ 0; 0 s_y]
Rotate anticlockwise by θ[cos θ −sin θ; sin θ cos θ]
Reflect in the line at angle φ through the origin[cos 2φ sin 2φ; sin 2φ −cos 2φ]
Shear (horizontal k, vertical m)[1 k; m 1]

To apply T₁ and then T₂, multiply the matrices as T₂ · T₁: the transformation applied first sits next to the vector. Because multiplication is not commutative, the order changes the result. (Some books and graphics tools use row vectors, p′ = p M, which reverses the order of every product; this lab uses column vectors throughout.)

Homogeneous coordinates

A translation moves the origin, so it is not a linear transformation and no 2×2 matrix can do it. The trick is to write each point as a 3-component column (x, y, 1). Then a translation becomes the 3×3 matrix [1 0 tₓ; 0 1 t_y; 0 0 1], and rotations, scalings, reflections and shears put their 2×2 matrix in the top-left corner. Every combination of these is one 3×3 matrix product, which is how computer graphics handles them.

The determinant

For a 2×2 matrix, det [a b; c d] = ad − bc. Geometrically, |det A| is the factor by which A scales areas: the unit square becomes a parallelogram of area |det A|. The sign shows orientation: a negative determinant means the transformation includes a reflection, so shapes come out as mirror images. If det A = 0 the plane is squashed onto a line or a point. For 3×3 matrices the determinant scales volumes; it can be calculated by expanding along a row: det A = a11·det M11 − a12·det M12 + a13·det M13, where M1j is A with row 1 and column j removed.

The inverse

The inverse A⁻¹ undoes A: A·A⁻¹ = A⁻¹·A = I. Only square matrices with det A ≠ 0 have one (they are called invertible or non-singular). For a 2×2 matrix,A⁻¹ = 1/(ad − bc) · [d −b; −c a]. In general A⁻¹ = adj(A)/det A, where the adjugate adj(A) is the transpose of the matrix of cofactors. A singular matrix (det A = 0) has no inverse because it loses information: many points land on the same place, so you cannot tell where they came from.

Eigenvalues and eigenvectors

An eigenvector of A is a non-zero vector v that A only stretches, shrinks or reverses, without turning it off its line: A v = λ v. The number λ is its eigenvalue. For a 2×2 matrix the eigenvalues solve λ² − (a + d)λ + (ad − bc) = 0, the characteristic equation.

  • Two different real roots: two eigen-directions (for example a stretch, or the symmetric matrix [2 1; 1 2]).
  • A repeated root: either every vector is an eigenvector (A = λI) or there is only one eigen-direction (a shear).
  • Complex roots: no real eigenvectors at all. A rotation by 90° turns every vector, so nothing keeps its direction.

The product of the eigenvalues equals det A, and their sum equals the trace a + d.

3D transformations

In 3D, 3×3 matrices scale, rotate and reflect objects about the origin. The lab builds M = F·R·S: scale first, then rotate about one axis, then reflect in a coordinate plane. Its determinant scales volume, and a negative determinant produces a mirror image that no rotation could reach. Orbiting the camera changes your viewpoint only: the object and its matrix stay the same.

Formula reference

FormulaMeaning and conditions
(A ± B)ij = aij ± bijA and B the same size
(kA)ij = k·aijk is a number (a scalar)
(AB)ij = Σk aikbkjA is m×n, B is n×p; AB is m×p
(Aᵀ)ij = ajiTranspose: rows become columns
det [a b; c d] = ad − bcSigned area-scaling factor (square matrices only)
A⁻¹ = 1/(ad − bc) · [d −b; −c a]2×2 inverse; exists only if ad − bc ≠ 0
p′ = M p, with p = (x, y, 1)Homogeneous 2D transformation, column-vector convention
A v = λ v, v ≠ 0Eigenvector v with eigenvalue λ
λ² − (a + d)λ + (ad − bc) = 0Characteristic equation of a 2×2 matrix

Real-world applications

  • Computer graphics and games: every frame, 4×4 homogeneous matrices position, rotate and project millions of points onto the screen.
  • Robotics: chains of transformation matrices locate a robot arm’s hand from its joint angles.
  • Engineering: large systems of linear equations for structures and circuits are solved with matrices.
  • Data science: principal component analysis finds the eigenvectors of a data set’s covariance matrix to reveal its main directions of variation.
  • Search and networks: Google’s original PageRank was an eigenvector of a huge matrix of links between pages.
  • Physics: eigenvalues give the energy levels in quantum mechanics and the natural vibration frequencies of bridges and buildings.

Interesting facts

  • The word “matrix” was introduced by James Joseph Sylvester in 1850; Arthur Cayley defined matrix multiplication in 1858.
  • Chinese mathematicians solved systems of equations with grids of numbers, much like matrices, about 2,000 years ago in The Nine Chapters on the Mathematical Art.
  • Multiplying two n×n matrices the schoolbook way takes about n³ multiplications; cleverer algorithms, starting with Strassen’s in 1969, need fewer.
  • Graphics cards are, at heart, machines for multiplying matrices very quickly, which is why they also power modern AI.

Common misconceptions

  • “AB = BA.” Usually false, and one product may not even be defined.
  • “Multiply matrices entry by entry.” The matrix product combines rows with columns.
  • “Any square matrix has an inverse.” Only if its determinant is not zero.
  • “A negative determinant means negative area.” Area scales by |det|; the sign only records a flip.
  • “Every matrix has real eigenvectors.” Rotations, for example, have none.
  • “A matrix transformation is the same as adding vectors.” Adding a vector only shifts points; a matrix can rotate, stretch, shear and reflect them.

Important terms

Matrix
A rectangular array of numbers with a size rows × columns.
Identity matrix
The square matrix I with 1s on the diagonal; AI = IA = A.
Transpose
The matrix with rows and columns swapped.
Determinant
A number from a square matrix: its signed area or volume scale factor.
Inverse
The matrix that undoes A; exists only when det A ≠ 0.
Linear transformation
A map that keeps the origin fixed and preserves addition and scaling of vectors.
Homogeneous coordinates
Writing (x, y) as (x, y, 1) so translations become matrix products.
Eigenvector and eigenvalue
A non-zero v and number λ with A v = λ v.

Key takeaways

  • Check sizes first: AB needs columns of A = rows of B.
  • A matrix is a transformation; its columns show where the basis vectors go.
  • Order matters: “T₁ then T₂” is T₂·T₁ with column vectors.
  • |det| scales area or volume; a negative sign flips orientation; zero means no inverse.
  • Eigenvectors keep their line; eigenvalues tell how much they stretch, and some matrices have none that are real.

Knowledge check

Matrix Transformations and Linear Algebra: test your understanding

Answer each question to get instant feedback and an explanation. Use the simulator to check your thinking.

10 questions4 intermediate4 basic2 advanced

0 of 10 answered

  1. Q1IntermediateA is a 2×3 matrix and B is a 3×4 matrix. What is the size of AB, and is BA defined?
    Show answer

    Answer: B. AB is 2×4; BA is not defined

    AB needs the columns of A (3) to equal the rows of B (3), and has the outer sizes 2×4. BA would need the columns of B (4) to equal the rows of A (2), so it is not defined.

  2. Q2BasicFor A = [1 2; 3 4] and B = [5 6; 7 8], what is the entry in row 1, column 2 of AB?
    Show answer

    Answer: D. 22

    Row 1 of A times column 2 of B: 1·6 + 2·8 = 6 + 16 = 22.

  3. Q3IntermediateIn the 2D view, “rotate 90° then stretch sideways” gives a different shape from “stretch sideways then rotate 90°”. What does this show?
    Show answer

    Answer: A. Matrix multiplication is not commutative: in general AB ≠ BA

    Combining transformations multiplies their matrices, and the order of multiplication matters. With column vectors, “T₁ then T₂” is the product T₂·T₁.

  4. Q4IntermediateWhy do 2D transformations that include a translation use 3×3 matrices?
    Show answer

    Answer: C. A translation is not linear (it moves the origin), so points are written as (x, y, 1) to make it a matrix product

    Every 2×2 matrix keeps the origin fixed. Homogeneous coordinates add a 1, so that [1 0 tₓ; 0 1 t_y; 0 0 1] shifts every point by (tₓ, t_y).

  5. Q5IntermediateA 2×2 matrix has determinant −3. What does it do to the unit square?
    Show answer

    Answer: B. Maps it to a parallelogram of area 3 with its orientation reversed

    |det| = 3 is the area-scaling factor, and the negative sign means the image is a mirror image (orientation flips). Areas themselves are never negative.

  6. Q6BasicWhat is the determinant of [2 4; 1 2], and what does it tell you?
    Show answer

    Answer: D. 0: the plane collapses onto a line, so the matrix has no inverse

    det = 2·2 − 4·1 = 0. The two columns point the same way, so every vector lands on one line. Information is lost and cannot be undone.

  7. Q7AdvancedWhat is the inverse of A = [1 2; 3 4]?
    Show answer

    Answer: A. [−2 1; 3/2 −1/2]

    det A = 4 − 6 = −2, so A⁻¹ = (1/−2)·[4 −2; −3 1] = [−2 1; 3/2 −1/2]. Check: A·A⁻¹ = I.

  8. Q8BasicWhat does A v = λ v mean for an eigenvector v?
    Show answer

    Answer: C. A only stretches, shrinks or reverses v along its own line, by the factor λ

    An eigenvector keeps its line through the origin. The eigenvalue λ is the scale factor: |λ| > 1 stretches, |λ| < 1 shrinks, and a negative λ reverses the direction.

  9. Q9AdvancedIn the Eigen view, a 90° rotation matrix [0 −1; 1 0] shows no green eigen-lines. Why?
    Show answer

    Answer: A. Its eigenvalues are complex (±i), so no real vector keeps its direction

    λ² + 1 = 0 has no real solutions. A rotation turns every non-zero vector, so it has no real eigenvectors, even though it is invertible (det = 1).

  10. Q10BasicIn the 3D view you drag to orbit the camera around the transformed block. What happens to the transformation matrix?
    Show answer

    Answer: D. Nothing: moving the camera changes the viewpoint, not the object or its matrix

    Transforming an object changes its coordinates; moving the camera only changes how we look at it. The matrix, its determinant and the object stay the same.

References and further reading

  1. Abramson, J. (2021). Precalculus 2e, Section 9.5: Matrices and Matrix Operations; 9.7: Solving Systems with Inverses; 9.8: Solving Systems with Cramer’s Rule. OpenStax. openstax.org (opens in a new tab)
  2. Strang, G. (2016). Introduction to Linear Algebra (5th ed.). Wellesley-Cambridge Press.
  3. Foley, J. D., van Dam, A., Feiner, S. K., & Hughes, J. F. (1995). Computer Graphics: Principles and Practice (2nd ed.), Chapter 5: Geometrical Transformations. Addison-Wesley.
  4. Nicholson, W. K. (2021). Linear Algebra with Applications (Lyryx open edition), Chapters 2–3 and 5. lyryx.com (opens in a new tab)

This simulator is a simplified educational model. Found an error? Let us know. See our educational disclaimer.