norm 2 of a vector python code example
Example 1: p-norm of a vector python
np.linalg.norm(x, 2)
Example 2: using np.linalg.norm to get vector norm of two vectors
A = np.array([2,3])
B = np.array([3,1])
print(f"A = {A}, B = {B}\n")
AB = B - A
print(f"vector AB = {AB}\n")
d_AB = np.linalg.norm(AB)
print(f"distance AB = {d_AB}")