Skip to content

2. Vector Addition and Subtraction

Updated
17 Sept 2026
3 min read
6 sections
Page 4 of 17
Master Linear Algebra with Python

Vector Addition and Subtraction

Operating on vectors is the foundational building block for more complex operations like projections, transformations, and matrix multiplications. In this lesson, we will explore how to add and subtract vectors both algebraically and geometrically, and see how these two viewpoints are completely congruent.


1. The Dimensionality Constraint

Before performing any arithmetic operations on vectors, you must keep in mind the golden rule of vector algebra:

⚠️ The Dimensionality Rule: You can only add or subtract vectors that have the exact same dimensionality (the same number of elements).
If you attempt to add an mm-dimensional vector to an nn-dimensional vector where m≠nm \neq n, the operation is mathematically undefined. There is no corresponding element in the shorter vector to pair with elements of the longer vector!

2. The Algebraic Interpretation

Algebraically, adding or subtracting vectors is extremely simple: you just add or subtract the corresponding elements at each coordinate index.

u+v=[u1u2⋮un]+[v1v2⋮vn]=[u1+v1u2+v2⋮un+vn]\mathbf{u} + \mathbf{v} = \begin{bmatrix} u_1 \\ u_2 \\ \vdots \\ u_n \end{bmatrix} + \begin{bmatrix} v_1 \\ v_2 \\ \vdots \\ v_n \end{bmatrix} = \begin{bmatrix} u_1 + v_1 \\ u_2 + v_2 \\ \vdots \\ u_n + v_n \end{bmatrix}

Numerical Example (4D Vector)

Let's look at the 4D addition from our lecture:

[1043]+[2−3−21]=[1+20+(−3)4+(−2)3+1]=[3−324]\begin{bmatrix} 1 \\ 0 \\ 4 \\ 3 \end{bmatrix} + \begin{bmatrix} 2 \\ -3 \\ -2 \\ 1 \end{bmatrix} = \begin{bmatrix} 1+2 \\ 0+(-3) \\ 4+(-2) \\ 3+1 \end{bmatrix} = \begin{bmatrix} 3 \\ -3 \\ 2 \\ 4 \end{bmatrix}

3. The Geometric Interpretation: Addition

Geometrically, to add two vectors, we employ the Head-to-Tail Rule:

  1. Draw the first vector in its standard position (tail anchored at the origin).
  2. Translate (slide) the second vector so that its tail sits exactly at the head of the first vector. (Recall that translation preserves the vector's length and direction).
  3. Draw the resulting sum vector from the tail of the first vector (the origin) to the head of the translated second vector.

Example A: Adding Positive Coordinates

Adding [12]+[21]=[33]\begin{bmatrix} 1 \\ 2 \end{bmatrix} + \begin{bmatrix} 2 \\ 1 \end{bmatrix} = \begin{bmatrix} 3 \\ 3 \end{bmatrix}.

Vector Addition: Standard position vs Head-to-Tail Translation
Vector Addition: Standard position vs Head-to-Tail Translation

Example B: Adding Negative Coordinates

Adding [12]+[−2−1]=[−11]\begin{bmatrix} 1 \\ 2 \end{bmatrix} + \begin{bmatrix} -2 \\ -1 \end{bmatrix} = \begin{bmatrix} -1 \\ 1 \end{bmatrix}.

Vector Addition: Translating vectors with negative components
Vector Addition: Translating vectors with negative components

4. The Geometric Interpretation: Subtraction

Vector subtraction possesses two equivalent and highly useful geometric interpretations:

Method A: Flip and Add (Scalar Multiplication by $-1$)

You can treat subtraction v−w\mathbf{v} - \mathbf{w} as adding a scaled vector: v+(−1)w\mathbf{v} + (-1)\mathbf{w}.

  1. Multiplying a vector by $-1$ scales each of its elements by $-1$.
  2. Geometrically, this has the effect of rotating the vector by 180∘180^\circ (flipping its direction) while keeping its length unchanged.
  3. Perform standard head-to-tail addition by sliding this flipped vector to the head of the first vector.

Method B: Head-to-Head (Tail-to-Tail Connection)

  1. Place both vectors v\mathbf{v} and w\mathbf{w} in their standard position (both tails anchored at the origin).
  2. Draw the difference vector from the head of the subtracted vector (w\mathbf{w}, the one with the negative sign) to the head of the positive vector (v\mathbf{v}).
  3. If desired, you can then translate this resulting vector back to the standard position.
Geometric Vector Subtraction Methods
Geometric Vector Subtraction Methods

5. Python Implementation

Here is how to implement vector addition and subtraction using NumPy and plot the head-to-tail visual summation in Matplotlib:

python
import numpy as np
import matplotlib.pyplot as plt
from mpl_toolkits.mplot3d import Axes3D

# Two vectors in R2
v1 = np.array([ 3, -1 ])
v2 = np.array([ 2,  4 ])

# Algebraic addition
v3 = v1 + v2

# Plot them geometrically
plt.plot([0, v1[0]],[0, v1[1]],'b',linewidth=3,label='v1')
plt.plot([0, v2[0]]+v1[0],[0, v2[1]]+v1[1],'r',linewidth=3,label='v2 (translated)')
plt.plot([0, v3[0]],[0, v3[1]],'k',linewidth=3,label='v1+v2')

plt.legend()
plt.axis('square')
plt.axis((-6, 6, -6, 6 ))
plt.grid()
plt.show()
Out · plot
Output 1

Key Takeaways

  • Dimensionality Agreement: Vectors must share the exact same shape for addition and subtraction to be valid.
  • Vector Translation: Translating a vector's starting location does not alter its algebraic value. This translation property is what powers the geometric Head-to-Tail addition rule.
  • Direction Flipping: Subtracting a vector is equivalent to reversing its direction (scaling by $-1$) and adding it head-to-tail.