determin.ant
01-vectors / 1.4

Module 1: Vectors

Linear Combinations

Where you'll see this: a single neuron in a neural network computes a weighted sum of its inputs — that's a linear combination. Mixing colours on a screen (30% red + 59% green + 11% blue = perceived brightness). Any blend, mix, or weighted average is a linear combination.

You know how to scale a vector. You know how to add two vectors. Put those two ideas together and you get one of the most important concepts in all of linear algebra: the linear combination.

The idea

Take two vectors v1\mathbf{v}_1 and v2\mathbf{v}_2. Scale each one by some number, then add the results:

av1+bv2a\,\mathbf{v}_1 + b\,\mathbf{v}_2

The numbers aa and bb are called coefficients (or weights). By choosing different values for them you get different results. The collection of all possible results is something we'll explore in the next lesson.

A concrete example

Let v1=[2, 0]\mathbf{v}_1 = [2,\ 0] (points right) and v2=[0, 2]\mathbf{v}_2 = [0,\ 2] (points up). Then:

  • 1.5v1+1v2=[3, 2]1.5\,\mathbf{v}_1 + 1\,\mathbf{v}_2 = [3,\ 2]
  • 0v1+2v2=[0, 4]0\,\mathbf{v}_1 + 2\,\mathbf{v}_2 = [0,\ 4]
  • 1v1+0.5v2=[2, 1]-1\,\mathbf{v}_1 + 0.5\,\mathbf{v}_2 = [-2,\ 1]

Every point on the grid can be reached this way — just pick the right aa and bb.

Try it

In the interactive, v₁ and v₂ are fixed. Use the sliders to set aa and bb and land the result on the ★ target. The arrow goes blue → pink → result, showing the two steps of the combination geometrically.

Hint: the target is at [3, 2]. Since v₁ = [2, 0], you need a×2=3a \times 2 = 3, so a=1.5a = 1.5. Since v₂ = [0, 2], you need b×2=2b \times 2 = 2, so b=1b = 1.

Why this matters

Linear combinations are everywhere in applications:

  • Computer graphics: every pixel colour is a weighted sum of red, green, and blue
  • Machine learning: a neuron computes a weighted sum of its inputs — that's a linear combination
  • Signals: any waveform can be expressed as a weighted sum of sine waves (Fourier series)

In code

import numpy as np

v1 = np.array([2, 0])
v2 = np.array([0, 2])

a, b = 1.5, 1.0
result = a * v1 + b * v2
print(result)   # [3. 2.]
Scalar MultiplicationSpan
adjust the sliders — try to land on the ★ target
-6-6-5-5-4-4-3-3-2-2-1-1112233445566[3, 2]1v₁0.5v₂
a = 11 × [2, 0] = [2, 0]
b = 0.50.5 × [0, 2] = [0, 1]
1v₁ + 0.5v₂ = [2 + 0, 0 + 1] = [2, 1]