# Vector

Vectors are mathematical objects that encode magnitude and direction. Vectors are ubiquitous in physics and describe quantities such as force, velocity, electric field, etc.

There are 2 common ways to think of vectors: geometrically and numerically. In the geometric mindset, vectors are thought of as arrows pointing in a certain direction with a certain length or magnitude:

To describe a vector v numerically, we first pick a coordinate system whose origin is at the start of the arrow. Then we associate the vector with the coordinates of the arrowhead:

We can also have vectors in three dimensions or more:

We would write v as:

or as v = [4, 6, 8]^{T}. The T exponent stands for "transpose" and means to take the row vector, [4, 6, 8], and flip or transpose it into a column vector such that the leftmost entry becomes the top and rightmost becomes the bottom. The dimension of a vector is the number of coordinates it has. In the example above, since v has 3 coordinates, 4, 6, and 8, we say that v is 3-dimensional. Below, v, is 4-dimensional, w is 5-dimensional, and x is 6-dimensional:

### Vector addition

If we pick a coordinate system, then we write v and w as column vectors and simply add up the respective coordinates to get v + w.

Notice that the order of addition doesn't matter, so v + w = w + v. Geometrically, this is represented by starting from origin O, shifting by vector v to arrive at S, then shifting by vector w to arrive at P. Then v + w is the vector from O to P. We could also first shift by w to arrive at T, then shift by v but we would still arrive at the same endpoint P, so v + w = w + v in the geometric definition as well.

Note: Only vectors of the same dimension can be added. For example, we cannot add v = [ 1, 2, 3]^{T} and w = [4, 5]^{T} because v is 3-dimensional and w is 2-dimensional. But we can add v = [3, -1, 4]^{T} and w = [5, 9, -6]^{T} to get v + w = [3 + 5, -1 + 9, 4 - 6]^{T}= [8, 8, -2]^{T}.

### Vector multiplication by scalars

Given a coordinate system, we can multiply a vector v with a number c, called a scalar, by multiplying every coordinate of v by c:

Geometrically, the vector cv lies on the same line as v except that it is scaled by a factor of c, which is why c is called a scalar. If |c| > 1, cv will be larger, or have larger magnitude, than v. If c > 0, cv will point in the same direction as v. If c < 0, cv will point in the opposite direction as v. The diagram shows v being multiplied by -1 and 2:

### Vector subtraction

To subtract 2 vectors v and w to get v - w, we compute the coordinates of v minus the corresponding coordinates of w.

v - w should be a vector that satisfies w + (v - w) = v. Therefore, using our knowledge of vector addition, the following diagram gives a geometric interpretation of v - w as the vector from the head of w to the head of v.

Note that v - w = v + (-1)*w, which is v plus w scaled by a factor of -1. Just as with vector addition, we can only subtract vectors of the same dimension.

See also magnitude.