Skip to main content
Mathematics LibreTexts

29.1: Eigenvalues and eigenvectors review

  • Page ID
    69444
  • \( \newcommand{\vecs}[1]{\overset { \scriptstyle \rightharpoonup} {\mathbf{#1}} } \) \( \newcommand{\vecd}[1]{\overset{-\!-\!\rightharpoonup}{\vphantom{a}\smash {#1}}} \)\(\newcommand{\id}{\mathrm{id}}\) \( \newcommand{\Span}{\mathrm{span}}\) \( \newcommand{\kernel}{\mathrm{null}\,}\) \( \newcommand{\range}{\mathrm{range}\,}\) \( \newcommand{\RealPart}{\mathrm{Re}}\) \( \newcommand{\ImaginaryPart}{\mathrm{Im}}\) \( \newcommand{\Argument}{\mathrm{Arg}}\) \( \newcommand{\norm}[1]{\| #1 \|}\) \( \newcommand{\inner}[2]{\langle #1, #2 \rangle}\) \( \newcommand{\Span}{\mathrm{span}}\) \(\newcommand{\id}{\mathrm{id}}\) \( \newcommand{\Span}{\mathrm{span}}\) \( \newcommand{\kernel}{\mathrm{null}\,}\) \( \newcommand{\range}{\mathrm{range}\,}\) \( \newcommand{\RealPart}{\mathrm{Re}}\) \( \newcommand{\ImaginaryPart}{\mathrm{Im}}\) \( \newcommand{\Argument}{\mathrm{Arg}}\) \( \newcommand{\norm}[1]{\| #1 \|}\) \( \newcommand{\inner}[2]{\langle #1, #2 \rangle}\) \( \newcommand{\Span}{\mathrm{span}}\)\(\newcommand{\AA}{\unicode[.8,0]{x212B}}\)

    Definition

    A non-zero vector \(x\) in \(R^n\) is called an eigenvector of a \(n \times n\) matrix \(A\) if \(Ax\) is a scalar multiple of \(x\). If \(Ax = \lambda x\), then \(\lambda\) is called the eigenvalue of \(A\) corresponding to \(x\).

    Steps for finding the eigenvalues and eigenvectors

    We want to find \(\lambda\) and non-zero vector \(x\) such that \(Ax = \lambda x\) for a \(n \times n\) matrix.

    1. We introduce an identity matrix \(I\) of \(n \times n\). Then the equation becomes:

    \[Ax = \lambda I x \nonumber \]

    \[Ax-\lambda I x = 0 \nonumber \]

    \[(A-\lambda I)x = 0 \nonumber \]

    1. This suggests that we want to find \(\lambda\) such that \((A-\lambda I)x=0\) has a non-trivial solution. It is equivalent to that the matrix \(A-\lambda I\) is singular, i.e., has a determinant of \(0\). \(|A-\lambda I|=0\)
    2. The determinant is polynomial in \(\lambda\) (called the characteristic polynomial of \(A\)) with degree \(n\). We solve this equation (called the characteristic equation) for all possible \(\lambda\) (eigenvalues).
    3. After finding the eigenvalues, we substitute them back into \((A-\lambda I)x=0\) and find the eigenvectors \(x\).

    Let’s calculate eigenvalues for the following matrix:

    \[\begin{split} A=\begin{bmatrix} 0 & 0 & -2 \\ 1 & 2 & 1 \\ 1 & 0 & 3 \end{bmatrix}\end{split} \nonumber \]

    Find eigenvalues

    Looking at the above recipe, let’s solve the problem symbollically using sympy. First lets create a matrix \(B\) such that:

    \[B = A-\lambda I \nonumber \]

    %matplotlib inline
    import matplotlib.pylab as plt
    import numpy as np
    import sympy as sym
    sym.init_printing()
    #Most sympy requires defeing the variables as "symbols"
    #Once we do this we can use the variables in place of numbers
    lam = sym.symbols('lambda')
    
    A = sym.Matrix([[0, 0 ,-2], [1, 2, 1], [1, 0, 3]])
    I = sym.eye(3)
    
    B = A - lam*I
    
    B

    Now, per step 2, the determinate of \(B\) must be zero. Note that sympy calculates the determinate symbollically as follows:

    B.det()
    Do This

    Using the sympy.solve function on the determinate of \(B\) to solve for lam (\(\lambda\)). Verify that the solution to the last question produces the same eigenvalues as above.

    # Put your code to solve for det(B) = 0 here
    Do This

    First, let’s use the built in funciton eigenvals function in sympy to calculate the eigenvalues. Find out the meaning of the output.

    # Put your code here

    Find eigenvectors

    Now we know the eigenvalues, we can substitue them back into the equation to find the eigenvectors.

    We solve this symbollically using sympy. First let’s make a vector of our eigenvalues (from above):

    eig = [1,2]

    Now (per step 4 above) we need to solve the equation \((A-\lambda I)x=0\). One way to do this in sympy is as follows:

    x1,x2,x3 = sym.symbols(['x_1','x_2','x_3'])
    
    x = sym.Matrix([[x1],[x2],[x3]])
    x
    for lam in eig:
        vec = sym.solve((A - lam*I)*x,x)
        print(vec)
    {x_1: -2*x_3, x_2: x_3}
    {x_1: -x_3}
    
    Question

    Explain your output here. (Hint, you can also try the rref to find the solutions)

    Do This

    Next, let’s use the eigenvects function in sympy to find three linear independent eigenvectors for the matrix \(A\)?

    # Put your answer to the above question here
    Question

    Compare this answer to the eigenvectors we calculated above. Does this answer make sense? What does the syntax tell us?

    Do This

    Find the eigenvalues and eigenvectors of the following matrix:

    \[A_2=\begin{bmatrix} 2 & 1 \\ 0 & 2 \end{bmatrix} \nonumber \]

    Question

    What are the eigenvalues for the matrix \(A_2\)?

    Question

    What are the eigenvectors for the matrix \(A_2\)?


    This page titled 29.1: Eigenvalues and eigenvectors review is shared under a CC BY-NC 4.0 license and was authored, remixed, and/or curated by Dirk Colbry via source content that was edited to the style and standards of the LibreTexts platform; a detailed edit history is available upon request.

    • Was this article helpful?