{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [] }, { "cell_type": "markdown", "metadata": {}, "source": [] }, { "cell_type": "markdown", "metadata": {}, "source": [ "# 14 In-Class Assignment: Fundamental Spaces\n", "\n", " \n", "\n", "Image from: https://kevinbinz.com/2017/02/20/linear-algebra/\n", "\n", " " ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Agenda for today's class (80 minutes)\n", "\n", "1. [(20 minutes) Pre-class assignment review](#Pre-class_assignment_review)\n", "1. [(20 minutes) Four Fundamental Spaces](#Four_Fundamental_Subspaces)\n", "1. [(20 minutes) Practice Example](#Practice_Example)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "---\n", "\n", "\n", "## 1. Pre-class assignment review" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "* [14--Fundamental_Spaces_pre-class-assignment.ipynb](14--Fundamental_Spaces_pre-class-assignment.ipynb)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "---\n", "\n", "## 2. Four Fundamental Subspaces" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### The four fundamental subspaces\n", "\n", "* Columnspace, $\\mathcal{C}(A)$\n", "* Nullspace, $\\mathcal{N}(A)$\n", "* Rowspaces, $R(A)$\n", " * All linear combinations of rows\n", " * All the linear combinations of the colums of $A^\\top$, $\\mathcal{C}(A^\\top)$\n", "* Nullspace of $A^\\top$, $\\mathcal{N}(A^\\top)$ (the left nullspace of $A$)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Where are these spaces for a $m\\times n$ matrix $A$?\n", "* $\\mathcal{R}(A)$ is in $R^n$\n", "* $\\mathcal{N}(A)$ is in $R^n$\n", "* $\\mathcal{C}(A)$ is in $R^m$\n", "* $\\mathcal{N}(A^\\top)$ is in $R^m$" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "### Calculating basis and dimension\n", "\n", "#### For $\\mathcal{R}(A)$\n", "* If $A$ undergoes row reduction to row echelon form $B$, then $\\mathcal{C}(B)\\neq \\mathcal{C}(A)$, but $\\mathcal{R}(B) = \\mathcal{R}(A)$ (or $\\mathcal{C}(B^\\top) = \\mathcal{C}(A^\\top))$\n", "* A basis for the rowspace of $A$ (or $B$) is the first $r$ rows of $B$\n", " * So we row reduce $A$ and take the pivot rows and transpose them\n", "* The dimension is also equal to the rank $r$\n", "\n", "#### For $\\mathcal{N}(A)$\n", "* The bases are the special solutions (one for every free variable, $n-r$)\n", "* The dimension is $n- r$\n", "\n", "\n", "#### For $\\mathcal{C}(A) = \\mathcal{R}(A^\\top)$\n", "* Apply the row reduction on the transpose $A^\\top$.\n", "* The dimension is the rank $r$\n", "\n", "\n", "#### For $\\mathcal{N}(A^\\top)$\n", "* It is also called the left nullspace, because it ends up on the left (as seen below)\n", "* Here we have $A^\\top y = 0$\n", " * $y^\\top(A^\\top)^\\top = 0^\\top$\n", " * $y^\\top A = 0^\\top$\n", " * This is (again) the special solutions for $A^\\top$ (after row reduction)\n", "* The dimension is $m - r$" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "----\n", "\n", "\n", "## 3. Practice Example:\n", "\n", "Consider the linear transformation defined by the following matrix $A$. \n", "\n", "$$A = \n", "\\left[\n", "\\begin{matrix}\n", " 1 & 2 & 3 & 1 \\\\\n", " 1 & 1 & 2 & 1 \\\\\n", " 1 & 2 & 3 & 1 \n", " \\end{matrix}\n", "\\right] \n", "$$" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "%matplotlib inline\n", "import matplotlib.pylab as plt\n", "import numpy as np\n", "import sympy as sym\n", "sym.init_printing()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "**✅ Question:** What is the reduced row echelon form of $A$? You can use sympy." ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "#Put your answer to the above question here." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "**✅ Question:** Now let's calculate the row space of $A$. \n", "Note that the row space is defined by a linear combination of the non-zero row vectors in the reduced row echelon matrix:" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Put your answer to the above question here" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "✅ **Question:** What is the rank of matrix $A$? You should know the rank by inspecting the reduced row echelon form. Find a numpy or sympy function that you can use to verify your answer?" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "## Put code here to verify your answer." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "✅ **Question:** Using the reduced row echelon form define the leading variables in terms of the free variables for the homogeneous equation. " ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Put your answer to the above question here" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "✅ **Question:** The solution to the above question defines the nullspace of $A$ (aka the Kernel). Use the *sympy.nullspace* function to verify your answer." ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "# Put your code here" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "✅ ** Question:** Now let's calculate the range of $A$ (column space of $A$). Note that the range is spanned by the column vectors of $A$. \n", "Transpose $A$ and calculate the reduced row echelon form of the transposed matrix like we did above." ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "## Put your code here" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "✅ **Question:** The nonzero row vectors of the above solution will give a basis for the range (or $\\mathcal{C}(A)$). Write the range of $A$ as a linear combination of these nonzero vectors:" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Put your answer to the above question here." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "✅ **Question:** Finally, using the reduced row echelon form for $A^\\top$ define the leading variables in terms of the free variables and define the null space of $A^\\top$." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Put your answer to the above question here." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "----\n", "Written by Dr. Dirk Colbry, Michigan State University\n", " This work is licensed under a Creative Commons Attribution-NonCommercial 4.0 International License." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "\n" ] } ], "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.2" } }, "nbformat": 4, "nbformat_minor": 4 }