Welcome to the first lesson of your accelerated course on the essential mathematics for mechanistic interpretability. Your goal is to build a solid mathematical foundation for advanced MI work, and our journey begins here, with the most fundamental building block of linear algebra: the vector.
This lesson will introduce you to vectors as they exist in , the n-dimensional real coordinate space. We will explore them from two crucial perspectives: as ordered lists of numbers, which is likely how you've encountered them in your computer science and data engineering work, and as geometric objects with direction and magnitude. The main goal is to master the dot product, a key operation that connects these two viewpoints. By the end of this lesson, you will be able to compute the dot product and, more importantly, interpret it as a powerful measure of the angle and similarity between two vectors.
What is a Vector?
To start, it's essential to have a solid dual intuition for what a vector is. On one hand, a vector is simply a list of numbers. In machine learning, these can represent anything from the features of a house to a word embedding in a high-dimensional space. On the other hand, a vector is an arrow in a coordinate system, possessing both length and direction. Grasping both perspectives is crucial for building the geometric intuition that underpins much of linear algebra.
The following video from the "Essence of linear algebra" series by 3Blue1Brown provides an excellent introduction to this dual-faceted nature of vectors.
Vectors | Chapter 1, Essence of linear algebra
Watch the first four and a half minutes of this video, which introduces vectors from the physics (geometric) and computer science (numerical) perspectives.
Pay close attention to the segment from the CS perspective and how it's reconciled with the geometric view of an arrow rooted at the origin from its tail. This convention of placing a vector's tail at the origin is standard in linear algebra.
As the video explains, a vector in an -dimensional space, denoted as , can be formally written as an ordered list (or n-tuple) of real numbers. For example, a vector in is written as:
where are real numbers corresponding to the vector's coordinates along the x, y, and z axes, respectively. This representation is what allows us to perform algebraic operations on geometric objects.
The Dot Product: Computation and Geometry
Now that we have a working definition of a vector, we can explore how to combine two of them. The most fundamental operation for this is the dot product. It takes two vectors and produces a single number—a scalar.
Algebraic Definition
The dot product of two vectors and in is defined as the sum of the products of their corresponding components:
For example, if and , their dot product is .
The following resource provides a formal definition and a rigorous derivation of the geometric meaning of the dot product.
This reading will walk you through the definition of the dot product and connect it to its crucial geometric properties using the Law of Cosines.
First, read the introduction in "Section 6.1 The dot product" to solidify the computational definition, up to the generalization to m-dimensions. Next, focus on the section "The geometry of the dot product." Pay close attention to the proof that uses the Law of Cosines to arrive at the geometric formula for the dot product. Read from the introduction to the proof through the derivation itself, ending at the final formula. This derivation is a beautiful piece of mathematical reasoning that bridges the algebraic and geometric worlds.
Geometric Interpretation
As you saw in the reading, the simple algebraic operation of the dot product has a profound geometric meaning. The two key relationships are:
- Length: The dot product of a vector with itself gives the square of its length (also called its magnitude or norm, denoted ).
- Angle: The dot product of two different vectors is related to the angle between them.
This second formula is the cornerstone of the dot product's utility. It tells us that the dot product is fundamentally a measure of how much two vectors "agree" or point in the same direction.

This image summarizes the two ways to compute the dot product: the algebraic component form and the geometric formula involving the angle between the vectors. It also visualizes the projection of vector A onto vector B, which is related to the dot product.
The geometric formula also reveals that the dot product can be interpreted as the length of the projection of onto , multiplied by the length of . The next video provides a superb visual intuition for this idea of projection.
Dot products and duality | Chapter 9, Essence of linear algebra
This video offers a highly intuitive geometric explanation for the dot product.
Watch the segment from the geometric interpretation which explains the dot product in terms of projection. Then, watch the explanation of why order doesn't matter, which addresses the apparent asymmetry of the projection-based definition.
The Dot Product as a Measure of Similarity
Your work in data engineering and future work in MI will often involve measuring the "similarity" between high-dimensional vectors (like word embeddings or neuron activation patterns). The dot product provides a direct way to do this.
By rearranging the geometric formula, we get an expression for the cosine of the angle between the vectors:
This quantity is known as cosine similarity. It ranges from -1 to 1 and tells us about the orientation of the vectors, independent of their magnitudes.
- If , then , meaning . The vectors point in generally the same direction. A larger positive value implies a smaller angle and thus higher similarity.
- If , then , meaning . The vectors are orthogonal (perpendicular). This is a crucial concept we will return to throughout this course. It signifies a complete lack of directional alignment.
- If , then , meaning . The vectors point in generally opposite directions (dissimilar).

This diagram shows how the dot product and cosine similarity between a reference vector (P1) and several other vectors correlate with our visual intuition of similarity. P1 and P3 are highly similar (high positive dot product), while P1 and P4 are dissimilar (negative dot product).
This concept is not just an abstract geometric idea. As noted in the supplementary PDF "Dot products and geometry in Rn" from Michigan State University, the correlation coefficient used in statistics is precisely the cosine of the angle between two mean-centered data vectors. This provides a direct link between linear algebra and the data analysis you're familiar with.
Practice Problem
Let's put this into practice. Consider two vectors in :
- Calculate the dot product .
- Calculate the lengths of each vector, and .
- Calculate the angle between them in degrees. Are they more similar or dissimilar?
Solution:
Since the dot product is positive and the angle is close to , the vectors are nearly orthogonal but point in a slightly similar direction.
Conclusion
In this lesson, we established the foundational concept of vectors in and explored the dot product, a simple yet powerful tool that connects algebra to geometry.
Here are the key takeaways:
- Vectors can be understood both as lists of numbers (a CS perspective) and as arrows in space (a geometric perspective).
- The dot product is computed as .
- Geometrically, the dot product relates to vector lengths and the angle between them via the formula .
- The sign of the dot product tells us if vectors point in similar (), orthogonal (), or dissimilar () directions, making it a cornerstone for concepts like cosine similarity.
In our next lesson, we will formalize the concept of vector length by studying norms. We'll see how different ways of measuring length (like the L1 and L2 norms) can have different properties and applications, particularly in the context of machine learning optimization and regularization.