Computation Lab: Matrix Composition and Basis Action

An interactive lab for seeing how a matrix acts on basis vectors and how composing two maps differs from applying either one alone.
Modified

April 26, 2026

Keywords

computation, simulation, visualization, matrices, composition

1 Lab Goal

This lab helps you see one specific fact:

a matrix is fully determined by what it does to the basis vectors, and composing two maps creates a new matrix whose action depends on order.

2 Math Question

How do shear and scale maps affect:

  • the images of \(e_1\) and \(e_2\)
  • the image of a sample vector
  • the composed map \(AB\) versus \(BA\)

3 Model or Setup

We use two linear maps in \(\mathbb{R}^2\):

\[ B = \begin{bmatrix} 1 & s \\ 0 & 1 \end{bmatrix}, \qquad A = \begin{bmatrix} \lambda & 0 \\ 0 & 1 \end{bmatrix}. \]

Here \(B\) is a shear and \(A\) rescales the first coordinate.

4 Parameters and Controls

  • Shear s
  • Horizontal scale λ
  • Sample vector x

Defaults are 0.8, 1.5, and \(x=(1,1)\).

5 Code and Simulation

6 What To Observe

  • The images of \(e_1\) and \(e_2\) are exactly the columns of each matrix.
  • The composed images \(ABx\) and \(BAx\) usually differ.
  • Changing the shear alters how much the second basis direction spills into the first coordinate.
  • Changing the scale changes the effect of composition depending on when the scaling happens.

7 Interpretation

The plot is showing three core claims from the concept page:

  • columns record basis images
  • one matrix is one linear rule
  • composition becomes matrix multiplication, and order matters

8 Failure Modes and Numerical Cautions

  • This lab is deterministic and tiny, so it hides numerical conditioning issues.
  • In higher dimensions you cannot inspect basis images visually as easily, but the algebra stays the same.
  • A composition can look visually similar for one sample vector even when the matrices differ strongly.

9 Reproducibility Notes

  • execution engine: Observable JS
  • randomness: none
  • libraries: Quarto OJS with Plot and Inputs
  • render mode: interactive client-side

10 Extensions

  • replace the scaling map by a rotation-like matrix
  • compare one map written in two different bases

11 Sources and Further Reading

Back to top