$ \left\Vert \mathbf{a} \right\Vert_2 = \sqrt{\sum_{i=1}^n a_i^2} = \sqrt{a_1^2 + a_2^2 + a_3^3 + \cdots + a_n^2} $
import numpy as np
a = np.array([1, 2, 3])
n = np.linalg.norm(a)
print('norm=',n)
norm= 3.7416573867739413
$ \mathbf{a} \cdot \mathbf{b}= \sum_{i=1}^{n} a_i b_i = a_1 b_1 + a_2 b_2 + a_3 b_3 + \cdots + a_n b_n $
$ \mathbf{a} \cdot \mathbf{b}= \left\Vert\mathbf{a}\right\Vert\left\Vert\mathbf{b}\right\Vert\cos (\theta) $
$ \ theta $ is the angle between the vector $ \ mathbf {a} $ and the vector $ \ mathbf {b} $
import numpy as np
a = np.array([1, 2, 3])
b = np.array([4, 5, 6])
p = np.dot(a,b)
print('dot product=',p)
dot product= 32
$ \mathbf{a} \times \mathbf{b} =\left\Vert\mathbf{a}\right\Vert\left\Vert\mathbf{b}\right\Vert\sin (\theta) $
$ \ theta $ is the angle between the vector $ \ mathbf {a} $ and the vector $ \ mathbf {b} $
$ \begin{pmatrix}a_1\ a_2\ a_3 \end{pmatrix} \times \begin{pmatrix}b_1\ b_2\ b_3\end{pmatrix} = \begin{pmatrix}a_2b_3-a_3b_2\ a_3b_1-a_1b_3\ a_1b_2 - a_2b_1 \end{pmatrix} $
import numpy as np
a = np.array([1, 2, 3])
b = np.array([4, 5, 6])
p = np.cross(a,b)
print('cross product=',p)
cross product= [-3 6 -3]
Recommended Posts