{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "[Table of Contents](table_of_contents.ipynb)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "# Topic 25. Fundamental Subspaces of a Matrix\n", "Author: Autumn Twitchell atwitch23@gmail.com\n", " " ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Introduction\n", "The fundamental subspaces of a matrix are four vector spaces of a matrix. If we are given a matrix mxn matrix $A$, the fundamental spaces are as follows:\n", "1. The range space (or column space) of $A$: $R(A)$\n", "2. The nullspace (or kernel) of $A$: $N(A)$\n", "3. The range space of $A^*$ (or row space of $A$): $R(A^*)$ and \n", "4. The nullspace of $A^*$ (or left nullspace of $A$): $N(A^*)$. \n", "\n", "Note: If the matrix $A$ is real, $A^* = A^T$. If the matrix $A$ is complex, $A^* = A^H$. \n", "\n", "The four fundamental subspaces are important to understand the properties of matrices such as the rank of a matrix. They are also important in the Fundamental Theorem of Linear Algebra. The subspaces are also connected to the Singular Value Decomposition (SVD) of a matrix. When we know what the four subspaces of a matrix are, we have a good understanding of whether the matrix has no solution, one solution, or many solutions. Knowing this helps us to know how to find the best solution for the matrix.\n" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Explanation of the theory\n", "\n", "### $R(A)$\n", "\n", "Let $A$ be an mxn matrix. An easy way to think about $R(A)$ is to remember that it is called the column space of $A$, thus it is characterized as the span of the columns of $A$. So if we show $A$ as \n", "$A = [c_1,c_2,...,c_n]$, then a point $ x \\in \\mathbb{R}^n$ is transformed as $Ax = x_1c_1 + x_2c_2 + ... + x_nc_n$, which is a linear combination of the columns of $A$. So the range can be expressed as $R(A) = span(\\{c_1,c_2,...,c_n\\})$.\n", "\n", "### $N(A)$\n", "\n", "To find the nullspace, we are looking to solve the equation $Ax = 0$. It is often easiest to solve by reducing the matrix to row echelon form.\n", "\n", "### $R(A^*)$ and $N(A^*)$\n", "\n", "The method of solving $R(A^*)$ and $N(A^*)$ is extremely similar to solving $R(A)$ and $N(A)$. The difference is that we are looking at the transpose of $A$ (or hermitian if $A \\in \\mathbb{C}^{mxn}$). So we transpose the matrix and find the range space and nullspace of the transformed matrix.\n", "\n", "### Fundamental Theorem of Linear Algebra\n", "\n", "Some important properties for the fundamental subspaces are found in the fundamental theorem of linear algebra. It states that the column and row spaces ($R(A)$ and $R(A^*)$) have the same dimension r, which is the rank of the matrix. The nullspace has dimension n−r, and the left nullspace has dimension $m−r$. This means that if we are looking at an mxn matrix where $m \\geq n$, and it is full rank, the nullspace will only contain the zero vector.\n", "\n", "Another part of the fundamental theorem of algebra is that the nullspace and row space are orthogonal, as well as the range space and left nullspace. These properties are depicted in Dr. Beard's telephone pole diagram depicted below.\n", "\n", "\n", "\n", "\n", "\n", "As mentioned in the previous section, the fundamental subspaces are connected to the SVD of a matrix. If A is an mxn matrix, where $A = U\\Sigma V^H$, we find that\n", "\n", "$R(A) = span(U_1)$\n", "\n", "$N(A) = span(V_2)$\n", "\n", "$R(A^*) = span(V_1)$\n", "\n", "$N(A^*) = span(U_2)$\n", "\n", "where $U$ is an mxm matrix, $\\Sigma$ is an mxn diagonal matrix, and $V$ is an nxn matrix. $U_1$ is the first $r$ columns of $U$ and $U_2$ is the last $m-r$ columns of $U$. $V_1$ is the first $r$ columns of $V$ and $V_2$ is the last $n-r$ columns of $V$. \n", "So then our SVD looks something like this\n", "\n", "$A = U\\Sigma V^H = \\begin{bmatrix} U_1 & U_2\\\\ \\end{bmatrix}\n", "\\begin{bmatrix} \\Sigma_1 & 0\\\\ 0 & \\Sigma_2\\\\ \\end{bmatrix}\n", "\\begin{bmatrix} V_1^H \\\\ V_2^H\\\\ \\end{bmatrix}$\n", "\n", "More information on SVDs can be found Topic 24. Singular Value Decomposition.\n" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Simple Numerical Examples\n", "\n", "We're going to look at two matrices and solve for their four fundamental subspaces." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Example 1: Square Matrix" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Suppose\n", "$A = \n", "\\begin{bmatrix}\n", "1 & 3 & 3\\\\\n", "4 & 5 & 6\\\\\n", "7 & 8 & 9\\\\\n", "\\end{bmatrix}$\n", "\n", "#### Solving for $R(A)$\n", "\n", "We can easily spot that the columns of $A$ are \n", "$\\begin{bmatrix} 1 \\\\ 4 \\\\ 7 \\\\ \\end{bmatrix},\n", "\\begin{bmatrix} 3\\\\ 5 \\\\ 8 \\\\ \\end{bmatrix},\n", "\\begin{bmatrix} 3\\\\ 6 \\\\ 9 \\\\ \\end{bmatrix}$\n", "\n", "Thus $R(A) = span\\Bigg(\\Bigg\\{\n", "\\begin{bmatrix} 1 \\\\ 4 \\\\ 7 \\\\ \\end{bmatrix},\n", "\\begin{bmatrix} 3\\\\ 5\\\\ 8\\\\ \\end{bmatrix},\n", "\\begin{bmatrix} 3\\\\6\\\\ 9\\\\ \\end{bmatrix}\\Bigg\\}\\Bigg)$\n", "\n", "It isn't necessary to include all of the columns of $A$ if some are linearly dependent. If we were unsure as to whether they are linearly independent we could verify this with some linear algebra (see Topic 4. Linear Independence for more information). Here we're just going to let Python do it for us:\n" ] }, { "cell_type": "code", "execution_count": 23, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "A = \n" ] }, { "data": { "text/latex": [ "$\\displaystyle \\left[\\begin{matrix}1 & 3 & 3\\\\4 & 5 & 6\\\\7 & 8 & 9\\end{matrix}\\right]$" ], "text/plain": [ "⎡1 3 3⎤\n", "⎢ ⎥\n", "⎢4 5 6⎥\n", "⎢ ⎥\n", "⎣7 8 9⎦" ] }, "metadata": {}, "output_type": "display_data" }, { "name": "stdout", "output_type": "stream", "text": [ "rref of A = \n" ] }, { "data": { "text/latex": [ "$\\displaystyle \\left[\\begin{matrix}1 & 0 & 0\\\\0 & 1 & 0\\\\0 & 0 & 1\\end{matrix}\\right]$" ], "text/plain": [ "⎡1 0 0⎤\n", "⎢ ⎥\n", "⎢0 1 0⎥\n", "⎢ ⎥\n", "⎣0 0 1⎦" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "# Import modules for linear algebra\n", "import numpy as np\n", "import sympy\n", "sympy.init_printing()\n", "\n", "A = sympy.Matrix([[1,3,3], [4,5,6], [7,8,9]])\n", "print(\"A = \")\n", "display(A)\n", "\n", "# row reduce to see if it's linearly independent\n", "rr,a = A.rref()\n", "\n", "print(\"rref of A = \")\n", "display(rr)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "When we row reduce the matrix $A$, we can see that the rank of $A$ is 3, which is the number of columns and rows of $A$, thus $A$ is full rank and linearly independent. Therefore, we include all the columns of $A$ in the range of $A$." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "#### Solving for $N(A)$\n", "Now to find the nullspace $N(A)$, we solve for the equation $Ax = 0$\n", "\n", "Thus we have \n", "$\\begin{bmatrix}\n", "1 & 3 & 3\\\\\n", "4 & 5 & 6\\\\\n", "7 & 8 & 9\\\\\n", "\\end{bmatrix}\n", "\\begin{bmatrix} x_1\\\\ x_2\\\\ x_3\\\\ \\end{bmatrix}\n", "= \\begin{bmatrix} 0\\\\ 0\\\\ 0\\\\ \\end{bmatrix}$\n", "\n", "Interesting property of a matrix with linearly independent columns is that there is no vector $x$ that will that will make $Ax = 0$ unless $x$ is the zero vector.\n", "Therefore $N(A) = 0$\n" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "#### Solving for $R(A^*)$\n", "\n", "Because $A$ is a real matrix we know we will be solving for $R(A^T)$. As was mentioned in the introduction, the range space of $A^T$ is equivalent to the row space of $A$ because we are looking at the columns of $A^T$.\n", "\n", "$A^T = \\begin{bmatrix}\n", "1 & 4 & 7\\\\\n", "3 & 5 & 8\\\\\n", "3 & 6 & 9\\\\\n", "\\end{bmatrix}$\n", "\n", "We can see here that the column space of $A^T$ is equal to the \n", "$span\\Bigg(\\Bigg\\{\n", "\\begin{bmatrix} 1 \\\\ 3 \\\\ 3 \\\\ \\end{bmatrix},\n", "\\begin{bmatrix} 4\\\\ 5\\\\ 6\\\\ \\end{bmatrix},\n", "\\begin{bmatrix} 7\\\\ 8\\\\ 9\\\\ \\end{bmatrix}\\Bigg\\}\\Bigg)$\n", "\n", "Checking for linear independence, we get:" ] }, { "cell_type": "code", "execution_count": 25, "metadata": { "scrolled": true }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "rref of A^T = \n" ] }, { "data": { "text/latex": [ "$\\displaystyle \\left[\\begin{matrix}1 & 0 & 0\\\\0 & 1 & 0\\\\0 & 0 & 1\\end{matrix}\\right]$" ], "text/plain": [ "⎡1 0 0⎤\n", "⎢ ⎥\n", "⎢0 1 0⎥\n", "⎢ ⎥\n", "⎣0 0 1⎦" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "AT = A.T\n", "# row reduce to see if it's linearly independent\n", "rrat,a = AT.rref()\n", "\n", "print(\"rref of A^T = \")\n", "display(rrat)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Yay! The columns of $A^T$ are linearly independent which means the span of all the columns of $A^T$ are in $R(A^T)$.\n", "So $R(A^T) = span\\Bigg(\\Bigg\\{\n", "\\begin{bmatrix} 1 \\\\ 3 \\\\ 3 \\\\ \\end{bmatrix},\n", "\\begin{bmatrix} 4\\\\ 5\\\\ 6\\\\ \\end{bmatrix},\n", "\\begin{bmatrix} 7\\\\ 8\\\\ 9\\\\ \\end{bmatrix}\\Bigg\\}\\Bigg)$" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "#### Solving for $N(A^T)$\n", "Similar to finding $N(A)$, since the columns of $A^T$ are linearly independent, $N(A^T) = 0$." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Example 2: Stout Matrix\n", "\n", "(which means our transposed matrix will be tall)\n", "\n", "Suppose $B = \\begin{bmatrix}\n", "2 & 3 & 4\\\\\n", "5 & 6 & 7\\\\\n", "\\end{bmatrix}$" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "#### Solving for $R(B)$\n", "\n", "$R(B) = span\\Bigg(\\Bigg\\{\n", "\\begin{bmatrix} 2 \\\\ 5 \\\\ \\end{bmatrix},\n", "\\begin{bmatrix} 3\\\\ 6\\\\ \\end{bmatrix},\n", "\\begin{bmatrix} 4\\\\ 7\\\\ \\end{bmatrix}\\Bigg\\}\\Bigg)$" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "#### Solving for $N(B)$\n", "\n", "Solve $Bx = 0$\n", "\n", "Thus we have \n", "$\\begin{bmatrix}\n", "2 & 3 & 4\\\\\n", "5 & 6 & 7\\\\\n", "\\end{bmatrix}\n", "\\begin{bmatrix} x_1\\\\ x_2\\\\ x_3\\\\ \\end{bmatrix}\n", "= \\begin{bmatrix} 0\\\\ 0\\\\ \\end{bmatrix}$\n", "\n", "If we row reduce the matrix, we can find our nullspace:" ] }, { "cell_type": "code", "execution_count": 45, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "rref of B = \n" ] }, { "data": { "text/latex": [ "$\\displaystyle \\left[\\begin{matrix}1 & 0 & -1\\\\0 & 1 & 2\\end{matrix}\\right]$" ], "text/plain": [ "⎡1 0 -1⎤\n", "⎢ ⎥\n", "⎣0 1 2 ⎦" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "B = sympy.Matrix([[2,3,4], [5,6,7]])\n", "\n", "# row reduce to see if it's linearly independent\n", "rrb,b = B.rref()\n", "\n", "print(\"rref of B = \")\n", "display(rrb)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "We can see from the row reduced form that this matrix is full rank, but since there are more m columns than n rows, the nullspace will have a dimension of m-n. So in this case we should have one column in our nullspace. From the row reduced form we get the following equations:\n", "\n", "$\\begin{equation}\n", "\\begin{cases}\n", "x_1 - x_3 = 0\\\\\n", "x_2 + 2x_3 = 0\n", "\\end{cases}\n", "\\end{equation}$\n", "\n", "Thus we have\n", "$\\begin{bmatrix} x_1 \\\\ x_2 \\\\ x_3 \\\\ \\end{bmatrix} =\n", "\\begin{bmatrix} x_3\\\\ -2x_3\\\\ x_3\\\\ \\end{bmatrix}$\n", "\n", "Setting $x_3$ to 1, we have a basis for our nullspace:\n", "$N(B) = span\\Bigg(\\begin{bmatrix} 1\\\\ -2\\\\ 1\\\\ \\end{bmatrix}\\Bigg)$" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "#### Solving for $R(B^T)$\n", "\n", "$B^T = \\begin{bmatrix}\n", "2 & 5 \\\\\n", "3 & 6\\\\\n", "4 & 7\\\\\n", "\\end{bmatrix}$\n", "\n", "Thus $R(B^T) = span\\Bigg(\\begin{bmatrix}2 \\\\ 3\\\\ 4 \\\\ \\end{bmatrix},\n", "\\begin{bmatrix} 5 \\\\ 6\\\\ 7 \\\\ \\end{bmatrix}\\Bigg)$" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "#### Solving for $N(B^T)$\n", "\n", "Solve for \n", "\n", "$\\begin{bmatrix}\n", "2 & 5 \\\\\n", "3 & 6\\\\\n", "4 & 7\\\\\n", "\\end{bmatrix}\n", "\\begin{bmatrix}\n", "x_1 \\\\\n", "x_2\\\\\n", "\\end{bmatrix} \n", "= \\begin{bmatrix}\n", "0 \\\\\n", "0\\\\\n", "0\\\\\n", "\\end{bmatrix}$\n", "\n", "Let's look at the reduced row echelon form:" ] }, { "cell_type": "code", "execution_count": 46, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "rref of B = \n" ] }, { "data": { "text/latex": [ "$\\displaystyle \\left[\\begin{matrix}1 & 0\\\\0 & 1\\\\0 & 0\\end{matrix}\\right]$" ], "text/plain": [ "⎡1 0⎤\n", "⎢ ⎥\n", "⎢0 1⎥\n", "⎢ ⎥\n", "⎣0 0⎦" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "# row reduce to see if it's linearly independent\n", "rrb,b = B.T.rref()\n", "\n", "print(\"rref of B = \")\n", "display(rrb)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Because this is a tall matrix, our solution is overdetermined. Since our columns are linearly independent, the matrix is considered full rank and therefore $N(B^T)=0$. " ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## An Engineering Application\n", "\n", "Linear algebra is heavily used when it comes to solving electrical circuits. In most simple circuits that are solved, there is one solution for the system of equations. This means that the matrix used to solve the linear equations of the circuit is linearly independent and full rank, therefore the dimensions of $R(A)$ and $R(A^T)$ are the minimum value between the columns and rows of the matrix. This also means that $N(A)$ and $N(A^T)$ only contain the zero vector. \n", "\n", "In the case below, we are going to look at the current of a circuit that doesn't have any elements to it besides wire. \n", "\n", "\n", "\n", "In the picture above, we are going to solve for the difference in current (current is represented by the $b$'s) at the nodes $x_1,x_2,x_3,x_4$.\n", "\n", "Solving for the currents, we have:\n", "\n", "$\\begin{equation}\n", "\\begin{cases}\n", "-x_1 + x_3 = b_1\\\\\n", "x_3 - x_4 = b_2\\\\\n", "-x_1 + x_4 = b_3\\\\\n", "x_1 - x_2 = b_4\\\\\n", "-x_2 + x_4 = b_5\n", "\\end{cases}\n", "\\end{equation}$\n", "\n", "Which forms $Ax = b$:\n", "$\\begin{bmatrix}\n", "-1 & 0 & 1 & 0 \\\\\n", "0 & 0 & 1 & -1\\\\\n", "-1 & 0 & 0 & 1\\\\\n", "1 & -1 & 0 & 0\\\\\n", "0 & -1 & 0 & 1\\\\\n", "\\end{bmatrix}\n", "\\begin{bmatrix} x_1\\\\ x_2\\\\ x_3\\\\ x_4\\\\ \\end{bmatrix}\n", "= \\begin{bmatrix} b_1\\\\ b_2\\\\ b_3\\\\ b_4\\\\ \\end{bmatrix}$\n", "\n", "To see if our matrix $A$ is linearly independent, we'll row reduce the matrix using Python." ] }, { "cell_type": "code", "execution_count": 85, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "rref of A = \n" ] }, { "data": { "text/latex": [ "$\\displaystyle \\left[\\begin{matrix}1 & 0 & 0 & -1\\\\0 & 1 & 0 & -1\\\\0 & 0 & 1 & -1\\\\0 & 0 & 0 & 0\\\\0 & 0 & 0 & 0\\end{matrix}\\right]$" ], "text/plain": [ "⎡1 0 0 -1⎤\n", "⎢ ⎥\n", "⎢0 1 0 -1⎥\n", "⎢ ⎥\n", "⎢0 0 1 -1⎥\n", "⎢ ⎥\n", "⎢0 0 0 0 ⎥\n", "⎢ ⎥\n", "⎣0 0 0 0 ⎦" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "A = sympy.Matrix([[-1,0,1,0], [0,0,1,-1], [-1,0,0,1],[1,-1,0,0], [0,-1,0,1]])\n", "rref,a = A.rref()\n", "\n", "print(\"rref of A = \")\n", "display(rref)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "This shows us that the rank of the matrix is 3 since there are 3 rows with values in the matrix after the row reduction. Since the fourth column is a linear combination of the first three, we do not need to include it in our range space. \n", "\n", "Therefore we get\n", "$R(A) = span\\Bigg\\{\\begin{bmatrix} -1\\\\ 0\\\\ -1\\\\ 1\\\\ 0\\\\ \\end{bmatrix},\n", "\\begin{bmatrix} 0\\\\ 0\\\\ 0\\\\ -1\\\\ -1\\\\ \\end{bmatrix},\n", "\\begin{bmatrix} 1\\\\ 1\\\\ 0\\\\ 0\\\\ 0\\\\ \\end{bmatrix}\\Bigg\\}$\n", "\n", "Now we can keep going like this, or we can use some Python :)" ] }, { "cell_type": "code", "execution_count": 142, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "R(A) = span\n" ] }, { "data": { "text/latex": [ "$\\displaystyle \\left[ \\left[\\begin{matrix}-1\\\\0\\\\-1\\\\1\\\\0\\end{matrix}\\right], \\ \\left[\\begin{matrix}0\\\\0\\\\0\\\\-1\\\\-1\\end{matrix}\\right], \\ \\left[\\begin{matrix}1\\\\1\\\\0\\\\0\\\\0\\end{matrix}\\right]\\right]$" ], "text/plain": [ "⎡⎡-1⎤ ⎡0 ⎤ ⎡1⎤⎤\n", "⎢⎢ ⎥ ⎢ ⎥ ⎢ ⎥⎥\n", "⎢⎢0 ⎥ ⎢0 ⎥ ⎢1⎥⎥\n", "⎢⎢ ⎥ ⎢ ⎥ ⎢ ⎥⎥\n", "⎢⎢-1⎥, ⎢0 ⎥, ⎢0⎥⎥\n", "⎢⎢ ⎥ ⎢ ⎥ ⎢ ⎥⎥\n", "⎢⎢1 ⎥ ⎢-1⎥ ⎢0⎥⎥\n", "⎢⎢ ⎥ ⎢ ⎥ ⎢ ⎥⎥\n", "⎣⎣0 ⎦ ⎣-1⎦ ⎣0⎦⎦" ] }, "metadata": {}, "output_type": "display_data" }, { "name": "stdout", "output_type": "stream", "text": [ "N(A) = span\n" ] }, { "data": { "text/latex": [ "$\\displaystyle \\left[ \\left[\\begin{matrix}1\\\\1\\\\1\\\\1\\end{matrix}\\right]\\right]$" ], "text/plain": [ "⎡⎡1⎤⎤\n", "⎢⎢ ⎥⎥\n", "⎢⎢1⎥⎥\n", "⎢⎢ ⎥⎥\n", "⎢⎢1⎥⎥\n", "⎢⎢ ⎥⎥\n", "⎣⎣1⎦⎦" ] }, "metadata": {}, "output_type": "display_data" }, { "name": "stdout", "output_type": "stream", "text": [ "R(A^T) = span\n" ] }, { "data": { "text/latex": [ "$\\displaystyle \\left[ \\left[\\begin{matrix}-1\\\\0\\\\1\\\\0\\end{matrix}\\right], \\ \\left[\\begin{matrix}0\\\\0\\\\1\\\\-1\\end{matrix}\\right], \\ \\left[\\begin{matrix}1\\\\-1\\\\0\\\\0\\end{matrix}\\right]\\right]$" ], "text/plain": [ "⎡⎡-1⎤ ⎡0 ⎤ ⎡1 ⎤⎤\n", "⎢⎢ ⎥ ⎢ ⎥ ⎢ ⎥⎥\n", "⎢⎢0 ⎥ ⎢0 ⎥ ⎢-1⎥⎥\n", "⎢⎢ ⎥, ⎢ ⎥, ⎢ ⎥⎥\n", "⎢⎢1 ⎥ ⎢1 ⎥ ⎢0 ⎥⎥\n", "⎢⎢ ⎥ ⎢ ⎥ ⎢ ⎥⎥\n", "⎣⎣0 ⎦ ⎣-1⎦ ⎣0 ⎦⎦" ] }, "metadata": {}, "output_type": "display_data" }, { "name": "stdout", "output_type": "stream", "text": [ "N(A^T) = span\n" ] }, { "data": { "text/latex": [ "$\\displaystyle \\left[ \\left[\\begin{matrix}-1\\\\1\\\\1\\\\0\\\\0\\end{matrix}\\right], \\ \\left[\\begin{matrix}-1\\\\1\\\\0\\\\-1\\\\1\\end{matrix}\\right]\\right]$" ], "text/plain": [ "⎡⎡-1⎤ ⎡-1⎤⎤\n", "⎢⎢ ⎥ ⎢ ⎥⎥\n", "⎢⎢1 ⎥ ⎢1 ⎥⎥\n", "⎢⎢ ⎥ ⎢ ⎥⎥\n", "⎢⎢1 ⎥, ⎢0 ⎥⎥\n", "⎢⎢ ⎥ ⎢ ⎥⎥\n", "⎢⎢0 ⎥ ⎢-1⎥⎥\n", "⎢⎢ ⎥ ⎢ ⎥⎥\n", "⎣⎣0 ⎦ ⎣1 ⎦⎦" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "# Use sympy.columnspace() and sympy.nullspace() method \n", "A_columnspace = A.columnspace()\n", "A_nullspace = A.nullspace()\n", "A_T_columnspace = A.T.columnspace() \n", "A_T_nullspace = A.T.nullspace() \n", " \n", "print(\"R(A) = span\") \n", "display(A_columnspace)\n", "\n", "print(\"N(A) = span\") \n", "display(A_nullspace)\n", "\n", "print(\"R(A^T) = span\") \n", "display(A_T_columnspace)\n", "\n", "print(\"N(A^T) = span\") \n", "display(A_T_nullspace)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Knowing these spaces helps us to know what kind of problem we are dealing with. In this case the problem has many solutions." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Challenge Problem\n", "\n", "For an mxn matrix $A$, show that the $dim(N(A)) = n- rank(A)$." ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [] } ], "metadata": { "kernelspec": { "display_name": "Python 3", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.8.5" } }, "nbformat": 4, "nbformat_minor": 2 }