Blogs, Linear Algebra

Inner Product

As we continue to study vectors, we will be looking at the concept of distance and angles between vectors. In order to do so, we need to define an inner product on a vector space. Over the powers of real numbers, we were able to use the dot product as an inner product; however, this is not the only possibility. As such, we will look at examples with dot products and with a different inner product.

Over \(\mathbb{R}^{3}\)

Let \(\mathbf{u}=(1,1,2)\) and \(\mathbf{v}=(-1,3,0)\) in the vector space \(\mathbb{R}^{3}\), then find the following

  • \(||\mathbf{u}||\),
  • \(d(\mathbf{u},\mathbf{v})\),
  • \(\mathbf{u}\cdot \mathbf{v}\) and
  • the angle between \(\mathbf{u}\) and \(\mathbf{v}\).

\(||\mathbf{u}||\)

We first note that the magnitude of a vector in a vector space with a defined inner product is given by
\begin{align*}
||\mathbf{u}||=\sqrt{\mathbf{u}\cdot \mathbf{u}}.
\end{align*}

As such, we just need to find the dot product of \(\mathbf{u}\) with itself. This is then found at
\begin{align*}
||\mathbf{u}||&=\sqrt{\mathbf{u}\cdot \mathbf{u}} \\
&=\sqrt{(1,1,2) \cdot (1,1,2)} \\
&=\sqrt{1*1+1*1+2*2} \\
&=\sqrt{6}.
\end{align*}

\(d(\mathbf{u},\mathbf{v})\)

In order to find the distance between the two vectors, we need to find
\begin{align*}
d(\mathbf{u},\mathbf{v})&=||\mathbf{u}-\mathbf{v}|| \\
&=\sqrt{((1,1,2)-(-1,3,0))\cdot((1,1,2-(-1,3,0))} \\
&=\sqrt{(2,-2,2) \cdot (2,-2,2)} \\
&=\sqrt{2*2+(-2)(-2)+2*2} \\
&=\sqrt{12}.
\end{align*}

\(\mathbf{u} \cdot \mathbf{v}\)

In order to find the dot product of the two vectors, we need only use the definition to find that
\begin{align*}
\mathbf{u} \cdot \mathbf{v}&=(1,1,2) \cdot (-1,3,0) \\
&=1*(-1)+1*3+2*0 \\
&=2.
\end{align*}

The angle between

Recall the we had defined the dot product so the that angle between the vectors, \(\theta\) can be found as
\begin{align*}
\cos(\theta)=\frac{\mathbf{u} \cdot \mathbf{v}}{||\mathbf{u}|| * || \mathbf{v}||}.
\end{align*}

We found most of the required information, but we still need to find \(||\mathbf{v}||\) is we want to calculate this angle. Therefore, we find that
\begin{align*}
||\mathbf{v}||&=\sqrt{\mathbf{v} \cdot \mathbf{v}} \\
&=\sqrt{(-1,3,0) \cdot (-1,3,0)} \\
&=\sqrt{(-1)(-1)+3*3+0*0} \\
&=\sqrt{10}.
\end{align*}

Using the information we already have, we then find that
\begin{align*}
\cos(\theta)&=\frac{\mathbf{u} \cdot \mathbf{v}}{||\mathbf{u}|| * || \mathbf{v}||} \\
&=\frac{2}{\sqrt{6}*\sqrt{10}} \\
&=\frac{2}{\sqrt{60}} \\
&=\frac{1}{\sqrt{15}}.
\end{align*}

Hence, we find that the angle between the vectors is \(\cos^{-1}(\frac{1}{\sqrt{15}})\).

Vectors in \(C[0,1]\).

Now that we have worked through an example in \(\mathbf{R}^{2}\) we will look work with an example using continuous function on the interval \([0,1]\). We know that \(C[0,1]\) is a vector space under the usual addition and scalar multiplication, but we still need an inner product. As such, we will define our inner product for \(C[0,1]\) as, for \(f,g \in P_{1}\),
\begin{align*}
\langle f, g \rangle =\int_{0}^{1}f(x)g(x)dx.
\end{align*}

Before continuing, we should do a quick check that this inner product does satisfy the definition of inner product. For \(f(x),g(x),h(x) \in C[0,1]\) and \(c \in \mathbb{R}\), we note that

  1. \(\int_{0}^{1}f(x)g(x)dx=\int_{0}^{1}g(x)f(x)dx\), that is \(\langle f,g \rangle=\langle g, f \rangle\).
  2. \begin{align*}
    \int_{0}^{1}f(x)(g(x)+h(x))dx&=\int_{0}^{1}f(x)g(x)+f(x)h(x)dx \\
    &=\int_{0}^{1}f(x)g(x)dx +\int_{0}^{1}f(x)h(x)dx,
    \end{align*}
    that is \(\langle f,g+h\rangle=\langle f,g \rangle +\langle f,h\rangle \).
  3. \(c\int_{0}^{1}f(x)g(x)dx=\int_{0}^{1}cf(x)g(x)dx\), that is \(c \langle f,g \rangle=\langle cf,g \rangle\).
  4. \(\int_{0}^{1}f(x)^{2}dx \geq \int_{0}^{1}0 dx\) since \(f(x)^{2} \geq 0\) and \(\int_{0}^{1}f(x)^{2}dx=0\) if and only if \(f(x)=0\) for all \(x \in [0,1]\), that is, \(\langle f,f \rangle \geq 0\) and \(\langle f,f \rangle =0\) if and only if \(f=0\).

All of these conditions are satisfied, so we do indeed have an inner product. We will now look at the vectors
\begin{align*}
f(x)&=x+1 \text{ and }\\
g(x)&=3x+1.
\end{align*}
Using these, we will find the same values we found above.

\(||f||\)

Note that we will be using integrals here. If you need practice or a refresher with integrals, I would suggest looking at my posts on integrals.

We now find that
\begin{align*}
||f||&=\sqrt{\int_{0}^{1}(x+1)^{2}dx} \\
&=\sqrt{\frac{1}{3}(x+1)^{3}|_{0}^{1}} \\
&=\sqrt{\frac{8}{3}-\frac{1}{3}} \\
&=\sqrt{\frac{7}{3}}.
\end{align*}

\(d(f,g)\)

Again, using the definition, we find that
\begin{align*}
d(f,g)&=||f-g|| \\
&=\sqrt{\langle f-g,f-g\rangle} \\
&=\sqrt{\int_{0}^{1}(f(x)-g(x))^{2}dx} \\
&=\sqrt{\int_{0}^{1}(-2x)^{2}dx} \\
&=\sqrt{\int_{0}^{1}4(x)^{2}dx} \\
&=\sqrt{\frac{4}{3}x^{3}|_{0}^{1}} \\
&=\sqrt{\frac{4}{3}}.
\end{align*}

\(\langle f,g \rangle\)

Using our inner product, we find that
\begin{align*}
\langle f,g \rangle &=\int_{0}^{1}(x+1)(3x+1)dx \\
&=\int_{0}^{1}3x^{2}+4x+1dx \\
&=x^{3}+2x^{2}+x|_{0}^{1} \\
&=4.
\end{align*}

The angle between

As we had to do last time, we will need to find \(||g||\), before we can find the angle between \(f\) and \(g\). We, therefore, see that
\begin{align*}
||g||&=\sqrt{\int_{0}^{1}(3x+1)^{2}dx} \\
&=\sqrt{\frac{1}{9}(3x+1)^{3}|_{0}^{1}} \\
&=\sqrt{\frac{64}{9}-\frac{1}{9}} \\
&=\sqrt{\frac{63}{9}} \\
&=\sqrt{7}.
\end{align*}

We are now ready to find
\begin{align*}
\cos(\theta)&=\frac{\langle f,g \rangle}{||f|| * ||g||} \\
&=\frac{4}{\sqrt{\frac{7}{3}}*\sqrt{7}} \\
&=\frac{4 \sqrt{3}}{7}.
\end{align*}

Hence, the angle between \(f\) and \(g\) is \(\cos^{-1}(\frac{4 \sqrt{3}}{7})\).

Conclusion

As always, I hope you learned something and enjoyed the post. If you did, make sure to share the post with other people that will find it helpful and subscribe to our YouTube channel.

1 thought on “Inner Product”

We'd love to hear your thoughts!

This site uses Akismet to reduce spam. Learn how your comment data is processed.