{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [] }, { "cell_type": "markdown", "metadata": {}, "source": [ "# 18 Pre-Class Assignment: Inner Product" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Goals for today's pre-class assignment \n", "\n", "
\n", "\n", "1. [Inner Products](#Inner_Products)\n", "1. [Inner Product on Functions](#Inner_Product_on_Functions)\n", "1. [Assignment wrap-up](#Assignment_wrap-up)" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "%matplotlib inline\n", "import numpy as np\n", "import matplotlib.pyplot as plt\n", "import sympy as sym\n", "sym.init_printing()" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "---\n", "\n", "## 1. Inner Products\n", "\n", "**Definition:** An **inner product** on a vector space $V$ (Remember that $R^n$ is just one class of vector spaces) is a function that associates a number, denoted as $\\langle u,v \\rangle$, with each pair of vectors $u$ and $v$ of $V$. This function satisfies the following conditions for vectors $u, v, w$ and scalar $c$:\n", "\n", "- $\\langle u,v \\rangle = \\langle v,u \\rangle$ (symmetry axiom)\n", "- $\\langle u+v,w \\rangle = \\langle u,w \\rangle + \\langle v,w \\rangle$ (additive axiom) \n", "- $\\langle cu,v \\rangle = c\\langle v,u \\rangle$ (homogeneity axiom)\n", "- $\\langle u,u \\rangle \\ge 0 \\text{ and } \\langle u,u \\rangle = 0 \\text{ if and only if } u = 0$ (positive definite axiom) \n", "\n", "\n", "The dot product of $R^n$ is an inner product. Note that we can define new inner products for $R^n$.\n", "\n", "### Norm of a vector\n", "\n", "**Definition:** Let $V$ be an inner product space. The **norm** of a vector $v$ is denoted by $\\| v \\|$ and is defined by:\n", "\n", "$$\\| v \\| = \\sqrt{\\langle v,v \\rangle}.$$\n", "\n", "### Angle between two vectors\n", "\n", "**Definition:** Let $V$ be a real inner product space. The **angle $\\theta$ between two nonzero vectors $u$ and $v$** in $V$ is given by:\n", "\n", "$$cos(\\theta) = \\frac{\\langle u,v \\rangle}{\\| u \\| \\| v \\|}.$$\n", "\n", "### Orthogonal vectors\n", "\n", "**Definition:** Let $V$ be an inner product space. Two vectors $u$ and $v$ in $V$ are **orthogonal** if their inner product is zero:\n", "\n", "$$\\langle u,v \\rangle = 0.$$\n", "\n", "### Distance\n", "**Definition:** Let $V$ be an inner product space. The **distance between two vectors (points) $u$ and $v$** in $V$ is denoted by $d(u,v)$ and is defined by:\n", "\n", "$$d(u,v) = \\| u-v \\| = \\sqrt{\\langle u-v, u-v \\rangle}$$\n", "\n" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "#### Example:\n", "Let $R^2$ have an inner product defined by:\n", "$$\\langle (a_1,a_2),(b_1,b_2)\\rangle = 2a_1b_1 + 3a_2b_2.$$" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "✅ **QUESTION 1:** What is the norm of (1,-2) in this space?" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Put your answer to the above question here." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "✅ **QUESTION 2:** What is the distance between (1,-2) and (3,2) in this space?" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Put your answer to the above question here." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "✅ **QUESTION 3:** What is the angle between (1,-2) and (3,2) in this space?" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Put your answer to the above question here." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "✅ **QUESTION 4:** Determine if (1,-2) and (3,2) are orthogonal in this space?" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Put your answer to the above question here." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "---\n", "\n", "## 2. Inner Product on Functions" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ "from IPython.display import YouTubeVideo\n", "YouTubeVideo(\"8ZyeHtgMBjk\",width=640,height=360, cc_load_policy=True)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "#### Example\n", "Consider the following functions \n", "\n", "$$f(x)=3x-1$$\n", "$$g(x)=5x+3$$\n", "\n", "$$\\text{with inner product defined by }\\langle f,g\\rangle=\\int_0^1{f(x)g(x)dx}.$$\n", "\n", "✅ **QUESTION 5:** What is the norm of $f(x)$ in this space?" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Put your answer to the above question here. (Hint: you can use `sympy.integrate` to compute the integral)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "✅ **QUESTION 6:** What is the norm of g(x) in this space?" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Put your answer to the above question here." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "✅ **QUESTION 7:** What is the inner product of $f(x)$ and $g(x)$ in this space?" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Put your answer to the above question here." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "----\n", "\n", "\n", "## 3. Assignment wrap-up" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "✅ **Assignment-Specific QUESTION:** There is no Assignment specific question for this notebook. You can just say \"none\"." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Put your answer to the above question here" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "✅ **QUESTION:** Summarize what you did in this assignment." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Put your answer to the above question here" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "✅ **QUESTION:** What questions do you have, if any, about any of the topics discussed in this assignment after working through the jupyter notebook?" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Put your answer to the above question here" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "✅ **QUESTION:** How well do you feel this assignment helped you to achieve a better understanding of the above mentioned topic(s)?" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Put your answer to the above question here" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "✅ **QUESTION:** What was the **most** challenging part of this assignment for you? " ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Put your answer to the above question here" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "✅ **QUESTION:** What was the **least** challenging part of this assignment for you? " ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Put your answer to the above question here" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "✅ **QUESTION:** What kind of additional questions or support, if any, do you feel you need to have a better understanding of the content in this assignment?" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Put your answer to the above question here" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "✅ **QUESTION:** Do you have any further questions or comments about this material, or anything else that's going on in class?" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Put your answer to the above question here" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "✅ **QUESTION:** Approximately how long did this pre-class assignment take?" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Put your answer to the above question here" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "----\n", "\n", "Written by Dr. Dirk Colbry, Michigan State University\n", "