Track progress, take quizzes and save notes on this lesson.

Free forever · no card needed

Start free
Intermediate

Vectors

4.2.8 Vectors

Aligned to the AQA 7517 specification

Level
Intermediate
Reading time
5 min
Published
13 June 2026
Updated
1 July 2026
On this page
  1. 1.What Is a Vector?
  2. 2.Vector Addition and Scalar Multiplication
  3. 3.The Dot Product
  4. 4.Convex Combinations
  5. 5.Vectors in Code
  6. 6.Common Exam Mistakes

Key takeaways

  • A vector is a mathematical object with magnitude and direction, represented in computing as an ordered list of numbers (one per dimension) and stored like a 1D array or list.
  • The magnitude (length) of a vector is found with Pythagoras as the square root of the sum of its squared components, e.g. |v| = √(3² + 4²) = 5.
  • The dot product a · b = Σ aᵢbᵢ produces a single scalar, not a vector; it sums n products for n-dimensional vectors.
  • A convex combination w = αu + βv requires α ≥ 0, β ≥ 0 and α + β = 1, which guarantees w lies on or between u and v.
  • Vector addition adds corresponding components and is only defined when both vectors have the same number of dimensions.

What Is a Vector?

A vector is a mathematical object with two properties: magnitude (size) and direction. Vectors are used to represent quantities such as velocity, displacement, and forces — things where direction matters, not just amount.

In computing, a vector is represented as an ordered list of numbers — one number per dimension:

2D vector:  v = (3, 4)       ← x-component, y-component
3D vector:  v = (1, -2, 5)   ← x, y, z components
n-D vector: v = (v₁, v₂, ..., vₙ)

Geometric interpretation — a 2D vector (3, 4) means "3 units right, 4 units up." The magnitude (length) is calculated using Pythagoras:

In a program, a vector is stored just like a 1D array — or a list in Python:

v ← [3, 4]        // 2D vector
u ← [1, -2, 5]    // 3D vector

Vector Addition and Scalar Multiplication

Vector addition adds corresponding components. Two vectors must have the same number of dimensions to be added.

Example:

Scalar multiplication multiplies every component by a single number (the scalar):

Example:

FUNCTION vectorAdd(a, b)
    result ← []
    FOR i ← 1 TO LEN(a)
        result[i] ← a[i] + b[i]
    NEXT i
    RETURN result
ENDFUNCTION

FUNCTION scalarMult(scalar, v)
    result ← []
    FOR i ← 1 TO LEN(v)
        result[i] ← scalar * v[i]
    NEXT i
    RETURN result
ENDFUNCTION

(Extra context — not required by AQA 7517) Vector addition and scalar multiplication are not explicitly listed in the AQA 4.2.8 spec bullets, but they underpin the dot product and convex combination calculations.

The Dot Product

The dot product (scalar product) of two vectors produces a single number, not a vector. It is defined as:

Worked example:

FUNCTION dotProduct(a, b)
    total ← 0
    FOR i ← 1 TO LEN(a)
        total ← total + a[i] * b[i]
    NEXT i
    RETURN total
ENDFUNCTION

(Extra context — not required by AQA 7517) Geometric meaning: the dot product is related to the angle between the two vectors: . If the dot product is 0, the vectors are perpendicular () — used in 3D graphics, physics simulations, and machine learning.

Convex Combinations

A convex combination of two vectors and is a weighted average that produces a point on the line segment between them.

where , , and .

Key property: the constraint with both non-negative ensures always lies on or between and — never outside the segment.

Worked example — find the midpoint of two 2D vectors:

Setting gives ; setting gives ; any value in between gives an intermediate point.

Application — linear interpolation ("lerp") in computer graphics: smoothly animate a point from position to position by varying from 1 to 0 over time.

Worth saving these ideas?

Turn what you've read into instant revision cards. Free to get started.

Make flashcards

Vectors in Code

Vectors are implemented in code using arrays or lists — one slot per component. All vector operations follow naturally from array indexing.

Representing a 2D game object:

// Position and velocity as 2D vectors
position ← [100, 200]    // x=100, y=200
velocity ← [3, -1]       // 3 units/frame right, 1 up

// Update position each frame
FOR i ← 1 TO 2
    position[i] ← position[i] + velocity[i]
NEXT i

Computing magnitude (length):

FUNCTION magnitude(v)
    sumSquares ← 0
    FOR i ← 1 TO LEN(v)
        sumSquares ← sumSquares + v[i] ^ 2
    NEXT i
    RETURN sumSquares ^ 0.5   // Square root
ENDFUNCTION

(Extra context — not required by AQA 7517) Normalising a vector scales it to magnitude 1 while preserving direction — divide each component by the magnitude. In code: RETURN scalarMult(1 / magnitude(v), v).

Common Exam Mistakes

1. Confusing the dot product result type

The dot product of two vectors is a scalar (a single number), not a vector. Describing it as producing a vector is incorrect.

2. Adding vectors of different dimensions

Vector addition is only defined when both vectors have the same number of components. Adding a 2D vector to a 3D vector is undefined.

3. Getting the convex combination constraints wrong

Both weights must be non-negative and they must sum to 1. Forgetting either condition means the result may lie outside the segment between and .

4. Treating as optional

In a convex combination, is a requirement, not a coincidence. Omitting this constraint in an exam answer loses the mark that distinguishes a convex combination from general linear interpolation.

5. Indexing errors in dot product loops

The dot product sums terms for -dimensional vectors. Starting a loop at index 0 in AQA pseudocode (which uses 1-based indexing) or ending one step early produces an incorrect result.

Key terms

Vector
A mathematical object with magnitude and direction, represented in computing as an ordered list of numbers, one per dimension.
Magnitude
The length of a vector, calculated with Pythagoras as the square root of the sum of its squared components.
Scalar
A single number, as opposed to a vector; the dot product of two vectors produces a scalar.
Vector addition
Adding two vectors by adding their corresponding components, defined only when both have the same number of dimensions.
Scalar multiplication
Multiplying every component of a vector by a single number, the scalar.
Dot product
An operation that multiplies corresponding components of two vectors and sums them to produce a single scalar value.
Convex combination
A weighted sum αu + βv with non-negative weights summing to 1, giving a point on the line segment between the two vectors.

Frequently asked questions

The dot product is a scalar, a single number, not a vector. It is calculated as a · b = Σ aᵢbᵢ, summing the products of corresponding components, so describing it as producing a vector is incorrect.

A convex combination w = αu + βv requires both weights to be non-negative (α ≥ 0, β ≥ 0) and to sum to 1 (α + β = 1). These constraints guarantee the result lies on or between u and v, never outside the segment.

No. Vector addition is only defined when both vectors have the same number of components, because it adds corresponding components. Adding a 2D vector to a 3D vector is undefined.

Generate revision on any topic you study

Type any topic you're studying and Aicademy generates a complete lesson, quiz, and flashcard set, personalised to your level.

Lessons on anything

Structured, level-matched lessons on any topic you study

Practice quizzes

Find out what you actually know before the exam does

Flashcard sets

Lock in key concepts with instant revision cards

Ask Aica

Stuck on something? Get a clear explanation, any time

Prev

Hash Tables and Dictionaries

Next

Graph Traversal: BFS and DFS

Related lessons

Top students don’t revise more. They revise what counts.

Start revising free

Free to start. No card needed.