From edd10658284e47b19bb3fc173441809a7fa8d29d Mon Sep 17 00:00:00 2001 From: Dima Timofeev <1127655+CuriousDima@users.noreply.github.com> Date: Thu, 15 Aug 2024 22:37:48 -0700 Subject: [PATCH] eigenvalues and eigenvectors --- .../eigenvalues_and_eigenvectors.ipynb | 698 ++++++++++++++++++ 1 file changed, 698 insertions(+) create mode 100644 math/linear-algebra-for-ml/eigenvalues_and_eigenvectors.ipynb diff --git a/math/linear-algebra-for-ml/eigenvalues_and_eigenvectors.ipynb b/math/linear-algebra-for-ml/eigenvalues_and_eigenvectors.ipynb new file mode 100644 index 0000000..499bec3 --- /dev/null +++ b/math/linear-algebra-for-ml/eigenvalues_and_eigenvectors.ipynb @@ -0,0 +1,698 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "metadata": { + "id": "EAt-K2qgcIou" + }, + "source": [ + "# Interpreting eigenvalues and eigenvectors" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "id": "FZYK-0rin5x7" + }, + "source": [ + "Welcome to the Week 4 Lab. Here you will practice finding and interpreting eigenvalues and eigenvectors for various linear transformations.\n", + "\n", + "**After this lab you will be able to:**\n", + "- use Python to find eigenvalues and eigenvectors\n", + "- visualize and interpret eigenvalues and eigenvectors" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Table of Contents\n", + "- [ 1 - Eigenvalues and Eigenvectors: Definition and Interpretation](#1)\n", + " - [ 1.1 - Definition of Eigenvalues and Eigenvectors](#1.1)\n", + " - [ 1.2 - Finding Eigenvalues and Eigenvectors with Python](#1.2)\n", + "- [ 2 - Eigenvalues and Eigenvectors of the Standard Transformations in a Plane](#2)\n", + " - [ 2.1 - Example 1: Reflection about y-axis (the vertical axis)](#2.1)\n", + " - [ 2.2 - Example 2: Shear in x-direction](#2.2)\n", + " - [ 2.3 - Example 3: Rotation](#2.3)\n", + " - [ 2.4 - Example 4: Identity Matrix and Scaling in All Directions](#2.4)\n", + " - [ 2.5 - Example 5: Projection onto x-axis](#2.5)\n" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "id": "XI8PBrk_2Z4V" + }, + "source": [ + "## Packages\n", + "\n", + "Run the following cell to load the packages you'll need. The `utils.py` file includes a function you'll use later to plot transformations." + ] + }, + { + "cell_type": "code", + "execution_count": 1, + "metadata": { + "tags": [ + "graded" + ] + }, + "outputs": [], + "source": [ + "import numpy as np\n", + "import matplotlib.pyplot as plt\n", + "import utils" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "\n", + "## 1 - Eigenvalues and Eigenvectors: Definition and Interpretation\n", + "\n", + "\n", + "### 1.1 - Definition of Eigenvalues and Eigenvectors\n", + "\n", + "Let's consider a linear transformation defined by matrix $A=\\begin{bmatrix}2 & 3 \\\\ 2 & 1 \\end{bmatrix}$. Apply this transformation to the standard basis vectors $e_1=\\begin{bmatrix}1 \\\\ 0\\end{bmatrix}$ and $e_2=\\begin{bmatrix}0 \\\\ 1\\end{bmatrix}$ and visualize the result. Hopefully using a matrix to transform a basis of vectors is familiar from earlier lectures in the course." + ] + }, + { + "cell_type": "code", + "execution_count": 2, + "metadata": { + "tags": [ + "graded" + ] + }, + "outputs": [], + "source": [ + "A = np.array([[2, 3],[2, 1]])\n", + "e1 = np.array([[1],[0]])\n", + "e2 = np.array([[0],[1]])" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "You can use the function `plot_transformation` defined in `utils.py` to visualize the transformation generated by the matrix $A$." + ] + }, + { + "cell_type": "code", + "execution_count": 3, + "metadata": { + "tags": [ + "graded" + ] + }, + "outputs": [ + { + "data": { + "image/png": "iVBORw0KGgoAAAANSUhEUgAAAaYAAAGfCAYAAAAUBHZmAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjMuNCwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8QVMy6AAAACXBIWXMAAAsTAAALEwEAmpwYAAAjrElEQVR4nO3de3RV9Z338c/35H4jXJJAEgkXQVAEUWOLaBEvaL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obf/Ie6L9151qe63Phc65OZFOhcM5RtKTanuqcqukeZKmpMD3jh7x+nVMAID+h9cxAQC8QpgAAF4hTAAArxAmAIBXCBMAwCuECQDgFcIEAPAKYQIAeOX/A1diOaBVX2BPAAAAAElFTkSuQmCC\n", + "text/plain": [ + "
" + ] + }, + "metadata": { + "needs_background": "light" + }, + "output_type": "display_data" + } + ], + "source": [ + "utils.plot_transformation(A, e1, e2, vector_name='e');" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Both of the original basis vectors $e_1$ and $e_2$ changed their length and direction with the transformation $A$. What if you could choose some other basis vectors where only their lengths will change? This means that for the vector $v$, its transformation will be $Av=\\lambda v$. \n", + "\n", + "As you saw in the lectures, a vector $v$ with this property is called an **eigenvector** and the scaling factor $\\lambda$ is called an **eigenvalue**.\n", + "\n", + "Note that if $v$ is an eigenvector, so that $Av = \\lambda v$, then any multiple or scaled version of $v$ is also an eigenvector with the same eigenvalue. If we let $k$ represent that scale factor, we would write this mathematically as: \n", + "\n", + "$$A(kv)=k(Av)=k \\lambda v = \\lambda (kv),$$ \n", + "where $k$ is any real valued constant different from zero.\n", + "\n", + "In other words, for each eigenvalue, there are infinitely many valid eigenvectors. You can imagine them as all pointing along the same straight line and just having different lengths, or norms. In practice, you will choose just one eigenvector, and it is common to choose the eigenvector which has a norm of 1." + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "\n", + "### 1.2 - Finding Eigenvalues and Eigenvectors with Python" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "In Python eigenvalues and eigenvectors can be found using the `NumPy` function `np.linalg.eig()`. It returns a tuple consisting of a vector and an array. The vector contains the eigenvalues. The array contains the corresponding eigenvectors, one eigenvector per column. Note that this function chooses the eigenvectors so that they have a norm of 1.\n", + "\n", + "With the following code you can find an eigenvalues and eigenvectors for the previously defined matrix $A$:" + ] + }, + { + "cell_type": "code", + "execution_count": 4, + "metadata": { + "tags": [ + "graded" + ] + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "\n", + "\n", + "Matrix A:\n", + "[[2 3]\n", + " [2 1]] \n", + "\n", + "Eigenvalues of matrix A:\n", + "[ 4. -1.]\n", + "\n", + "Eigenvectors of matrix A:\n", + "[[ 0.83205029 -0.70710678]\n", + " [ 0.5547002 0.70710678]]\n" + ] + } + ], + "source": [ + "A_eig = np.linalg.eig(A)\n", + "\n", + "print(\"\\n\")\n", + "\n", + "print(f\"Matrix A:\\n{A} \\n\\nEigenvalues of matrix A:\\n{A_eig[0]}\\n\\nEigenvectors of matrix A:\\n{A_eig[1]}\")" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Remember that the first element of the tuple contains the eigenvalues, and the second one has the eigenvectors, one in each column. This means that the first eigenvector can be extrancted with the code `A_eig[1][:,0]` and second eigenvector with the code `A_eig[1][:,1]`. \n", + "\n", + "Let's visualize the result of the transformation on the eigenvectors:" + ] + }, + { + "cell_type": "code", + "execution_count": 5, + "metadata": { + "tags": [ + "graded" + ] + }, + "outputs": [ + { + "data": { + "image/png": "iVBORw0KGgoAAAANSUhEUgAAAaYAAAGfCAYAAAAUBHZmAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjMuNCwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8QVMy6AAAACXBIWXMAAAsTAAALEwEAmpwYAAAmJklEQVR4nO3dd3Rc9Z3+8eczkqxqy0WyXEDYxgYXigF5Y5pjSMwGCAllAwllAwG8hGULu8umsBtgw+ZsskAglGRJg4WE5EdyMAumxwYnwRSbYGNwBRt3uUiyrN6+vz9UojLqc+d+Z+b9OscH5t6Zud97dOXHz63mnBMAAL6IhD0AAAA6I5gAAF4hmAAAXiGYAABeIZgAAF5JD3sAnRUUFLgpU6aEPQwAQMBWr159wDlXGG2eV8E0ZcoUrVq1KuxhAAACZmYf9zaPXXkAAK8QTAAArxBMAACvEEwAAK8QTAAArxBMAACvEEwAAK8QTAAArxB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0sqQxzFsZna8WtcjS1KVpIucc++FO6rhM7PrJU2XdFXYYwlD3BqTmd3ZdgCvrz8Lu30mV9Izknap9ZiTd4ayXkmi+z5gizINnjGzeySdIekS51xz2OOJgY2S5kqaL+mHkh5N9BM7zOxYtR6/vWIAd8tJSvFsTPcqOW8Ee68GsV5J4IBa7xg/odv08erZouARM/u+pC+q9S4sH4U9nlho+4t7S9vLVWY2T9LNkq4Nb1TDdqpa90ysM7P2aWmSFpjZDZJynXP1YQ0uHuIWTMl6I9jBrFcycM41mNlqSYskPdlp1iJJvw1nVOiPmd2n1lBa6JzbEPZ4AhSRlBn2IIZpiaRV3ab9XNJmtTappG9R3h1jisGNYL1lZhPU2jSOaZs0u+0Y2nbnXFloAxu8eyQ9ZmZvSfqjpBvUepr/j0Id1TC1tfTpbS8jkorNbK5at7uEbb1m9qBaj1VcKKm8bTuUpCqf/9HXHzP7L0lLJe1Q6wkdl6v11PiEvpbJOVchqaLzNDOrVut2mIwPUu3Bu9PFk/lGsGZ2u6Tbosy6JtFOSzazG9V63G+iWq/9udk5tyLcUQ1PH9veo865q+M6mBgys95+ye9wzt0ez7HEkpk9Iukstf5j75Bar/X5b+fci2GOKwhm9qpS6HRx74IJAJDaEuU6JgBAiiCYAABeIZgAAF4hmAAAXiGYAABeIZgAAF4hmAAAXiGYAABe+f9q14LYFlX51AAAAABJRU5ErkJggg==\n", + "text/plain": [ + "
" + ] + }, + "metadata": { + "needs_background": "light" + }, + "output_type": "display_data" + } + ], + "source": [ + "utils.plot_transformation(A, A_eig[1][:,0], A_eig[1][:,1]);" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "As you can see, $v_1$ is being streched by a factor of 4, while $v_2$ shows a change of the direction, which is equivalent to a factor of -1. Both vectors, however, are still parallel to the direction they were originally pointing and so meet the definition of an eigenvector." + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "\n", + "## 2 - Eigenvalues and Eigenvectors of some Standard Transformations in a Plane\n" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "\n", + "### 2.1 - Example 1: Reflection about y-axis (the vertical axis)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "If you want to create a reflection about the y-axis, you need to keep the value of the y-axis fixed, while changing the direction of the vector arounf the x-axis. \n", + "This can be done with the matrix\n", + "$$A_{\\text{reflection_yaxis}}= \\left[\\begin{matrix}-1& 0\\\\0 &1\\end{matrix}\\right]. $$ \n", + "\n", + "\n", + "\n", + "In the following code, you will define the matrix, find its eigenvalues and eigenvectors, and visualize the result How would you interpret this linear transformation in terms of the eigenvectors and thier eigenvalues?" + ] + }, + { + "cell_type": "code", + "execution_count": 6, + "metadata": { + "scrolled": false, + "tags": [ + "graded" + ] + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Matrix A:\n", + " [[-1 0]\n", + " [ 0 1]] \n", + "\n", + "Eigenvalues of matrix A:\n", + " [-1. 1.] \n", + "\n", + "Eigenvectors of matrix A:\n", + " [[1. 0.]\n", + " [0. 1.]]\n" + ] + }, + { + "data": { + "image/png": "iVBORw0KGgoAAAANSUhEUgAAAaYAAAGfCAYAAAAUBHZmAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjMuNCwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8QVMy6AAAACXBIWXMAAAsTAAALEwEAmpwYAAAZLUlEQVR4nO3dfXBd9X3n8c/36snSvbZkW9d68AN+ELEtB3CwyBoIDg0Y0rCbDXGXlElmQ6bBSWg6SbcDs92HBlLS6UxpS0KWpmS7SQayKUPZhKQYQkIAQ8qDhTEgkG0sbCzLWNajZVnP0m//kCJblizL1r06X0nv14wn3HPuPedrBfvNuefccy2EIAAAvIhFPQAAAKciTAAAVwgTAMAVwgQAcIUwAQBcyYx6gFMVFhaG5cuXRz0GACDNXn311cYQQnKsda7CtHz5clVWVkY9BgAgzczsvTOt4608AIArhAkA4AphAgC4QpgAAK4QJgCAK4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sjnmPGM7PPSPq2pL+S9CFJ/ybpCTNbFulgM19CUpWkr0nqjHgWjGFaXPxgZp+Q9K+SCrgR7NQwswpJOyStCCEciHicGcnMXpb0Rgjh1lOWvSPpX0IIfx7dZLOHmbVL+moI4YdRz4KTPB4xjYUbwWJGMbNsSRs0eHR6qqckXTH1EwF+uA/TRG4EC0xDhZIyJNWftrxeUvHUjwP4MWVhMrO7h040jvfr6tNeE5f0C0l1GjznhPNwPj97TJnT30u3MZYBs0pav/biNPeKG8FG5V6dw88eU6JRg3feP/3oaJFGH0UBs8qUhYkbwUbnXH72mBohhB4ze1XSZkmPnLJqs6RHo5kK8GEqj5gmJAU3gsUkmFmxBv8r/gNDi8qHzvMdDCE0RzbYzPR3kh40s1ck/VbSlzX4cYnvRTrVDDf0bkzZ0MOYpGVmtl6Df7/wzoED7i4X50aw0TKzOyV9Y4xVX+CS2tQzs9s0eP60RIOfrfnTEML2aKea2cb5O+ZHIYRbpnQYjMldmAAAs5v7y8UBALMLYQIAuEKYAACuECYAgCuECQDgCmECALhCmAAArhAmAIAr/x/kIc3bW/+ZVwAAAABJRU5ErkJggg==\n", + "text/plain": [ + "
" + ] + }, + "metadata": { + "needs_background": "light" + }, + "output_type": "display_data" + } + ], + "source": [ + "# Define transformation matrix A_reflection_yaxis as a numpy array.\n", + "A_reflection_yaxis = np.array([[-1,0],[0,1]])\n", + "# Find eigenvalues and eigenvectors of matrix A_reflection_yaxis.\n", + "A_reflection_yaxis_eig = np.linalg.eig(A_reflection_yaxis)\n", + "\n", + "print(f\"Matrix A:\\n {A_reflection_yaxis} \\n\\nEigenvalues of matrix A:\\n {A_reflection_yaxis_eig[0]}\",\n", + " f\"\\n\\nEigenvectors of matrix A:\\n {A_reflection_yaxis_eig[1]}\")\n", + "\n", + "utils.plot_transformation(A_reflection_yaxis, A_reflection_yaxis_eig[1][:,0],A_reflection_yaxis_eig[1][:,1]);" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "In the examples you've seen so far, you've considered 2 $\\times$ 2 matrices, and each of them have had 2 distinct eigenvalues, and 2 distinct eigenvectors. A natural question arises: is it always possible to find two different eigenvectors for any linear transformation in the plane? As you already learned in the lectures, the answer is unfortunately no. You'll see a case of this happening in the following example." + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "\n", + "### 2.2 - Example 2: Shear in x-direction" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "A **shear transformation** looks like the image below. This transformation displaces each point in a fixed direction by an amount proportional to its signed distance from a given line parallel to that direction. You can imagine it as slicing the plane into layers and then sliding those layers past one another. Let's explore how many eigenvectors this kind of transformation has.\n", + "\n", + "\n", + "\n", + "\n", + "\n", + "To create a matrix transformation that shears in the x-direction, you want to displace the component in the y-direction by some factor, say 0.5. This can be done with the following matrix:\n", + "\n", + "$$A_{\\text{shear_x}}= \\left[\\begin{matrix}1& 0.5\\\\0 &1\\end{matrix}\\right]. $$ \n", + "\n", + "\n", + "Note that vector $e_1=\\begin{bmatrix}1 \\\\ 0\\end{bmatrix}$ will remain the same, and vector $e_2=\\begin{bmatrix}0 \\\\ 1\\end{bmatrix}$ will transform into a vector $\\begin{bmatrix}0.5 \\\\ 1\\end{bmatrix}$.\n", + "\n", + "In the next cell, you will define the shear matrix, find the eigenvalues and eigenvectors, and visualize the transformation applied to the eigenvectors you find." + ] + }, + { + "cell_type": "code", + "execution_count": 7, + "metadata": { + "scrolled": false, + "tags": [ + "graded" + ] + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Matrix A_shear_x:\n", + " [[1. 0.5]\n", + " [0. 1. ]]\n", + "\n", + "Eigenvalues of matrix A_shear_x:\n", + " [1. 1.] \n", + "\n", + "Eigenvectors of matrix A_shear_x \n", + " [[ 1.0000000e+00 -1.0000000e+00]\n", + " [ 0.0000000e+00 4.4408921e-16]]\n" + ] + }, + { + "data": { + "image/png": "iVBORw0KGgoAAAANSUhEUgAAAaYAAAGfCAYAAAAUBHZmAAAAOX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OrDhNzfJnUl+M8muAY+FIzghDn5orb0qyV8kme9CsJOjtbY6ya1JntV13QMDHs5Qaq19M8kdXde986Bp9yf5X13X/c7gRjZ1tNZ2JHlP13WfGvRYeELFLaYjcSFYhkprbUaS52f/1unBbkzywskfEdRRPkzHcyFYOAEtTDItyYZDpm9IsmTyhwN1TFqYWmvXHNjReLSflx7ymDlJ/jzJ+uzf58TT8HReeybNoZ+ltyNMgymlr197cYiPxoVgB+WjeQqvPZNic/Zfef/QraPTc/hWFEwpkxYmF4IdnKfy2jM5uq7b21q7LclVSa47aNZVSa4fzKighsncYjouPbgQLM9Aa21J9r+Lf86BSRce2M/3YNd1WwY2sOH0n5N8urX2rSRfS/Lu7D9d4r8NdFRD7sCnMSsO3BxJsqy1dkn2///ik4MCyh0u7kKwg9Va+0CS9x9h1tscUtt7rbWrs3//6RnZf27Nb3Vdd8tgRzXcjvJ/zB91XffWSR0MR1QuTABMbeUPFwdgahEmAEoRJgBKESYAShEmAEoRJgBKESYAShEmAEr5/6pxQMBhB5ASAAAAAElFTkSuQmCC\n", + "text/plain": [ + "
" + ] + }, + "metadata": { + "needs_background": "light" + }, + "output_type": "display_data" + } + ], + "source": [ + "# Define transformation matrix A_shear_x as a numpy array.\n", + "A_shear_x = np.array([[1, 0.5],[0, 1]])\n", + "# Find eigenvalues and eigenvectors of matrix A_shear_x.\n", + "A_shear_x_eig = np.linalg.eig(A_shear_x)\n", + "\n", + "print(f\"Matrix A_shear_x:\\n {A_shear_x}\\n\\nEigenvalues of matrix A_shear_x:\\n {A_shear_x_eig[0]}\",\n", + " f\"\\n\\nEigenvectors of matrix A_shear_x \\n {A_shear_x_eig[1]}\")\n", + "\n", + "utils.plot_transformation(A_shear_x, A_shear_x_eig[1][:,0], A_shear_x_eig[1][:,1]);" + ] + }, + { + "cell_type": "code", + "execution_count": 8, + "metadata": { + "tags": [ + "graded" + ] + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Matrix A_rotation:\n", + " [[ 0 1]\n", + " [-1 0]]\n", + "\n", + "Eigenvalues of matrix A_rotation:\n", + " [0.+1.j 0.-1.j] \n", + "\n", + "Eigenvectors of matrix A_rotation \n", + " [[0.70710678+0.j 0.70710678-0.j ]\n", + " [0. +0.70710678j 0. -0.70710678j]]\n" + ] + } + ], + "source": [ + "A_rotation = np.array([[0, 1],[-1, 0]])\n", + "A_rotation_eig = np.linalg.eig(A_rotation)\n", + "\n", + "\n", + "\n", + "\n", + "print(f\"Matrix A_rotation:\\n {A_rotation}\\n\\nEigenvalues of matrix A_rotation:\\n {A_rotation_eig[0]}\",\n", + " f\"\\n\\nEigenvectors of matrix A_rotation \\n {A_rotation_eig[1]}\")\n" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "As you can see, there are two eigenvalues in the output, but they are actually complex numbers. Note in Python the imaginary part of the complex numbers is indicated with a `j` instead of the $i$ you see more commonly in mathematics. \n", + "\n", + "This matrix has two complex eigenvalues and two corresponding complex eigenvectors. Since there are no real eigenvectors, however, we can interpret this result as saying there are no vectors on the plane that will keep their direction after a 90 degree rotation. And think about it, that makes sense. If you rotate the plane, every vector will now be facing in a new direction.\n", + "\n", + "If you're less familiar with real vs. complex numbers don't worry. The main point here is that some 2 $\\times$ 2 matrices will only have one or zero real eigenvectors, and hopefully you're developing intuition for why that's the case. If there are no vectors that point in the same direction after the matrix transformation is applied, we wouldn't expect to find any eigenvectors. With that in mind, let's look at another interesting example." + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "\n", + "### 2.4 - Example 4: Identity Matrix and Scaling in All Directions\n", + "\n", + "What happens if we transform the plane using the identity matrix? This means that there will be no change to any vector in the plane. Since every point and vector does not move at all, in this case every vector is still facing in the same direction, and every vectors meets the definition of an eigenvector.\n", + "\n", + "In the next cell, you will explore what kinds of output you get from `NumPy` when you try to calculate the eigenvalues and eigenvectors of the identity matrix." + ] + }, + { + "cell_type": "code", + "execution_count": 9, + "metadata": { + "tags": [ + "graded" + ] +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cuQr/7qnLcj2J+/L7As+vO+60W/t3b0zj33nk5m59Ir07vdS8727d2TzI7dk6lmXHvK8wEjOmDiqzFhyeWYsufxlt88670NZ+5NrM+3s96XsF8f5l1570Ps3TZPHb/x0jpu7JFMWH/ipFAP3fS89s9+Y3tlnjM7wQBJh4hjTd8p52bH5sux8bkPG9b36K/+2r783mx/+UbqnvyFbVt+WJDn5vX+V7mkLUjo6M/cdn2z1yHDMESaOOQe7hvRyek84O+detfyg26ad/Y9HayRgP64xAVAVYQKgKsIEQFWECYCqCBMAVREmAKoiTABURZgAqIowAVAVYQKgKsIEQFWECYCqCBMAVREmAKoiTABURZgAqIowAVAVYQKgKsIEQFWECYCqCBMAVREmAKoiTABURZgAqIowAVAVYQKgKsIEQFWECYCqCBMAVREmAKoiTABURZgAqIowAVAVYQKgKsIEQFWECYCqCBMAVREmAKoiTABURZgAqIowAVAVYQKgKsIEQFWECYCqCBMAVREmAKoiTABURZgAqIowAVAVYQKgKsIEQFWECYCqCBMAVREmAKoiTABURZgAqIowAVAVYQKgKsIEQFWECYCqCBMAVREmAKoiTABURZgAqIowAVAVYQKgKsIEQFWECYCqCBMAVREmAKoiTABURZgAqIowAVAVYQKgKsIEQFWECYCqCBMAVREmAKoiTABURZgAqIowAVAVYQKgKsIEQFWECYCqCBMAVREmAKoiTABURZgAqIowAVAVYQKgKsIEQFWECYCqCBMAVREmAKoiTABURZgAqIowAVAVYQKgKsIEQFWECYCqCBNQvdO+8Xf58kOrD1h7ZMvWzPzKDbl/45b2DEXLCBNQvUWTjs+qzVsPWPur5Q/k0lNOzBlTJrZnKFpGmIDqnT65L49seTFMd/YP5Kfrn86/PWdxkuRPf/TznHL993LFT37ZrhEZRcIEHLbVa1dl1+6dLdv/6ZP6smrLc/tuX738/nxw0fyceFxPkuQji9+Q69725pYdnyOrZWEqpVxZSllTShkupdxVSrmwVccC2uvRR+/MLz5zcf72v30kN936P7Jp68ZR3f+iyX0ZGN6RTcM7cuMTT2bl5q35xNmL9m2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kybf323RJkhvaMxVQg7Z/UeDBHOYHwfL68ddJri+l3Jnk50k+kmR2ki+2dSparpTSm2TBCzc7kswtpZydZFPTNJ45OcZV+XJxHwR77CilXJnkqiSz8vz7Wj7RNM3t7Z2KVnvhevItB9n0taZprjiiw1CdKsMEwLHLy8UBqIowAVAVYQKgKsIEQFWECYCqCBMAVREmAKoiTABU5f8DRm+gJXHfWWoAAAAASUVORK5CYII=\n", + "text/plain": [ + "
" + ] + }, + "metadata": { + "needs_background": "light" + }, + "output_type": "display_data" + }, + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Matrix A_identity:\n", + " [[1 0]\n", + " [0 1]]\n", + "\n", + "Eigenvalues of matrix A_identity:\n", + " [1. 1.] \n", + "\n", + "Eigenvectors of matrix A_identity\n", + " [[1. 0.]\n", + " [0. 1.]]\n" + ] + } + ], + "source": [ + "A_identity = np.array([[1, 0],[0, 1]])\n", + "A_identity_eig = np.linalg.eig(A_identity)\n", + "\n", + "utils.plot_transformation(A_identity, A_identity_eig[1][:,0], A_identity_eig[1][:,1]);\n", + "\n", + "print(f\"Matrix A_identity:\\n {A_identity}\\n\\nEigenvalues of matrix A_identity:\\n {A_identity_eig[0]}\",\n", + " f\"\\n\\nEigenvectors of matrix A_identity\\n {A_identity_eig[1]}\")" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "As you can see, the out of the `np.linalg.eig()` function shows that there are two eigenvalues that are equal to each other $\\lambda = 1$, which is true. But the list of eigenvectors does not cover all of them. It can be shown algebraically that all of the vectors will be eigenvectors for identity matrix. Using software, you can't see it sometimes, so be careful! That's why understanding of mathematical objects behind your code and models is so important.\n", + "\n", + "Check that the same will happen finding eigenvectors for the scaling (dilation) in both directions x and y by factor of $2$. In this case every vector is facing the same direction as it was before, but twice as long. Once again, every vector meets the definition of an eigenvector, but `NumPy` will only provide two." + ] + }, + { + "cell_type": "code", + "execution_count": 10, + "metadata": { + "tags": [ + "graded" + ] + }, + "outputs": [ + { + "data": { + "image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eh4MmMyPvXhIXAjWk3pJfRp9djRLo8+igCnHzL4l6ZMa+GSEt6OeB2dNWpi4EKwvIYQeM9spaZ2kx4dtWidpczRTAZPDzB7WQJRuCiHsj3oejBT5BwWOZYIXgsWl+6akR83sVUm/lPR5SZWS/jrSqdLA4CvBqga/zJA018yWS2oMIfDIQQqZ2V9K+oykj0lqGvz3RpLaQghtkQ2GIS5fLs6FYCePmW2QdJ+kCg28r+bLIYQXo51q6ht8PvW5MTb9fQjhnkkdJs2Y2fn+0XsghHD/ZM6CsbkMEwAgffFycQCAK4QJAOAKYQIAuEKYAACuECYAgCuECQDgCmECALhCmAAArvx/mJ70oQ9p/pAAAAAASUVORK5CYII=\n", + "text/plain": [ + "
" + ] + }, + "metadata": { + "needs_background": "light" + }, + "output_type": "display_data" + }, + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Matrix A_scaling:\n", + " [[2 0]\n", + " [0 2]]\n", + "\n", + "Eigenvalues of matrix A_scaling:\n", + " [2. 2.] \n", + "\n", + "Eigenvectors of matrix A_scaling\n", + " [[1. 0.]\n", + " [0. 1.]]\n" + ] + } + ], + "source": [ + "A_scaling = np.array([[2, 0],[0, 2]])\n", + "A_scaling_eig = np.linalg.eig(A_scaling)\n", + "\n", + "utils.plot_transformation(A_scaling, A_scaling_eig[1][:,0], A_scaling_eig[1][:,1]);\n", + "\n", + "print(f\"Matrix A_scaling:\\n {A_scaling}\\n\\nEigenvalues of matrix A_scaling:\\n {A_scaling_eig[0]}\",\n", + " f\"\\n\\nEigenvectors of matrix A_scaling\\n {A_scaling_eig[1]}\")" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "\n", + "### 2.5 - Example 5: Projection onto x-axis" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Let's investigate one last interesting example: projection onto the x-axis. This transformation keeps only the x component of the vector and sets all y-values to 0.\n", + "\n", + "The transformation that projects onto the x-axis can be defined by the matrix\n", + "$$A_{\\text{projection}}=\\begin{bmatrix}1 & 0 \\\\ 0 & 0 \\end{bmatrix}.$$ " + ] + }, + { + "cell_type": "code", + "execution_count": 11, + "metadata": { + "tags": [ + "graded" + ] + }, + "outputs": [ + { + "data": { + "image/png": "iVBORw0KGgoAAAANSUhEUgAAAaYAAAGfCAYAAAAUBHZmAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjMuNCwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8QVMy6AAAACXBIWXMAAAsTAAALEwEAmpwYAAAUB0lEQVR4nO3de7DfdX3n8dfn5Jwkh3NCEnLlFgJEIYkC6pGlKGqplLZOt2Xc0TrutHSqrGXcqe6One3eWh12Z2fHtvaybFdnVx10W8cyrnZERKnC1KoQ6gXkGuQSboHcCCH35Lt/kIbcuDXnd37vnPN4zGTg9/3+fr/v+8w38Px9v9/f+f1a13UBgCoG+j0AABxImAAoRZgAKEWYAChFmAAoZbDfAxxo/vz53dKlS/s9BgA9dtttt63rum7BkdaVCtPSpUuzatWqfo8BQI+11h56oXVO5QFQijABUIowAVCKMAFQijABUIowAVCKMAFQijABUIowAVCKMAFQijABUIowAVCKMAFQijABUIowAVCKMAFQijABUIowAVCKMAFQijABUIowAVCKMAFQijABUIowAVCKMAFQijABUIowAVCKMAFQijABUIowAVCKMAFQijABUIowAVCKMAFQijABUIowAVCKMAFQijABUIowAVCKMAFQijABUIowAVCKMAFQijABUIowAVCKMAFQijABUIowAVCKMAFQijABUIowAVCKMAFQijABUIowAVCKMAFQijABUIowAVCKMAFQijABUIowAVCKMAFQijABUIowAVCKMAFQijABUIowAVCKMAFQijABUIowAVCKMAFQijABUIowAVCKMAFQijABUIowAVCKMAFQijABUIowAVCKMAFQijABUIowAVCKMAFQijABUIowAVCKMAFQijABUIowAVCKMAFQijABUIowAVCKMAFQijABUIowAVCKMAFQijABUIowAVCKMAFQijABUIowAVCKMAFQijABUIowAVCKMAFQijABUIowAVCKMAFQijABUIowAVCKMAFQijABUIowUcpZn/+bf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z0xQsF6LanNuSpbdsneBqgEmFiwm3csTPfX7v+iOu6JDeseWJiBwJKESYm3I2PPJFXz5mVT198Qc5fOG//8r/+hYvyK6efkm+scToPprK+f4grU8/5C+fl5ssuyUBr+V8/uW//8hVzZ+f/XHxBHjzCmyKAqUOYmHBLZo286Pqlx49O0CRARU7lAVCKMAFQijABUIowAVCKMAFQijABUIowAVCKMAFQijABUIowAVCKMAFQijABUIowAVCKMAFQijABUIowAVCKMAFQijABUIowAVCKMAFQijABUIowAVCKMAFQijABUIowAVCKMAFQijABUIowAVCKMAFQijABUIowAVCKMAFQijABUIowAVCKMAFQijABUIowAVCKMAFQijABUIowAVCKMAFQijABUIowAVCKMAFQijABUIowAVCKMAFQijABUIowAVCKMAFQijABUIowAVCKMAFQijABUIowAVCKMAFQijABUIowAVCKMAFQijABUIowAVCKMAFQijABUIowAVCKMAFQijABUIowAVCKMAFQijABUIowAVCKMAFQijABUIowAVCKMAFQijABUIowAVCKMAFQijABUIowAVCKMAFQijABUIowAVCKMAFQijABUIowAVCKMAFQijABUIowAVCKMAFQijABUIowAVCKMAFQijABUIowAVCKMAFQijABUIowAVCKMAFQijABUIowAVCKMAFQijABUIowAVCKMAHlnfX5v8mn7lx90LJ7N23O4k9fm9vXb+rPUPSMMAHlLZ97fO7ZuPmgZR+79Y5cdsapee28Of0Zip4RJqC8FSfMzr2bng/TLWvX5W8ffSL//vUrkyTv/cZ3csY1X87lN363XyMyjoQJOGqr19yTXbt39uz5V8ydnXs2PbP/9kdvvT3vW35mTp01kiT5wMpX5eq3vrFn22di9SxMrbUrW2sPtNa2t9Zua61d1KttAf1133235O//+OL81f/+QK7/9v/Nhs3rx/X5l58wO+u278iG7Tty3UOP5a6Nm/Ph85bvX3/RSQszOjQ4rtukf3qyJ1tr707yJ0muTPJ3+/75tdbaiq7rHu7FNoH+ueQt78kNP/p8XrV+VbJ+Ve675RNZM3JGBpZckNece2levWT5Sz/Jizh7zvEZaMmdG5/OVavuyIfOPTtzZ0wfp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dd37D1h2X5K/7rru9/o3GROptbYlyQe9a5d/VPWIiUmutTY9yRvy3JHxgW5IcuHETwRUIUz0y/wk05KsPWT52jz3C9rAFDVhYWqtXbXvIueL/XnbRM1DGYeeS25HWAZMIRP5tRefiA+C5XnrkuzJ4UdHC3P4URQwhUxYmHwQLAfqum5na+22JJck+eIBqy5Jcm1/pgIq6PsXBR7JUX4QLMeOP0pyTWvtliTfSfKBJCcl+Yu+TkXPtdZGkyzbd3MgyZLW2nlJNnRd58zJFFfy7eI+CHbqaK1dmeR3k5yY536v5cNd193c36notX3Xk791hFWf7bru8gkdhnJKhgmAqcvbxQEoRZgAKEWYAChFmAAoRZgAKEWYAChFmAAoRZgAKOX/AxYwuHnRMHnOAAAAAElFTkSuQmCC\n", + "text/plain": [ + "
" + ] + }, + "metadata": { + "needs_background": "light" + }, + "output_type": "display_data" + }, + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Matrix A_projection:\n", + " [[1 0]\n", + " [0 0]]\n", + "\n", + "Eigenvalues of matrix A_projection:\n", + " [1. 0.] \n", + "\n", + "Eigenvectors of matrix A_projection\n", + " [[1. 0.]\n", + " [0. 1.]]\n" + ] + } + ], + "source": [ + "A_projection = np.array([[1, 0],[0, 0]])\n", + "A_projection_eig = np.linalg.eig(A_projection)\n", + "\n", + "utils.plot_transformation(A_projection, A_projection_eig[1][:,0], A_projection_eig[1][:,1]);\n", + "\n", + "\n", + "print(f\"Matrix A_projection:\\n {A_projection}\\n\\nEigenvalues of matrix A_projection:\\n {A_projection_eig[0]}\",\n", + " f\"\\n\\nEigenvectors of matrix A_projection\\n {A_projection_eig[1]}\")" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "This matrix has two real eigenvalues, and one of them is equal to $0$. There is nothing wrong with this, $\\lambda$ can be equal to $0$! In this case, this just means that anything that lies on the y-axis will be sent to zero, since it has no component in the x-direction. Since there are two distinct eigenvalues, the transformation still has two eigenvectors.\n", + "\n", + "Congratulations! You have reached the end of this lab. Hopefully by now you have a clearer intuition about what eigenvalues and eigenvectors represent, and why different 2 $\\times$ 2 matrices have different numbers of eigenvectors." + ] + } + ], + "metadata": { + "accelerator": "GPU", + "colab": { + "collapsed_sections": [], + "name": "C1_W1_Assignment_Solution.ipynb", + "provenance": [] + }, + "coursera": { + "schema_names": [ + "AI4MC1-1" + ] + }, + "grader_version": "2", + "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.8" + }, + "toc": { + "base_numbering": 1, + "nav_menu": {}, + "number_sections": true, + "sideBar": true, + "skip_h1_title": false, + "title_cell": "Table of Contents", + "title_sidebar": "Contents", + "toc_cell": false, + "toc_position": {}, + "toc_section_display": true, + "toc_window_display": false + }, + "vscode": { + "interpreter": { + "hash": "478841ab876a4250505273c8a697bbc1b6b194054b009c227dc606f17fb56272" + } + } + }, + "nbformat": 4, + "nbformat_minor": 1 +}