# 18 Pre-Class Assignment: Inner Product¶

## Goals for today’s pre-class assignment¶

```
%matplotlib inline
import numpy as np
import matplotlib.pyplot as plt
import sympy as sym
sym.init_printing()
```

```
---------------------------------------------------------------------------
ModuleNotFoundError Traceback (most recent call last)
<ipython-input-1-f3e5c23067e5> in <module>
----> 1 get_ipython().run_line_magic('matplotlib', 'inline')
2 import numpy as np
3 import matplotlib.pyplot as plt
4 import sympy as sym
5 sym.init_printing()
~/REPOS/MTH314_Textbook/MakeTextbook/envs/lib/python3.9/site-packages/IPython/core/interactiveshell.py in run_line_magic(self, magic_name, line, _stack_depth)
2342 kwargs['local_ns'] = self.get_local_scope(stack_depth)
2343 with self.builtin_trap:
-> 2344 result = fn(*args, **kwargs)
2345 return result
2346
~/REPOS/MTH314_Textbook/MakeTextbook/envs/lib/python3.9/site-packages/decorator.py in fun(*args, **kw)
230 if not kwsyntax:
231 args, kw = fix(args, kw, sig)
--> 232 return caller(func, *(extras + args), **kw)
233 fun.__name__ = func.__name__
234 fun.__doc__ = func.__doc__
~/REPOS/MTH314_Textbook/MakeTextbook/envs/lib/python3.9/site-packages/IPython/core/magic.py in <lambda>(f, *a, **k)
185 # but it's overkill for just that one bit of state.
186 def magic_deco(arg):
--> 187 call = lambda f, *a, **k: f(*a, **k)
188
189 if callable(arg):
~/REPOS/MTH314_Textbook/MakeTextbook/envs/lib/python3.9/site-packages/IPython/core/magics/pylab.py in matplotlib(self, line)
97 print("Available matplotlib backends: %s" % backends_list)
98 else:
---> 99 gui, backend = self.shell.enable_matplotlib(args.gui.lower() if isinstance(args.gui, str) else args.gui)
100 self._show_matplotlib_backend(args.gui, backend)
101
~/REPOS/MTH314_Textbook/MakeTextbook/envs/lib/python3.9/site-packages/IPython/core/interactiveshell.py in enable_matplotlib(self, gui)
3511 """
3512 from IPython.core import pylabtools as pt
-> 3513 gui, backend = pt.find_gui_and_backend(gui, self.pylab_gui_select)
3514
3515 if gui != 'inline':
~/REPOS/MTH314_Textbook/MakeTextbook/envs/lib/python3.9/site-packages/IPython/core/pylabtools.py in find_gui_and_backend(gui, gui_select)
278 """
279
--> 280 import matplotlib
281
282 if gui and gui != 'auto':
ModuleNotFoundError: No module named 'matplotlib'
```

## 1. Inner Products¶

**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\):

\(\langle u,v \rangle = \langle v,u \rangle\) (symmetry axiom)

\(\langle u+v,w \rangle = \langle u,w \rangle + \langle v,w \rangle\) (additive axiom)

\(\langle cu,v \rangle = c\langle v,u \rangle\) (homogeneity axiom)

\(\langle u,u \rangle \ge 0 \text{ and } \langle u,u \rangle = 0 \text{ if and only if } u = 0\) (positive definite axiom)

The dot product of \(R^n\) is an inner product. Note that we can define new inner products for \(R^n\).

### Norm of a vector¶

**Definition:** Let \(V\) be an inner product space. The **norm** of a vector \(v\) is denoted by \(\| v \|\) and is defined by:

### Angle between two vectors¶

**Definition:** Let \(V\) be a real inner product space. The **angle \(\theta\) between two nonzero vectors \(u\) and \(v\)** in \(V\) is given by:

### Orthogonal vectors¶

**Definition:** Let \(V\) be an inner product space. Two vectors \(u\) and \(v\) in \(V\) are **orthogonal** if their inner product is zero:

### Distance¶

**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:

#### Example:¶

Let \(R^2\) have an inner product defined by: $\(\langle (a_1,a_2),(b_1,b_2)\rangle = 2a_1b_1 + 3a_2b_2.\)$

✅ **QUESTION 1:** What is the norm of (1,-2) in this space?

Put your answer to the above question here.

✅ **QUESTION 2:** What is the distance between (1,-2) and (3,2) in this space?

Put your answer to the above question here.

✅ **QUESTION 3:** What is the angle between (1,-2) and (3,2) in this space?

Put your answer to the above question here.

✅ **QUESTION 4:** Determine if (1,-2) and (3,2) are orthogonal in this space?

Put your answer to the above question here.

## 2. Inner Product on Functions¶

```
from IPython.display import YouTubeVideo
YouTubeVideo("8ZyeHtgMBjk",width=640,height=360, cc_load_policy=True)
```

### Example¶

Consider the following functions

✅ **QUESTION 5:** What is the norm of \(f(x)\) in this space?

Put your answer to the above question here. (Hint: you can use `sympy.integrate`

to compute the integral)

✅ **QUESTION 6:** What is the norm of g(x) in this space?

Put your answer to the above question here.

✅ **QUESTION 7:** What is the inner product of \(f(x)\) and \(g(x)\) in this space?

Put your answer to the above question here.

## 3. Assignment wrap-up¶

✅ **Assignment-Specific QUESTION:** There is no Assignment specific question for this notebook. You can just say “none”.

Put your answer to the above question here

✅ **QUESTION:** Summarize what you did in this assignment.

Put your answer to the above question here

✅ **QUESTION:** What questions do you have, if any, about any of the topics discussed in this assignment after working through the jupyter notebook?

Put your answer to the above question here

✅ **QUESTION:** How well do you feel this assignment helped you to achieve a better understanding of the above mentioned topic(s)?

Put your answer to the above question here

✅ **QUESTION:** What was the **most** challenging part of this assignment for you?

Put your answer to the above question here

✅ **QUESTION:** What was the **least** challenging part of this assignment for you?

Put your answer to the above question here

✅ **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?

Put your answer to the above question here

✅ **QUESTION:** Do you have any further questions or comments about this material, or anything else that’s going on in class?

Put your answer to the above question here

✅ **QUESTION:** Approximately how long did this pre-class assignment take?

Put your answer to the above question here

Written by Dr. Dirk Colbry, Michigan State University

This work is licensed under a Creative Commons Attribution-NonCommercial 4.0 International License.