Vectors, explained with pictures

A vector is an arrow. Grab the tip of an arrow and drag it. You will see what adding, scaling and the dot product look like.

Short answer. A vector is an arrow with a direction and a length. In numbers, you write it like (3, 1). That means "3 to the right, 1 up." Something with just one number (a temperature, a weight) is called a scalar.

a = ( , )

b = ( , )

Drag the circles at the arrow tips, or change the numbers.

Definitions

The text below explains things with arrows on a plane, which have two numbers, but the definitions are the same with n numbers. u and v are vectors in ℝⁿ, and c is a real number.

vector
An ordered list of n real numbers, v = (v₁, v₂, …, vₙ), is a vector in ℝⁿ. ℝⁿ is the set of all such vectors.

ℝn={(v1,v2,…,vn)∣v1,v2,…,vn∈ℝ}

component
vᵢ is the i-th component of v. Two vectors are equal when all their components are equal.

𝐮=𝐯⟺ui=vi(i=1,2,…,n)

zero vector
The vector whose components are all 0. Adding it to any vector leaves that vector unchanged.

0=(0,0,…,0),𝐯+0=𝐯

addition
Add the components in the same position.

𝐮+𝐯=(u1+v1,u2+v2,…,un+vn)

scalar multiplication
Multiply every component by the same real number c.

c𝐯=(cv1,cv2,…,cvn)

norm (length)
The positive square root of the sum of the squares of the components. It is the length of the arrow.

‖𝐯‖=v12+v22+⋯+vn2

unit vector
A vector with norm 1. If v ≠ 0, dividing v by its own norm gives the unit vector in the same direction as v.

‖𝐮‖=1,𝐯‖𝐯‖=1‖𝐯‖𝐯(𝐯≠0)

1. Adding: one walk after another

To add two vectors, add across to across, and up to up. (3, 1) + (1, 2.5) = (4, 3.5). In the picture, you walk along a, then from there you walk along b. The dashed line is that path. The black arrow shows where you end up. Why across to across and up to up? Section 2 builds it one step at a time.

Try this. ① Walk b first and then a. You end up at the same place (the dashed lines form a parallelogram). ② Point b exactly opposite to a. The sum becomes (0, 0). You are back where you started.

2. How the formula is built: why add across to across, and up to up

The meaning of adding is in the picture: walk along a, then walk along b from there. That one picture gives you a + b = (a₁ + b₁, a₂ + b₂). Here a₁ and a₂ are the across and up numbers of a, and b₁ and b₂ are the same for b. The numbers are the starting values of the lab above: a = (3, 1) and b = (1, 2.5).

Press "Next" to go one step at a time. The formula above gets a new piece (the orange background marks it), the picture changes by that much, and the reason appears beside it. The dashed arrows are steps (green for the steps of a, blue for the steps of b).

Written only as equations, the steps above look like this. A step across is a vector whose second component is 0, and a step up is one whose first component is 0.

𝐚=[a1a2]=[a10]+[0a2],𝐛=[b1b2]=[b10]+[0b2]

𝐚+𝐛=[a10]+[0a2]+[b10]+[0b2]

=[a1+b10]+[0a2+b2]=[a1+b1a2+b2]

[31]+[12.5]=[3+11+2.5]=[43.5]

In equations, (3, 1) is written standing up, as a column. It is the same arrow.

  1. Split a: a = (a₁, a₂). a = (3, 1) is two steps: 3 to the right and 1 up.
  2. Split b: b = (b₁, b₂). b = (1, 2.5) is two steps: 1 to the right and 2.5 up.
  3. Tip to tail: a + b = (a₁, a₂) + (b₁, b₂). An arrow is only a direction and a length, so moving it does not change it. Put the tail of b on the tip of a and you get the path "walk a, then walk b". Where it ends, (4, 3.5), is a + b.
  4. Gather across and up: a + b = (a₁ + b₁, a₂ + b₂). A step across never changes your height, and a step up never changes how far across you are. So the order of the steps does not change where you end. The end is the sum of the across steps, 3 + 1 = 4, and the sum of the up steps, 1 + 2.5 = 3.5.
  5. Done. The straight arrow from the start to the end is a + b = (4, 3.5). Vectors with 3 or more numbers add the same way, one slot at a time (vectors in n dimensions).

3. Scaling: multiplying by one number

Multiply a vector by one number, and the direction stays the same, only the length changes. Multiply across and up by the same number. 1.5 × (3, 1) = (4.5, 1.5). Press "Scaling" above and move the slider.

Try this. ① Multiply by a number smaller than 1 and the arrow shrinks. ② Multiply by a negative number and it points the other way. ③ Multiply by 0 and it becomes a point.

4. Dot product: how much do they point the same way?

The dot product turns two vectors into one number. Multiply across by across, multiply up by up, then add. (3, 1) · (1, 2.5) = 3×1 + 1×2.5 = 5.5.

This number tells you how much the two arrows point the same way. Press "Dot product" above, and the shadow of b falls on a in orange. The dot product is the length of that shadow × the length of a.

Dot productMeaningAngle between
PositiveThey point roughly the same wayLess than 90°
0They are at a right angle. They are unrelated90°
NegativeThey point roughly opposite waysMore than 90°

Try this. ① Turn b to a right angle with a. The shadow disappears and the dot product becomes 0. ② Point b the same way as a. The dot product is at its largest (the two lengths multiplied).

Where is it used?

Common questions

What is a vector?

An arrow with a direction and a length. In numbers, you write it as a group of numbers, like (how far across, how far up).

What is the difference between a vector and a scalar?

A scalar is a single number (a temperature of 20 degrees, a weight of 3 kg). A vector is a group of numbers and has a direction (3 to the east, 1 to the north).

What does the dot product tell you?

It tells you, with one number, how much two vectors point the same way. The same way gives a positive number. A right angle gives 0. Opposite ways give a negative number.

Where are vectors used in AI?

Words, sentences and images are turned into vectors of hundreds to thousands of numbers (embeddings). Things with similar meanings get vectors that point in similar directions. So the dot product or cosine similarity is used to find similar things.

Words

Word used hereWord used in textbooks
arrowvector
one numberscalar
across, upcomponents
putting b on the tip of atriangle law of vector addition, tip-to-tail method
lengthmagnitude, norm. Written ‖a‖
scalingscalar multiplication
dot productinner product, scalar product. Written a · b
shadowprojection

← Cramer's ruleDot product →