Gradient Lab
Eigenvector Spotter
Given a 2x2 matrix and four candidate directions, click the one that A merely stretches instead of rotating - the eigenvector.
How it works
Each round the game builds a random 2x2 matrix A = P·D·P⁻¹ from a random invertible integer matrix P and a diagonal D with two distinct nonzero integer eigenvalues. By construction the columns of P are exactly the eigenvectors of A. You are shown A (entries displayed rounded to 2 decimals, computed at full precision) and four labeled arrows on a small plot: one true eigenvector and three decoy directions, each checked at generation time to not be an eigenvector and to not be parallel to either true eigenvector.
Click the direction that stays on its own line when A is applied - the one A only stretches or flips. After you pick, the reveal shows A·v for your choice and states whether the result is a scalar multiple of the input. The correctness test in the code is the cross product: v is an eigenvector when (Av)ₓ·vᵧ - (Av)ᵧ·vₓ is zero (within 1e-6), meaning Av and v are parallel.
There is one correct option per round - the puzzle deliberately excludes the other eigenvector from the candidates. Press next for a fresh matrix; rounds continue indefinitely.
How scoring works
Score goes up by 1 for each correct first click; the round counter goes up by 1 either way. There are no points for speed, no streak bonus, and no penalty beyond the missed point. The HUD shows ROUND and SCORE for the session.
What an eigenvector actually is
An eigenvector of A is a nonzero direction v with Av = λv: the matrix moves every point on that line to another point on the same line, scaling by the eigenvalue λ. A negative λ flips the direction but keeps the line, which the game counts as staying on its own line - flips are allowed, rotation is not.
The test the game itself runs is the one you should run mentally: compute Av and check whether it is proportional to v. Two vectors (p, q) and (r, s) are parallel exactly when the cross product p·s - q·r is zero. That is one multiplication pattern, no division, and no need to find λ first - which matters because the matrix entries are messy decimals while the candidates are small integers.
Geometrically, everything not on an eigenline gets rotated at least a little. The plot gives you a first filter: apply A roughly in your head to each arrow and ask which output would land on the same line through the origin.
Fast arithmetic on messy matrices
The candidates have small integer coordinates like (2, -1), so Av is two dot products of a 2-vector against rows of A. With A = [[a, b], [c, d]] and v = (x, y), Av = (ax + by, cx + dy). Then the parallel check is (ax+by)·y - (cx+dy)·x = 0. You are comparing a handful of two-digit products - entirely feasible in your head or on paper within a few seconds per candidate.
Work by elimination rather than confirmation. A candidate fails the moment the cross product is clearly nonzero - and with rounded display entries, 'clearly nonzero' means far from zero, not just slightly off. Because entries are shown rounded, the true eigenvector's cross product may come out near zero rather than exactly zero in your hand check; the decoys are constructed to be genuinely non-parallel, so they miss by a lot. Pick the candidate closest to zero.
A useful shortcut: compute the ratio of Av's components and compare it to y/x for the candidate. If (ax+by)/(cx+dy) matches x/y's structure - same ratio between components - it is your eigenvector. Sign flips across both components are fine (negative eigenvalue); a sign flip in only one component is rotation.
Why eigenvectors matter beyond the click
The construction A = P·D·P⁻¹ the game uses is diagonalization run backwards, and it is the reason eigenvectors matter in practice: in the eigenbasis, applying A is just componentwise scaling. Powers of A, matrix exponentials, and long-run behavior of linear dynamical systems all become trivial once you know the eigen-directions - Aⁿ = P·Dⁿ·P⁻¹.
In quant work this shows up as principal components of a covariance matrix (directions of maximal variance), the stationary behavior of Markov chains (the eigenvector for eigenvalue 1), and stability of discretized systems (eigenvalues inside or outside the unit circle). Getting fluent at 'does this matrix preserve this direction' is the atomic skill under all of them.
Note the game's edge case: if both eigenvalues were equal, A would be a multiple of the identity and every vector would be an eigenvector - so the generator forces distinct eigenvalues. That degenerate case is itself a classic interview probe: for A = cI, the eigenspace is the whole plane.
A worked example
Suppose the matrix shown is A = [[1, 2], [3, 0]] and the candidates are A = (1, 1), B = (2, -3), C = (1, -2), D = (3, 1).
Candidate (1, 1): Av = (1·1 + 2·1, 3·1 + 0·1) = (3, 3). Cross product 3·1 - 3·1 = 0. Parallel - this is an eigenvector (in fact λ = 3).
Check a decoy to see the contrast. Candidate (2, -3): Av = (1·2 + 2·(-3), 3·2 + 0·(-3)) = (-4, 6). Cross product (-4)·(-3) - 6·2 = 12 - 12 = 0 - careful, that one is also parallel: (-4, 6) = -2·(2, -3), so (2, -3) is the matrix's other eigenvector with λ = -2. The real game never offers both: the second true eigenvector is excluded from the decoys, so in play only one candidate passes.
Candidate (1, -2): Av = (1 - 4, 3 - 0) = (-3, 3). Cross product (-3)·(-2) - 3·1 = 6 - 3 = 3 ≠ 0. Rotated - not an eigenvector. Candidate (3, 1): Av = (5, 9). Cross product 5·1 - 9·3 = -22 ≠ 0. Not an eigenvector. Click the candidate whose cross product is zero.
Common mistakes
• Rejecting a direction because Av points the opposite way. A flip means a negative eigenvalue - the vector is still on its own line and still an eigenvector.
• Solving the characteristic polynomial for λ first. You never need the eigenvalues here; the parallelism cross product is faster and is exactly the test the game grades with.
• Comparing only one component ratio. (ax+by)/x matching some scale is not enough - both components must scale by the same factor, which is what the cross product checks in one line.
• Expecting your hand computation on the rounded display entries to give exactly zero. The underlying matrix is full precision; pick the candidate whose cross product is closest to zero, since decoys miss by a wide margin.
• Forgetting that eigenvectors are directions, not points: any nonzero scalar multiple of an eigenvector is the same answer, so normalize mentally to the smallest integers and compare lines, not arrow lengths.
Why interviews test this
Every quant-research and quant-dev linear algebra screen touches eigenvectors: define them, find them for a small matrix, explain diagonalization, or connect them to PCA on a covariance matrix. The 2x2 case is the standard whiteboard size, and interviewers watch whether you reach for the definition Av = λv and a parallelism check rather than grinding the characteristic polynomial.
Follow-ups this game prepares you for: what happens when eigenvalues repeat (the identity-multiple degenerate case), why symmetric matrices have orthogonal eigenvectors, and why the top eigenvector of a covariance matrix is the direction of maximal variance.