Vector Operations

The Rules of Moving in Space

In the last lesson, we established our "Grand Unified Theory" of vectors: a list of numbers is an arrow in space. This insight is powerful, but it’s just the beginning.

Now, we need to define the rules for how these vectors interact. How do they move? How can we combine them? These rules are called operations, and the two most fundamental are addition and scalar multiplication.

They might sound fancy, but as you'll see, they have simple, beautiful geometric interpretations.

Vector Addition: Combining Journeys
Let’s start with a simple question: What does it mean to add two vectors together?

The Data Scientist's View (The Easy Part)

Let's say we have two vectors, vv and ww.

v=[2,1]v = [2, 1]

w=[1,3]w = [1, 3]

From the "list of numbers" perspective, the answer is incredibly simple. To add two vectors, you just add their corresponding components.

v+w=[2+1,1+3]=[3,4]v + w = [2+1, 1+3] = [3, 4]

This is called element-wise addition. It's easy to compute, but it doesn't give us much intuition. Why does this rule make sense? For that, we turn to the Physicist.

The Physicist's View (The "Aha!" Moment)

Geometrically, adding vectors is like combining a series of movements. Imagine a vector as a journey: "walk 2 steps east, then 1 step north."

To add vector ww to vv, we simply start the journey of ww where the journey of vv ended.

  1. Draw v: Start at the origin and draw the arrow for [2,1][2, 1].
  2. Draw w: Start at the tip of vv and draw the arrow for [1,3][1, 3] (1 step east, 3 steps north).
  3. The Result: The sum, v+wv + w, is the new vector that starts at the origin and ends at the tip of the final vector, ww.

This is the "tip-to-tail" rule, and it perfectly matches our numerical result! The final destination is indeed [3,4][3, 4]. This visual confirmation shows us that our element-wise addition rule isn't arbitrary; it has a deep geometric meaning.

Application: Combining Portfolio Returns

Imagine vv represents the change in value of your stock portfolio today ([+$200 stock gain,$50 bond loss][+\$200 \text{ stock gain}, -\$50 \text{ bond loss}]).

ww represents the change in value tomorrow ([+$100 stock gain,+$150 bond gain][+\$100 \text{ stock gain}, +\$150 \text{ bond gain}]).

Your total change over the two days is simply v+wv + w.

v+w=[200+100,50+150]=[+$300 stock gain,+$100 bond gain]v + w = [200+100, -50+150] = [+\$300 \text{ stock gain}, +\$100 \text{ bond gain}]

Vector addition provides a natural way to aggregate changes across multiple time periods or multiple assets.

Scalar Multiplication: Scaling Vectors
Our second fundamental operation is scalar multiplication. A "scalar" is just a fancy word for a regular, single number (like 3, -1, or 0.5), not a vector.

The Data Scientist's View (Again, The Easy Part)

Let's take our vector v=[2,1]v = [2, 1] and multiply it by the scalar 3.

Just like with addition, the rule is simple: you multiply every component of the vector by the scalar.

3v=[32,31]=[6,3]3 * v = [3 * 2, 3 * 1] = [6, 3]

The Physicist's View (The Intuition)

Geometrically, multiplying a vector by a scalar scales its length.

  • Multiplying by a scalar > 1 stretches the vector.
  • Multiplying by a scalar between 0 and 1 shrinks it.
  • Multiplying by a negative scalar flips its direction and then scales it.

The new vector [6,3][6, 3] points in the exact same direction as [2,1][2, 1], but it's exactly three times as long. Once again, the numeric rule and the geometric intuition align perfectly.

Application: Adjusting a Trading Strategy

Imagine your vector ss represents a trading signal: [Buy 200 shares of AAPL,Sell 50 shares of GOOG][\text{Buy 200 shares of AAPL}, \text{Sell 50 shares of GOOG}].

  • If you want to double down on your strategy, you simply compute 2s2 * s.
  • If you want to reverse your position, you compute 1s-1 * s.
  • If you want to reduce your risk by half, you compute 0.5s0.5 * s.

Scalar multiplication is the language of scaling risk, size, and direction in quantitative models.

Putting It All Together

By combining these two simple operations, we can now move anywhere in our vector space. Any vector can be described as a combination of a few fundamental "basis" vectors, which is a powerful idea we'll explore in a later lesson.

For example, the vector [5,4][5, 4] can be seen as 5[1,0]+4[0,1]5 * [1, 0] + 4 * [0, 1]. We are scaling and adding fundamental vectors to create new ones.

Summary: The Two Fundamental Rules

Vector Addition (v+wv + w)

Combine vectors by adding their components. Geometrically, this is the "tip-to-tail" rule for combining journeys.

Scalar Multiplication (cvc * v)

Scale a vector by multiplying every component by a scalar. Geometrically, this stretches, shrinks, or flips the vector without changing its fundamental direction.

These two operations are the simple, elegant building blocks upon which all of linear algebra is constructed.