8.4 Inner product

For two vectors \(\mathbf{x}\) and \(\mathbf{y}\), the standard inner (dot) product of the two vectors in \(\mathbb{R}^k\) is \[<\mathbf{x},\mathbf{y}> = \mathbf{x}^T\mathbf{y} = \sum_{i=1}^k x_iy_i = x_{1}y_1 + x_2y_2+\cdots+x_ky_k\]

To be an inner product, it has to satisfy 1) \(<\mathbf{x},\mathbf{x}>\geq 0\) with equality if \(\mathbf{x}=\mathbf{0}\) 2) \(<\mathbf{x},\mathbf{y}> = <\mathbf{y},\mathbf{x}>\) and 3) \(<a\mathbf{x}+b\mathbf{y},\mathbf{z}> = a<\mathbf{x},\mathbf{z}>+b<\mathbf{y},\mathbf{z}>\)

x = 1:10
y = 21:30
x
y
class(x); class(y)

x %*% y #If x is a numeric vector (not a matrix), R doesn't differentiate between a column vector or row vector

x = matrix(x,ncol=1) #If x is a column vector (matrix with 1 column), it matters.
y = matrix(y,ncol=1)

class(x); class(y)

#x%*%y #Get an Error!

t(x)%*%y