Skip to content

Commit 532b2ca

Browse files
committed
Exercises and solutions
1 parent 088167c commit 532b2ca

3 files changed

Lines changed: 303 additions & 12 deletions

File tree

Eigenvalues.ipynb

Lines changed: 37 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
"cell_type": "markdown",
2323
"metadata": {},
2424
"source": [
25-
"### Example 1: Matrix representing horizontal shear\n",
25+
"### Example 1: Matrix representing horizontal stretch\n",
2626
"\n",
2727
"Let's consider first the following matrix.\n",
2828
"\n",
@@ -32,12 +32,12 @@
3232
"\\end{equation}\n",
3333
"$$\n",
3434
"\n",
35-
"We saw in [Chapter 3](Planar_Transformations.ipynb) that multiplication by this matrix has the effect of a horizontal shear."
35+
"We saw in [Chapter 3](Planar_Transformations.ipynb) that multiplication by this matrix has the effect of a horizontal stretch."
3636
]
3737
},
3838
{
3939
"cell_type": "code",
40-
"execution_count": 2,
40+
"execution_count": 1,
4141
"metadata": {
4242
"tags": [
4343
"hide-input"
@@ -100,7 +100,7 @@
100100
"cell_type": "markdown",
101101
"metadata": {},
102102
"source": [
103-
"For this example it is possible to deduce the eigenvalues and eigenvectors since the effect of the matrix is rather simple. Any vector that does not have its direction changed by this transformation is an eigenvector. In particular, we notice that any vector along the $x_1$-axis will be scaled by the shear, but the direction will be unchanged. Let's choose the unit vector to label as $V_1$\n",
103+
"For this example it is possible to deduce the eigenvalues and eigenvectors since the effect of the matrix is rather simple. Any vector that does not have its direction changed by this transformation is an eigenvector. In particular, we notice that any vector along the $x_1$-axis will be scaled by the stretch, but the direction will be unchanged. Let's choose the unit vector to label as $V_1$\n",
104104
"\n",
105105
"$$\n",
106106
"\\begin{equation}\n",
@@ -121,7 +121,7 @@
121121
"\\end{equation}\n",
122122
"$$\n",
123123
"\n",
124-
"Since $AV_2 = V_2$, it must be that the associated eigenvalue is $\\lambda_2 = 1.$ Again we note that there is a whole collection eigenvectors associated with $\\lambda_2$, since any multiple of $V_2$ is also unchanged by the transformation."
124+
"Since $AV_2 = V_2$, it must be that the associated eigenvalue is $\\lambda_2 = 1.$ Again we note that there is a whole collection of eigenvectors associated with $\\lambda_2$, since any multiple of $V_2$ is also unchanged by the transformation."
125125
]
126126
},
127127
{
@@ -141,15 +141,16 @@
141141
},
142142
{
143143
"cell_type": "code",
144-
"execution_count": 3,
144+
"execution_count": 2,
145145
"metadata": {},
146146
"outputs": [
147147
{
148148
"name": "stdout",
149149
"output_type": "stream",
150150
"text": [
151151
"[[-0.6]\n",
152-
" [ 1.2]]\n",
152+
" [ 1.2]] \n",
153+
"\n",
153154
"[[0.]\n",
154155
" [0.]]\n"
155156
]
@@ -160,7 +161,7 @@
160161
"X = np.array([[1],[2]])\n",
161162
"Y = np.array([[2],[1]])\n",
162163
"\n",
163-
"print(B@X)\n",
164+
"print(B@X,'\\n')\n",
164165
"print(B@Y)\n"
165166
]
166167
},
@@ -226,7 +227,7 @@
226227
"\n",
227228
"Since $BV_1 = V_1$ the eigenvalue corresponding to $V_1$ is $\\lambda_1 = 1$.\n",
228229
"\n",
229-
"The other eigenvalue for this matrix may not be as easy to discover by examining the directions of various choices of $X$ and the corresponding directions of $BX$. If we closely consider the definition of eigenvalues however, we realize there is any nonzero vector $V$ such that $BV=0$, then that vector must be an eigenvector, with zero as the corresponding eigenvalue. To make the statement in terms of the fundamental subspaces, zero is an eigenvalue of the matrix $B$ if there are any nonzero vectors in $\\mathcal{N}(B)$. \n",
230+
"The other eigenvalue for this matrix may not be as easy to discover by examining the directions of various choices of $X$ and the corresponding directions of $BX$. If we closely consider the definition of eigenvalues however, we realize that if there exists any nonzero vector $V$ such that $BV=0$, then that vector must be an eigenvector with zero as the corresponding eigenvalue. To make the statement in terms of the fundamental subspaces, zero is an eigenvalue of the matrix $B$ if there are any nonzero vectors in $\\mathcal{N}(B)$. \n",
230231
"\n",
231232
"In this example, since $B$ represents an orthogonal projection, $\\mathcal{N}(B)$ is the subspace orthogonal to $\\mathcal{C}(B)$. We can label any such vector as $V_2$ \n",
232233
"\n",
@@ -252,7 +253,33 @@
252253
"source": [
253254
"### Exercises\n",
254255
"\n",
255-
"- Determine the eigenvalues and corresponding eigenvectors of the following matrix by considering the transformation that it represents. Check your answers with a computations.\n",
256+
"**Exercise 1:** Determine the eigenvalues and corresponding eigenvectors of the following matrix by considering the transformation that it represents. Check your answers with a computations.\n",
257+
"\n",
258+
"$(a)$\n",
259+
"\n",
260+
"$$\n",
261+
"\\begin{equation}\n",
262+
"A = \\left[ \\begin{array}{cc} 1 & 0 \\\\ 0 & -3 \\end{array}\\right]\n",
263+
"\\end{equation}\n",
264+
"$$\n",
265+
"\n",
266+
"$(b)$\n",
267+
"\n",
268+
"$$\n",
269+
"\\begin{equation}\n",
270+
"B = \\left[ \\begin{array}{cc} 1 & 1 \\\\ 0 & 1 \\end{array}\\right]\n",
271+
"\\end{equation}\n",
272+
"$$\n",
273+
"\n",
274+
"$(c)$\n",
275+
"\n",
276+
"$$\n",
277+
"\\begin{equation}\n",
278+
"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",
279+
"\\end{equation}\n",
280+
"$$\n",
281+
"\n",
282+
"$(d)$\n",
256283
"\n",
257284
"$$\n",
258285
"\\begin{equation}\n",
@@ -272,7 +299,6 @@
272299
}
273300
],
274301
"metadata": {
275-
"celltoolbar": "Tags",
276302
"kernelspec": {
277303
"display_name": "Python 3",
278304
"language": "python",

Eigenvalues_Solutions.ipynb

Lines changed: 264 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,264 @@
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+
}

_toc.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,4 +43,5 @@
4343
- file: Linear_Systems_Solutions
4444
- file: Vector_Spaces_Solutions
4545
- file: Linear_Transformations_Solutions
46-
- file: Inner_Products_Solutions
46+
- file: Inner_Products_Solutions
47+
- file: Eigenvalues_Solutions

0 commit comments

Comments
 (0)