viewof shear = Inputs.range([-2, 2], {
value: 0.8,
step: 0.05,
label: "Shear s"
})
viewof scaleX = Inputs.range([0.25, 2.5], {
value: 1.5,
step: 0.05,
label: "Horizontal scale λ"
})
viewof x1 = Inputs.range([-2, 2], {
value: 1,
step: 0.05,
label: "Sample vector x-coordinate"
})
viewof x2 = Inputs.range([-2, 2], {
value: 1,
step: 0.05,
label: "Sample vector y-coordinate"
})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.
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 sHorizontal 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
- MIT 18.06SC: Linear Transformations and their Matrices -
First pass- official source for the basis-image and composition viewpoint. Checked2026-04-24. - Introduction to Applied Linear Algebra – Vectors, Matrices, and Least Squares -
Second pass- good computational reinforcement on transformations and maps. Checked2026-04-24. - Deep learning, transformers and graph neural networks: a linear algebra perspective -
Paper bridge- useful later, when you want to see modern learned operators through the same lens. Checked2026-04-24.