If you find any mistakes, please make a comment! Thank you.

Solution to Mathematics for Machine Learning Exercise 3.3

Compute the distance between $$\mathbf x=\begin{bmatrix}1\\2\\3\end{bmatrix},\quad \mathbf y=\begin{bmatrix}-1\\-1\\0\end{bmatrix}$$ using

a. $\langle \mathbf x,\mathbf y\rangle :=\mathbf x^\top \mathbf y$

b. $\langle \mathbf x,\mathbf y\rangle :=\mathbf x^\top \mathbf A\mathbf y$, $\mathbf A=\begin{bmatrix}2&1&0\\1&3&-1\\ 0&-1&2\end{bmatrix}$

Solution: The distance between $\mathbf x$ and $\mathbf y$ is given by $\sqrt{\langle \mathbf x-\mathbf y,\mathbf x-\mathbf y\rangle }$ and we have $$\mathbf z:=\mathbf x-\mathbf y =\begin{bmatrix}2\\3\\3\end{bmatrix}$$ a. In this case, \begin{align*}\langle \mathbf z,\mathbf z\rangle =\mathbf z^\top \mathbf z=2^2+3^2+3^2=22.\end{align*}Hence the distance is $\sqrt{22}$.

b. In this case, \begin{align*}\langle \mathbf z,\mathbf z\rangle =&\mathbf z^\top \mathbf A\mathbf z\\ =&[2,3,3]\begin{bmatrix}2&1&0\\1&3&-1\\ 0&-1&2\end{bmatrix}\begin{bmatrix}2\\3\\3\end{bmatrix}\\=&[7,8,3]\begin{bmatrix}2\\3\\3\end{bmatrix}=47.\end{align*}Hence the distance is $\sqrt{47}$.

Close Menu