Skip to main content
Mathematics LibreTexts

5.2: Visualizing the problem

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

    \( \newcommand{\vectorA}[1]{\vec{#1}}      % arrow\)

    \( \newcommand{\vectorAt}[1]{\vec{\text{#1}}}      % arrow\)

    \( \newcommand{\vectorB}[1]{\overset { \scriptstyle \rightharpoonup} {\mathbf{#1}} } \)

    \( \newcommand{\vectorC}[1]{\textbf{#1}} \)

    \( \newcommand{\vectorD}[1]{\overrightarrow{#1}} \)

    \( \newcommand{\vectorDt}[1]{\overrightarrow{\text{#1}}} \)

    \( \newcommand{\vectE}[1]{\overset{-\!-\!\rightharpoonup}{\vphantom{a}\smash{\mathbf {#1}}}} \)

    \( \newcommand{\vecs}[1]{\overset { \scriptstyle \rightharpoonup} {\mathbf{#1}} } \)

    \( \newcommand{\vecd}[1]{\overset{-\!-\!\rightharpoonup}{\vphantom{a}\smash {#1}}} \)

    \(\newcommand{\avec}{\mathbf a}\) \(\newcommand{\bvec}{\mathbf b}\) \(\newcommand{\cvec}{\mathbf c}\) \(\newcommand{\dvec}{\mathbf d}\) \(\newcommand{\dtil}{\widetilde{\mathbf d}}\) \(\newcommand{\evec}{\mathbf e}\) \(\newcommand{\fvec}{\mathbf f}\) \(\newcommand{\nvec}{\mathbf n}\) \(\newcommand{\pvec}{\mathbf p}\) \(\newcommand{\qvec}{\mathbf q}\) \(\newcommand{\svec}{\mathbf s}\) \(\newcommand{\tvec}{\mathbf t}\) \(\newcommand{\uvec}{\mathbf u}\) \(\newcommand{\vvec}{\mathbf v}\) \(\newcommand{\wvec}{\mathbf w}\) \(\newcommand{\xvec}{\mathbf x}\) \(\newcommand{\yvec}{\mathbf y}\) \(\newcommand{\zvec}{\mathbf z}\) \(\newcommand{\rvec}{\mathbf r}\) \(\newcommand{\mvec}{\mathbf m}\) \(\newcommand{\zerovec}{\mathbf 0}\) \(\newcommand{\onevec}{\mathbf 1}\) \(\newcommand{\real}{\mathbb R}\) \(\newcommand{\twovec}[2]{\left[\begin{array}{r}#1 \\ #2 \end{array}\right]}\) \(\newcommand{\ctwovec}[2]{\left[\begin{array}{c}#1 \\ #2 \end{array}\right]}\) \(\newcommand{\threevec}[3]{\left[\begin{array}{r}#1 \\ #2 \\ #3 \end{array}\right]}\) \(\newcommand{\cthreevec}[3]{\left[\begin{array}{c}#1 \\ #2 \\ #3 \end{array}\right]}\) \(\newcommand{\fourvec}[4]{\left[\begin{array}{r}#1 \\ #2 \\ #3 \\ #4 \end{array}\right]}\) \(\newcommand{\cfourvec}[4]{\left[\begin{array}{c}#1 \\ #2 \\ #3 \\ #4 \end{array}\right]}\) \(\newcommand{\fivevec}[5]{\left[\begin{array}{r}#1 \\ #2 \\ #3 \\ #4 \\ #5 \\ \end{array}\right]}\) \(\newcommand{\cfivevec}[5]{\left[\begin{array}{c}#1 \\ #2 \\ #3 \\ #4 \\ #5 \\ \end{array}\right]}\) \(\newcommand{\mattwo}[4]{\left[\begin{array}{rr}#1 \amp #2 \\ #3 \amp #4 \\ \end{array}\right]}\) \(\newcommand{\laspan}[1]{\text{Span}\{#1\}}\) \(\newcommand{\bcal}{\cal B}\) \(\newcommand{\ccal}{\cal C}\) \(\newcommand{\scal}{\cal S}\) \(\newcommand{\wcal}{\cal W}\) \(\newcommand{\ecal}{\cal E}\) \(\newcommand{\coords}[2]{\left\{#1\right\}_{#2}}\) \(\newcommand{\gray}[1]{\color{gray}{#1}}\) \(\newcommand{\lgray}[1]{\color{lightgray}{#1}}\) \(\newcommand{\rank}{\operatorname{rank}}\) \(\newcommand{\row}{\text{Row}}\) \(\newcommand{\col}{\text{Col}}\) \(\renewcommand{\row}{\text{Row}}\) \(\newcommand{\nul}{\text{Nul}}\) \(\newcommand{\var}{\text{Var}}\) \(\newcommand{\corr}{\text{corr}}\) \(\newcommand{\len}[1]{\left|#1\right|}\) \(\newcommand{\bbar}{\overline{\bvec}}\) \(\newcommand{\bhat}{\widehat{\bvec}}\) \(\newcommand{\bperp}{\bvec^\perp}\) \(\newcommand{\xhat}{\widehat{\xvec}}\) \(\newcommand{\vhat}{\widehat{\vvec}}\) \(\newcommand{\uhat}{\widehat{\uvec}}\) \(\newcommand{\what}{\widehat{\wvec}}\) \(\newcommand{\Sighat}{\widehat{\Sigma}}\) \(\newcommand{\lt}{<}\) \(\newcommand{\gt}{>}\) \(\newcommand{\amp}{&}\) \(\definecolor{fillinmathshade}{gray}{0.9}\)

    We can visualize the solution to a system of linear equations in a graph. If we make \(b\) the "\(y\)"-axis and \(c\) the "\(x\)"-axis. For each equation, we calculate the \(b\) value for each \(c\), and two equations give us two lines.

    Note

    This is sometimes called the “Row Picture.” I will ask you why it has this name in class so think about it.

    Question

    The above video described three (3) elementary operators that can be applied to a system of linear equations and not change their answer. What are these three operators?

    from IPython.display import YouTubeVideo
    YouTubeVideo("BSxWO6FGib0",width=640,height=360, cc_load_policy=True)
    %matplotlib inline
    import matplotlib.pylab as plt
    import numpy as np
    c = np.linspace(0,20)
    c
    array([ 0.        ,  0.40816327,  0.81632653,  1.2244898 ,  1.63265306,
            2.04081633,  2.44897959,  2.85714286,  3.26530612,  3.67346939,
            4.08163265,  4.48979592,  4.89795918,  5.30612245,  5.71428571,
            6.12244898,  6.53061224,  6.93877551,  7.34693878,  7.75510204,
            8.16326531,  8.57142857,  8.97959184,  9.3877551 ,  9.79591837,
           10.20408163, 10.6122449 , 11.02040816, 11.42857143, 11.83673469,
           12.24489796, 12.65306122, 13.06122449, 13.46938776, 13.87755102,
           14.28571429, 14.69387755, 15.10204082, 15.51020408, 15.91836735,
           16.32653061, 16.73469388, 17.14285714, 17.55102041, 17.95918367,
           18.36734694, 18.7755102 , 19.18367347, 19.59183673, 20.        ])
    b1 = 30-c
    b2 = (690-20*c)/25

    Row Picture

    plt.plot(c,b1)
    plt.plot(c,b2)
    plt.xlabel('c (hours worked as carpenter)')
    plt.ylabel('b (hours worked as blacksmith)')
    plt.scatter(12,18);

    Now, consider the next set of equations which do not have a solution

    \[-2x+y=3 \nonumber \]

    \[-4x+2y=2 \nonumber \]

    x = np.linspace(-10,10)
    y1 =  3+2*x
    y2 = (2+4*x)/2
    plt.plot(x,y1)
    plt.plot(x,y2);
    from IPython.display import YouTubeVideo
    YouTubeVideo("Z9gkovHDpIQ",width=640,height=360, cc_load_policy=True)

    Consider the next set of equations which have infinite many solutions

    \[4x-2y=6 \nonumber \]

    \[6x-3y=9 \nonumber \]

    x = np.linspace(-10,10)
    y1 =  (4*x-6)/2
    y2 = (6*x-9)/3
    plt.plot(x,y1)
    plt.plot(x,y2)
    # 'Run' this cell to view the plot
    [<matplotlib.lines.Line2D at 0x7f911c4b3250>]
    Do This

    Plot the following equations from -100 to 100

    \[ 18x+21y = 226 \nonumber \]

    \[ 72x-3y = 644 \nonumber \]

    # Put your python code here
    Question

    Using the graph, what is a visual estimation of the solution to these two equations? Hint, you may want to change the \(x\) range to “zoom” in on the intersection.

    Column Picture

    I think a good programmer is a lazy person. Let’s avoid writing all of the letters in the above euqation by changing it into a column vector format as follows.

    \[ \begin{split} c \left[ \begin{matrix} 1 \\ 20 \end{matrix} \right] + b \left[ \begin{matrix} 1 \\ 5 \end{matrix} \right] = \left[ \begin{matrix} 30 \\ 330 \end{matrix} \right] \end{split} \nonumber \]

    Notice that this still represents the same system of equations. We just write the constants as column vectors and we only have to write the unknowns once (Since they are the same for all equations).

    Let’s plot this “column picture”, which shows how the above equation is a “linear combination” of the two column vectors.

    One way to think about this is we can only move in straight lines in two directions. The first direction is (1,20) and the second is (1,5). The solution to the problem is how far in each direction we need to move to arrive at our final destination of (30,330).

    The first column is a vector in the (1,20) direction. The variable \(c\) is how far in the (1,20) direction we want to go. Then \(b\) is how far in the (1,5) direction we want to go to arrive at the point (30,330).

    We will use the matplotlib function arrow to plot the vectors. The arrow function takes a starting point \([x,y]\) and a direction \([dx,dy]\) as inputs and draws an arrow from the starting point in the direction specified.

    First thing to do is plot the first column as a vector. From the origin (0,0) to \(c \left[ \begin{matrix} 1 \\ 20 \end{matrix} \right] \)

    or \(x=c\) and \(y=20c\) with \(c=12\)

    c = 12
    
    #hack to inicialize bounds of plot (need this to get the arrows to work?)
    plt.plot(0,0)
    plt.plot(30,330)
    
    # Plot the first arrow 
    plt.arrow(0, 0, c*1, c*20,head_width=2, head_length=10, fc='blue', ec='blue')
    # 'Run' this cell to view the plot
    <matplotlib.patches.FancyArrow at 0x7f911c3969d0>

    Next thing to do is plot the second column as a vector by adding it to the first. This arrow will start at the end of the previous vector and “add” the second column vector:

    b = 18
    
    #hack to inicialize bounds of plot (need this to get the arrows to work?)
    plt.plot(0,0)
    plt.plot(30,330)
    
    # Plot the first arrow
    plt.arrow(0, 0, c*1, c*20,head_width=2, head_length=10, fc='blue', ec='blue')
    
    #Plot the second arrow starting at the end of the first
    plt.arrow(c, c*20, b*1, b*5, head_width=2, head_length=10, fc='red', ec='red')
    # 'Run' this cell to view the plot
    <matplotlib.patches.FancyArrow at 0x7f911c485550>

    The takeaway to this figure is that these two column vectors, when added together, end up at the point that represents the right hand side of the above equation (i.e. (30, 330)).

    #hack to inicialize bounds of plot (need this to get the arrows to work?)
    plt.plot(0,0)
    plt.plot(30,330)
    
    # Plot the first arrow
    plt.arrow(0, 0, c*1, c*20,head_width=2, head_length=10, fc='blue', ec='blue')
    
    #Plot the second arrow starting at the end of the first
    plt.arrow(c, c*20, b*1, b*5, head_width=2, head_length=10, fc='red', ec='red')
    
    #Plot a righthand column vector as a point.
    plt.arrow(0,0, 30, 330, head_width=2, head_length=10, fc='purple', ec='purple')
    plt.xlabel('x');
    plt.ylabel('y');

    We say that the two column vectors “span” the \(xy\)-plane. This means that any point on the x,y plane can be represented as a linear combination of the two vectors.

    Question

    Give an example of two column vectors that do NOT span the \(xy\)−plane


    This page titled 5.2: Visualizing the problem 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.

    • Was this article helpful?