<jupyter_start><jupyter_text>Columnspace and nullspace of a matrix  Columnspaces of matrices We saw in the previous lecture that columns of a matrix can be regarded as vectors. Consider the following example matrix.<jupyter_code>A = Matrix([[1, 1, 2], [2, 1, 3], [3, 1, 4], [4, 1, 5]])
A
b = Matrix([1, 2, 3, 4])
b<jupyter_output><empty_output><jupyter_text>Each of the column spaces are vectors (column space) in $\mathbb{R}^4$.  The linear combinations of all the column vectors form a subspace.  Is it the whole $V= \mathbb{R}^4$, though?  The reason why we ask, is because we want to bring it back to a system of linear equations and ask the question: _Is there (always) a solution to_ (1)_?_ $${A}\underline{x}=\underline{b}\tag{1}$$ In other words, which right-hand sides $\underline{b}$ are allowed?  In our example above we are in $\mathbb{R}^4$ and we ask if linear combination of all of them fill $\mathbb{R}^4$. From our example above some right-hand sides will be allowed (they form a subspace).  Let's look at an example for $\underline{b}$.<jupyter_code>x1, x2, x3 = symbols('x1, x2, x3')
vec_x = Matrix([x1, x2, x3])
b = Matrix([1, 2, 3, 4])
A, vec_x, b
A * vec_x<jupyter_output><empty_output><jupyter_text>While we can view this as a system of linear equation, we will prefer the column view.  By viewing the matrix of coefficients, with the columns as vectors, we are asking: _How many, $x_1$, of column $1$ plus how many, $x_2$, of columns $2$, plus how many, $x_3$ of column $3$ equals $\underline{b}$_?  The question is easier to visualize when written as in (2). $$x_1\begin{bmatrix}1\\2\\3\\4\end{bmatrix}+x_2\begin{bmatrix}1\\1\\1\\1\end{bmatrix}+x_3\begin{bmatrix}2\\3\\4\\5\end{bmatrix}=\underline{b}\tag{2}$$ Well, since $\underline{b}$ is the same as the first column, $\underline{x}$ would be as shown in (3). $$\begin{bmatrix}1\\0\\0\end{bmatrix}\tag{3}$$<jupyter_code>A * Matrix([1, 0, 0]) == b<jupyter_output><empty_output><jupyter_text>Linear independence We really need to know if the columns above are linearly independent (not constant multiples or additions of each other).  We note that column three above is a linear combination of the first two, so adds nothing _new_.  Actually, we could also throw away the first one because it is column $3$ plus $-1$ times column $2$.  Same for column$2$.  We thus have two columns left and we say that the column space is of dimension $2$ (a 2-dimensional subspace of $\mathbb{R}^4$).  The nullspace The null space contains all solutions of $\underline{x}$ for $A\underline{x}=\underline{0}$.  This solution(s) is (are) in $\mathbb{R}^3$.<jupyter_code>zero_b = Matrix([0, 0, 0, 0])
A, vec_x, zero_b<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.13160813308687616, 'fraction_numerical': 0.02920517560073937, 'mean_word_length': 4.819354838709677, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 17, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '4', 'dir': 'jupyter-structured-clean-dedup', 'id': '32980', 'license': 'MIT', 'n_tokens_mistral': 904, 'n_tokens_neox': 865, 'n_words': 371, 'path': 'Mathematics/Linear Algebra/0.0 MIT-18.06 - Jupyter/Lecture_6_Column_and_null_spaces.ipynb', 'repo_name': 'okara83/Becoming-a-Data-Scientist', 'size': '2705'}