|
46 | 46 | "\\end{equation}\n", |
47 | 47 | "$$\n", |
48 | 48 | "\n", |
49 | | - "We see that $(AB)_{23} = U\\cdot V$, the dot product of the second row of $A$ with the third row of $B$. In general the entry $(AB)_{ij}$ will be the dot product of the $i$th row of $A$ with the $j$th column of $B$. \n", |
| 49 | + "We see that $(AB)_{23} = U\\cdot V$, the dot product of the second row of $A$ with the third column of $B$. In general the entry $(AB)_{ij}$ will be the dot product of the $i$th row of $A$ with the $j$th column of $B$. \n", |
50 | 50 | "\n", |
51 | 51 | "Taking advantage of this connection, we could also write the definition of the dot product by viewing the vectors as $n\\times 1$ matrices, and making use of matrix transposes.\n", |
52 | 52 | "\n", |
|
529 | 529 | "source": [ |
530 | 530 | "## Code solution here." |
531 | 531 | ] |
| 532 | + }, |
| 533 | + { |
| 534 | + "cell_type": "markdown", |
| 535 | + "metadata": {}, |
| 536 | + "source": [ |
| 537 | + "**Exercise 4:** Create a Python function named $\\texttt{DifferenceMagnitude}$ which takes two $n \\times 1$ vectors as arguments and returns the magnitude of their difference. Use this function to determine $|| X - Y||$ where vectors $X$ and $Y$ are given below.\n", |
| 538 | + "\n", |
| 539 | + "$$\n", |
| 540 | + "\\begin{equation}\n", |
| 541 | + "X = \\left[ \\begin{array}{r} 3 \\\\ -1 \\\\ 2 \\end{array}\\right] \\hspace{1cm} \n", |
| 542 | + "Y = \\left[ \\begin{array}{r} 4 \\\\ 2 \\\\ 0 \\end{array}\\right] \n", |
| 543 | + "\\end{equation}\n", |
| 544 | + "$$" |
| 545 | + ] |
| 546 | + }, |
| 547 | + { |
| 548 | + "cell_type": "code", |
| 549 | + "execution_count": 36, |
| 550 | + "metadata": {}, |
| 551 | + "outputs": [], |
| 552 | + "source": [ |
| 553 | + "## Code solution here" |
| 554 | + ] |
| 555 | + }, |
| 556 | + { |
| 557 | + "cell_type": "markdown", |
| 558 | + "metadata": {}, |
| 559 | + "source": [ |
| 560 | + "**Exercise 5:** Create a Python function which takes an $n \\times 1$ vector as its argument and returns the unit vector of the argument vector. Use the NumPy $\\texttt{random}$ module to generate a random $3 \\times 1 $ vector, and test this function on that vector." |
| 561 | + ] |
| 562 | + }, |
| 563 | + { |
| 564 | + "cell_type": "code", |
| 565 | + "execution_count": 37, |
| 566 | + "metadata": {}, |
| 567 | + "outputs": [], |
| 568 | + "source": [ |
| 569 | + "## Code solution here" |
| 570 | + ] |
| 571 | + }, |
| 572 | + { |
| 573 | + "cell_type": "markdown", |
| 574 | + "metadata": {}, |
| 575 | + "source": [ |
| 576 | + "**Exercise 6:** Find a vector $Y$ in $\\mathbb{R}^2$ such that $X\\cdot Y = ||Y - X||$ where the vector $X$ is given below. Is the vector $Y$ unique ? Verify your answer through a computation.\n", |
| 577 | + "\n", |
| 578 | + "$$\n", |
| 579 | + "\\begin{equation}\n", |
| 580 | + "X = \\left[ \\begin{array}{r} 1 \\\\ 1 \\end{array}\\right] \n", |
| 581 | + "\\end{equation}\n", |
| 582 | + "$$" |
| 583 | + ] |
| 584 | + }, |
| 585 | + { |
| 586 | + "cell_type": "code", |
| 587 | + "execution_count": 38, |
| 588 | + "metadata": {}, |
| 589 | + "outputs": [], |
| 590 | + "source": [ |
| 591 | + "## Code solution here" |
| 592 | + ] |
| 593 | + }, |
| 594 | + { |
| 595 | + "cell_type": "markdown", |
| 596 | + "metadata": {}, |
| 597 | + "source": [ |
| 598 | + "**Exercise 7:** Create a Python function named $\\texttt{Angle}$ which takes two vectors as arguments and returns $\\cos{\\theta}$ where ${\\theta}$ is the angle between the two vectors. Use this function to show that vectors $U$ and $W$ are orthogonal.\n", |
| 599 | + "\n", |
| 600 | + "$$\n", |
| 601 | + "\\begin{equation}\n", |
| 602 | + "U = \\left[ \\begin{array}{r} 1 \\\\ -1 \\\\ 2 \\end{array}\\right] \\hspace{1cm} \n", |
| 603 | + "W = \\left[ \\begin{array}{r} 2 \\\\ 0 \\\\ -1 \\end{array}\\right] \n", |
| 604 | + "\\end{equation}\n", |
| 605 | + "$$" |
| 606 | + ] |
| 607 | + }, |
| 608 | + { |
| 609 | + "cell_type": "code", |
| 610 | + "execution_count": 39, |
| 611 | + "metadata": {}, |
| 612 | + "outputs": [], |
| 613 | + "source": [ |
| 614 | + "## Code solution here" |
| 615 | + ] |
| 616 | + }, |
| 617 | + { |
| 618 | + "cell_type": "markdown", |
| 619 | + "metadata": {}, |
| 620 | + "source": [ |
| 621 | + "**Exercise 8:** Given that $||X+Y|| = 3$, $X\\cdot Y = 2$, find $||X-Y||$." |
| 622 | + ] |
| 623 | + }, |
| 624 | + { |
| 625 | + "cell_type": "code", |
| 626 | + "execution_count": 40, |
| 627 | + "metadata": {}, |
| 628 | + "outputs": [], |
| 629 | + "source": [ |
| 630 | + "## Code solution here" |
| 631 | + ] |
532 | 632 | } |
533 | 633 | ], |
534 | 634 | "metadata": { |
|
0 commit comments