Linear Algebra
Vectors: Data as Arrows
Everything becomes a vector
A vector is simply an ordered list of numbers:
That's it. Three numbers, in order. But this humble object is the universal container of machine learning, because anything can be encoded as a list of numbers:
- A house: [size, bedrooms, age] →
- A grayscale image: one number per pixel → a vector with thousands of entries
- A word: modern models represent "king" as a vector of ~1,000 numbers (an embedding)
- You, to a recommender system: your ratings of every movie
Each number is called a component or feature, and the number of components is the vector's dimension. Geometrically, a 2-D vector is an arrow from the origin to a point — direction plus length. We can't picture 1,000-D space, but the math works identically, and the geometric intuition (distances, angles) still applies.
The operations you need
Addition — combine componentwise: .
Scalar multiplication — stretch or shrink: .
The dot product — the star of the show. Multiply matching components, then add:
Why it matters: the dot product measures alignment. It is large and positive when two vectors point the same way, zero when they are perpendicular (unrelated), negative when they oppose. This gives us cosine similarity:
When a search engine finds documents "similar" to your query, or a chatbot retrieves relevant memories, it is computing dot products between embedding vectors. Also: a neuron in a neural network computes exactly one dot product (weights · inputs) plus a bias. That's all a neuron is.
Length (norm) — Pythagoras generalized:
The distance between two points is the norm of their difference — this powers the k-nearest-neighbors algorithm you'll meet in the ML path.
Key takeaways
- A vector is an ordered list of numbers; all data in ML is vectors.
- Dot product = similarity. It is the single most executed operation in AI — GPUs exist to do billions of them per second.
- Norms measure length; differences of vectors measure distance.
Try it yourself — live code
Output
Press Run to execute the code (it runs in your browser, in a sandbox).Check your understanding
1.What is the dot product of and ?
2.A large positive dot product between two vectors means they…
3.What does a neuron in a neural network compute at its core?
0% of Mathematics for AI completed