Inner Product

The inner product is the multiplicative sum of two vectors with the same length resulting in a scalar.

Mathematically, it is represented as follows:

$$ \begin{bmatrix} x_1 \\ . \\ . \\ x_n \end{bmatrix} * \begin{bmatrix} y_1 \\ . \\ . \\ y_n \end{bmatrix} = \sum_{i=1}^n {x_i y_i} $$

To demonstrate with an example, the inner product of the following two vectors is given by:

$$\begin{bmatrix} 1 \\ 2 \\ 3 \\ 4 \end{bmatrix} * \begin{bmatrix} 5 \\ 6 \\ 7 \\ 8 \end{bmatrix} = 1*5 + 2*6 + 3*7 + 4*8 = 5 + 12 + 21 + 32 = 70 $$

Implementation with Numpy

import numpy as np

vect_1 = np.array([1,2,3,4])
vect_2 = np.array([5,6,7,8])

np.dot(vect_1, vect_2)
70