|
106 | 106 | "\n", |
107 | 107 | "The proof of this theorem is beyond the scope of our course. But, this is such an important theorem that it's sometimes called the **fundamental theorem of linear algebra**. It tells us, for one, that the dimension of the null space is equal to the number of columns minus the rank. \"Nullity\" is just another word for the dimension of the null space.\n", |
108 | 108 | "\n", |
| 109 | + "<iframe width=\"560\" height=\"315\" src=\"https://www.youtube.com/embed/x1jZjbCfVYs?si=2q5SVMZ_LmHr1rJy\" title=\"YouTube video player\" frameborder=\"0\" allow=\"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share\" referrerpolicy=\"strict-origin-when-cross-origin\" allowfullscreen></iframe>\n", |
| 110 | + "\n", |
109 | 111 | "Let's see how it can be used in practice. Some of these examples are taken from Gilbert Strang's book." |
110 | 112 | ] |
111 | 113 | }, |
|
331 | 333 | "In both (and in the infinitely many other) cases, $\\begin{bmatrix} 3 \\\\ 1 \\end{bmatrix} \\in \\text{colsp}(A)$ and $\\begin{bmatrix} 1 \\\\ 3 \\end{bmatrix} \\in \\text{nullsp}(A)$.\n", |
332 | 334 | ":::\n", |
333 | 335 | "\n", |
334 | | - "### Example: Orthogonal Complements\n", |
335 | | - "\n", |
336 | | - "Suppose $\\vec r \\in \\text{colsp}(A^T)$ and $\\vec n \\in \\text{nullsp}(A)$, meaning $\\vec r$ is in the row space of $A$ and $\\vec n$ is in the null space of $A$.\n", |
337 | | - "\n", |
338 | | - "Prove that $\\vec r$ and $\\vec n$ must be orthogonal.\n", |
339 | | - "\n", |
340 | | - ":::{seealso} Solution\n", |
341 | | - ":class: dropdown\n", |
342 | | - "\n", |
343 | | - "The row space of $A$, $\\text{colsp}(A^T)$, is the set of all vectors $\\vec r$ where $\\vec r = A^T \\vec y$ for some $\\vec y \\in \\mathbb{R}^n$. Note that if $A$ is an $n \\times d$ matrix, then $A^T$ is a $d \\times n$ matrix, and $\\vec r$ is in $\\mathbb{R}^d$.\n", |
344 | | - "\n", |
345 | | - "The null space of $A$, $\\text{nullsp}(A)$, is the set of all vectors $\\vec n$ where $A \\vec n = \\vec 0$. Note that if $A$ is an $n \\times d$ matrix, then $\\vec n$ is in $\\mathbb{R}^d$.\n", |
346 | | - "\n", |
347 | | - "So, $\\vec r$ and $\\vec n$ are both in $\\mathbb{R}^d$, which means they exist in the same universe (they have the same number of components), and so we _can_ ask if they're orthogonal. (If they had different numbers of components, this question would be a non-starter.)\n", |
348 | | - "\n", |
349 | | - "In order to show that they're orthogonal, we need to show that their dot product is 0.\n", |
350 | | - "\n", |
351 | | - "$$\\begin{align*} \\vec r \\cdot \\vec n &= (A^T \\vec y) \\cdot \\vec n \\\\ &= \\underbrace{(A^T \\vec y)^T \\vec n}_{\\vec u \\cdot \\vec v = \\vec u^T \\vec v} \\\\ &= y^T \\underbrace{A \\vec n}_{\\vec 0} \\\\ &= y^T \\vec 0 \\\\ &= 0 \\end{align*}$$\n", |
352 | | - "\n", |
353 | | - "So, every vector in the row space of $A$ is orthogonal to every vector in the null space of $A$!\n", |
354 | | - ":::\n", |
355 | | - "\n", |
356 | | - ":::{attention} The row space and null space are orthogonal complements!\n", |
357 | | - "\n", |
358 | | - "Above, we proved that the row space and null space are orthogonal complements, in $\\mathbb{R}^d$. This means that every element in the row space is orthogonal to every element in the null space. The concept of an orthogonal complement was first introduced in [Chapter 4.3](../04_linear_independence/03-vector-spaces-basis-dimension.ipynb).\n", |
359 | | - "\n", |
360 | | - "It is also true that the column space and left null space are orthogonal complements, in $\\mathbb{R}^n$. Meaning, if\n", |
361 | | - "\n", |
362 | | - "$$\\vec x \\in \\text{colsp}(A), \\qquad \\vec y \\in \\text{nullsp}(A^T)$$\n", |
363 | | - "\n", |
364 | | - "then it must be the case that $\\vec x \\cdot \\vec y = 0$.\n", |
365 | | - "\n", |
366 | | - "To summarize:\n", |
367 | | - "- The row space, $\\text{colsp}(A^T)$, and null space, $\\text{nullsp}(A)$, are orthogonal complements; both are subspaces of $\\mathbb{R}^d$.\n", |
368 | | - "- The column space, $\\text{colsp}(A)$, and left null space, $\\text{nullsp}(A^T)$, are orthogonal complements; both are subspaces of $\\mathbb{R}^n$.\n", |
369 | | - ":::\n", |
370 | | - "\n", |
371 | 336 | "### Example: Rank of $AB$ vs. Rank of $A$ or $B$\n", |
372 | 337 | "\n", |
373 | 338 | "Suppose $A$ is an $n \\times d$ matrix, and $B$ is a $d \\times p$ matrix.\n", |
|
407 | 372 | "So intuitively, when we multiply two matrices, the rank of the resulting matrix can't be greater than the rank of either of the two matrices we started with, but it can \"drop\".\n", |
408 | 373 | ":::\n", |
409 | 374 | "\n", |
410 | | - "### Example: Rank of $X^TX$ 🚨\n", |
| 375 | + "### Example: Orthogonal Complements 🎥\n", |
| 376 | + "\n", |
| 377 | + "Suppose $\\vec r \\in \\text{colsp}(A^T)$ and $\\vec n \\in \\text{nullsp}(A)$, meaning $\\vec r$ is in the row space of $A$ and $\\vec n$ is in the null space of $A$.\n", |
| 378 | + "\n", |
| 379 | + "Prove that $\\vec r$ and $\\vec n$ must be orthogonal.\n", |
| 380 | + "\n", |
| 381 | + "<iframe width=\"560\" height=\"315\" src=\"https://www.youtube.com/embed/dcqA-6-vYA4?si=R_xevblhlyN2Ce7m\" title=\"YouTube video player\" frameborder=\"0\" allow=\"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share\" referrerpolicy=\"strict-origin-when-cross-origin\" allowfullscreen></iframe>\n", |
| 382 | + "\n", |
| 383 | + ":::{seealso} Solution\n", |
| 384 | + ":class: dropdown\n", |
| 385 | + "\n", |
| 386 | + "The row space of $A$, $\\text{colsp}(A^T)$, is the set of all vectors $\\vec r$ where $\\vec r = A^T \\vec y$ for some $\\vec y \\in \\mathbb{R}^n$. Note that if $A$ is an $n \\times d$ matrix, then $A^T$ is a $d \\times n$ matrix, and $\\vec r$ is in $\\mathbb{R}^d$.\n", |
| 387 | + "\n", |
| 388 | + "The null space of $A$, $\\text{nullsp}(A)$, is the set of all vectors $\\vec n$ where $A \\vec n = \\vec 0$. Note that if $A$ is an $n \\times d$ matrix, then $\\vec n$ is in $\\mathbb{R}^d$.\n", |
| 389 | + "\n", |
| 390 | + "So, $\\vec r$ and $\\vec n$ are both in $\\mathbb{R}^d$, which means they exist in the same universe (they have the same number of components), and so we _can_ ask if they're orthogonal. (If they had different numbers of components, this question would be a non-starter.)\n", |
| 391 | + "\n", |
| 392 | + "In order to show that they're orthogonal, we need to show that their dot product is 0.\n", |
| 393 | + "\n", |
| 394 | + "$$\\begin{align*} \\vec r \\cdot \\vec n &= (A^T \\vec y) \\cdot \\vec n \\\\ &= \\underbrace{(A^T \\vec y)^T \\vec n}_{\\vec u \\cdot \\vec v = \\vec u^T \\vec v} \\\\ &= y^T \\underbrace{A \\vec n}_{\\vec 0} \\\\ &= y^T \\vec 0 \\\\ &= 0 \\end{align*}$$\n", |
| 395 | + "\n", |
| 396 | + "So, every vector in the row space of $A$ is orthogonal to every vector in the null space of $A$!\n", |
| 397 | + ":::\n", |
| 398 | + "\n", |
| 399 | + ":::{attention} The row space and null space are orthogonal complements!\n", |
| 400 | + "\n", |
| 401 | + "Above, we proved that the row space and null space are orthogonal complements, in $\\mathbb{R}^d$. This means that every element in the row space is orthogonal to every element in the null space. The concept of an orthogonal complement was first introduced in [Chapter 4.3](../04_linear_independence/03-vector-spaces-basis-dimension.ipynb).\n", |
| 402 | + "\n", |
| 403 | + "It is also true that the column space and left null space are orthogonal complements, in $\\mathbb{R}^n$. Meaning, if\n", |
| 404 | + "\n", |
| 405 | + "$$\\vec x \\in \\text{colsp}(A), \\qquad \\vec y \\in \\text{nullsp}(A^T)$$\n", |
| 406 | + "\n", |
| 407 | + "then it must be the case that $\\vec x \\cdot \\vec y = 0$.\n", |
| 408 | + "\n", |
| 409 | + "To summarize:\n", |
| 410 | + "- The row space, $\\text{colsp}(A^T)$, and null space, $\\text{nullsp}(A)$, are orthogonal complements; both are subspaces of $\\mathbb{R}^d$.\n", |
| 411 | + "- The column space, $\\text{colsp}(A)$, and left null space, $\\text{nullsp}(A^T)$, are orthogonal complements; both are subspaces of $\\mathbb{R}^n$.\n", |
| 412 | + ":::\n", |
| 413 | + "\n", |
| 414 | + "### Example: Rank of $X^TX$ 🎥\n", |
411 | 415 | "\n", |
412 | 416 | "Prove that $\\text{rank}(X^T X) = \\text{rank}(X)$ for any $n \\times d$ matrix $X$.\n", |
413 | 417 | "\n", |
414 | | - "The matrix $X^TX$ is hugely important for our regression problem, and you'll also see in a homework that it helps define the **covariance** matrix of our data. (The 🚨 is to emphasize how important this example is.)\n", |
| 418 | + "The matrix $X^TX$ is hugely important for our regression problem, and you'll also see in a homework that it helps define the **covariance** matrix of our data.\n", |
| 419 | + "\n", |
| 420 | + "<iframe width=\"560\" height=\"315\" src=\"https://www.youtube.com/embed/hOyaHqGmO1I?si=DlSODDS57gRB_ZwB\" title=\"YouTube video player\" frameborder=\"0\" allow=\"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share\" referrerpolicy=\"strict-origin-when-cross-origin\" allowfullscreen></iframe>\n", |
415 | 421 | "\n", |
416 | 422 | ":::{seealso} Solution\n", |
417 | 423 | ":class: dropdown\n", |
|
0 commit comments