⬜ Matrix Transformations
Edit the 2×2 matrix entries and watch the coordinate grid transform in real time. Rotate, scale, shear, reflect — see eigenvectors glow as they stay on their lines, and watch the determinant measure the area change.
How to read this
The light grey grid shows the original coordinate system. The coloured grid shows the same grid after the matrix transformation. The red arrow is the transformed î = (1,0) basis vector; the blue arrow is ĵ = (0,1). Eigenvectors (yellow) are special vectors that only stretch or flip — they never rotate.
Key concepts
A 2×2 matrix
M = [[a,b],[c,d]] transforms
every point (x,y) → (ax+by, cx+dy). The
determinant det(M) = ad−bc
measures how area changes: det=1 preserves area, det=−1 reflects,
det=0 collapses space to a line (or point).
Eigenvalues λ satisfy Mv =
λv — the matrix only stretches the eigenvector by λ, never rotates
it. Real eigenvalues exist when the discriminant (trace² − 4·det) ≥
0. λ = (trace ± √(trace²−4·det)) / 2.
About this Simulation
This visualizer applies a live-editable 2×2 matrix M = [[a,b],[c,d]] to every point of the plane via (x,y) → (ax+by, cx+dy), redrawing the coordinate grid, the unit circle and the basis vectors î, ĵ each frame so the linear map is visible as continuous motion rather than an abstract formula. Alongside the grid, the code computes trace = a+d and det = ad−bc, then solves the characteristic equation λ² − trace·λ + det = 0 for the matrix's eigenvalues; whenever the discriminant trace²−4det is non-negative it also recovers the matching eigenvectors from (M−λI)v = 0 and draws them as dashed yellow lines that pass straight through the transformation unrotated. Eight presets (identity, two rotations, uniform scale, horizontal shear, both axis reflections, and a general "compress" matrix) let you jump straight to canonical cases, while a classifier below the canvas names whatever matrix the four sliders currently describe.
🔍 What it shows
How any 2×2 linear map bends the coordinate grid and the unit circle into an ellipse in real time: the transformed î and ĵ arrows are literally the matrix's own columns, the determinant reported in the stats bar equals the area-scale factor (and its sign flags a reflection), and any real eigenvectors are drawn as dashed lines that only stretch — never rotate — as the animation morphs from the identity matrix to your matrix.
🖱️ How to use it
Drag the a, b, c, d sliders to build any matrix, or click a preset (Identity, Rotate 45°/90°, Scale ×2, Shear X, Reflect X/Y, Compress) to load one instantly. Toggle the Grid, Basis vectors, Eigenvectors and Unit circle layers on or off, and use Animate to watch the morph from identity to your current matrix; press the ? button for the full formula reference panel.
💡 Did you know?
A pure rotation matrix always has complex eigenvalues (unless it rotates by 0° or 180°) — because a genuine rotation turns every vector to a new direction, no real vector can stay pinned to its own line, so there is no real eigenvector for the visualizer to draw, and the stats bar reports λ₁ and λ₂ as "complex" instead.
Frequently Asked Questions
What does a 2×2 matrix actually do to the plane?
A 2×2 matrix M = [[a,b],[c,d]] is a linear map that sends every point (x,y) to (ax+by, cx+dy). Because the map is linear, straight lines stay straight, the origin never moves, and parallel lines stay parallel — only the grid's angles and spacing change. In this visualizer the transformed coordinate grid is drawn by applying exactly this formula to every grid line, and the two colored arrows show where the basis vectors î=(1,0) and ĵ=(0,1) land — those images are simply the matrix's own columns (a,c) and (b,d).
How does the visualizer compute the eigenvalues and eigenvectors?
The code first computes trace = a+d and det = ad−bc, then solves the characteristic equation λ² − trace·λ + det = 0 directly with the quadratic formula λ = (trace ± √(trace²−4·det))/2. If the discriminant trace²−4·det is negative the eigenvalues are complex and no real eigenvectors are drawn. For each real eigenvalue λ, the eigenvector is read off from the first row of (M−λI)v=0, giving v=(−b,a); if b is numerically zero it falls back to the second row instead, avoiding division by zero.
What does the determinant tell you here, and how is it used?
det(M) = ad−bc measures how the transformation scales area: the stats bar and the orange transformed unit-circle-turned-ellipse both reflect it directly, since the ellipse's area equals |det(M)| times the original circle's area. A positive determinant preserves orientation, a negative one flips it (a reflection), and det=0 means the matrix is singular — it squashes the whole 2D plane onto a single line or point, which the visualizer reports as the "Singular (collapses)" type.
Why do the eigenvectors stay on the same line while everything else rotates?
By definition an eigenvector v satisfies Mv = λv: the matrix maps it to a scalar multiple of itself, so its direction (or exact opposite, for negative λ) never changes, only its length. The visualizer highlights this by drawing each eigenvector as a dashed yellow line through the origin and animating the matrix from identity to M — every other vector in the grid visibly rotates and stretches, but the eigenvector arrows just grow or shrink along their original dashed line, which is exactly what "only stretches, never rotates" means algebraically.
Why do some matrices in this tool have no real eigenvectors at all?
A rotation matrix has trace²−4·det < 0 for any angle other than 0° or 180°, since rotations satisfy trace=2cosθ and det=1, giving a discriminant of 4cos²θ−4 which is negative whenever cosθ ≠ ±1. Geometrically this makes sense: a genuine rotation turns every nonzero vector to a new direction, so no real vector can stay on its own line and be a candidate eigenvector — the eigenvalues instead form a complex-conjugate pair e^{±iθ}, and the visualizer correctly reports "complex" for λ₁ and λ₂ and skips drawing eigenvector lines in that case.