Eigenvectors & eigenvalues

Step 6 of 18 in Foundations · Concept · Medium

An eigenvector is a direction a matrix only stretches, never turns; the eigenvalue is how much. They reveal a system's long-run behaviour.

The lesson

Multiply most vectors by a matrix A and they change direction. An eigenvector does not: Av = λv. It is only stretched, by its eigenvalue λ (and flipped if λ is negative).

Worked example: A = [[2, 1], [1, 2]]
  1. Try v = [1, 1]: Av = [3, 3] = 3v. An eigenvector with eigenvalue 3.
  2. Try v = [1, −1]: Av = [1, −1] = 1v. An eigenvector with eigenvalue 1.
  3. Every other vector is a mix of these two. A triples one part and leaves the other alone.

That last line is why eigenvectors describe long-run behaviour. Apply A again and again and the part along the top eigenvector grows fastest, so the vector swings round to line up with it. This is power iteration: start from a random vector, multiply by A, rescale to length 1 so the numbers stay sane, and repeat. Once v has settled, the eigenvalue is v·(Av).

Common mistake. An eigenvector has no fixed length or sign: v, −v and 2v are the same eigenvector. Compare your result with NumPy's up to sign, not entry by entry.

Check yourself

  1. A = [[3, 1], [0, 2]] and v = [1, 0]. v is an eigenvector. What is its eigenvalue?

    Show the answer

    3. Av = [3·1 + 1·0, 0·1 + 2·0] = [3, 0] = 3v.

  2. A matrix has eigenvalues 5, 2 and 0.5. Power iteration converges to the eigenvector for:

    • 0.5
    • the average of the three
    • 5
    Show the answer

    5. Each multiplication scales the three parts by 5, 2 and 0.5. After many steps the part scaled by 5 dwarfs the rest.

  3. v is an eigenvector of A with eigenvalue 3. What is A(2v)?

    • 3v
    • 6v
    • 5v
    Show the answer

    6v. A(2v) = 2·Av = 2·3v = 6v. So 2v is an eigenvector too, with the same eigenvalue 3.

Build it

  1. Power iteration

    Find the top eigenvector by repeatedly multiplying a random vector by A and normalizing.

    Done when: Matches np.linalg.eig's top eigenvector (up to sign).

    Runs in your browser: write the code on the map and the tests mark it.

Case study: PageRank: Google's eigenvector

  • The web is a matrix of links; a page's rank is its entry in the top eigenvector.
  • Power iteration on billions of pages is how it was computed in practice.
  • The damping factor makes the matrix well-behaved so the iteration converges.

Read the case study

Resources

Earn this star

On the map, your answers are marked and you log what you built. Finish the step and its star lights.

Open this step on the map