Vector Addition and Scalar Multiplication -- Geometric Perspective
Vector Addition: Concatenating Two Displacements
A vector can be understood as an arrow starting from the origin — it has length and direction.
Adding two vectors means concatenating two displacements together.
Triangle Law
Connect the start of the second vector b to the end of the first vector a.
The line from the start of a to the end of b is a + b.
Intuition: "First go along a, then go along b"
Parallelogram Law
Using a and b as two adjacent sides, draw a parallelogram.
The diagonal from the starting point is a + b.
Intuition: Both laws give exactly the same result
Scalar Multiplication: Stretching or Shrinking a Vector
Multiplying a vector by a scalar (an ordinary number) results inChanging the vector's length while keeping its line direction unchanged。
|c| > 1
Stretching
e.g., 2v: length ×2
0 < |c| < 1
Shrinking
e.g., 0.5v: length ÷2
c < 0
Reversing Direction
e.g., -v: opposite direction
c = 0
Shrinking to a Point
e.g., 0v = zero vector
Scalar multiplication only changes the vector's "length", not the direction of the line it lies on (negative numbers reverse the direction but it remains on the same line).
This property is calledcollinearity— the two vectors before and after scalar multiplication always lie on the same line.
Everyday Examples
Vector Addition: Multi-Segment Trips in Navigation
Starting from home, first walk 300 m east (vector a = (300, 0)), then 400 m north (vector b = (0, 400)).
Finally you are 500 m away in the northeast direction of home—this is a + b = (300, 400).
Scalar multiplication: video playback speed
At normal speed, walking 5 steps takes 5 seconds. At 2× speed—same direction, same number of steps—it takes only 2.5 seconds.
The displacement vector hasn't changed direction, but the "size per step" has doubled—this is the effect of 2v.
Reverse: going back the way you came
You walk 100 m east (v = (100, 0)), then want to return to the starting point—you need to walk 100 m west (-v = (-100, 0)).
The negative sign is the "make a U-turn" command for the vector's direction.
Mathematical Definitions
Vector Addition
To add two vectors of the same dimension, add the corresponding elements respectively.
\[ \mathbf{a} + \mathbf{b} = \begin{bmatrix} a_1 \\ a_2 \\ \vdots \\ a_n \end{bmatrix} + \begin{bmatrix} b_1 \\ b_2 \\ \vdots \\ b_n \end{bmatrix} = \begin{bmatrix} a_1 + b_1 \\ a_2 + b_2 \\ \vdots \\ a_n + b_n \end{bmatrix} \]Prerequisite: the two vectors must have the same dimension, otherwise addition is meaningless.
Vector Subtraction
Vector subtraction = adding the opposite vector: \( \mathbf{a} - \mathbf{b} = \mathbf{a} + (-\mathbf{b}) \)
Scalar Multiplication of Vectors
A scalar c multiplied by a vector means multiplying every element of the vector by c:
\[ c \cdot \mathbf{v} = c \cdot \begin{bmatrix} v_1 \\ v_2 \\ \vdots \\ v_n \end{bmatrix} = \begin{bmatrix} c \cdot v_1 \\ c \cdot v_2 \\ \vdots \\ c \cdot v_n \end{bmatrix} \]Quick Reference of Operation Properties
| Property | Formula | Intuition |
|---|---|---|
| Commutative law | \( \mathbf{a} + \mathbf{b} = \mathbf{b} + \mathbf{a} \) | Whichever segment you walk first is the same |
| Associative law | \( (\mathbf{a}+\mathbf{b})+\mathbf{c} = \mathbf{a}+(\mathbf{b}+\mathbf{c}) \) | No matter how you group the walks, it's the same |
| Distributive law | \( c(\mathbf{a}+\mathbf{b}) = c\mathbf{a} + c\mathbf{b} \) | Add first then stretch = stretch first then add |
Python Hands-On
Example
# Create two vectors
a_example = np.array([3, 1]) # a = (3, 1)
b_example = np.array([1, 2]) # b = (1, 2)
# Vector addition: add corresponding positions
add_result = a_example + b_example
print("a + b =", add_result) # [4, 3]
# Vector subtraction
sub_result = a_example - b_example
print("a - b =", sub_result) # [2, -1]
# Scalar multiplication: multiply each element by a scalar
c = 2.5
scale_result = c * a_example
print(f"{c} * a =", scale_result) # [7.5, 2.5]
# Negative vector: completely opposite direction
neg = -a_example
print("-a =", neg) # [-3, -1]
# NumPy broadcasting: scalar operates directly on each element of the vector
print("a + 10 =", a_example + 10) # Add 10 to every element
print("a * 3 =", a_example * 3) # Multiply every element by 3
a + b = [4 3] a - b = [2 -1] 2.5 * a = [7.5 2.5] -a = [-3 -1] a + 10 = [13 11] a * 3 = [9 3]
Example
import matplotlib.pyplot as plt
plt.rcParams['font.sans-serif'] = ['Arial Unicode MS', 'SimHei', 'DejaVu Sans']
plt.rcParams['axes.unicode_minus'] = False
example_a = np.array([3, 1])
example_b = np.array([1, 2])
example_sum = example_a + example_b
fig, axes = plt.subplots(1, 2, figsize=(12, 5))
# Left figure: triangle rule
for ax, title in zip(axes, ['Triangle Rule', 'Parallelogram Rule']):
ax.set_xlim(-1, 6); ax.set_ylim(-1, 5)
ax.axhline(y=0, color='gray', lw=0.5); ax.axvline(x=0, color='gray', lw=0.5)
ax.set_aspect('equal'); ax.grid(True, alpha=0.3); ax.set_title(title)
# Draw the triangle rule
ax = axes[0]
ax.arrow(0, 0, example_a[0], example_a[1], head_width=0.2, head_length=0.2,
fc='#e74c3c', ec='#e74c3c', lw=2, label='a')
ax.arrow(example_a[0], example_a[1], example_b[0], example_b[1],
head_width=0.2, head_length=0.2, fc='#3498db', ec='#3498db', lw=2, label='b')
ax.arrow(0, 0, example_sum[0], example_sum[1], head_width=0.2, head_length=0.2,
fc='#2E7DCC', ec='#2E7DCC', lw=2, ls='dashed', label='a+b')
ax.legend()
# Draw the parallelogram rule
ax = axes[1]
ax.arrow(0, 0, example_a[0], example_a[1], head_width=0.2, head_length=0.2,
fc='#e74c3c', ec='#e74c3c', lw=2, label='a')
ax.arrow(0, 0, example_b[0], example_b[1], head_width=0.2, head_length=0.2,
fc='#3498db', ec='#3498db', lw=2, label='b')
ax.arrow(example_a[0], example_a[1], example_b[0], example_b[1],
head_width=0.2, head_length=0.2, fc='#3498db', ec='#3498db', lw=1.5, ls='dotted', alpha=0.6)
ax.arrow(example_b[0], example_b[1], example_a[0], example_a[1],
head_width=0.2, head_length=0.2, fc='#e74c3c', ec='#e74c3c', lw=1.5, ls='dotted', alpha=0.6)
ax.arrow(0, 0, example_sum[0], example_sum[1], head_width=0.2, head_length=0.2,
fc='#2E7DCC', ec='#2E7DCC', lw=2, ls='dashed', label='a+b')
ax.legend()
plt.tight_layout(); plt.show()
Interactive Vector Addition Demo
Drag the endpoints of the red vector a and blue vector b below, and observe the green resultant vector a+b changing in real time. Experience the triangle law and parallelogram law:
Application Scenarios in AI
Semantic Operations of Word Vectors
The most famous discovery of word embedding models such as Word2Vec and GloVe: vector addition and subtraction have semantic meaning.
\[ \text{vec}(\text{king}) - \text{vec}(\text{man}) + \text{vec}(\text{woman}) \approx \text{vec}(\text{queen}) \]Subtraction removes the "male" feature component, and addition adds the "female" feature component. The resulting vector is closest to "queen" in the embedding space.
This kind of semantic operation is not limited to gender — "Paris - France + Italy ≈ Rome" works on the same principle. Vector addition and subtraction act as "feature editing" here.
Bias in Neural Networks
In each neuron's computation \( y = Wx + b \), +b is vector addition — the bias shifts the result of wx as a whole.
Without the bias b, the model's output at x=0 would necessarily be 0, which severely limits the model's expressive power. The bias is equivalent to giving each neuron a "default activation value".
Gradient Update
The parameter update during training \( \theta_{new} = \theta_{old} - \eta \nabla J \) is a combination of scalar multiplication (learning rate × gradient) and vector subtraction.
Scalar multiplication controls the size of each update (the larger the learning rate, the larger the step), and subtraction moves the parameters in the direction of decreasing loss.
Data Preprocessing: Mean Centering
Before training a neural network, a "mean subtraction" operation is often applied to the data: \( x_{norm} = x - \mu \). This is vector subtraction — translating the data center to the origin, which helps gradient descent converge faster.
Other extensions