The non-negative real number is called the norm of a vector v (associated with the previous scalar product).. This is also called module or length. Let’s see how it is represented:
This is an equation we’ve worked with before, but written differently.
As we can see, the entire equation is raised to 1/2, which would be equivalent to the square root. If instead of being raised to 1/2, it were raised to another number, for example 1/4 or 1/3, the norm would change.
Why is this interesting? Because in physics and geometry it is interesting to know the length of said vector, which is why the norm of a vector is defined.
What is the norm of a vector?
For example, if we define the distance between two vectors or and v as the length of the difference or – v, we must define the length of a vector. Instead of using the term length for vectors, we generally use the term norm and it is denoted by ||v||.
The norm of a vector has the following properties:
||v|| It is a non-negative real number. ||v|| = 0 ↔ v = 0 For any scalar α, ||α . v|| = |α| . ||v|| ||or + v|| ≤ ||or|| + ||v||
How do we calculate the norm of a vector in Python?
We will use a vector that is already defined:
one p
array ([1, 3, 5, 7])
We can calculate the norm of a vector in Python using a linear algebra module that belongs to numpy and is called linalg.norm.
np.linalg.norm (u_np)
9.16515138991168
This result would then be the norm or module of the resulting vector.
Exercise
Can you think of another way to calculate the norm of the vector u?
In the end, we are taking the square root of the scalar product of said vector u by u itself:
np.sqrt(u_np@u_np)
9.16515138991168
Do you want to continue learning?
Now that we have seen how the vector norm works, we can continue learning about Big Data, one of the most in-demand disciplines today and with the best salaries. For you to achieve your goals, we have the Big Data, Artificial Intelligence & Machine Learning Full Stack Bootcamp, an intensive training in which you can acquire all the theoretical and practical knowledge to enter the job market in a few months. Dare to transform your future and enter now to request more information!