|
| 1 | +{ |
| 2 | + "cells": [ |
| 3 | + { |
| 4 | + "cell_type": "markdown", |
| 5 | + "id": "40096028", |
| 6 | + "metadata": {}, |
| 7 | + "source": [ |
| 8 | + "## Eigenvalues" |
| 9 | + ] |
| 10 | + }, |
| 11 | + { |
| 12 | + "cell_type": "code", |
| 13 | + "execution_count": 1, |
| 14 | + "id": "207ddd81", |
| 15 | + "metadata": {}, |
| 16 | + "outputs": [], |
| 17 | + "source": [ |
| 18 | + "import laguide as lag\n", |
| 19 | + "import numpy as np\n", |
| 20 | + "import scipy.linalg as sla\n", |
| 21 | + "%matplotlib inline\n", |
| 22 | + "import matplotlib.pyplot as plt\n", |
| 23 | + "import math" |
| 24 | + ] |
| 25 | + }, |
| 26 | + { |
| 27 | + "cell_type": "markdown", |
| 28 | + "id": "9c0b10fd", |
| 29 | + "metadata": {}, |
| 30 | + "source": [ |
| 31 | + "**Exercise 1:** Determine the eigenvalues and corresponding eigenvectors of the following matrices by considering the transformations that they represent. Check your answers with a few computations.\n", |
| 32 | + "\n", |
| 33 | + "$(a)$\n", |
| 34 | + "\n", |
| 35 | + "$$\n", |
| 36 | + "\\begin{equation}\n", |
| 37 | + "A = \\left[ \\begin{array}{cc} 1 & 0 \\\\ 0 & -3 \\end{array}\\right]\n", |
| 38 | + "\\end{equation}\n", |
| 39 | + "$$\n", |
| 40 | + "\n", |
| 41 | + "**Solution:**\n", |
| 42 | + "\n", |
| 43 | + "Recall from [Chapter 4](Planar_Transformations.ipynb) that applying the transformation represented by $A$ is equivalent to stretching in the direction of the $y$-axis by a factor of 3 and then reflecting over the $y$-axis. If we imagine what this does to vectors in the plane then we might see that any vector that lies on the $x$-axis will be left unaffected. Therefore our first eigenvalue is $\\lambda_1 = 1$ which corresponds to any scalar multiple of our first eigenvector $V_1 = \\begin{equation} \\left[ \\begin{array}{cc} 1 \\\\ 0 \\end{array}\\right] \\end{equation}$. Additionally, any vector that lies on the $y$-axis will simply be scaled by a factor of $-3$. Therefore our second eigenvalue is $\\lambda_2 = -3$ which corresponds to any scalar multiple of our second eigenvector $V_2 = \\begin{equation} \\left[ \\begin{array}{cc} 0 \\\\ 1 \\end{array}\\right] \\end{equation}$." |
| 44 | + ] |
| 45 | + }, |
| 46 | + { |
| 47 | + "cell_type": "code", |
| 48 | + "execution_count": 5, |
| 49 | + "id": "998fed9b", |
| 50 | + "metadata": {}, |
| 51 | + "outputs": [ |
| 52 | + { |
| 53 | + "name": "stdout", |
| 54 | + "output_type": "stream", |
| 55 | + "text": [ |
| 56 | + "[[1]\n", |
| 57 | + " [0]] \n", |
| 58 | + "\n", |
| 59 | + "[[ 0]\n", |
| 60 | + " [-3]] \n", |
| 61 | + "\n", |
| 62 | + "[[5]\n", |
| 63 | + " [0]] \n", |
| 64 | + "\n", |
| 65 | + "[[ 1]\n", |
| 66 | + " [-3]] \n", |
| 67 | + "\n", |
| 68 | + "[[0]\n", |
| 69 | + " [0]]\n" |
| 70 | + ] |
| 71 | + } |
| 72 | + ], |
| 73 | + "source": [ |
| 74 | + "A = np.array([[1,0],[0,-3]])\n", |
| 75 | + "V1 = np.array([[1],[0]])\n", |
| 76 | + "V2 = np.array([[0],[1]])\n", |
| 77 | + "R = np.array([[5],[0]])\n", |
| 78 | + "S = np.array([[1],[1]])\n", |
| 79 | + "T = np.array([[0],[0]])\n", |
| 80 | + "\n", |
| 81 | + "print(A@V1,'\\n')\n", |
| 82 | + "print(A@V2,'\\n')\n", |
| 83 | + "print(A@R,'\\n')\n", |
| 84 | + "print(A@S,'\\n')\n", |
| 85 | + "print(A@T)" |
| 86 | + ] |
| 87 | + }, |
| 88 | + { |
| 89 | + "cell_type": "markdown", |
| 90 | + "id": "49afdb15", |
| 91 | + "metadata": {}, |
| 92 | + "source": [ |
| 93 | + "$(b)$\n", |
| 94 | + "\n", |
| 95 | + "$$\n", |
| 96 | + "\\begin{equation}\n", |
| 97 | + "B = \\left[ \\begin{array}{cc} 1 & 1 \\\\ 0 & 1 \\end{array}\\right]\n", |
| 98 | + "\\end{equation}\n", |
| 99 | + "$$" |
| 100 | + ] |
| 101 | + }, |
| 102 | + { |
| 103 | + "cell_type": "markdown", |
| 104 | + "id": "3ff762a1", |
| 105 | + "metadata": {}, |
| 106 | + "source": [ |
| 107 | + "**Solutions:**\n", |
| 108 | + "\n", |
| 109 | + "Recall from [Chapter 4](Planar_Transformations.ipynb) that applying the transformation represented by $B$ is equivalent to shearing along the $x$-axis with a shearing factor of 1. Any vector that lies along the $x$-axis will be left unchanged because its $y$-coordinate is 0 and thus adds nothing to $x$-coordinate. Therefore our first eigenvalue is $\\lambda_1 = 1$ which corresponds to any scalar multiple of our first eigenvector $V_1 = \\begin{equation} \\left[ \\begin{array}{cc} 1 \\\\ 0 \\end{array}\\right] \\end{equation}$. Any other vector with a nonzero $y$-coordinate will shear off of its original span, and thus cannot be a scalar multiple of itself. Therefore $V_1$ is the only eigenvalue of $B$." |
| 110 | + ] |
| 111 | + }, |
| 112 | + { |
| 113 | + "cell_type": "code", |
| 114 | + "execution_count": 6, |
| 115 | + "id": "373ed00d", |
| 116 | + "metadata": {}, |
| 117 | + "outputs": [ |
| 118 | + { |
| 119 | + "name": "stdout", |
| 120 | + "output_type": "stream", |
| 121 | + "text": [ |
| 122 | + "[[1]\n", |
| 123 | + " [0]] \n", |
| 124 | + "\n", |
| 125 | + "[[1]\n", |
| 126 | + " [1]] \n", |
| 127 | + "\n", |
| 128 | + "[[5]\n", |
| 129 | + " [0]] \n", |
| 130 | + "\n", |
| 131 | + "[[2]\n", |
| 132 | + " [1]] \n", |
| 133 | + "\n", |
| 134 | + "[[0]\n", |
| 135 | + " [0]]\n" |
| 136 | + ] |
| 137 | + } |
| 138 | + ], |
| 139 | + "source": [ |
| 140 | + "B = np.array([[1,1],[0,1]])\n", |
| 141 | + "V1 = np.array([[1],[0]])\n", |
| 142 | + "V2 = np.array([[0],[1]])\n", |
| 143 | + "R = np.array([[5],[0]])\n", |
| 144 | + "S = np.array([[1],[1]])\n", |
| 145 | + "T = np.array([[0],[0]])\n", |
| 146 | + "\n", |
| 147 | + "print(B@V1,'\\n')\n", |
| 148 | + "print(B@V2,'\\n')\n", |
| 149 | + "print(B@R,'\\n')\n", |
| 150 | + "print(B@S,'\\n')\n", |
| 151 | + "print(B@T)" |
| 152 | + ] |
| 153 | + }, |
| 154 | + { |
| 155 | + "cell_type": "markdown", |
| 156 | + "id": "1f01b50f", |
| 157 | + "metadata": {}, |
| 158 | + "source": [ |
| 159 | + "$(c)$\n", |
| 160 | + "\n", |
| 161 | + "$$\n", |
| 162 | + "\\begin{equation}\n", |
| 163 | + "C = \\left[ \\begin{array}{cc} cos(\\frac{\\pi}{2}) & -sin(\\frac{\\pi}{2}) \\\\ sin(\\frac{\\pi}{2}) & cos(\\frac{\\pi}{2}) \\end{array}\\right]\n", |
| 164 | + "\\end{equation}\n", |
| 165 | + "$$" |
| 166 | + ] |
| 167 | + }, |
| 168 | + { |
| 169 | + "cell_type": "markdown", |
| 170 | + "id": "2c4751f6", |
| 171 | + "metadata": {}, |
| 172 | + "source": [ |
| 173 | + "**Solution:**\n", |
| 174 | + "\n", |
| 175 | + "Recall from [Chapter 4](Planar_Transformations.ipynb) that applying the transformation represented by $C$ is equivalent to a rotation about the origin by the angle $\\frac{\\pi}{2}$. Any nonzero vector that is transformed by this matrix will be pointing directly perpendicular to its original direction, so cannot lie on its original span. Therefore $C$ has no eigenvalues nor any eigenvectors." |
| 176 | + ] |
| 177 | + }, |
| 178 | + { |
| 179 | + "cell_type": "code", |
| 180 | + "execution_count": 15, |
| 181 | + "id": "732123da", |
| 182 | + "metadata": {}, |
| 183 | + "outputs": [ |
| 184 | + { |
| 185 | + "name": "stdout", |
| 186 | + "output_type": "stream", |
| 187 | + "text": [ |
| 188 | + "[[0.]\n", |
| 189 | + " [1.]] \n", |
| 190 | + "\n", |
| 191 | + "[[-1.]\n", |
| 192 | + " [ 0.]] \n", |
| 193 | + "\n", |
| 194 | + "[[0.]\n", |
| 195 | + " [5.]] \n", |
| 196 | + "\n", |
| 197 | + "[[-1.]\n", |
| 198 | + " [ 1.]] \n", |
| 199 | + "\n", |
| 200 | + "[[0.]\n", |
| 201 | + " [0.]]\n" |
| 202 | + ] |
| 203 | + } |
| 204 | + ], |
| 205 | + "source": [ |
| 206 | + "C = np.array([[math.cos(math.pi/2),-math.sin(math.pi/2)],[math.sin(math.pi/2),math.cos(math.pi/2)]])\n", |
| 207 | + "V1 = np.array([[1],[0]])\n", |
| 208 | + "V2 = np.array([[0],[1]])\n", |
| 209 | + "R = np.array([[5],[0]])\n", |
| 210 | + "S = np.array([[1],[1]])\n", |
| 211 | + "T = np.array([[0],[0]])\n", |
| 212 | + "\n", |
| 213 | + "print(np.round(C@V1),'\\n')\n", |
| 214 | + "print(np.round(C@V2),'\\n')\n", |
| 215 | + "print(np.round(C@R),'\\n')\n", |
| 216 | + "print(np.round(C@S),'\\n')\n", |
| 217 | + "print(np.round(C@T))" |
| 218 | + ] |
| 219 | + }, |
| 220 | + { |
| 221 | + "cell_type": "markdown", |
| 222 | + "id": "b9faa15a", |
| 223 | + "metadata": {}, |
| 224 | + "source": [ |
| 225 | + "$(d)$\n", |
| 226 | + "\n", |
| 227 | + "$$\n", |
| 228 | + "\\begin{equation}\n", |
| 229 | + "D = \\left[ \\begin{array}{cc} -0.6 & -0.8 \\\\ -0.8 & 0.6 \\end{array}\\right]\n", |
| 230 | + "\\end{equation}\n", |
| 231 | + "$$" |
| 232 | + ] |
| 233 | + }, |
| 234 | + { |
| 235 | + "cell_type": "code", |
| 236 | + "execution_count": null, |
| 237 | + "id": "6ca4efac", |
| 238 | + "metadata": {}, |
| 239 | + "outputs": [], |
| 240 | + "source": [] |
| 241 | + } |
| 242 | + ], |
| 243 | + "metadata": { |
| 244 | + "kernelspec": { |
| 245 | + "display_name": "Python 3", |
| 246 | + "language": "python", |
| 247 | + "name": "python3" |
| 248 | + }, |
| 249 | + "language_info": { |
| 250 | + "codemirror_mode": { |
| 251 | + "name": "ipython", |
| 252 | + "version": 3 |
| 253 | + }, |
| 254 | + "file_extension": ".py", |
| 255 | + "mimetype": "text/x-python", |
| 256 | + "name": "python", |
| 257 | + "nbconvert_exporter": "python", |
| 258 | + "pygments_lexer": "ipython3", |
| 259 | + "version": "3.7.3" |
| 260 | + } |
| 261 | + }, |
| 262 | + "nbformat": 4, |
| 263 | + "nbformat_minor": 5 |
| 264 | +} |
0 commit comments