Skip to main content
Mathematics LibreTexts

23.2: The Basis of a Vector Space

  • Page ID
    68051
  • \( \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}}\)

    %matplotlib inline
    import matplotlib.pylab as plt
    import numpy as np
    import sympy as sym
    from urllib.request import urlretrieve
    sym.init_printing(use_unicode=True)
    urlretrieve('https://raw.githubusercontent.com/colbrydi/jupytercheck/master/answercheck.py', 
                'answercheck.py');

    Let \(U\) be a vector space with basis \(B=\{u_1, \ldots, u_n\}\), and let \(u\) be a vector in \(U\). Because a basis “spans” the vector space, we know that there exists scalars \(a_1, \ldots, a_n\) such that:

    \[ u = a_1u_1 + \dots + a_nu_n \nonumber \]

    Since a basis is a linearly independent set of vectors we know the scalars \(a_1, \ldots, a_n\) are unique.

    The values \(a_1, \ldots, a_n\) are called the coordinates of \(u\) relative to the basis (\(B\)) and is typically written as a column vector:

    \[\begin{split} u_B =
    \left[
    \begin{matrix}
    a_1 \\
    \vdots \\
    a_n
    \end{matrix}
    \right]
    \end{split} \nonumber \]

    We can create a transition matrix \(P\) using the inverse of the matrix with the basis vectors being columns.

    \[P = [ u_1 \ldots u_n ]^{-1} \nonumber \]

    Now we will show that matrix \(P\) will transition vector \(u\) in the standard coordinate system to the coordinates relative to the basis \(B\):

    \[ u_B = Pu \nonumber \]

    EXAMPLE: Consider the vector \(u = \left[ \begin{matrix} 5 \\ 3 \end{matrix} \right]\) and the basis vectors \(B=\{(1,2),(3,−1)\}\). The following code calculates the \(P\) transition matrix from \(B\) and then uses \(P\) to calculate the values of \(u_B\) (\(a_1\) and \(a_2\)):

    u = np.matrix([[5],[3]])
    sym.Matrix(u)
    B = np.matrix([[1,2],[3,-1]]).T
    sym.Matrix(B)
    P = np.linalg.inv(B)
    ub = P*u
    
    sym.Matrix(ub)

    Here we would like to view this from \(R^n\). Let \(B = [u_1 \ldots u_n]\), then the values of \(u_B\) can be found by solving the linear system \(u = Bu_{b}\). The columns of \(B\) are a basis, therefore, the matrix \(B\) is an \(n \times n\) square matrix and it has an inverse. Therefore, we can solve the linear system and obtain \(u_B = B^{-1}u = Pu\).

    Let’s try to visualize this with a plot:

    ax = plt.axes();
    
    
    #Blue arrow representing first Basis Vector
    ax.arrow(0, 0, B[0,0],B[1,0], head_width=.2, head_length=.2, fc='blue', ec='blue');
    
    
    #Green arrow representing Second Basis Vector
    plt.plot([0,B[0,1]],[0,B[1,1]],color='green'); #Need this line to make the figure work. Not sure why.
    ax.arrow(0, 0, B[0,1],B[1,1], head_width=.2, head_length=.2, fc='green', ec='green');
    
    #Original point u as a red dot
    ax.scatter(u[0,0],u[1,0], color='red');
    
    plt.show()
    #plt.axis('equal');

    Notice that the blue arrow represents the first basis vector and the green arrow is the second basis vector in \(B\). The solution to \(u_B\) shows 2 units along the blue vector and 1 units along the green vector, which puts us at the point (5,3).

    This is also called a change in coordinate systems.

    Question

    What is the coordinate vector of \(u\) relative to the given basis \(B\) in \(R^3\)?

    \[u = (9,-3,21) \nonumber \]

    \[B = \{(2,0,-1), (0,1,3), (1,1,1)\} \nonumber \]

    Store this coordinate in a variable ub for checking:

    #Put your answer here
    from answercheck import checkanswer
    
    checkanswer.vector(ub,'f72f62c739096030e0074c4e1dfca159');

    Let’s look more closely into the matrix \(P\), what is the meaning of the columns of the matrix \(P\)?

    We know that \(P\) is the inverse of \(B\), therefore, we have \(BP = I\). Then we can look at the first column of the \(P\), say \(p_{1}\), we have that \(Bp_{1}\) is the column vector \((1,0,0)\), which is exactly the first component from the standard basis. This is true for other columns.

    It means that if we want to change an old basis \(B\) to a new basis \(B′\), we need to find out all the coordinates in the new basis for the old basis, and the transition matrix is by putting all the coordinates as columns.

    Here is the matrix \(B\) again:

    B = np.matrix([[2,0,-1],[0,1,3],[1,1,1]]).T
    sym.Matrix(B)

    The first column of P should be the solution to \(Bx=\left[ \begin{matrix} 1 \\ 0 \\ 0 \end{matrix} \right]\). We can use the numpy.linalg.solve function to find this solution:

    # The first column of P should be 
    u1 = np.matrix([1,0,0]).T
    p1 = np.linalg.solve(B,u1)
    p1

    We can find a similar answer for columns \(p_2\) and \(p_3\):

    # The second column of P should be 
    u2 = np.matrix([0,1,0]).T
    p2 = np.linalg.solve(B,u2)
    p2
    # The third column of P should be 
    u3 = np.matrix([0,0,1]).T
    p3 = np.linalg.solve(B,u3)
    p3
    # concatenate three column together into a 3x3 matrix
    P = np.concatenate((p1, p2, p3), axis=1)
    sym.Matrix(P)
    # Find the new coordinate in the new basis
    u = np.matrix([9,-3,21]).T
    UB = P*u
    print(UB)

    This should be basically the same answer as you got above.


    This page titled 23.2: The Basis of a Vector Space 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?