Linear algebra, 8 min read
Vectors
An arrow, a list of numbers and a point in space are three faces of the same thing.
- Key idea
- Definition
- Intuition
- Example
- Watch out
A vector can be seen in three ways, and a good mathematician switches between them depending on what is needed.
- An arrow. It has a direction and a length. This is how a physicist sees it.
- A list of numbers. For example (3,2). This is how a programmer sees it.
- A point. The tip of an arrow that starts at the origin.
Adding and scaling
You add two vectors component by component. You multiply a vector by a number by multiplying every component.
(32)+(14)=(46)2⋅(32)=(64)
Vectors in NumPy import numpy as np
u = np.array([3, 2])
v = np.array([1, 4])
print("sum:", u + v)
print("double:", 2 * u)
print("length of u:", np.linalg.norm(u))
The length of a vector
You get the length from the Pythagorean theorem. The arrow (3,2) is the hypotenuse of a triangle with legs 3 and 2.
What is the length of the vector (3, 4)?